diff options
author | Sasi Inguva <isasi-at-google.com@ffmpeg.org> | 2018-03-29 15:58:09 -0700 |
---|---|---|
committer | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2018-06-05 16:00:19 +0100 |
commit | 318d0fcbfe5637013342d53d44bb7ea8867fb4d0 (patch) | |
tree | 15ac30dcaf6c32c3a514fedf8ecadcaffe42feaf /libavformat | |
parent | d8c0bbb0aa45eed61b159c4842473fe27e77ac12 (diff) | |
download | ffmpeg-318d0fcbfe5637013342d53d44bb7ea8867fb4d0.tar.gz |
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 <isasi@isasi.mtv.corp.google.com>
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mov.c | 9 |
1 files 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(&frame_duration_buffer); |