[Ffmpeg-devel] H264 playback problems related to num_reorder_frames check

Måns Rullgård mans
Sat Mar 17 14:21:25 CET 2007

Frank Otto <Frank.Otto at pci.uni-heidelberg.de> writes:

> Hi,
> recent ffmpeg versions have trouble playing back H264 video,
> at least when it was created with x264 (I have no other H264
> encoder). The playback is all jerky as if the frames are in
> the wrong order.
> Mplayer gives the following warning at the start of playback:
>   [h264 @ 0xb6cbfba8]illegal num_reorder_frames -1
> It seems this warning and the playback problems are caused
> by this piece of code inside "decode_vui_parameters" from "h264.c"
> (added in rev. 7663 by "michael"):
>         if(num_reorder_frames > 16 /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
>             av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", num_reorder_frames);
>             return -1;
>         }
>         sps->num_reorder_frames= num_reorder_frames;
> And locally "num_reorder_frames" is declared *unsigned*, while in
> the SPS structure it is declared as signed, so the check is hit
> and the function returns before setting sps->num_reorder_frames .
> Now the question is, who is at fault:
> - x264 for creating files which result in negative num_reorder_frames
> - ffmpeg for not allowing negative num_reorder_frames

The spec defines num_reorder_frames as unsigned.  The error must be

> Versions of ffmpeg/mplayer from before this check was added play
> the video just fine. The old behaviour can easily be restored by
> declaring num_reorder_frames as signed.

Please upload a problematic file to the usual place.

M?ns Rullg?rd
mans at mansr.com

More information about the ffmpeg-devel mailing list