[FFmpeg-devel] [PATCH] mjpegdec: ensure SOF before SOS/EOI
Sat Jul 4 20:25:48 CEST 2009
On Sat, Jul 04, 2009 at 07:42:11PM +0200, Michael Niedermayer wrote:
> On Fri, Jul 03, 2009 at 04:42:15PM +0200, Reimar D?ffinger wrote:
> > On Wed, Jul 01, 2009 at 10:15:22PM +0200, Reimar D?ffinger wrote:
> > > this fixes issue1240, mjpeg/smclockmjpeg.avi.1.0
> > > The problem is, it reaches EOI before SOF, thus get_buffer was
> > > never called and the picture it returns has invalid values for
> > > data (NULL in this case, but it could be values from a previous
> > > frame which still would be wrong).
> > > This could also happen, if avcodec_check_dimensions failed, which
> > > might make this even more of an issue.
> > > Attached patch fixes it and also protects the decode_sos part so
> > > it will only be called with a valid picture.
> > Any objections?
> > As a second step I suggest extending the code as in attached patch.
> > This allows to decode JPEGs that have a misplaced EOI somewhere too
> > early, decodes images that lack an EOI marker and most importantly
> > makes the decoder fail and return -1 when the parsed data is complete
> > gibberish (no e.g. no SOF at all).
> > AFAICT currently when you pass random data to the MJPEG decoder it will
> > basically say "hey, everything's fine, I just don't have any decoded
> > data yet" which IMO is inappropriate.
> all fine, i assume you split this a little before commit ...
Yes, I just hadn't decided yet how to split it best.
I changed the code for the SOS case to use av_log and break instead of
return -1 to match the EOI code, hope you don't mind.
More information about the ffmpeg-devel