On Fri, Mar 11, 2016 at 12:34:19PM -0800, Sasi Inguva wrote: > Fill DTS if all packets have been read in avformat_find_stream_info, and still > has_decode_delay_been_guessed returns false. > > Signed-off-by: Sasi Inguva <is...@google.com> > --- > libavformat/utils.c | 37 +++++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/libavformat/utils.c b/libavformat/utils.c > index 5f48de1..f22309d 100644 > --- a/libavformat/utils.c > +++ b/libavformat/utils.c > @@ -877,6 +877,7 @@ static int has_decode_delay_been_guessed(AVStream *st) > avpriv_h264_has_num_reorder_frames(st->codec) == > st->codec->has_b_frames) > return 1; > #endif > + > if (st->codec->has_b_frames<3) > return st->nb_decoded_frames >= 7; > else if (st->codec->has_b_frames<4) > @@ -3165,6 +3166,7 @@ int avformat_find_stream_info(AVFormatContext *ic, > AVDictionary **options) > int64_t max_stream_analyze_duration; > int64_t max_subtitle_analyze_duration; > int64_t probesize = ic->probesize; > + int eof_reached = 0; > > flush_codecs = probesize > 0; > > @@ -3331,6 +3333,7 @@ int avformat_find_stream_info(AVFormatContext *ic, > AVDictionary **options) > > if (ret < 0) { > /* EOF or error*/ > + eof_reached = 1; > break; > } > > @@ -3454,6 +3457,40 @@ int avformat_find_stream_info(AVFormatContext *ic, > AVDictionary **options) > count++; > } > > + if (eof_reached && ic->internal->packet_buffer) { > + int stream_index; > + for (stream_index = 0; stream_index < ic->nb_streams; > stream_index++) { > + AVPacketList *pktl = ic->internal->packet_buffer; > + int64_t pts_buffer[MAX_REORDER_DELAY+1]; > + > + // EOF already reached while reading the stream above. > + // So continue with reoordering DTS with whatever delay we have. > + int codec_delay = st->codec->has_b_frames; > + > + st = ic->streams[stream_index]; > +
> + if (st->codec->codec_id != AV_CODEC_ID_H264 || > + has_decode_delay_been_guessed(st)) { > + continue; > + } has_decode_delay_been_guessed already contains the H264 check, theres no need to duplicate it here > + > + > + for (; pktl; pktl = get_next_pkt(ic, st, pktl)) { > + if (pktl->pkt.stream_index != stream_index) > + continue; > + > + if (pktl->pkt.pts != AV_NOPTS_VALUE && codec_delay <= > MAX_REORDER_DELAY) { > + int j; > + pts_buffer[0] = pktl->pkt.pts; > + for (j = 0; j < codec_delay && pts_buffer[j] > > pts_buffer[j + 1]; j++) > + FFSWAP(int64_t, pts_buffer[j], pts_buffer[j + 1]); wrong indention > + > + pktl->pkt.dts = select_from_pts_buffer(st, pts_buffer, > pktl->pkt.dts); > + } > + } this loop occurs elsewhere too, please factor it into a function and not duplicate it otherwise it certainly would become out of sync if either is changed [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel