- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I'm using the IPP 5.3 JPEG encoder to create an MJPEG encoder. Everything works fine except that an occasional frame will have about a 10 line duplication within the image. I have attached an avi file which illustrates this (e.g. frames 14,27,36,39). Also attached areencoder/decoder logs that list the byte counts. It occurs whether using the Intel MJPEG decoder (using the Simple Player sample ) or else other third party decoders via windows media player.
Things I'vetested which have lead me to isolate the encoder::
- Source image data seems OK (recording withother encoders or just raw output does not display this artifact).
- Other decoders also display this artifact, seeming to indicate its not in the decoder.
- The byte increasefor the erroneous frame seems to be approximately the amount of bytes for the number of duplicate lines.
- Same problem with different data sources (cameras - color/grayscale, etc)
System specs:
Intel Core2 Quad
Windows XP
Intel IPP 5.3.3.082
Statically linked Intel Libs
Statically linked Intel audio/video libs ( built usingstatic c rtuntime (/MT) )
MFC Test app (static C runtime (/MT) )
CPU usage : ~ 25%
Here's the encode routine.
pSrc is an simple rgb array
width640
height480
int
MJPEGEncoder::EncodeFrame(unsigned char* pSrc, int nSrcBytes, unsigned char* pDest, int nDestBytes, int* pnDestBytesUsed){
int iResult = 0;JERRCODE jerr;
IppiSize imgSize;
CJPEGEncoder encoder;
CMemBuffOutput jpegDest;
JMODE mode = JPEG_BASELINE;
JCOLOR color = JC_YCBCR;
JSS sampling = JS_422;
int step = (m_iWidth * 3) + DIB_PAD_BYTES(m_iWidth, 3);int quality = 85;int nSourceChannels = 3;imgSize.width = m_iWidth;
imgSize.height = m_iHeight;
MyTimer timer;
timer.Start();
jpegDest.Open(pDest, nDestBytes);
jerr = encoder.SetSource((Ipp8u*)pSrc, step, imgSize, nSourceChannels, JC_RGB);
if(jerr != JPEG_OK){
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Error setting source [err code = %d]. ", jerr);return jerr;}
jerr = encoder.SetParams(mode, color, sampling, 0, 0, quality);
if(jerr != JPEG_OK){
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Error setting params [ err code = %d]. ", jerr);return jerr;}
jerr = jpegDest.Open(pDest, nDestBytes);
if(jerr != JPEG_OK){
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Error opening destination [err code = %d]. ", jerr);return jerr;}
jerr = encoder.SetDestination(&jpegDest);
if(jerr != JPEG_OK){
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Error setting destination [err code = %d]. ", jerr);return jerr;}
jerr = encoder.WriteHeader();
if(jerr != JPEG_OK){
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Error writing header [err code = %d]. ", jerr);return jerr;}
jerr = encoder.WriteData();
if(jerr != JPEG_OK){
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Error writing data [err code = %d]. ", jerr);return jerr;}
timer.Stop();
double dMillisecs = timer.Duration() * 1000.0f; // millisecs*pnDestBytesUsed = encoder.NumOfBytes();
if(m_bWriteTraceFile)fprintf(m_fpTrace,
"[MJPEG] Frame Encoded. [Time(msecs):%3.2f nInBytes:%d nOutBytes:%d nBytesAvailable:%d ", dMillisecs, nSrcBytes, *pnDestBytesUsed, nDestBytes);return iResult;}
Again, it works fine, except 1 in every n frames or so will have a duplicated segement, where n tends to vary.
If anyone has any thoughts or suggestions I really appreciate it.
Morgan
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Morgan,
Thanks for detailed info you provided. I really see no any major issues in code you provide, except you calljpegDest.Open(pDest, nDestBytes) twice, but that should not lead to an issue in this particular case. I would recommend you to store each frame as a separate JPEG file to verify that wrong data comes from JPEG encoder and not corrupted somehow at AVI creation time.
Note, you may want to call get_num_threads() or set_num_threads()functions (defined in jpegbase.h) to see if that behaviour is related to threading implemented in encoder.
Regards,
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the reply, Vladimir.
Same problem occurs when saving each frame as a JPEG. Attached image shows the problem. Around the chin area the lines are duplicated. It looks like exactly 8 lines are duplicated, which i think is the same as the encoder's block size.
Calling get_num_threads returns 4.
However, changingthenum threads to 1 -the problem seems to have gone away, with the exception that i now get an occasional 4x4 pixel flickering light grey block in the top-right corner of the image, however thisi can work around.
testing with different threads count:
numthreads 1 - OK (no line duplicates)
numthreads 2 - OK (no line duplicates)
numthreads 3 - BAD (line duplicates)
numthreads 4 - BAD (line duplicates)
So, I'll leave her at 2 threads and call it good.
Thanks so much for the help. I don't think i would have discovered that on my own.
Morgan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Vladimir
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page