diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-08-09 04:49:09 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-08-10 22:40:50 +0200 |
commit | ed15be7519af8aa68bdf58ccdf39915b560d11a2 (patch) | |
tree | c559a923f1fc0ce51b0dbe6cfd4ba4ee600a320a /libavformat | |
parent | 69281934935e0b93e20fa905c1cdbc5a1b24fd2a (diff) | |
download | ffmpeg-ed15be7519af8aa68bdf58ccdf39915b560d11a2.tar.gz |
avformat/matroskaenc: fix MAX_CUEPOINT_SIZE calculation
Fixes assertion failure
Fixes Ticket3822
as a side-effect this makes some mkv files a few bytes smaller
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 64d029de41ed556b765df50c7080b06fd5a86417)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/matroskaenc.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 92d091f7cf..fc9c72852a 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -445,8 +445,21 @@ static int64_t mkv_write_cues(AVFormatContext *s, mkv_cues *cues, mkv_track *tra ebml_master cuepoint, track_positions; mkv_cuepoint *entry = &cues->entries[i]; uint64_t pts = entry->pts; + int ctp_nb = 0; - cuepoint = start_ebml_master(pb, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(num_tracks)); + // Calculate the number of entries, so we know the element size + for (j = 0; j < num_tracks; j++) + tracks[j].has_cue = 0; + for (j = 0; j < cues->num_entries - i && entry[j].pts == pts; j++) { + int tracknum = entry[j].stream_idx; + av_assert0(tracknum>=0 && tracknum<num_tracks); + if (tracks[tracknum].has_cue && s->streams[tracknum]->codec->codec_type != AVMEDIA_TYPE_SUBTITLE) + continue; + tracks[tracknum].has_cue = 1; + ctp_nb ++; + } + + cuepoint = start_ebml_master(pb, MATROSKA_ID_POINTENTRY, MAX_CUEPOINT_SIZE(ctp_nb)); put_ebml_uint(pb, MATROSKA_ID_CUETIME, pts); // put all the entries from different tracks that have the exact same |