[FFmpeg-devel] Problem with initial dts in h264
John Stebbins
stebbins
Mon Dec 7 00:26:30 CET 2009
A recent change has caused the initial dts in h264 streams returned by
av_read_frame to be incorrect. The commit was r20599. The root cause
of the problem comes from moving the assignment of s->avctx->pix_fmt
from h264.c:decode_init() to decode_slice_header(). This movement has the
side effect of making has_codec_parameters() in libavformat/utils.c fail
during av_find_stream_info(). This causes try_decode_frame() to be called
which ultimately sets st->codec->has_b_frames = 2. This the causes
compute_pkt_fields() in libavformat/utils.c to start buffering up multiple
pts values in st->pts_buffer. All this happens during the initial call
to av_find_stream_info. Then later, when the application calls
av_read_frame, the pts values that were buffered during the previous
av_find_stream_info are used to set the dts value of the returned packet.
This is especially obnoxious when the reader does a seek before
av_read_frame.
The reason this worked prior to r20599 is that st->codec->has_b_frames would
only be set to 0 during av_find_stream_info, so only the first entry of
st->pts_buffer would ever be filled in. And this first entry is always
replaced on the next iteration.
More information about the ffmpeg-devel
mailing list