New submission from Dan <[email protected]>:

I am using libavformat/libavcodec to decode a mjpeg stream.

The problem that I encountered was that the ends of my jpeg images were 
not being detected, and thus av_read_frame wasn't returning.

It seems that in mjpeg_parser.c, the function 'find_frame_end' has a 
single condition for detecting the end of a jpeg: EOF.
Since I'm feeding in a stream, I never hit an EOF, and therefore it 
always returned END_NOT_FOUND.

To fix this, I added another condition: the presence of the 'EOI' flag 
(0xFFD9).

...
      if(state == 0xFFD9){
        return i+1;
      }
      
      else if(state == 0xFFD8){
        pc->frame_start_found=0;
        pc->state=0;
        return i-1;
      }
...


The EOI flag is in the JPEG standard:
http://gvsoft.homedns.org/exif/exif-explanation.html

The function is detecting 0xFFD8 as the SOI (start of image), but for 
some reason, not 0xFFD9 as the EOI.

----------
messages: 13282
priority: normal
status: new
substatus: new
title: mjpeg_parser does not detect end of jpeg in jpeg stream (easy fix)
topic: avcodec
type: bug

________________________________________________
FFmpeg issue tracker <[email protected]>
<https://roundup.ffmpeg.org/issue2507>
________________________________________________

Reply via email to