[FFmpeg-cvslog] avformat/mov: Set duration to zero if the duration is UINT_MAX
ffmpeg | branch: master | Sasi Inguva | Wed Oct 26 12:40:13 2016 -0700| [9d8d7bdffb0e0e229b7d896c2df04a0237e9a243] | committer: James Almer avformat/mov: Set duration to zero if the duration is UINT_MAX Fixes some MP4F files which have duration in mdhd set to UINT_MAX instead of zero. Signed-off-by: Sasi Inguva Signed-off-by: James Almer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9d8d7bdffb0e0e229b7d896c2df04a0237e9a243 --- libavformat/mov.c | 5 + 1 file changed, 5 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 1f436e21d6..29bd3103e3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1489,6 +1489,11 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) } st->duration = (version == 1) ? avio_rb64(pb) : avio_rb32(pb); /* duration */ +if ((version == 1 && st->duration == UINT64_MAX) || +(version != 1 && st->duration == UINT32_MAX)) { +st->duration = 0; +} + lang = avio_rb16(pb); /* language */ if (ff_mov_lang_to_iso639(lang, language)) av_dict_set(>metadata, "language", language, 0); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog To unsubscribe, visit link above, or email ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-cvslog] lavf/mov.c: Set start_time for all streams (in case of edit lists).
ffmpeg | branch: master | Sasi Inguva | Mon Aug 6 16:28:50 2018 -0700| [12673bb25342c772e1bf5fd2adebd85f97dc616e] | committer: Michael Niedermayer lavf/mov.c: Set start_time for all streams (in case of edit lists). Fixes vorbis mp4 audio files, with edit list specified. Since st->skip_samples is not set in case of vorbis , ffmpeg computes the start_time as negative. Signed-off-by: Sasi Inguva Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12673bb25342c772e1bf5fd2adebd85f97dc616e --- libavformat/mov.c | 4 ++-- tests/fate/mov.mak | 5 + tests/ref/fate/mov-neg-firstpts-discard-vorbis | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 6885ef3b4b..c863047d79 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3686,9 +3686,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) st->index_entries[i].timestamp -= msc->min_corrected_pts; } } -// Start time should be equal to zero or the duration of any empty edits. -st->start_time = empty_edits_sum_duration; } +// Start time should be equal to zero or the duration of any empty edits. +st->start_time = empty_edits_sum_duration; // Update av stream length, if it ends up shorter than the track's media duration st->duration = FFMIN(st->duration, edit_list_dts_entry_end - start_dts); diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 6f0e28d21e..3d9e4280bb 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -19,6 +19,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-stream-shorter-than-movie \ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \ + fate-mov-neg-firstpts-discard-vorbis \ fate-mov-aac-2048-priming \ fate-mov-zombie \ fate-mov-init-nonkeyframe \ @@ -89,6 +90,10 @@ fate-mov-bbi-elst-starts-b: CMD = framemd5 -flags +bitexact -acodec aac_fixed -i # Makes sure that the stream start_time is not negative when the first packet is a DISCARD packet with negative timestamp. fate-mov-neg-firstpts-discard: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=start_time -bitexact $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov +# Makes sure that the VORBIS audio stream start_time is not negative when the first few packets are DISCARD packets +# with negative timestamps (skip_samples is not set for Vorbis, so ffmpeg computes start_time as negative if not specified by demuxer). +fate-mov-neg-firstpts-discard-vorbis: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=start_time -bitexact $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard_vorbis.mp4 + # Makes sure that expected frames are generated for mov_neg_first_pts_discard.mov with -vsync 1 fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov -vsync 1 diff --git a/tests/ref/fate/mov-neg-firstpts-discard-vorbis b/tests/ref/fate/mov-neg-firstpts-discard-vorbis new file mode 100644 index 00..2e295e3b68 --- /dev/null +++ b/tests/ref/fate/mov-neg-firstpts-discard-vorbis @@ -0,0 +1,3 @@ +[STREAM] +start_time=0.00 +[/STREAM] ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/mov.c: Set st->start_time for video streams explicitly.
ffmpeg | branch: master | Sasi Inguva | Tue May 29 15:36:07 2018 -0700| [fe6c4f0c47d4390bead6e226cb12b45584b76301] | committer: Michael Niedermayer lavf/mov.c: Set st->start_time for video streams explicitly. If start_time is not set, ffmpeg takes the duration from the global movie instead of the per stream duration. Signed-off-by: Sasi Inguva Signed-off-by: Michael Niedermayer > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe6c4f0c47d4390bead6e226cb12b45584b76301 --- libavformat/mov.c| 20 + tests/fate/mov.mak | 4 tests/ref/fate/mov-neg-firstpts-discard | 2 +- tests/ref/fate/mov-stream-shorter-than-movie | 33 4 files changed, 54 insertions(+), 5 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index cab7247cc5..4ad19122b3 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3673,11 +3673,15 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // If the minimum pts turns out to be greater than zero after fixing the index, then we subtract the // dts by that amount to make the first pts zero. -if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && msc->min_corrected_pts > 0) { -av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts); -for (i = 0; i < st->nb_index_entries; ++i) { -st->index_entries[i].timestamp -= msc->min_corrected_pts; +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { +if (msc->min_corrected_pts > 0) { +av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts); +for (i = 0; i < st->nb_index_entries; ++i) { +st->index_entries[i].timestamp -= msc->min_corrected_pts; +} } +// Start time should be equal to zero or the duration of any empty edits. +st->start_time = empty_edits_sum_duration; } // Update av stream length, if it ends up shorter than the track's media duration @@ -4013,6 +4017,14 @@ static void mov_build_index(MOVContext *mov, AVStream *st) mov_fix_index(mov, st); } +// Update start time of the stream. +if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries > 0) { +st->start_time = st->index_entries[0].timestamp + sc->dts_shift; +if (sc->ctts_data) { +st->start_time += sc->ctts_data[0].duration; +} +} + mov_estimate_video_delay(mov, st); } diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index eadee3abfa..960b1867dd 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -16,6 +16,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-frag-overlap \ fate-mov-bbi-elst-starts-b \ fate-mov-neg-firstpts-discard-frames \ + fate-mov-stream-shorter-than-movie \ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \ fate-mov-aac-2048-priming \ @@ -88,6 +89,9 @@ fate-mov-neg-firstpts-discard: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entri # Makes sure that expected frames are generated for mov_neg_first_pts_discard.mov with -vsync 1 fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov -vsync 1 +# Makes sure that no frame is dropped/duplicated with fps filter due to start_time / duration miscalculations. +fate-mov-stream-shorter-than-movie: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_stream_shorter_than_movie.mov -vf fps=fps=24 -an + fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets -show_frames -bitexact -print_format compact $(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov diff --git a/tests/ref/fate/mov-neg-firstpts-discard b/tests/ref/fate/mov-neg-firstpts-discard index 7c982d3ffe..2e295e3b68 100644 --- a/tests/ref/fate/mov-neg-firstpts-discard +++ b/tests/ref/fate/mov-neg-firstpts-discard @@ -1,3 +1,3 @@ [STREAM] -start_time=N/A +start_time=0.00 [/STREAM] diff --git a/tests/ref/fate/mov-stream-shorter-than-movie b/tests/ref/fate/mov-stream-shorter-than-movie new file mode 100644 index 00..28f3ef378c --- /dev/null +++ b/tests/ref/fate/mov-stream-shorter-than-movie @@ -0,0 +1,33 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 640x480 +#sar 0: 0/1 +#stream#, dts,pts, duration, size, hash +0, 0, 0,1, 46
[FFmpeg-cvslog] lavf/mov.c: Fix timestamps to be strictly monotonic for video also.
ffmpeg | branch: master | Sasi Inguva | Thu Mar 29 15:58:09 2018 -0700| [318d0fcbfe5637013342d53d44bb7ea8867fb4d0] | committer: Derek Buitenhuis lavf/mov.c: Fix timestamps to be strictly monotonic for video also. We already do this for audio, but it should be done for video too. If we don't, seeking back to the start of the file, for example, can become quite broken, since the first N packets will have repeating and nonmonotonic PTS, yet they need to be decoded even if they are to be discarded. Signed-off-by: Sasi Inguva Signed-off-by: Derek Buitenhuis > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=318d0fcbfe5637013342d53d44bb7ea8867fb4d0 --- libavformat/mov.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 08cc382a68..cab7247cc5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3587,7 +3587,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) flags |= AVINDEX_DISCARD_FRAME; av_log(mov->fc, AV_LOG_DEBUG, "drop a frame at curr_cts: %"PRId64" @ %"PRId64"\n", curr_cts, index); -if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && edit_list_start_encountered == 0) { +if (edit_list_start_encountered == 0) { num_discarded_begin++; frame_duration_buffer = av_realloc(frame_duration_buffer, num_discarded_begin * sizeof(int64_t)); @@ -3598,7 +3598,8 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) frame_duration_buffer[num_discarded_begin - 1] = frame_duration; // Increment skip_samples for the first non-zero audio edit list -if (first_non_zero_audio_edit > 0 && st->codecpar->codec_id != AV_CODEC_ID_VORBIS) { +if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && +first_non_zero_audio_edit > 0 && st->codecpar->codec_id != AV_CODEC_ID_VORBIS) { st->skip_samples += frame_duration; } } @@ -3611,9 +3612,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } if (edit_list_start_encountered == 0) { edit_list_start_encountered = 1; -// Make timestamps strictly monotonically increasing for audio, by rewriting timestamps for +// Make timestamps strictly monotonically increasing by rewriting timestamps for // discarded packets. -if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && frame_duration_buffer) { +if (frame_duration_buffer) { fix_index_entry_timestamps(st, st->nb_index_entries, edit_list_dts_counter, frame_duration_buffer, num_discarded_begin); av_freep(_duration_buffer); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/utils.c: Don't compute start_time from DISCARD packets for video.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Wed Mar 21 13:36:38 2018 -0700| [829aebf95d44c1e850fd31692a273e6c6ab8161a] | committer: Michael Niedermayer lavf/utils.c: Don't compute start_time from DISCARD packets for video. Signed-off-by: Sasi Inguva <is...@isasi.mtv.corp.google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=829aebf95d44c1e850fd31692a273e6c6ab8161a --- libavformat/utils.c| 4 +++- tests/fate/mov.mak | 10 +- tests/ref/fate/mov-neg-firstpts-discard| 3 +++ tests/ref/fate/mov-neg-firstpts-discard-frames | 24 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 4d0b56c2a8..f13c8208b1 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1158,7 +1158,9 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, } if (st->start_time == AV_NOPTS_VALUE) { -st->start_time = pts; +if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || !(pkt->flags & AV_PKT_FLAG_DISCARD)) { +st->start_time = pts; +} if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->sample_rate) st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, st->codecpar->sample_rate}, st->time_base); } diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 64f92e9488..9d7d62a023 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -13,8 +13,10 @@ FATE_MOV = fate-mov-3elist \ fate-mov-elst-ends-betn-b-and-i \ fate-mov-frag-overlap \ fate-mov-bbi-elst-starts-b \ + fate-mov-neg-firstpts-discard-frames \ -FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \ +FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \ + fate-mov-aac-2048-priming \ fate-mov-zombie \ fate-mov-init-nonkeyframe \ fate-mov-displaymatrix \ @@ -72,6 +74,12 @@ fate-mov-frag-overlap: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/frag_overlap.mp4 # GOP structure : B B I in presentation order. fate-mov-bbi-elst-starts-b: CMD = framemd5 -flags +bitexact -acodec aac_fixed -i $(TARGET_SAMPLES)/h264/twofields_packet.mp4 +# Makes sure that the stream start_time is not negative when the first packet is a DISCARD packet with negative timestamp. +fate-mov-neg-firstpts-discard: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=start_time -bitexact $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov + +# Makes sure that expected frames are generated for mov_neg_first_pts_discard.mov with -vsync 1 +fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov -vsync 1 + fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets -show_frames -bitexact -print_format compact $(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov diff --git a/tests/ref/fate/mov-neg-firstpts-discard b/tests/ref/fate/mov-neg-firstpts-discard new file mode 100644 index 00..7c982d3ffe --- /dev/null +++ b/tests/ref/fate/mov-neg-firstpts-discard @@ -0,0 +1,3 @@ +[STREAM] +start_time=N/A +[/STREAM] diff --git a/tests/ref/fate/mov-neg-firstpts-discard-frames b/tests/ref/fate/mov-neg-firstpts-discard-frames new file mode 100644 index 00..81b59b384b --- /dev/null +++ b/tests/ref/fate/mov-neg-firstpts-discard-frames @@ -0,0 +1,24 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#tb 0: 1/30 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +#stream#, dts,pts, duration, size, hash +0, 0, 0,1, 115200, 1e55263b359b4c99c3463655a1120f11 +0, 1, 1,1, 115200, ce33efea81064e7c23deb57dc4c21995 +0, 2, 2,1, 115200, 42234f25d6191ab13c3676a7937c921b +0, 3, 3,1, 115200, eab2ccb227c66cba4c9feb8cdbf28ef8 +0, 4, 4,1, 115200, c8816e0b151b2c892163e35086918520 +0, 5, 5,1, 115200, c633f5604c8651165d551ee88fb4cd92 +0, 6, 6,1, 115200, 5f3f8530d720fef3ac4c937e7f488ea7 +0, 7, 7,1, 115200, be24a583909ca92008b642f39be02685 +0, 8, 8,1, 115200, 83872a6e5c3369fe76f684de31bd9a36 +0, 9, 9,1, 115200, 4629d6eb656883b337e8e0b381f2db8d +0, 10, 10,1, 115200, f6bec55bc026440d23a44b948900e785 +0, 11, 11,1, 115200, 7
[FFmpeg-cvslog] lavf/mov.c: Use the correct offset to shift timestamp when seeking.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Fri Mar 9 13:30:21 2018 -0800| [43205df645bc10bc780c646ca0d652b574535f06] | committer: Michael Niedermayer lavf/mov.c: Use the correct offset to shift timestamp when seeking. Fixes seek for files with empty edits and files with negative ctts (dts_shift > 0). Added fate samples and tests. Signed-off-by: Sasi Inguva <is...@isasi.mtv.corp.google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=43205df645bc10bc780c646ca0d652b574535f06 --- libavformat/isom.h | 1 + libavformat/mov.c| 27 --- tests/fate/seek.mak | 6 ++ tests/ref/seek/empty-edit-mp4| 134 +++ tests/ref/seek/test-iibbibb-mp4 | 122 tests/ref/seek/test-iibbibb-neg-ctts-mp4 | 122 6 files changed, 401 insertions(+), 11 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 65676fb0f5..4da34142f0 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -168,6 +168,7 @@ typedef struct MOVStreamContext { int *keyframes; int time_scale; int64_t time_offset; ///< time offset of the edit list entries +int64_t min_corrected_pts; ///< minimum Composition time shown by the edits excluding empty edits. int current_sample; int64_t current_index; MOVIndexRange* index_ranges; diff --git a/libavformat/mov.c b/libavformat/mov.c index 39c2179dcd..51228f5df2 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3378,7 +3378,6 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) int64_t edit_list_start_ctts_sample = 0; int64_t curr_cts; int64_t curr_ctts = 0; -int64_t min_corrected_pts = -1; int64_t empty_edits_sum_duration = 0; int64_t edit_list_index = 0; int64_t index; @@ -3419,6 +3418,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) msc->ctts_sample = 0; msc->ctts_allocated_size = 0; +// Reinitialize min_corrected_pts so that it can be computed again. +msc->min_corrected_pts = -1; + // If the dts_shift is positive (in case of negative ctts values in mov), // then negate the DTS by dts_shift if (msc->dts_shift > 0) { @@ -3563,10 +3565,10 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } } } else { -if (min_corrected_pts < 0) { -min_corrected_pts = edit_list_dts_counter + curr_ctts + msc->dts_shift; +if (msc->min_corrected_pts < 0) { +msc->min_corrected_pts = edit_list_dts_counter + curr_ctts + msc->dts_shift; } else { -min_corrected_pts = FFMIN(min_corrected_pts, edit_list_dts_counter + curr_ctts + msc->dts_shift); +msc->min_corrected_pts = FFMIN(msc->min_corrected_pts, edit_list_dts_counter + curr_ctts + msc->dts_shift); } if (edit_list_start_encountered == 0) { edit_list_start_encountered = 1; @@ -3625,16 +3627,16 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } } } -// If there are empty edits, then min_corrected_pts might be positive intentionally. So we subtract the -// sum duration of emtpy edits here. -min_corrected_pts -= empty_edits_sum_duration; +// If there are empty edits, then msc->min_corrected_pts might be positive +// intentionally. So we subtract the sum duration of emtpy edits here. +msc->min_corrected_pts -= empty_edits_sum_duration; // If the minimum pts turns out to be greater than zero after fixing the index, then we subtract the // dts by that amount to make the first pts zero. -if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && min_corrected_pts > 0) { -av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", min_corrected_pts); +if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && msc->min_corrected_pts > 0) { +av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts); for (i = 0; i < st->nb_index_entries; ++i) { -st->index_entries[i].timestamp -= min_corrected_pts; +st->index_entries[i].timestamp -= msc->min_corrected_pts; } } @@ -3697,6 +3699,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st) if (empty_duration) empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale); sc->time_offset = start_time - empty_du
[FFmpeg-cvslog] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Mon Dec 18 15:31:16 2017 -0800| [58a25aeb8e69532aae6ed1762fe7e0b260990010] | committer: Michael Niedermayer lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=58a25aeb8e69532aae6ed1762fe7e0b260990010 --- libavformat/mov.c| 56 tests/fate/mov.mak | 7 + tests/ref/fate/mov-guess-delay-1 | 3 +++ tests/ref/fate/mov-guess-delay-2 | 3 +++ tests/ref/fate/mov-guess-delay-3 | 3 +++ 5 files changed, 72 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 28d60289aa..480e506370 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3241,6 +3241,60 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, unsigned int* ctts_count, uns return *ctts_count; } +#define MAX_REORDER_DELAY 16 +static void mov_estimate_video_delay(MOVContext *c, AVStream* st) { +MOVStreamContext *msc = st->priv_data; +int ind; +int ctts_ind = 0; +int ctts_sample = 0; +int64_t pts_buf[MAX_REORDER_DELAY + 1]; // Circular buffer to sort pts. +int buf_start = 0; +int buf_size = 0; +int j, r, num_swaps; + +if (st->codecpar->video_delay <= 0 && msc->ctts_data && +st->codecpar->codec_id == AV_CODEC_ID_H264) { +st->codecpar->video_delay = 0; +for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; ++ind) { +if (buf_size == (MAX_REORDER_DELAY + 1)) { +// If circular buffer is full, then move the first element forward. +buf_start = (buf_start + 1) % buf_size; +} else { +++buf_size; +} + +// Point j to the last elem of the buffer and insert the current pts there. +j = (buf_start + buf_size - 1) % buf_size; +pts_buf[j] = st->index_entries[ind].timestamp + msc->ctts_data[ctts_ind].duration; + +// The timestamps that are already in the sorted buffer, and are greater than the +// current pts, are exactly the timestamps that need to be buffered to output PTS +// in correct sorted order. +// Hence the video delay (which is the buffer size used to sort DTS and output PTS), +// can be computed as the maximum no. of swaps any particular timestamp needs to +// go through, to keep this buffer in sorted order. +num_swaps = 0; +while (j != buf_start) { +r = (j - 1 + buf_size) % buf_size; +if (pts_buf[j] < pts_buf[r]) { +FFSWAP(int64_t, pts_buf[j], pts_buf[r]); +++num_swaps; +} +j = r; +} +st->codecpar->video_delay = FFMAX(st->codecpar->video_delay, num_swaps); + +ctts_sample++; +if (ctts_sample == msc->ctts_data[ctts_ind].count) { +ctts_ind++; +ctts_sample = 0; +} +} +av_log(c->fc, AV_LOG_DEBUG, "Setting codecpar->delay to %d for stream st: %d\n", + st->codecpar->video_delay, st->index); +} +} + static void mov_current_sample_inc(MOVStreamContext *sc) { sc->current_sample++; @@ -3897,6 +3951,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st) // Fix index according to edit lists. mov_fix_index(mov, st); } + +mov_estimate_video_delay(mov, st); } static int test_same_origin(const char *src, const char *ref) { diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 19b01304fb..907dfa0b69 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -13,6 +13,9 @@ FATE_MOV = fate-mov-3elist \ fate-mov-elst-ends-betn-b-and-i \ fate-mov-frag-overlap \ fate-mov-bbi-elst-starts-b \ + fate-mov-guess-delay-1 \ + fate-mov-guess-delay-2 \ + fate-mov-guess-delay-3 \ FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \ fate-mov-zombie \ @@ -82,3 +85,7 @@ fate-mov-spherical-mono: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries str fate-mov-gpmf-remux: CMD = md5 -i $(TARGET_SAMPLES)/mov/fake-gp-media-with-real-gpmf.mp4 -map 0 -c copy -fflags +bitexact -f mp4 fate-mov-gpmf-remux: CMP = oneline fate-mov-gpmf-remux: REF = 8f48e435ee1f6b7e173ea756141eabf3 + +fate-mov-guess-delay-1: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries stream=has_b_frames -select_streams v $(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4 +fate-mov-guess-delay-2: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries strea
[FFmpeg-cvslog] lavf/mov.c: Don't correct edit list start to zero, when we can't find a frame before edit list start.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Mon Nov 13 18:09:28 2017 -0800| [54f8ac199fe38b2837146621963bb543868130be] | committer: Michael Niedermayer lavf/mov.c: Don't correct edit list start to zero, when we can't find a frame before edit list start. After c2a8f0fcbe57ea9ccaa864130f078af10516c3c1 this can happen on normal edit lists starting on a B-frame. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=54f8ac199fe38b2837146621963bb543868130be --- libavformat/mov.c| 4 +- tests/fate/mov.mak | 6 + tests/ref/fate/mov-bbi-elst-starts-b | 391 +++ 3 files changed, 398 insertions(+), 3 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index fd170baa57..79023ef369 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3380,13 +3380,11 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) if (find_prev_closest_index(st, e_old, nb_old, ctts_data_old, ctts_count_old, search_timestamp, AVSEEK_FLAG_ANY, , _index_old, _sample_old) < 0) { av_log(mov->fc, AV_LOG_WARNING, - "st: %d edit list %"PRId64" Cannot find an index entry before timestamp: %"PRId64".\n" - "Rounding edit list media time to zero.\n", + "st: %d edit list %"PRId64" Cannot find an index entry before timestamp: %"PRId64".\n", st->index, edit_list_index, search_timestamp); index = 0; ctts_index_old = 0; ctts_sample_old = 0; -edit_list_media_time = 0; } } current = e_old + index; diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index a98372c5e1..680baea773 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -12,6 +12,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-ibi-elst-starts-b \ fate-mov-elst-ends-betn-b-and-i \ fate-mov-frag-overlap \ + fate-mov-bbi-elst-starts-b \ FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \ fate-mov-zombie \ @@ -63,6 +64,11 @@ fate-mov-ibi-elst-starts-b: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES) # Makes sure that we handle overlapping framgments fate-mov-frag-overlap: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/frag_overlap.mp4 +# Makes sure that we pick the right frames according to edit list when there is no keyframe with PTS < edit list start. +# For example, when video starts on a B-frame, and edit list starts on that B-frame too. +# GOP structure : B B I in presentation order. +fate-mov-bbi-elst-starts-b: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/h264/twofields_packet.mp4 + fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets -show_frames -bitexact -print_format compact $(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov diff --git a/tests/ref/fate/mov-bbi-elst-starts-b b/tests/ref/fate/mov-bbi-elst-starts-b new file mode 100644 index 00..d3ede1a86c --- /dev/null +++ b/tests/ref/fate/mov-bbi-elst-starts-b @@ -0,0 +1,391 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#tb 0: 1001/3 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 1920x1080 +#sar 0: 1/1 +#tb 1: 1/48000 +#media_type 1: audio +#codec_id 1: pcm_s16le +#sample_rate 1: 48000 +#channel_layout 1: 3 +#channel_layout_name 1: stereo +#stream#, dts,pts, duration, size, hash +0, 0, 0,1, 3110400, e9454409af76038dbe56e834921d2fa8 +1, 0, 0, 1024, 4096, 620f0b67a91f7f74151bc5be745b7110 +1, 1024, 1024, 1024, 4096, 8ab1a8e40b154f577914e43ec6cdc674 +0, 1, 1,1, 3110400, 37aa620e494d22ba248feea9a5a869a0 +1, 2048, 2048, 1024, 4096, 41f09b125271955596ef56436e5ae7b3 +1, 3072, 3072, 1024, 4096, e4934aa9fbaf7dcd578fe9f404bfdd39 +0, 2, 2,1, 3110400, 7b8be9619e4e1d618ab1ed85aff3957b +1, 4096, 4096, 1024, 4096, 5321f9a453ff71e420b592c9188560f4 +0, 3, 3,1, 3110400, 756a4551420853bc3ae444e6b86169f3 +1, 5120, 5120, 1024, 4096, fa45be5ec01b9c0ae78f876f290602e2 +1, 6144, 6144, 1024, 4096, bce7b47534cf6ae5db1fa27805fd52a6 +0, 4, 4,1, 3110400, 94a93c1669a96ebf41a7258177849396 +1, 7168, 7168, 1024, 4096, 15f899020d6e186b2f2a15b60034fa26 +0, 5,
[FFmpeg-cvslog] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Nov 9 16:11:22 2017 -0800| [bc509617310d60216e1f1433a13bebe16d4d9d40] | committer: Michael Niedermayer lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index. Partially fixes t/6699. Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=bc509617310d60216e1f1433a13bebe16d4d9d40 --- libavformat/mov.c | 32 +++--- tests/fate/mov.mak| 4 tests/ref/fate/mov-elst-ends-betn-b-and-i | 33 +++ 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 5fc597ee26..fd170baa57 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3298,6 +3298,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) int packet_skip_samples = 0; MOVIndexRange *current_index_range; int i; +int found_keyframe_after_edit = 0; if (!msc->elst_data || msc->elst_count <= 0 || nb_old <= 0) { return; @@ -3393,6 +3394,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // Iterate over index and arrange it according to edit list edit_list_start_encountered = 0; +found_keyframe_after_edit = 0; for (; current < e_old_end; current++, index++) { // check if frame outside edit list mark it for discard frame_duration = (current + 1 < e_old_end) ? @@ -3505,18 +3507,26 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } // Break when found first key frame after edit entry completion -if (((curr_cts + frame_duration) >= (edit_list_duration + edit_list_media_time)) && +if ((curr_cts + frame_duration >= (edit_list_duration + edit_list_media_time)) && ((flags & AVINDEX_KEYFRAME) || ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO { - -if (ctts_data_old && ctts_sample_old != 0) { -if (add_ctts_entry(>ctts_data, >ctts_count, - >ctts_allocated_size, - ctts_sample_old - edit_list_start_ctts_sample, - ctts_data_old[ctts_index_old].duration) == -1) { -av_log(mov->fc, AV_LOG_ERROR, "Cannot add CTTS entry %"PRId64" - {%"PRId64", %d}\n", - ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample, - ctts_data_old[ctts_index_old].duration); -break; +if (ctts_data_old) { +// If we have CTTS and this is the the first keyframe after edit elist, +// wait for one more, because there might be trailing B-frames after this I-frame +// that do belong to the edit. +if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO && found_keyframe_after_edit == 0) { +found_keyframe_after_edit = 1; +continue; +} +if (ctts_sample_old != 0) { +if (add_ctts_entry(>ctts_data, >ctts_count, + >ctts_allocated_size, + ctts_sample_old - edit_list_start_ctts_sample, + ctts_data_old[ctts_index_old].duration) == -1) { +av_log(mov->fc, AV_LOG_ERROR, "Cannot add CTTS entry %"PRId64" - {%"PRId64", %d}\n", + ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample, + ctts_data_old[ctts_index_old].duration); +break; +} } } break; diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 01893a0767..76f66ff498 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -10,6 +10,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-gpmf-remux \ fate-mov-440hz-10ms \ fate-mov-ibi-elst-starts-b \ + fate-mov-elst-ends-betn-b-and-i \ FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \ fate-mov-zombie \ @@ -42,6 +43,9 @@ fate-mov-1elist-ends-last-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-1e # Makes sure that we handle timestamps of packets in case of multiple edit lists with one of them ending on a B-frame correctly. fate-mov-2elist-elist1-ends-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-2elist-elist1-ends-bframe.mov +# Makes sure that if edit lis
[FFmpeg-cvslog] lavf/mov.c: Refine edit list start seek, based on PTS computed from CTTS.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Nov 2 17:33:28 2017 -0700| [c2a8f0fcbe57ea9ccaa864130f078af10516c3c1] | committer: Michael Niedermayer lavf/mov.c: Refine edit list start seek, based on PTS computed from CTTS. Partially fixes t/6699. Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c2a8f0fcbe57ea9ccaa864130f078af10516c3c1 --- libavformat/mov.c| 129 +++ tests/fate/mov.mak | 8 +++ tests/ref/fate/mov-ibi-elst-starts-b | 33 + 3 files changed, 127 insertions(+), 43 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 60f0228e2d..7954db6e47 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3014,34 +3014,99 @@ static int get_edit_list_entry(MOVContext *mov, } /** - * Find the closest previous frame to the timestamp, in e_old index + * Find the closest previous frame to the timestamp_pts, in e_old index * entries. Searching for just any frame / just key frames can be controlled by * last argument 'flag'. - * Returns the index of the entry in st->index_entries if successful, - * else returns -1. + * Note that if ctts_data is not NULL, we will always search for a key frame + * irrespective of the value of 'flag'. If we don't find any keyframe, we will + * return the first frame of the video. + * + * Here the timestamp_pts is considered to be a presentation timestamp and + * the timestamp of index entries are considered to be decoding timestamps. + * + * Returns 0 if successful in finding a frame, else returns -1. + * Places the found index corresponding output arg. + * + * If ctts_old is not NULL, then refines the searched entry by searching + * backwards from the found timestamp, to find the frame with correct PTS. + * + * Places the found ctts_index and ctts_sample in corresponding output args. */ -static int64_t find_prev_closest_index(AVStream *st, - AVIndexEntry *e_old, - int nb_old, - int64_t timestamp, - int flag) +static int find_prev_closest_index(AVStream *st, + AVIndexEntry *e_old, + int nb_old, + MOVStts* ctts_data, + int64_t ctts_count, + int64_t timestamp_pts, + int flag, + int64_t* index, + int64_t* ctts_index, + int64_t* ctts_sample) { +MOVStreamContext *msc = st->priv_data; AVIndexEntry *e_keep = st->index_entries; int nb_keep = st->nb_index_entries; -int64_t found = -1; int64_t i = 0; +int64_t index_ctts_count; + +av_assert0(index); + +// If dts_shift > 0, then all the index timestamps will have to be offset by +// at least dts_shift amount to obtain PTS. +// Hence we decrement the searched timestamp_pts by dts_shift to find the closest index element. +if (msc->dts_shift > 0) { +timestamp_pts -= msc->dts_shift; +} st->index_entries = e_old; st->nb_index_entries = nb_old; -found = av_index_search_timestamp(st, timestamp, flag | AVSEEK_FLAG_BACKWARD); +*index = av_index_search_timestamp(st, timestamp_pts, flag | AVSEEK_FLAG_BACKWARD); // Keep going backwards in the index entries until the timestamp is the same. -if (found >= 0) { -for (i = found; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp; +if (*index >= 0) { +for (i = *index; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp; i--) { if ((flag & AVSEEK_FLAG_ANY) || (e_old[i - 1].flags & AVINDEX_KEYFRAME)) { -found = i - 1; +*index = i - 1; +} +} +} + +// If we have CTTS then refine the search, by searching backwards over PTS +// computed by adding corresponding CTTS durations to index timestamps. +if (ctts_data && *index >= 0) { +av_assert0(ctts_index); +av_assert0(ctts_sample); +// Find out the ctts_index for the found frame. +*ctts_index = 0; +*ctts_sample = 0; +for (index_ctts_count = 0; index_ctts_count < *index; index_ctts_count++) { +if (*ctts_index < ctts_count) { +(*ctts_sample)++; +if (ctts_data[*ctts_index].count == *ctts_sample) { +(*ctts_index)++; +*ctts_sample = 0; +} +} +} + +while (*index >= 0 && (*ctts_index) &g
[FFmpeg-cvslog] lavf/mov.c: Fix parsing of edit list atoms with invalid elst entry count.
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Wed Oct 18 20:11:16 2017 -0700| [80137531139588774e048d6e1dae34ab5cbbbfa2] | committer: Michael Niedermayer lavf/mov.c: Fix parsing of edit list atoms with invalid elst entry count. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=80137531139588774e048d6e1dae34ab5cbbbfa2 --- libavformat/mov.c | 21 ++- tests/fate/mov.mak | 4 ++ tests/ref/fate/mov-invalid-elst-entry-count | 57 + 3 files changed, 81 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 2ee67561e4..209b7470a9 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4852,6 +4852,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVStreamContext *sc; int i, edit_count, version; +int64_t elst_entry_size; if (c->fc->nb_streams < 1 || c->ignore_editlist) return 0; @@ -4860,6 +4861,21 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) version = avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ edit_count = avio_rb32(pb); /* entries */ +atom.size -= 8; + +elst_entry_size = version == 1 ? 20 : 12; +if (atom.size != edit_count * elst_entry_size) { +if (c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) { +av_log(c->fc, AV_LOG_ERROR, "Invalid edit list entry_count: %d for elst atom of size: %"PRId64" bytes.\n", + edit_count, atom.size + 8); +return AVERROR_INVALIDDATA; +} else { +edit_count = atom.size / elst_entry_size; +if (edit_count * elst_entry_size != atom.size) { +av_log(c->fc, AV_LOG_WARNING, "ELST atom of %"PRId64" bytes, bigger than %d entries.", atom.size, edit_count); +} +} +} if (!edit_count) return 0; @@ -4872,17 +4888,20 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR(ENOMEM); av_log(c->fc, AV_LOG_TRACE, "track[%u].edit_count = %i\n", c->fc->nb_streams - 1, edit_count); -for (i = 0; i < edit_count && !pb->eof_reached; i++) { +for (i = 0; i < edit_count && atom.size > 0 && !pb->eof_reached; i++) { MOVElst *e = >elst_data[i]; if (version == 1) { e->duration = avio_rb64(pb); e->time = avio_rb64(pb); +atom.size -= 16; } else { e->duration = avio_rb32(pb); /* segment duration */ e->time = (int32_t)avio_rb32(pb); /* media time */ +atom.size -= 8; } e->rate = avio_rb32(pb) / 65536.0; +atom.size -= 4; av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n", e->duration, e->time, e->rate); diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 5013e7d528..604703e254 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -6,6 +6,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-1elist-ends-last-bframe \ fate-mov-2elist-elist1-ends-bframe \ fate-mov-3elist-encrypted \ + fate-mov-invalid-elst-entry-count \ fate-mov-gpmf-remux \ fate-mov-440hz-10ms \ @@ -43,6 +44,9 @@ fate-mov-2elist-elist1-ends-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov- # Makes sure that we handle edit lists and start padding correctly. fate-mov-440hz-10ms: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/440hz-10ms.m4a +# Makes sure that we handle invalid edit list entry count correctly. +fate-mov-invalid-elst-entry-count: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/invalid_elst_entry_count.mov + fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets -show_frames -bitexact -print_format compact $(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov diff --git a/tests/ref/fate/mov-invalid-elst-entry-count b/tests/ref/fate/mov-invalid-elst-entry-count new file mode 100644 index 00..13b575816b --- /dev/null +++ b/tests/ref/fate/mov-invalid-elst-entry-count @@ -0,0 +1,57 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 640x480 +#sar 0: 1/1 +#stream#, dts,pts, duration, size, hash +0, 0, 0,1, 460800, 549730883a0b56e6accaf021903daecf +0, 1, 1,1, 460800, 783389b4342d4be925fc52447
[FFmpeg-cvslog] ffmpeg.c: Fallback to duration_dts, when duration_pts can't be determined.
ffmpeg | branch: release/3.4 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Oct 10 10:36:58 2017 -0700| [8500de89ea9111e859c1ca8c51e7a3ed2ff76846] | committer: Michael Niedermayer ffmpeg.c: Fallback to duration_dts, when duration_pts can't be determined. This is required for FLV files, for which duration_pts comes out to be zero. Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Thomas Mundt <tmund...@gmail.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> (cherry picked from commit 2b006ccf8318d84101ed83b75df4c9682a963217) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8500de89ea9111e859c1ca8c51e7a3ed2ff76846 --- fftools/ffmpeg.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6d64bc1043..3ee31473dc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2665,8 +2665,13 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo ist->next_dts = AV_NOPTS_VALUE; } -if (got_output) -ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q); +if (got_output) { +if (duration_pts > 0) { +ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q); +} else { +ist->next_pts += duration_dts; +} +} break; case AVMEDIA_TYPE_SUBTITLE: if (repeating) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmpeg.c: Fallback to duration_dts, when duration_pts can't be determined.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Oct 10 10:36:58 2017 -0700| [2b006ccf8318d84101ed83b75df4c9682a963217] | committer: Michael Niedermayer ffmpeg.c: Fallback to duration_dts, when duration_pts can't be determined. This is required for FLV files, for which duration_pts comes out to be zero. Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Thomas Mundt <tmund...@gmail.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2b006ccf8318d84101ed83b75df4c9682a963217 --- fftools/ffmpeg.c | 9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6d64bc1043..3ee31473dc 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2665,8 +2665,13 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo ist->next_dts = AV_NOPTS_VALUE; } -if (got_output) -ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q); +if (got_output) { +if (duration_pts > 0) { +ist->next_pts += av_rescale_q(duration_pts, ist->st->time_base, AV_TIME_BASE_Q); +} else { +ist->next_pts += duration_dts; +} +} break; case AVMEDIA_TYPE_SUBTITLE: if (repeating) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavfi/avfilter.c: Correct guess_status_pts to account for differing link timebases.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Fri Oct 6 09:31:13 2017 -0700| [123f6dc6b56392cdc8ec648da52c64c94ea0ff0c] | committer: Nicolas George lavfi/avfilter.c: Correct guess_status_pts to account for differing link timebases. Signed-off-by: Sasi Inguva <is...@google.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=123f6dc6b56392cdc8ec648da52c64c94ea0ff0c --- libavfilter/avfilter.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 58917ed445..f0f849b326 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -427,19 +427,19 @@ int ff_request_frame(AVFilterLink *link) return 0; } -static int64_t guess_status_pts(AVFilterContext *ctx, int status) +static int64_t guess_status_pts(AVFilterContext *ctx, int status, AVRational link_time_base) { unsigned i; int64_t r = INT64_MAX; for (i = 0; i < ctx->nb_inputs; i++) if (ctx->inputs[i]->status_out == status) -r = FFMIN(r, ctx->inputs[i]->current_pts); +r = FFMIN(r, av_rescale_q(ctx->inputs[i]->current_pts, ctx->inputs[i]->time_base, link_time_base)); if (r < INT64_MAX) return r; av_log(ctx, AV_LOG_WARNING, "EOF timestamp not reliable\n"); for (i = 0; i < ctx->nb_inputs; i++) -r = FFMIN(r, ctx->inputs[i]->status_in_pts); +r = FFMIN(r, av_rescale_q(ctx->inputs[i]->status_in_pts, ctx->inputs[i]->time_base, link_time_base)); if (r < INT64_MAX) return r; return AV_NOPTS_VALUE; @@ -458,7 +458,7 @@ static int ff_request_frame_to_filter(AVFilterLink *link) ret = ff_request_frame(link->src->inputs[0]); if (ret < 0) { if (ret != AVERROR(EAGAIN) && ret != link->status_in) -ff_avfilter_link_set_in_status(link, ret, guess_status_pts(link->src, ret)); +ff_avfilter_link_set_in_status(link, ret, guess_status_pts(link->src, ret, link->time_base)); if (ret == AVERROR_EOF) ret = 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/movenc.c: Set sgpd and sbgp atoms to represent decoder delay for AAC.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Aug 8 17:00:19 2017 -0700| [e7e1fbc49bf64e1a1d19e2a469dd1962d4bdb770] | committer: Michael Niedermayer lavf/movenc.c: Set sgpd and sbgp atoms to represent decoder delay for AAC. According to https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html and ISO-IEC-14496-12 Section 10.1.1.1 and 10.1.1.3 Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Derek Buitenhuis <derek.buitenh...@gmail.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e7e1fbc49bf64e1a1d19e2a469dd1962d4bdb770 --- libavformat/movenc.c| 22 +++--- tests/ref/fate/adtstoasc_ticket3715 | 4 ++-- tests/ref/fate/copy-psp | 4 ++-- tests/ref/fate/movenc | 12 ++-- 4 files changed, 25 insertions(+), 17 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0e5b45d150..5c53ab24e0 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -2208,14 +2208,16 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) (AVRational){1, 1000}, (AVRational){1, 48000}); -if (track->entry) { -sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries)); -if (!sgpd_entries) -return AVERROR(ENOMEM); -} +if (!track->entry) +return 0; -av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS); +sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries)); +if (!sgpd_entries) +return AVERROR(ENOMEM); +av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC); + +if (track->par->codec_id == AV_CODEC_ID_OPUS) { for (i = 0; i < track->entry; i++) { int roll_samples_remaining = roll_samples; int distance = 0; @@ -2242,6 +2244,12 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) sgpd_entries[entries].group_description_index = distance ? ++group : 0; } } +} else { +entries++; +sgpd_entries[entries].count = track->sample_count; +sgpd_entries[entries].roll_distance = 1; +sgpd_entries[entries].group_description_index = ++group; +} entries++; if (!group) { @@ -2304,7 +2312,7 @@ static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext if (track->cenc.aes_ctr) { ff_mov_cenc_write_stbl_atoms(>cenc, pb); } -if (track->par->codec_id == AV_CODEC_ID_OPUS) { +if (track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC) { mov_preroll_write_stbl_atoms(pb, track); } return update_size(pb, pos); diff --git a/tests/ref/fate/adtstoasc_ticket3715 b/tests/ref/fate/adtstoasc_ticket3715 index 949b565c2f..96795a2ca3 100644 --- a/tests/ref/fate/adtstoasc_ticket3715 +++ b/tests/ref/fate/adtstoasc_ticket3715 @@ -1,5 +1,5 @@ -ef8ce3cbd1d86113e7c991a816086068 *tests/data/fate/adtstoasc_ticket3715.mov -33270 tests/data/fate/adtstoasc_ticket3715.mov +0221e04333e6ac432fa42960502f0d5a *tests/data/fate/adtstoasc_ticket3715.mov +33324 tests/data/fate/adtstoasc_ticket3715.mov #extradata 0:2, 0x00340022 #tb 0: 1/44100 #media_type 0: audio diff --git a/tests/ref/fate/copy-psp b/tests/ref/fate/copy-psp index 6603d3ff26..81eb172549 100644 --- a/tests/ref/fate/copy-psp +++ b/tests/ref/fate/copy-psp @@ -1,5 +1,5 @@ -6889223644fc560069c8591984175a62 *tests/data/fate/copy-psp.psp -2041379 tests/data/fate/copy-psp.psp +cada61453a2483ef8ba1fb82c8bbff25 *tests/data/fate/copy-psp.psp +2041433 tests/data/fate/copy-psp.psp #extradata 0: 51, 0xaf6d1012 #extradata 1:2, 0x00b200a1 #tb 0: 1/9 diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 09e603aeb7..47bcf9d515 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -1,18 +1,18 @@ write_data len 36, time nopts, type header atom ftyp -write_data len 2335, time nopts, type header atom - +write_data len 2389, time nopts, type header atom - write_data len 788, time 100, type sync atom moof write_data len 110, time nopts, type trailer atom - -214242e9c7c93171d2f47f5b47776559 3269 non-empty-moov +17a37691eba8b858cf15e60aa9a7dbf7 3323 non-empty-moov write_data len 36, time nopts, type header atom ftyp -write_data len 2667, time nopts, type header atom - +write_data len 2721, time nopts, type header atom - write_data len 908, time 97, type sync atom moof write_data len 110, time nopts, type trailer atom - -44467d568a3cc38d414fd8ed4b2a968f 3721 non-empty-moov-elst +0026ffe059c06c592021f972bf2c5e79 3775 non-empty-moov-elst write_data len 36, time nopts, type
[FFmpeg-cvslog] lavf/mov.c: offset index timestamps by the minimum pts to make first pts zero
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Jun 6 11:16:01 2017 -0700| [93db5e3fc41ac0242acab86c3e4ce3a3dfb80075] | committer: wm4 lavf/mov.c: offset index timestamps by the minimum pts to make first pts zero If the videos starts with B frame, then the minimum composition time as computed by stts + ctts will be non-zero. Hence we need to shift the DTS, so that the first pts is zero. This was the intention of that code-block. However it was subtracting by the wrong amount. For example, for one of the videos in the bug nonFormatted.mp4 we have stts: sample_count duration 960 1001 ctts: sample_count duration 1 3003 2 0 1 3003 The resulting composition times are : 3003, 1001, 2002, 6006, ... The minimum composition time or PTS is 1001, which should be used to offset DTS. However the code block was wrongly using ctts[0] which is 3003. Hence the PTS was negative. This change computes the minimum pts encountered while fixing the index, and then subtracts it from all the timestamps after the edit list fixes are applied. Samples files available from: https://bugs.chromium.org/p/chromium/issues/detail?id=721451 https://bugs.chromium.org/p/chromium/issues/detail?id=723537 fate-suite/h264/twofields_packet.mp4 is a similar file starting with 2 B frames. Before this change the PTS of first two B-frames was -6006 and -3003, and I am guessing one of them got dropped when being decoded and remuxed to the framecrc before, and now it is not being dropped. Signed-off-by: Sasi Inguva <is...@google.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=93db5e3fc41ac0242acab86c3e4ce3a3dfb80075 --- libavformat/mov.c| 57 -- tests/ref/fate/h264-twofields-packet | 60 ++-- 2 files changed, 70 insertions(+), 47 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 3845e63b53..d7d64c3361 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3039,6 +3039,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) int64_t edit_list_dts_entry_end = 0; int64_t edit_list_start_ctts_sample = 0; int64_t curr_cts; +int64_t curr_ctts = 0; +int64_t min_corrected_pts = -1; +int64_t empty_edits_sum_duration = 0; int64_t edit_list_index = 0; int64_t index; int64_t index_ctts_count; @@ -3053,6 +3056,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) int first_non_zero_audio_edit = -1; int packet_skip_samples = 0; MOVIndexRange *current_index_range; +int i; if (!msc->elst_data || msc->elst_count <= 0 || nb_old <= 0) { return; @@ -3080,13 +3084,9 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // If the dts_shift is positive (in case of negative ctts values in mov), // then negate the DTS by dts_shift -if (msc->dts_shift > 0) +if (msc->dts_shift > 0) { edit_list_dts_entry_end -= msc->dts_shift; - -// Offset the DTS by ctts[0] to make the PTS of the first frame 0 -if (ctts_data_old && ctts_count_old > 0) { -edit_list_dts_entry_end -= ctts_data_old[0].duration; -av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by ctts[%d].duration: %d\n", 0, ctts_data_old[0].duration); +av_log(mov->fc, AV_LOG_DEBUG, "Shifting DTS by %d because of negative CTTS.\n", msc->dts_shift); } start_dts = edit_list_dts_entry_end; @@ -3100,6 +3100,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) edit_list_dts_entry_end += edit_list_duration; num_discarded_begin = 0; if (edit_list_media_time == -1) { +empty_edits_sum_duration += edit_list_duration; continue; } @@ -3179,11 +3180,13 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // frames (pts) before or after edit list curr_cts = current->timestamp + msc->dts_shift; +curr_ctts = 0; if (ctts_data_old && ctts_index_old < ctts_count_old) { -av_log(mov->fc, AV_LOG_DEBUG, "shifted frame pts, curr_cts: %"PRId64" @ %"PRId64", ctts: %d, ctts_count: %"PRId64"\n", - curr_cts, ctts_index_old, ctts_data_old[ctts_index_old].duration, ctts_count_old); -curr_cts += ctts_data_old[ctts_index_old].duration; +curr_ctts = ctts_data_old[ctts_index_old].duration; +av_log(mov->fc, AV_LOG_DEBUG, "stts: %"PRId64" ctts: %"PRId64", ctts_index: %"PRId64", ctts_count: %"PRId64"\n", + curr_cts, curr_ctts, ctts_index_old, ctts_count_old); +curr_cts += curr_ctts; ctts_sample_old++;
[FFmpeg-cvslog] tests/fate-run.sh: Show packet flags for fate gapless tests.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Mon Sep 26 11:42:52 2016 -0700| [87071478b4a70d3651ce73ee6b9a95a525074403] | committer: Michael Niedermayer tests/fate-run.sh: Show packet flags for fate gapless tests. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=87071478b4a70d3651ce73ee6b9a95a525074403 --- tests/fate-run.sh| 2 +- tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 30 ++-- tests/ref/fate/gaplessenc-pcm-to-mov-aac | 30 ++-- tests/ref/fate/gaplessinfo-itunes1 | 30 ++-- tests/ref/fate/gaplessinfo-itunes2 | 30 ++-- 5 files changed, 61 insertions(+), 61 deletions(-) diff --git a/tests/fate-run.sh b/tests/fate-run.sh index 29a36cea3a..3e8d43c930 100755 --- a/tests/fate-run.sh +++ b/tests/fate-run.sh @@ -107,7 +107,7 @@ probegaplessinfo(){ pktfile1="${outdir}/${test}.pkts" framefile1="${outdir}/${test}.frames" cleanfiles="$cleanfiles $pktfile1 $framefile1" -run ffprobe${PROGSUF} -bitexact -select_streams a -of compact -count_packets -show_entries packet=pts,dts,duration:stream=nb_read_packets -v 0 "$filename" "$@" > "$pktfile1" +run ffprobe${PROGSUF} -bitexact -select_streams a -of compact -count_packets -show_entries packet=pts,dts,duration,flags:stream=nb_read_packets -v 0 "$filename" "$@" > "$pktfile1" head -n 8 "$pktfile1" tail -n 9 "$pktfile1" run ffprobe${PROGSUF} -bitexact -select_streams a -of compact -count_frames -show_entries frame=pkt_pts,pkt_dts,best_effort_timestamp,pkt_duration,nb_samples:stream=nb_read_frames -v 0 "$filename" "$@" > "$framefile1" diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac index a06fbba0fc..76cbf22358 100644 --- a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac +++ b/tests/ref/fate/gaplessenc-itunes-to-ipod-aac @@ -7,22 +7,22 @@ duration_ts=103326 start_time=0.00 duration=2.367000 [/FORMAT] -packet|pts=-1024|dts=-1024|duration=1024side_data| +packet|pts=-1024|dts=-1024|duration=1024|flags=KDside_data| -packet|pts=0|dts=0|duration=1024 -packet|pts=1024|dts=1024|duration=1024 -packet|pts=2048|dts=2048|duration=1024 -packet|pts=3072|dts=3072|duration=1024 -packet|pts=4096|dts=4096|duration=1024 -packet|pts=5120|dts=5120|duration=1024 -packet|pts=95232|dts=95232|duration=1024 -packet|pts=96256|dts=96256|duration=1024 -packet|pts=97280|dts=97280|duration=1024 -packet|pts=98304|dts=98304|duration=1024 -packet|pts=99328|dts=99328|duration=1024 -packet|pts=100352|dts=100352|duration=1024 -packet|pts=101376|dts=101376|duration=1024 -packet|pts=102400|dts=102400|duration=926 +packet|pts=0|dts=0|duration=1024|flags=K_ +packet|pts=1024|dts=1024|duration=1024|flags=K_ +packet|pts=2048|dts=2048|duration=1024|flags=K_ +packet|pts=3072|dts=3072|duration=1024|flags=K_ +packet|pts=4096|dts=4096|duration=1024|flags=K_ +packet|pts=5120|dts=5120|duration=1024|flags=K_ +packet|pts=95232|dts=95232|duration=1024|flags=K_ +packet|pts=96256|dts=96256|duration=1024|flags=K_ +packet|pts=97280|dts=97280|duration=1024|flags=K_ +packet|pts=98304|dts=98304|duration=1024|flags=K_ +packet|pts=99328|dts=99328|duration=1024|flags=K_ +packet|pts=100352|dts=100352|duration=1024|flags=K_ +packet|pts=101376|dts=101376|duration=1024|flags=K_ +packet|pts=102400|dts=102400|duration=926|flags=K_ stream|nb_read_packets=102 frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024 frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024 diff --git a/tests/ref/fate/gaplessenc-pcm-to-mov-aac b/tests/ref/fate/gaplessenc-pcm-to-mov-aac index 305d78e9b6..2b17956e2b 100644 --- a/tests/ref/fate/gaplessenc-pcm-to-mov-aac +++ b/tests/ref/fate/gaplessenc-pcm-to-mov-aac @@ -7,22 +7,22 @@ duration_ts=529200 start_time=0.00 duration=12.024000 [/FORMAT] -packet|pts=-1024|dts=-1024|duration=1024side_data| +packet|pts=-1024|dts=-1024|duration=1024|flags=KDside_data| -packet|pts=0|dts=0|duration=1024 -packet|pts=1024|dts=1024|duration=1024 -packet|pts=2048|dts=2048|duration=1024 -packet|pts=3072|dts=3072|duration=1024 -packet|pts=4096|dts=4096|duration=1024 -packet|pts=5120|dts=5120|duration=1024 -packet|pts=521216|dts=521216|duration=1024 -packet|pts=522240|dts=522240|duration=1024 -packet|pts=523264|dts=523264|duration=1024 -packet|pts=524288|dts=524288|duration=1024 -packet|pts=525312|dts=525312|duration=1024 -packet|pts=526336|dts=526336|duration=1024 -packet|pts=527360|dts=527360|duration=1024 -packet|pts=528384|dts=528384|duration=816 +packet|pts=0|dts=0|duration=10
[FFmpeg-cvslog] lavf/mov.c: Add -advanced_editlist option for mov format.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Mon Jan 9 09:23:38 2017 -0800| [ef71dc7948322254d1f0fa41218b91f2da0279d9] | committer: Michael Niedermayer lavf/mov.c: Add -advanced_editlist option for mov format. Adding an MOV format option to turn on/off the editlist supporting code, introduced in https://github.com/FFmpeg/FFmpeg/commit/ca6cae73db207f17a0d5507609de12842d8f0ca3 Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ef71dc7948322254d1f0fa41218b91f2da0279d9 --- libavformat/isom.h | 1 + libavformat/mov.c | 27 +++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index abcacab..d9956cf 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -234,6 +234,7 @@ typedef struct MOVContext { unsigned int nb_chapter_tracks; int use_absolute_path; int ignore_editlist; +int advanced_editlist; int ignore_chapters; int seek_individually; int64_t next_root_atom; ///< offset of the next root atom diff --git a/libavformat/mov.c b/libavformat/mov.c index e487e59..4550cf0 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3309,7 +3309,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st) uint64_t stream_size = 0; if (sc->elst_count) { -int i, edit_start_index = 0; +int i, edit_start_index = 0, multiple_edits = 0; int64_t empty_duration = 0; // empty duration of the first edit list entry int64_t start_time = 0; // start time of the media @@ -3322,15 +3322,28 @@ static void mov_build_index(MOVContext *mov, AVStream *st) edit_start_index = 1; } else if (i == edit_start_index && e->time >= 0) { start_time = e->time; +} else { +multiple_edits = 1; } } +if (multiple_edits && !mov->advanced_editlist) +av_log(mov->fc, AV_LOG_WARNING, "multiple edit list entries, " + "Use -advanced_editlist to correctly decode otherwise " + "a/v desync might occur\n"); + /* adjust first dts according to edit list */ if ((empty_duration || start_time) && mov->time_scale > 0) { if (empty_duration) empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale); sc->time_offset = start_time - empty_duration; +if (!mov->advanced_editlist) +current_dts = -sc->time_offset; } + +if (!multiple_edits && !mov->advanced_editlist && +st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0) +sc->start_pad = start_time; } /* only use old uncompressed audio chunk demuxing when stts specifies it */ @@ -3564,8 +3577,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st) } } -// Fix index according to edit lists. -mov_fix_index(mov, st); +if (!mov->ignore_editlist && mov->advanced_editlist) { +// Fix index according to edit lists. +mov_fix_index(mov, st); +} } static int test_same_origin(const char *src, const char *ref) { @@ -6478,7 +6493,11 @@ static const AVOption mov_options[] = { "Seek each stream individually to the to the closest point", OFFSET(seek_individually), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS}, -{"ignore_editlist", "", OFFSET(ignore_editlist), AV_OPT_TYPE_BOOL, {.i64 = 0}, +{"ignore_editlist", "Ignore the edit list atom.", OFFSET(ignore_editlist), AV_OPT_TYPE_BOOL, {.i64 = 0}, +0, 1, FLAGS}, +{"advanced_editlist", +"Modify the AVIndex according to the editlists. Use this option to decode in the order specified by the edits.", +OFFSET(advanced_editlist), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS}, {"ignore_chapters", "", OFFSET(ignore_chapters), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS}, ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/mov.c: Correct keyframe search in edit list to return the very first keyframe/ frame with matching timestamp. Fixes ticket#5904
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Wed Feb 15 12:07:55 2017 -0800| [7e538c947547b04267f0b307b0e7d96a84d558e0] | committer: Michael Niedermayer lavf/mov.c: Correct keyframe search in edit list to return the very first keyframe/frame with matching timestamp. Fixes ticket#5904 Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e538c947547b04267f0b307b0e7d96a84d558e0 --- libavformat/mov.c | 12 1 file changed, 12 insertions(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index b518177..2a7cbfe 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2847,11 +2847,23 @@ static int64_t find_prev_closest_index(AVStream *st, AVIndexEntry *e_keep = st->index_entries; int nb_keep = st->nb_index_entries; int64_t found = -1; +int64_t i = 0; st->index_entries = e_old; st->nb_index_entries = nb_old; found = av_index_search_timestamp(st, timestamp, flag | AVSEEK_FLAG_BACKWARD); +// Keep going backwards in the index entries until the timestamp is the same. +if (found >= 0) { +for (i = found; i > 0 && e_old[i].timestamp == e_old[i - 1].timestamp; + i--) { +if ((flag & AVSEEK_FLAG_ANY) || +(e_old[i - 1].flags & AVINDEX_KEYFRAME)) { +found = i - 1; +} +} +} + /* restore AVStream state*/ st->index_entries = e_keep; st->nb_index_entries = nb_keep; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmpeg.c: Add output file index and stream index to vstats file.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Wed Jan 25 16:41:44 2017 -0800| [03e42a4fecae42eec4687fd6f1e1c504303f9b83] | committer: Michael Niedermayer ffmpeg.c: Add output file index and stream index to vstats file. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=03e42a4fecae42eec4687fd6f1e1c504303f9b83 --- doc/ffmpeg.texi | 8 +++- ffmpeg.c| 9 +++-- ffmpeg_opt.c| 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index cdea1a2..996d6a6 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -637,9 +637,15 @@ Dump video coding statistics to @file{vstats_HHMMSS.log}. @item -vstats_file @var{file} Dump video coding statistics to @var{file}. @item -vstats_version @var{file} -Specifies which version of the vstats format to use. If version is 1, format is +Specifies which version of the vstats format to use. Default is 2. + +version = 1 : @code{frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s} + +version > 1: + +@code{out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s} @item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream}) top=1/bottom=0/auto=-1 field first @item -dc @var{precision} diff --git a/ffmpeg.c b/ffmpeg.c index 977708c..0a8f448 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1347,8 +1347,13 @@ static void do_video_stats(OutputStream *ost, int frame_size) enc = ost->enc_ctx; if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { frame_number = ost->st->nb_frames; -fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, -ost->quality / (float)FF_QP2LAMBDA); +if (vstats_version <= 1) { +fprintf(vstats_file, "frame= %5d q= %2.1f ", frame_number, +ost->quality / (float)FF_QP2LAMBDA); +} else { +fprintf(vstats_file, "out= %2d st= %2d frame= %5d q= %2.1f ", ost->file_index, ost->index, frame_number, +ost->quality / (float)FF_QP2LAMBDA); +} if (ost->error[0]>=0 && (enc->flags & AV_CODEC_FLAG_PSNR)) fprintf(vstats_file, "PSNR= %6.2f ", psnr(ost->error[0] / (enc->width * enc->height * 255.0 * 255.0))); diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index b1a62e8..6a47d32 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -121,7 +121,7 @@ int frame_bits_per_raw_sample = 0; float max_error_rate = 2.0/3; int filter_nbthreads = 0; int filter_complex_nbthreads = 0; -int vstats_version = 1; +int vstats_version = 2; static int intra_only = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/matroskaenc.c: Free dyn bufs in mkv_free. Fixes memory leaks when muxing fails.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Jan 26 11:26:46 2017 -0800| [e4a1d87ef88d57cca21ec425120c6a370fdb0210] | committer: Michael Niedermayer lavf/matroskaenc.c: Free dyn bufs in mkv_free. Fixes memory leaks when muxing fails. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e4a1d87ef88d57cca21ec425120c6a370fdb0210 --- libavformat/matroskaenc.c | 17 + 1 file changed, 17 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index f731b67..88f6c64 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -393,6 +393,23 @@ static void put_xiph_size(AVIOContext *pb, int size) * Free the members allocated in the mux context. */ static void mkv_free(MatroskaMuxContext *mkv) { +uint8_t* buf; +if (mkv->dyn_bc) { +avio_close_dyn_buf(mkv->dyn_bc, ); +av_free(buf); +} +if (mkv->info_bc) { +avio_close_dyn_buf(mkv->info_bc, ); +av_free(buf); +} +if (mkv->tracks_bc) { +avio_close_dyn_buf(mkv->tracks_bc, ); +av_free(buf); +} +if (mkv->tags_bc) { +avio_close_dyn_buf(mkv->tags_bc, ); +av_free(buf); +} if (mkv->main_seekhead) { av_freep(>main_seekhead->entries); av_freep(>main_seekhead); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffmpeg_opt.c: Introduce a -vstats_version option and document the existing -vstats format.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Jan 24 08:23:54 2017 -0800| [f227fc4c2a9f355d787621f8c3698bd1921fb019] | committer: Michael Niedermayer ffmpeg_opt.c: Introduce a -vstats_version option and document the existing -vstats format. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f227fc4c2a9f355d787621f8c3698bd1921fb019 --- doc/ffmpeg.texi | 4 ffmpeg.h| 1 + ffmpeg_opt.c| 3 +++ 3 files changed, 8 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index b56bdbe..cdea1a2 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -636,6 +636,10 @@ Calculate PSNR of compressed frames. Dump video coding statistics to @file{vstats_HHMMSS.log}. @item -vstats_file @var{file} Dump video coding statistics to @var{file}. +@item -vstats_version @var{file} +Specifies which version of the vstats format to use. If version is 1, format is + +@code{frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s} @item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream}) top=1/bottom=0/auto=-1 field first @item -dc @var{precision} diff --git a/ffmpeg.h b/ffmpeg.h index 75bf50e..458bb8a 100644 --- a/ffmpeg.h +++ b/ffmpeg.h @@ -597,6 +597,7 @@ extern char *videotoolbox_pixfmt; extern int filter_nbthreads; extern int filter_complex_nbthreads; +extern int vstats_version; extern const AVIOInterruptCB int_cb; diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index a1c02fc..b1a62e8 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -121,6 +121,7 @@ int frame_bits_per_raw_sample = 0; float max_error_rate = 2.0/3; int filter_nbthreads = 0; int filter_complex_nbthreads = 0; +int vstats_version = 1; static int intra_only = 0; @@ -3547,6 +3548,8 @@ const OptionDef options[] = { "dump video coding statistics to file" }, { "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file }, "dump video coding statistics to file", "file" }, +{ "vstats_version", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { _version }, +"Version of the vstats format to use."}, { "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_filters }, "set video filters", "filter_graph" }, { "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC | ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/utils.c: Make sure skip_samples never goes negative.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Fri Nov 4 15:31:58 2016 -0700| [18108f36183836e9651f79f4c779737264318aa1] | committer: Michael Niedermayer lavc/utils.c: Make sure skip_samples never goes negative. Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Derek Buitenhuis <derek.buitenh...@gmail.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18108f36183836e9651f79f4c779737264318aa1 --- libavcodec/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 87de15f..d6dca18 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2391,7 +2391,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr && !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { -avctx->internal->skip_samples -= frame->nb_samples; +avctx->internal->skip_samples = FFMAX(0, avctx->internal->skip_samples - frame->nb_samples); *got_frame_ptr = 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/mov.c: Fallback to finding non-keyframe in fix_index, if keyframe search fails.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Wed Nov 9 10:51:13 2016 -0800| [c8dc11bb9ef92b8e90142a41e91b192346f4d7a0] | committer: Michael Niedermayer lavf/mov.c: Fallback to finding non-keyframe in fix_index, if keyframe search fails. Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Derek Buitenhuis <derek.buitenh...@gmail.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8dc11bb9ef92b8e90142a41e91b192346f4d7a0 --- libavformat/mov.c | 41 tests/fate/mov.mak | 6 +- tests/ref/fate/mp4-init-nonkeyframe | 120 3 files changed, 155 insertions(+), 12 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index ca978c2..9ec7d03 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2822,16 +2822,17 @@ static int get_edit_list_entry(MOVContext *mov, } /** - * Find the closest previous keyframe to the timestamp, in e_old index - * entries. + * Find the closest previous frame to the timestamp, in e_old index + * entries. Searching for just any frame / just key frames can be controlled by + * last argument 'flag'. * Returns the index of the entry in st->index_entries if successful, * else returns -1. */ -static int64_t find_prev_closest_keyframe_index(AVStream *st, -AVIndexEntry *e_old, -int nb_old, -int64_t timestamp, -int flag) +static int64_t find_prev_closest_index(AVStream *st, + AVIndexEntry *e_old, + int nb_old, + int64_t timestamp, + int flag) { AVIndexEntry *e_keep = st->index_entries; int nb_keep = st->nb_index_entries; @@ -3048,10 +3049,21 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) search_timestamp = FFMAX(search_timestamp - msc->time_scale, e_old[0].timestamp); } -index = find_prev_closest_keyframe_index(st, e_old, nb_old, search_timestamp, 0); +index = find_prev_closest_index(st, e_old, nb_old, search_timestamp, 0); if (index == -1) { -av_log(mov->fc, AV_LOG_ERROR, "Missing key frame while reordering index according to edit list\n"); -continue; +av_log(mov->fc, AV_LOG_WARNING, + "st: %d edit list: %"PRId64" Missing key frame while searching for timestamp: %"PRId64"\n", + st->index, edit_list_index, search_timestamp); +index = find_prev_closest_index(st, e_old, nb_old, search_timestamp, AVSEEK_FLAG_ANY); + +if (index == -1) { +av_log(mov->fc, AV_LOG_WARNING, + "st: %d edit list %"PRId64" Cannot find an index entry before timestamp: %"PRId64".\n" + "Rounding edit list media time to zero.\n", + st->index, edit_list_index, search_timestamp); +index = 0; +edit_list_media_time = 0; +} } current = e_old + index; @@ -4443,7 +4455,14 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) } e->rate = avio_rb32(pb) / 65536.0; av_log(c->fc, AV_LOG_TRACE, "duration=%"PRId64" time=%"PRId64" rate=%f\n", -e->duration, e->time, e->rate); + e->duration, e->time, e->rate); + +if (e->time < 0 && e->time != -1 && +c->fc->strict_std_compliance >= FF_COMPLIANCE_STRICT) { +av_log(c->fc, AV_LOG_ERROR, "Track %d, edit %d: Invalid edit list media time=%"PRId64"\n", + c->fc->nb_streams-1, i, e->time); +return AVERROR_INVALIDDATA; +} } sc->elst_count = i; diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 30e441d..bb02d6b 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -6,7 +6,8 @@ FATE_MOV = fate-mov-3elist \ fate-mov-1elist-ends-last-bframe \ fate-mov-2elist-elist1-ends-bframe \ fate-mov-zombie \ - fate-mov-aac-2048-priming + fate-mov-aac-2048-priming \ + fate-mp4-init-nonkeyframe FATE_SAMPLES_AVCONV += $(FATE_MOV) @@ -34,3 +35,6 @@ fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets - fate-mov-zombie: ffprobe$(PROGSSUF)$(EXESUF) fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_p
[FFmpeg-cvslog] lavf/mov.c: Use the first sidx for tracks without sidx.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Wed Oct 26 11:31:03 2016 -0700| [4abe1ff08f1fb2a909c4a99bd9e44a81e2c3cc3d] | committer: Michael Niedermayer lavf/mov.c: Use the first sidx for tracks without sidx. According to spec ISO_IEC_15444_12 "For any media stream for which no segment index is present, referred to as non‐indexed stream, the media stream associated with the first Segment Index box in the segment serves as a reference stream in a sense that it also describes the subsegments for any non‐indexed media stream." Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Derek Buitenhuis <derek.buitenh...@gmail.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4abe1ff08f1fb2a909c4a99bd9e44a81e2c3cc3d --- libavformat/isom.h | 1 + libavformat/mov.c | 25 ++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 9038057..d684502 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -179,6 +179,7 @@ typedef struct MOVStreamContext { int32_t *display_matrix; uint32_t format; +int has_sidx; // If there is an sidx entry for this stream. struct { int use_subsamples; uint8_t* auxiliary_info; diff --git a/libavformat/mov.c b/libavformat/mov.c index 4222088..9179b58 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4202,7 +4202,8 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) uint8_t version; unsigned i, track_id; AVStream *st = NULL; -MOVStreamContext *sc; +AVStream *ref_st; +MOVStreamContext *sc, *ref_sc; MOVFragmentIndex *index = NULL; MOVFragmentIndex **tmp; AVRational timescale; @@ -4284,9 +4285,26 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) c->fragment_index_data = tmp; c->fragment_index_data[c->fragment_index_count++] = index; +sc->has_sidx = 1; + +if (offset == avio_size(pb)) { +for (i = 0; i < c->fc->nb_streams; i++) { +if (c->fc->streams[i]->id == c->fragment_index_data[0]->track_id) { +ref_st = c->fc->streams[i]; +ref_sc = ref_st->priv_data; +break; +} +} +for (i = 0; i < c->fc->nb_streams; i++) { +st = c->fc->streams[i]; +sc = st->priv_data; +if (!sc->has_sidx) { +st->duration = sc->track_end = av_rescale(ref_st->duration, sc->time_scale, ref_sc->time_scale); +} +} -if (offset == avio_size(pb)) c->fragment_index_complete = 1; +} return 0; } @@ -5847,13 +5865,14 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt) static int mov_seek_fragment(AVFormatContext *s, AVStream *st, int64_t timestamp) { MOVContext *mov = s->priv_data; +MOVStreamContext *sc = st->priv_data; int i, j; if (!mov->fragment_index_complete) return 0; for (i = 0; i < mov->fragment_index_count; i++) { -if (mov->fragment_index_data[i]->track_id == st->id) { +if (mov->fragment_index_data[i]->track_id == st->id || !sc->has_sidx) { MOVFragmentIndex *index = mov->fragment_index_data[i]; for (j = index->item_count - 1; j >= 0; j--) { if (index->items[j].time <= timestamp) { ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/mov.c: Use the correct timescale when seeking for audio.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Sun Oct 23 22:37:50 2016 -0700| [5e965582d5129ec1c5cbe67125fff8c96c6ba3c6] | committer: Rostislav Pehlivanov lavf/mov.c: Use the correct timescale when seeking for audio. Signed-off-by: Sasi Inguva <is...@google.com> Reviewed-by: Derek Buitenhuis <derek.buitenh...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5e965582d5129ec1c5cbe67125fff8c96c6ba3c6 --- libavformat/mov.c | 2 +- tests/fate/mov.mak | 6 +- tests/ref/fate/mov-aac-2048-priming | 217 3 files changed, 223 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 357d800..414007e 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3028,7 +3028,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // Audio decoders like AAC need need a decoder delay samples previous to the current sample, // to correctly decode this frame. Hence for audio we seek to a frame 1 sec. before the // edit_list_media_time to cover the decoder delay. -search_timestamp = FFMAX(search_timestamp - mov->time_scale, e_old[0].timestamp); +search_timestamp = FFMAX(search_timestamp - msc->time_scale, e_old[0].timestamp); } index = find_prev_closest_keyframe_index(st, e_old, nb_old, search_timestamp, 0); diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 4b5885b..6b79832 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -4,7 +4,8 @@ FATE_MOV = fate-mov-3elist \ fate-mov-1elist-noctts \ fate-mov-elist-starts-ctts-2ndsample \ fate-mov-1elist-ends-last-bframe \ - fate-mov-2elist-elist1-ends-bframe + fate-mov-2elist-elist1-ends-bframe \ + fate-mov-aac-2048-priming FATE_SAMPLES_AVCONV += $(FATE_MOV) @@ -26,3 +27,6 @@ fate-mov-1elist-ends-last-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-1e # Makes sure that we handle timestamps of packets in case of multiple edit lists with one of them ending on a B-frame correctly. fate-mov-2elist-elist1-ends-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-2elist-elist1-ends-bframe.mov + +fate-mov-aac-2048-priming: ffprobe$(PROGSSUF)$(EXESUF) +fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov diff --git a/tests/ref/fate/mov-aac-2048-priming b/tests/ref/fate/mov-aac-2048-priming new file mode 100644 index 000..d5ae31e --- /dev/null +++ b/tests/ref/fate/mov-aac-2048-priming @@ -0,0 +1,217 @@ +packet|codec_type=audio|stream_index=0|pts=-2048|pts_time=-0.046440|dts=-2048|dts_time=-0.046440|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=281|pos=36|flags=KD +packet|codec_type=audio|stream_index=0|pts=-1024|pts_time=-0.023220|dts=-1024|dts_time=-0.023220|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=258|pos=294|flags=KD +packet|codec_type=audio|stream_index=0|pts=0|pts_time=0.00|dts=0|dts_time=0.00|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=146|pos=552|flags=K_ +packet|codec_type=audio|stream_index=0|pts=1024|pts_time=0.023220|dts=1024|dts_time=0.023220|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=698|flags=K_ +packet|codec_type=audio|stream_index=0|pts=2048|pts_time=0.046440|dts=2048|dts_time=0.046440|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=222|pos=884|flags=K_ +packet|codec_type=audio|stream_index=0|pts=3072|pts_time=0.069660|dts=3072|dts_time=0.069660|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=186|pos=1106|flags=K_ +packet|codec_type=audio|stream_index=0|pts=4096|pts_time=0.092880|dts=4096|dts_time=0.092880|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=206|pos=1292|flags=K_ +packet|codec_type=audio|stream_index=0|pts=5120|pts_time=0.116100|dts=5120|dts_time=0.116100|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=199|pos=1498|flags=K_ +packet|codec_type=audio|stream_index=0|pts=6144|pts_time=0.139320|dts=6144|dts_time=0.139320|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=236|pos=1697|flags=K_ +packet|codec_type=audio|stream_index=0|pts=7168|pts_time=0.162540|dts=7168|dts_time=0.162540|duration=1024|duration_time=0.023220|convergence_duration=N/A|convergence_duration_time=N/A|size=208|pos=1933|flags=K_ +packet|codec_type=audio|stream_index=0|pts=8192|pts_time=0.185760|dts=8192|dts_time=0.185760|duration=1024|duration_time=0.02
[FFmpeg-cvslog] lavc/movtextdec.c: Avoid infinite loop on invalid data.
ffmpeg | branch: release/2.8 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Sep 27 19:23:20 2016 -0700| [ca216c71c77db13171717a69307a56c35f3246be] | committer: Michael Niedermayer lavc/movtextdec.c: Avoid infinite loop on invalid data. Signed-off-by: Sasi Inguva <is...@google.com> (cherry picked from commit 7e9e1b7070242a79fa6e3acd749d7fe76e39ea7b) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca216c71c77db13171717a69307a56c35f3246be --- libavcodec/movtextdec.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 257d598..e7c3d49 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -476,6 +476,10 @@ static int mov_text_decode_frame(AVCodecContext *avctx, tsmb_type = AV_RB32(tsmb); tsmb += 4; +if (tsmb_size == 0) { + return AVERROR_INVALIDDATA; +} + if (tsmb_size == 1) { if (m->tracksize + 16 > avpkt->size) break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/mov.c: Make audio timestamps strictly monotonically increasing inside an edit list.
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Mon Sep 26 09:56:26 2016 -0700| [dba2db6c0e4a18b9b69b846650401bf3a1d5a019] | committer: Michael Niedermayer lavf/mov.c: Make audio timestamps strictly monotonically increasing inside an edit list. Fixes gapless decoding. Adjust skip_samples field correctly in case of DISCARDed audio frames. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dba2db6c0e4a18b9b69b846650401bf3a1d5a019 --- libavformat/mov.c| 80 tests/ref/fate/gaplessenc-itunes-to-ipod-aac | 2 +- tests/ref/fate/gaplessenc-pcm-to-mov-aac | 2 +- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index b84d9c0..8b7bbf1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2856,6 +2856,21 @@ static int64_t add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, } /** + * Rewrite timestamps of index entries in the range [end_index - frame_duration_buffer_size, end_index) + * by subtracting end_ts successively by the amounts given in frame_duration_buffer. + */ +static void fix_index_entry_timestamps(AVStream* st, int end_index, int64_t end_ts, + int64_t* frame_duration_buffer, + int frame_duration_buffer_size) { +int i = 0; +av_assert0(end_index >= 0 && end_index <= st->nb_index_entries); +for (i = 0; i < frame_duration_buffer_size; i++) { +end_ts -= frame_duration_buffer[frame_duration_buffer_size - 1 - i]; +st->index_entries[end_index - 1 - i].timestamp = end_ts; +} +} + +/** * Append a new ctts entry to ctts_data. * Returns the new ctts_count if successful, else returns -1. */ @@ -2919,7 +2934,10 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) int64_t edit_list_media_time_dts = 0; int64_t edit_list_start_encountered = 0; int64_t search_timestamp = 0; - +int64_t* frame_duration_buffer = NULL; +int num_discarded_begin = 0; +int first_non_zero_audio_edit = -1; +int packet_skip_samples = 0; if (!msc->elst_data || msc->elst_count <= 0) { return; @@ -2955,6 +2973,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) edit_list_index++; edit_list_dts_counter = edit_list_dts_entry_end; edit_list_dts_entry_end += edit_list_duration; +num_discarded_begin = 0; if (edit_list_media_time == -1) { continue; } @@ -2962,7 +2981,14 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // If we encounter a non-negative edit list reset the skip_samples/start_pad fields and set them // according to the edit list below. if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) { -st->skip_samples = msc->start_pad = 0; +if (first_non_zero_audio_edit < 0) { +first_non_zero_audio_edit = 1; +} else { +first_non_zero_audio_edit = 0; +} + +if (first_non_zero_audio_edit > 0) +st->skip_samples = msc->start_pad = 0; } //find closest previous key frame @@ -3041,24 +3067,56 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } if (curr_cts < edit_list_media_time || curr_cts >= (edit_list_duration + edit_list_media_time)) { -if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && curr_cts < edit_list_media_time && -curr_cts + frame_duration > edit_list_media_time && -st->skip_samples == 0 && msc->start_pad == 0) { -st->skip_samples = msc->start_pad = edit_list_media_time - curr_cts; - -// Shift the index entry timestamp by skip_samples to be correct. -edit_list_dts_counter -= st->skip_samples; +if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id != AV_CODEC_ID_VORBIS && +curr_cts < edit_list_media_time && curr_cts + frame_duration > edit_list_media_time && +first_non_zero_audio_edit > 0) { +packet_skip_samples = edit_list_media_time - curr_cts; +st->skip_samples += packet_skip_samples; + +// Shift the index entry timestamp by packet_skip_samples to be correct. +edit_list_dts_counter -= packet_skip_samples; if (edit_list_start_encountered == 0) { - edit_list_start_encountered = 1; +
[FFmpeg-cvslog] lavc/utils.c: Subtract skip_samples when frame is DISCARDed.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Mon Sep 26 18:41:01 2016 -0700| [7e0235bdb145cf7975bda240acb629991c4b7048] | committer: Michael Niedermayer lavc/utils.c: Subtract skip_samples when frame is DISCARDed. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e0235bdb145cf7975bda240acb629991c4b7048 --- libavcodec/utils.c | 16 +++- libavcodec/version.h | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 0d78f0b..cf85300 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2335,7 +2335,6 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, uint32_t discard_padding = 0; uint8_t skip_reason = 0; uint8_t discard_reason = 0; -int demuxer_skip_samples = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(); @@ -2343,7 +2342,6 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if (ret < 0) goto fail; -demuxer_skip_samples = avctx->internal->skip_samples; avctx->internal->pkt = if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, ); @@ -2368,13 +2366,6 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, frame->sample_rate = avctx->sample_rate; } - -if (frame->flags & AV_FRAME_FLAG_DISCARD) { -// If using discard frame flag, ignore skip_samples set by the decoder. -avctx->internal->skip_samples = demuxer_skip_samples; -*got_frame_ptr = 0; -} - side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, _size); if(side && side_size>=10) { avctx->internal->skip_samples = AV_RL32(side); @@ -2384,6 +2375,13 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, skip_reason = AV_RL8(side + 8); discard_reason = AV_RL8(side + 9); } + +if ((frame->flags & AV_FRAME_FLAG_DISCARD) && *got_frame_ptr && +!(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { +avctx->internal->skip_samples -= frame->nb_samples; +*got_frame_ptr = 0; +} + if (avctx->internal->skip_samples > 0 && *got_frame_ptr && !(avctx->flags2 & AV_CODEC_FLAG2_SKIP_MANUAL)) { if(frame->nb_samples <= avctx->internal->skip_samples){ diff --git a/libavcodec/version.h b/libavcodec/version.h index 71dac40..91abd31 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 57 -#define LIBAVCODEC_VERSION_MINOR 59 +#define LIBAVCODEC_VERSION_MINOR 60 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/movtextdec.c: Avoid infinite loop on invalid data.
ffmpeg | branch: release/3.0 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Sep 27 19:23:20 2016 -0700| [82b58841c9d0e9d7d76d59438fe6b2a315e07e38] | committer: Michael Niedermayer lavc/movtextdec.c: Avoid infinite loop on invalid data. Signed-off-by: Sasi Inguva <is...@google.com> (cherry picked from commit 7e9e1b7070242a79fa6e3acd749d7fe76e39ea7b) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=82b58841c9d0e9d7d76d59438fe6b2a315e07e38 --- libavcodec/movtextdec.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index 8d0e814..28f7b8f 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -477,6 +477,10 @@ static int mov_text_decode_frame(AVCodecContext *avctx, tsmb_type = AV_RB32(tsmb); tsmb += 4; +if (tsmb_size == 0) { + return AVERROR_INVALIDDATA; +} + if (tsmb_size == 1) { if (m->tracksize + 16 > avpkt->size) break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/movtextdec.c: Avoid infinite loop on invalid data.
ffmpeg | branch: release/3.1 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Sep 27 19:23:20 2016 -0700| [39dc26f0c104fb601fbe4fb0e66c3aa4341f3cb7] | committer: Michael Niedermayer lavc/movtextdec.c: Avoid infinite loop on invalid data. Signed-off-by: Sasi Inguva <is...@google.com> (cherry picked from commit 7e9e1b7070242a79fa6e3acd749d7fe76e39ea7b) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=39dc26f0c104fb601fbe4fb0e66c3aa4341f3cb7 --- libavcodec/movtextdec.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index abf8711..a33fff7 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -471,6 +471,10 @@ static int mov_text_decode_frame(AVCodecContext *avctx, tsmb_type = AV_RB32(tsmb); tsmb += 4; +if (tsmb_size == 0) { + return AVERROR_INVALIDDATA; +} + if (tsmb_size == 1) { if (m->tracksize + 16 > avpkt->size) break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavc/movtextdec.c: Avoid infinite loop on invalid data.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Tue Sep 27 19:23:20 2016 -0700| [7e9e1b7070242a79fa6e3acd749d7fe76e39ea7b] | committer: Philip Langdale lavc/movtextdec.c: Avoid infinite loop on invalid data. Signed-off-by: Sasi Inguva <is...@google.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7e9e1b7070242a79fa6e3acd749d7fe76e39ea7b --- libavcodec/movtextdec.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c index abf8711..a33fff7 100644 --- a/libavcodec/movtextdec.c +++ b/libavcodec/movtextdec.c @@ -471,6 +471,10 @@ static int mov_text_decode_frame(AVCodecContext *avctx, tsmb_type = AV_RB32(tsmb); tsmb += 4; +if (tsmb_size == 0) { + return AVERROR_INVALIDDATA; +} + if (tsmb_size == 1) { if (m->tracksize + 16 > avpkt->size) break; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] ffprobe.c: Indicate decode-but-discard packets when doing -show_packets.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Sep 15 13:36:19 2016 -0700| [6a2cbf901461c4d2766618343e6f57739500393d] | committer: Michael Niedermayer ffprobe.c: Indicate decode-but-discard packets when doing -show_packets. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6a2cbf901461c4d2766618343e6f57739500393d --- ffprobe.c | 3 +- tests/ref/fate/concat-demuxer-extended-lavf-mxf| 2 +- .../ref/fate/concat-demuxer-extended-lavf-mxf_d10 | 2 +- tests/ref/fate/concat-demuxer-simple1-lavf-mxf | 242 - tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10 | 140 +- tests/ref/fate/concat-demuxer-simple2-lavf-ts | 298 ++--- tests/ref/fate/ffprobe_compact | 28 +- tests/ref/fate/ffprobe_csv | 28 +- tests/ref/fate/ffprobe_default | 28 +- tests/ref/fate/ffprobe_flat| 28 +- tests/ref/fate/ffprobe_ini | 28 +- tests/ref/fate/ffprobe_json| 28 +- tests/ref/fate/ffprobe_xml | 28 +- 13 files changed, 442 insertions(+), 441 deletions(-) diff --git a/ffprobe.c b/ffprobe.c index 657867d..e64c66e 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -1815,7 +1815,8 @@ static void show_packet(WriterContext *w, InputFile *ifile, AVPacket *pkt, int p print_val("size", pkt->size, unit_byte_str); if (pkt->pos != -1) print_fmt("pos", "%"PRId64, pkt->pos); elseprint_str_opt("pos", "N/A"); -print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_'); +print_fmt("flags", "%c%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_', + pkt->flags & AV_PKT_FLAG_DISCARD ? 'D' : '_'); if (pkt->side_data_elems) { int size; diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf b/tests/ref/fate/concat-demuxer-extended-lavf-mxf index b894938..f7905aa 100644 --- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf +++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf @@ -1 +1 @@ -0aa1ca6ff6e2e5aa926454d22fdaecd5 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe +21eb3a629ff504b55c93a66879a31362 *tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 index b378a2d..0c49f1f 100644 --- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 +++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 @@ -1 +1 @@ -14c2b8d8f82f261c9627b33c481c0e8c *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe +67a03ad49f1bd17131f751313639b61e *tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf index 3fc7957..6bba76a 100644 --- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf +++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf @@ -1,124 +1,124 @@ -video|0|0|0.00|-1|-0.04|1|0.04|N/A|N/A|24801|6144|K -audio|1|0|0.00|0|0.00|1920|0.04|N/A|N/A|3840|31232|K -video|0|3|0.12|0|0.00|1|0.04|N/A|N/A|16743|35840|_ -audio|1|1920|0.04|1920|0.04|1920|0.04|N/A|N/A|3840|52736|K -video|0|1|0.04|1|0.04|1|0.04|N/A|N/A|13812|57344|_ -audio|1|3840|0.08|3840|0.08|1920|0.04|N/A|N/A|3840|71680|K -video|0|2|0.08|2|0.08|1|0.04|N/A|N/A|13607|76288|_ -audio|1|5760|0.12|5760|0.12|1920|0.04|N/A|N/A|3840|90112|K -video|0|6|0.24|3|0.12|1|0.04|N/A|N/A|16158|94720|_ -audio|1|7680|0.16|7680|0.16|1920|0.04|N/A|N/A|3840|04|K -video|0|4|0.16|4|0.16|1|0.04|N/A|N/A|13943|115712|_ -audio|1|9600|0.20|9600|0.20|1920|0.04|N/A|N/A|3840|130048|K -video|0|5|0.20|5|0.20|1|0.04|N/A|N/A|11223|134656|_ -audio|1|11520|0.24|11520|0.24|1920|0.04|N/A|N/A|3840|145920|K -video|0|9|0.36|6|0.24|1|0.04|N/A|N/A|20298|150528|_ -audio|1|13440|0.28|13440|0.28|1920|0.04|N/A|N/A|3840|171008|K -video|0|7|0.28|7|0.28|1|0.04|N/A|N/A|13341|175616|_ -audio|1|15360|0.32|15360|0.32|1920|0.04|N/A|N/A|3840|189440|K -video|0|8|0.32|8|0.32|1|0.04|N/A|N/A|12362|194048|_ -audio|1|17280|0.36|17280|0.36|1920|0.04|N/A|N/A|3840|206848|K -video|0|12|0.48|9|0.36|1|0.04|N/A|N/A|24786|211456|K -audio|1|19200|0.40|19200|0.40|1920|0.04|N/A|N/A|3840|236544|K -video|0|10|0.40|10|0.40|1|0.04|N/A|N/A|13377|241152|_ -audio|1|21120|0.44|21120|0.44|1920|0.04|N/A|N/A|38
[FFmpeg-cvslog] lavf/utils: Support av_index_search_timestamp in case of AVIndexEntry with discarded packets.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Sep 15 13:36:18 2016 -0700| [b518d809f16359945eded03c2504641a7f497532] | committer: Michael Niedermayer lavf/utils: Support av_index_search_timestamp in case of AVIndexEntry with discarded packets. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b518d809f16359945eded03c2504641a7f497532 --- libavformat/utils.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index d605a96..f043bae 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1937,6 +1937,16 @@ int ff_index_search_timestamp(const AVIndexEntry *entries, int nb_entries, while (b - a > 1) { m = (a + b) >> 1; + +// Search for the next non-discarded packet. +while ((entries[m].flags & AVINDEX_DISCARD_FRAME) && m < b) { +m++; +if (m == b && entries[m].timestamp >= wanted_timestamp) { +m = b - 1; +break; +} +} + timestamp = entries[m].timestamp; if (timestamp >= wanted_timestamp) b = m; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avutil/frame: Add a flag to discard frame after decode.
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Sep 15 13:36:14 2016 -0700| [3cb400c11a75e6f645e5267831e6398bdb0b084e] | committer: Michael Niedermayer avutil/frame: Add a flag to discard frame after decode. Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3cb400c11a75e6f645e5267831e6398bdb0b084e --- libavutil/frame.c | 1 + libavutil/frame.h | 4 libavutil/version.h | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index 662c20d..3c74931 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -114,6 +114,7 @@ static void get_frame_defaults(AVFrame *frame) frame->colorspace = AVCOL_SPC_UNSPECIFIED; frame->color_range = AVCOL_RANGE_UNSPECIFIED; frame->chroma_location = AVCHROMA_LOC_UNSPECIFIED; +frame->flags = 0; } static void free_side_data(AVFrameSideData **ptr_sd) diff --git a/libavutil/frame.h b/libavutil/frame.h index 8a41a86..1e2691e 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -396,6 +396,10 @@ typedef struct AVFrame { */ #define AV_FRAME_FLAG_CORRUPT (1 << 0) /** + * A flag to mark the frames which need to be decoded, but shouldn't be output. + */ +#define AV_FRAME_FLAG_DISCARD (1 << 2) +/** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index 7d32c7b..60b58eb 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 55 -#define LIBAVUTIL_VERSION_MINOR 29 +#define LIBAVUTIL_VERSION_MINOR 30 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avcodec/utils: If using discard frame flag, ignore skip_samples set by the decoder
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Sun Sep 18 22:09:03 2016 -0700| [a53201879ca36af6fcc8a0d4bcc1fa6d759b67ec] | committer: Michael Niedermayer avcodec/utils: If using discard frame flag, ignore skip_samples set by the decoder Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a53201879ca36af6fcc8a0d4bcc1fa6d759b67ec --- libavcodec/utils.c | 4 1 file changed, 4 insertions(+) diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 4734a70..b0345b6 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2320,6 +2320,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, uint32_t discard_padding = 0; uint8_t skip_reason = 0; uint8_t discard_reason = 0; +int demuxer_skip_samples = 0; // copy to ensure we do not change avpkt AVPacket tmp = *avpkt; int did_split = av_packet_split_side_data(); @@ -2327,6 +2328,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if (ret < 0) goto fail; +demuxer_skip_samples = avctx->internal->skip_samples; avctx->internal->pkt = if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, ); @@ -2353,6 +2355,8 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, if (frame->flags & AV_FRAME_FLAG_DISCARD) { +// If using discard frame flag, ignore skip_samples set by the decoder. +avctx->internal->skip_samples = demuxer_skip_samples; *got_frame_ptr = 0; } ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libx264: Increase x264 opts character limit to 4096
ffmpeg | branch: release/2.8 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Jul 21 18:52:41 2016 -0700| [0f6e244bb0090ebe84147d5fab9429b29a2c1cc4] | committer: Michael Niedermayer libx264: Increase x264 opts character limit to 4096 Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> (cherry picked from commit 282477bf4534439ecb06f14d46446a4f1ab82284) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f6e244bb0090ebe84147d5fab9429b29a2c1cc4 --- libavcodec/libx264.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index a54743e..4c92144 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -698,8 +698,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if(x4->x264opts){ const char *p= x4->x264opts; while(p){ -char param[256]={0}, val[256]={0}; -if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){ +char param[4096]={0}, val[4096]={0}; +if(sscanf(p, "%4095[^:=]=%4095[^:]", param, val) == 1){ OPT_STR(param, "1"); }else OPT_STR(param, val); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libx264: Increase x264 opts character limit to 4096
ffmpeg | branch: release/3.0 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Jul 21 18:52:41 2016 -0700| [6e13acaadd5ce44068c090675d0f84dc0d73b152] | committer: Michael Niedermayer libx264: Increase x264 opts character limit to 4096 Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> (cherry picked from commit 282477bf4534439ecb06f14d46446a4f1ab82284) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6e13acaadd5ce44068c090675d0f84dc0d73b152 --- libavcodec/libx264.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 5030d65..35339bc 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -783,8 +783,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if(x4->x264opts){ const char *p= x4->x264opts; while(p){ -char param[256]={0}, val[256]={0}; -if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){ +char param[4096]={0}, val[4096]={0}; +if(sscanf(p, "%4095[^:=]=%4095[^:]", param, val) == 1){ OPT_STR(param, "1"); }else OPT_STR(param, val); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libx264: Increase x264 opts character limit to 4096
ffmpeg | branch: release/3.1 | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Jul 21 18:52:41 2016 -0700| [7c01fa962e7fb08754f191a3840af56654fa0841] | committer: Michael Niedermayer libx264: Increase x264 opts character limit to 4096 Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> (cherry picked from commit 282477bf4534439ecb06f14d46446a4f1ab82284) Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7c01fa962e7fb08754f191a3840af56654fa0841 --- libavcodec/libx264.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index c8f2380..b730c91 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -777,8 +777,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if(x4->x264opts){ const char *p= x4->x264opts; while(p){ -char param[256]={0}, val[256]={0}; -if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){ +char param[4096]={0}, val[4096]={0}; +if(sscanf(p, "%4095[^:=]=%4095[^:]", param, val) == 1){ OPT_STR(param, "1"); }else OPT_STR(param, val); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libx264: Increase x264 opts character limit to 4096
ffmpeg | branch: master | Sasi Inguva <isasi-at-google@ffmpeg.org> | Thu Jul 21 18:52:41 2016 -0700| [282477bf4534439ecb06f14d46446a4f1ab82284] | committer: Michael Niedermayer libx264: Increase x264 opts character limit to 4096 Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=282477bf4534439ecb06f14d46446a4f1ab82284 --- libavcodec/libx264.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index c8f2380..b730c91 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -777,8 +777,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if(x4->x264opts){ const char *p= x4->x264opts; while(p){ -char param[256]={0}, val[256]={0}; -if(sscanf(p, "%255[^:=]=%255[^:]", param, val) == 1){ +char param[4096]={0}, val[4096]={0}; +if(sscanf(p, "%4095[^:=]=%4095[^:]", param, val) == 1){ OPT_STR(param, "1"); }else OPT_STR(param, val); ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] fate: add test for "Fix DTS for short H264 streams"
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Sat Mar 12 02:40:25 2016 -0800| [6fa5c8235b0cdb8bd33cc072759866d64e307f8c] | committer: Michael Niedermayer fate: add test for "Fix DTS for short H264 streams" Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6fa5c8235b0cdb8bd33cc072759866d64e307f8c --- tests/fate/h264.mak |3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak index 46178cd..9c2cd50 100644 --- a/tests/fate/h264.mak +++ b/tests/fate/h264.mak @@ -192,6 +192,7 @@ FATE_H264 := $(FATE_H264:%=fate-h264-conformance-%) \ $(FATE_H264_REINIT_TESTS:%=fate-h264-reinit-%)\ fate-h264-extreme-plane-pred \ fate-h264-lossless\ + fate-h264-dts_5frames \ FATE_H264-$(call DEMDEC, H264, H264) += $(FATE_H264) FATE_H264-$(call DEMDEC, MOV, H264) += fate-h264-crop-to-container @@ -395,3 +396,5 @@ fate-h264-lossless: CMD = framecrc -i $(TARGET_SAM fate-h264-direct-bff: CMD = framecrc -i $(TARGET_SAMPLES)/h264/direct-bff.mkv fate-h264-reinit-%: CMD = framecrc -i $(TARGET_SAMPLES)/h264/$(@:fate-h264-%=%).h264 -vf format=yuv444p10le,scale=w=352:h=288 + +fate-h264-dts_5frames:CMD = probeframes $(TARGET_SAMPLES)/h264/dts_5frames.mkv ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] avformat/utils: factor update_dts_from_pts() out
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Sat Mar 12 02:40:25 2016 -0800| [e939dde48d446216530a4106e0471f1a155dfe26] | committer: Michael Niedermayer avformat/utils: factor update_dts_from_pts() out Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e939dde48d446216530a4106e0471f1a155dfe26 --- libavformat/utils.c | 64 ++- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index e0aea87..3c050ef 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -936,14 +936,44 @@ static int64_t select_from_pts_buffer(AVStream *st, int64_t *pts_buffer, int64_t return dts; } +/** + * Updates the dts of packets of a stream in pkt_buffer, by re-ordering the pts + * of the packets in a window. + */ +static void update_dts_from_pts(AVFormatContext *s, int stream_index, +AVPacketList *pkt_buffer) +{ +AVStream *st = s->streams[stream_index]; +int delay = st->codec->has_b_frames; +int i; + +int64_t pts_buffer[MAX_REORDER_DELAY+1]; + +for (i = 0; i<MAX_REORDER_DELAY+1; i++) +pts_buffer[i] = AV_NOPTS_VALUE; + +for (; pkt_buffer; pkt_buffer = get_next_pkt(s, st, pkt_buffer)) { +if (pkt_buffer->pkt.stream_index != stream_index) +continue; + +if (pkt_buffer->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY) { +pts_buffer[0] = pkt_buffer->pkt.pts; +for (i = 0; i pts_buffer[i + 1]; i++) +FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]); + +pkt_buffer->pkt.dts = select_from_pts_buffer(st, pts_buffer, pkt_buffer->pkt.dts); +} +} +} + static void update_initial_timestamps(AVFormatContext *s, int stream_index, int64_t dts, int64_t pts, AVPacket *pkt) { AVStream *st = s->streams[stream_index]; AVPacketList *pktl = s->internal->packet_buffer ? s->internal->packet_buffer : s->internal->parse_queue; -int64_t pts_buffer[MAX_REORDER_DELAY+1]; +AVPacketList *pktl_it; + uint64_t shift; -int i, delay; if (st->first_dts != AV_NOPTS_VALUE || dts == AV_NOPTS_VALUE || @@ -951,36 +981,28 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, is_relative(dts)) return; -delay = st->codec->has_b_frames; st->first_dts = dts - (st->cur_dts - RELATIVE_TS_BASE); st->cur_dts = dts; shift = (uint64_t)st->first_dts - RELATIVE_TS_BASE; -for (i = 0; i<MAX_REORDER_DELAY+1; i++) -pts_buffer[i] = AV_NOPTS_VALUE; - if (is_relative(pts)) pts += shift; -for (; pktl; pktl = get_next_pkt(s, st, pktl)) { -if (pktl->pkt.stream_index != stream_index) +for (pktl_it = pktl; pktl_it; pktl_it = get_next_pkt(s, st, pktl_it)) { +if (pktl_it->pkt.stream_index != stream_index) continue; -if (is_relative(pktl->pkt.pts)) -pktl->pkt.pts += shift; - -if (is_relative(pktl->pkt.dts)) -pktl->pkt.dts += shift; +if (is_relative(pktl_it->pkt.pts)) +pktl_it->pkt.pts += shift; -if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != AV_NOPTS_VALUE) -st->start_time = pktl->pkt.pts; +if (is_relative(pktl_it->pkt.dts)) +pktl_it->pkt.dts += shift; -if (pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && has_decode_delay_been_guessed(st)) { -pts_buffer[0] = pktl->pkt.pts; -for (i = 0; i pts_buffer[i + 1]; i++) -FFSWAP(int64_t, pts_buffer[i], pts_buffer[i + 1]); +if (st->start_time == AV_NOPTS_VALUE && pktl_it->pkt.pts != AV_NOPTS_VALUE) +st->start_time = pktl_it->pkt.pts; +} -pktl->pkt.dts = select_from_pts_buffer(st, pts_buffer, pktl->pkt.dts); -} +if (has_decode_delay_been_guessed(st)) { +update_dts_from_pts(s, stream_index, pktl); } if (st->start_time == AV_NOPTS_VALUE) ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] lavf/utils: Fix DTS for short H264 streams.
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Sat Mar 12 02:40:25 2016 -0800| [895dd0967194dac597405b9b2691b148809e221a] | committer: Michael Niedermayer lavf/utils: Fix DTS for short H264 streams. 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: Michael Niedermayer <mich...@niedermayer.cc> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=895dd0967194dac597405b9b2691b148809e221a --- libavformat/utils.c | 13 + 1 file changed, 13 insertions(+) diff --git a/libavformat/utils.c b/libavformat/utils.c index 3c050ef..2936ed5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3188,6 +3188,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; @@ -3354,6 +3355,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) if (ret < 0) { /* EOF or error*/ +eof_reached = 1; break; } @@ -3477,6 +3479,17 @@ 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++) { +// EOF already reached while reading the stream above. +// So continue with reoordering DTS with whatever delay we have. +if (!has_decode_delay_been_guessed(st)) { +update_dts_from_pts(ic, stream_index, ic->internal->packet_buffer); +} +} +} + if (flush_codecs) { AVPacket empty_pkt = { 0 }; int err = 0; ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libvpx: Support setting color range for vp9.
ffmpeg | branch: master | Sasi Inguva <is...@google.com> | Sat Jan 9 12:48:49 2016 -0300| [cbcc88c0393f15512cbf06b895f3f58210376614] | committer: James Almer libvpx: Support setting color range for vp9. Pass through color range to vp9 encoder. Parse color range in libvpxdec.c. Reviewed-by: Ronald S. Bultje <rsbul...@gmail.com> Signed-off-by: Sasi Inguva <is...@google.com> Signed-off-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbcc88c0393f15512cbf06b895f3f58210376614 --- libavcodec/libvpxdec.c |6 ++ libavcodec/libvpxenc.c | 24 2 files changed, 30 insertions(+) diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c index 698c546..de72be9 100644 --- a/libavcodec/libvpxdec.c +++ b/libavcodec/libvpxdec.c @@ -69,6 +69,12 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img) AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED, AVCOL_SPC_RGB, }; avctx->colorspace = colorspaces[img->cs]; +#if VPX_IMAGE_ABI_VERSION >= 4 +static const enum AVColorRange color_ranges[] = { +AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG +}; +avctx->color_range = color_ranges[img->range]; +#endif #endif if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt != VPX_IMG_FMT_I420) return AVERROR_INVALIDDATA; diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index edb842a..99c3f95 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -125,6 +125,9 @@ static const char *const ctlidstr[] = { #if VPX_ENCODER_ABI_VERSION > 8 [VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE", #endif +#if VPX_ENCODER_ABI_VERSION >= 11 +[VP9E_SET_COLOR_RANGE] = "VP9E_SET_COLOR_RANGE", +#endif #endif }; @@ -368,6 +371,24 @@ static void set_colorspace(AVCodecContext *avctx) codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs); } #endif + +#if VPX_ENCODER_ABI_VERSION >= 11 +static void set_color_range(AVCodecContext *avctx) +{ +enum vpx_color_range vpx_cr; +switch (avctx->color_range) { +case AVCOL_RANGE_UNSPECIFIED: +case AVCOL_RANGE_MPEG: vpx_cr = VPX_CR_STUDIO_RANGE; break; +case AVCOL_RANGE_JPEG: vpx_cr = VPX_CR_FULL_RANGE; break; +default: +av_log(avctx, AV_LOG_WARNING, "Unsupported color range (%d)\n", + avctx->color_range); +return; +} + +codecctl_int(avctx, VP9E_SET_COLOR_RANGE, vpx_cr); +} +#endif #endif static av_cold int vpx_init(AVCodecContext *avctx, @@ -617,6 +638,9 @@ static av_cold int vpx_init(AVCodecContext *avctx, #if VPX_ENCODER_ABI_VERSION > 8 set_colorspace(avctx); #endif +#if VPX_ENCODER_ABI_VERSION >= 11 +set_color_range(avctx); +#endif } #endif ___ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog
[FFmpeg-cvslog] libavformat/matroska: Write stream durations in metadata, in the format of mkvmerge.
ffmpeg | branch: master | Sasi Inguva is...@google.com | Tue Aug 4 22:09:57 2015 -0700| [31852540d4fba0c4e8a16d0b3ddff08fc98e48fd] | committer: wm4 libavformat/matroska: Write stream durations in metadata, in the format of mkvmerge. Compute individual stream durations in matroska muxer. Write them as string tags in the same format as mkvmerge tool does. Signed-off-by: Sasi Inguva is...@google.com http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=31852540d4fba0c4e8a16d0b3ddff08fc98e48fd --- libavformat/matroskaenc.c| 79 +++--- tests/fate/wavpack.mak |4 +-- tests/ref/acodec/tta |4 +-- tests/ref/fate/binsub-mksenc |2 +- tests/ref/lavf/mkv |8 ++--- tests/ref/seek/lavf-mkv | 44 +++ 6 files changed, 105 insertions(+), 36 deletions(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 2d0d5f6..703abc3 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -44,6 +44,7 @@ #include libavutil/mathematics.h #include libavutil/opt.h #include libavutil/random_seed.h +#include libavutil/rational.h #include libavutil/samplefmt.h #include libavutil/sha.h #include libavutil/stereo3d.h @@ -131,6 +132,9 @@ typedef struct MatroskaMuxContext { int64_t last_track_timestamp[MAX_TRACKS]; +int64_t* stream_durations; +int64_t* stream_duration_offsets; + int allow_raw_vfw; } MatroskaMuxContext; @@ -1151,12 +1155,12 @@ static int mkv_write_simpletag(AVIOContext *pb, AVDictionaryEntry *t) return 0; } -static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid, - unsigned int uid, ebml_master *tags) +static int mkv_write_tag_targets(AVFormatContext *s, + unsigned int elementid, unsigned int uid, + ebml_master *tags, ebml_master* tag) { MatroskaMuxContext *mkv = s-priv_data; -ebml_master tag, targets; -AVDictionaryEntry *t = NULL; +ebml_master targets; int ret; if (!tags-pos) { @@ -1166,11 +1170,24 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme *tags = start_ebml_master(s-pb, MATROSKA_ID_TAGS, 0); } -tag = start_ebml_master(s-pb, MATROSKA_ID_TAG,0); +*tag = start_ebml_master(s-pb, MATROSKA_ID_TAG,0); targets = start_ebml_master(s-pb, MATROSKA_ID_TAGTARGETS, 0); if (elementid) put_ebml_uint(s-pb, elementid, uid); end_ebml_master(s-pb, targets); +return 0; +} + +static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int elementid, + unsigned int uid, ebml_master *tags) +{ +ebml_master tag; +int ret; +AVDictionaryEntry *t = NULL; + +ret = mkv_write_tag_targets(s, elementid, uid, tags, tag); +if (ret 0) +return ret; while ((t = av_dict_get(m, , t, AV_DICT_IGNORE_SUFFIX))) { if (av_strcasecmp(t-key, title) @@ -1220,6 +1237,25 @@ static int mkv_write_tags(AVFormatContext *s) if (ret 0) return ret; } +if (!mkv-is_live) { +for (i = 0; i s-nb_streams; i++) { +ebml_master tag_target; +ebml_master tag; + +mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, tags, tag_target); + +tag = start_ebml_master(s-pb, MATROSKA_ID_SIMPLETAG, 0); +put_ebml_string(s-pb, MATROSKA_ID_TAGNAME, DURATION); +mkv-stream_duration_offsets[i] = avio_tell(s-pb); + +// Reserve space to write duration as a 20-byte string. +// 2 (ebml id) + 1 (data size) + 20 (data) +put_ebml_void(s-pb, 23); +end_ebml_master(s-pb, tag); +end_ebml_master(s-pb, tag_target); +} +} + for (i = 0; i s-nb_chapters; i++) { AVChapter *ch = s-chapters[i]; @@ -1430,6 +1466,10 @@ static int mkv_write_header(AVFormatContext *s) } end_ebml_master(pb, segment_info); +// initialize stream_duration fields +mkv-stream_durations = av_mallocz(s-nb_streams * sizeof(int64_t)); +mkv-stream_duration_offsets = av_mallocz(s-nb_streams * sizeof(int64_t)); + ret = mkv_write_tracks(s); if (ret 0) return ret; @@ -1801,6 +1841,11 @@ static int mkv_write_packet_internal(AVFormatContext *s, AVPacket *pkt, int add_ } mkv-duration = FFMAX(mkv-duration, ts + duration); + +if (mkv-stream_durations) +mkv-stream_durations[pkt-stream_index] = +FFMAX(mkv-stream_durations[pkt-stream_index], ts + duration); + return 0; } @@ -1978,6 +2023,28 @@ static int mkv_write_trailer(AVFormatContext *s) avio_seek(pb, mkv-duration_offset, SEEK_SET); put_ebml_float(pb, MATROSKA_ID_DURATION, mkv-duration); +// update stream durations +if (mkv-stream_durations