[FFmpeg-devel] [PATCH] Avoid reading beyond end of stream in resync function.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Aug 12 21:27:20 CEST 2013

On Mon, Aug 12, 2013 at 09:05:01PM +0200, Michael Niedermayer wrote:
> On Mon, Aug 12, 2013 at 07:40:32PM +0200, Reimar Döffinger wrote:
> > This ends up printing a nonsense warning about
> > "marker does not match f_code".
> > This happens particularly frequently with VDPAU hwaccel
> > since there we fast-forward the stream directly to the end.
> > (Note: possibly it is incorrect for us to skip all the way to
> > the end for VDPAU, possibly someone should investigate that,
> > I am a bit lost in that regard).
> its a bit guesswork but
> decode_slice() should maybe update s->mb_y in the hwaccel case
> (if no better idea exists setting it to mb_height when the bitstream
>  end is reached could be tried)
> when mb_y is updated then ff_h263_resync() wont be run unless its
> needed
> the patch could interfere with error concealment beause even if we
> are over the end we could have read over a resync marker and there
> still might be an intact slice start previously that wasnt decoded

My understanding is that shouldn't be possible.
If there is a resync marker, ff_h263_find_resync_marker should have
found it and we would only have fast-forwarded to it, not the end
of the frame.
Which is also why I am weary about updating mb_y since I can't properly
test this code (my card doesn't support MPEG-4, I had this tested by
giving it to a user, but that will be fairly limited testing) and I'm a bit
afraid of possibly breaking something.
This patch seemed like a way that at least can't really break anything.
Still, missing updating of mb_y seams like a reasonable explanation of
why this happens.

More information about the ffmpeg-devel mailing list