From 8161ac2902836032b6f6684aa48275325f8ca9ef Mon Sep 17 00:00:00 2001 From: Gyan Doshi Date: Sun, 31 Mar 2019 00:00:50 +0530 Subject: [PATCH] lavf/movenc: fix tmcd writing for non-MP4/MOV modes write_tmcd allows tmcd track to be created with any mode but in mov_write_header, index for first tmcd track is only set for modes MP4 or MOV, causing a crash if tmcd creation is attempted with other modes. --- libavformat/movenc.c | 2 +- tests/fate/lavf-container.mak | 2 +- tests/ref/lavf/ismv | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7f5dcd703e..c67f909608 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6381,7 +6381,7 @@ static int mov_write_header(AVFormatContext *s) nb_tracks++; } - if (mov->mode == MODE_MOV || mov->mode == MODE_MP4) + if (mov->nb_meta_tmcd) tmcd_track = nb_tracks; for (i = 0; i < s->nb_streams; i++) { diff --git a/tests/fate/lavf-container.mak b/tests/fate/lavf-container.mak index a531914aad..22387d04d8 100644 --- a/tests/fate/lavf-container.mak +++ b/tests/fate/lavf-container.mak @@ -34,7 +34,7 @@ fate-lavf-flm: CMD = lavf_container "" "-pix_fmt rgba" fate-lavf-gxf: CMD = lavf_container "-ar 48000" "-r 25 -s pal -ac 1 -threads 1" fate-lavf-gxf_pal: CMD = lavf_container_timecode_nodrop "-ar 48000 -r 25 -s pal -ac 1 -threads 1 -f gxf" fate-lavf-gxf_ntsc: CMD = lavf_container_timecode_drop "-ar 48000 -s ntsc -ac 1 -threads 1 -f gxf" -fate-lavf-ismv: CMD = lavf_container_timecode "-an -c:v mpeg4 -threads 1" +fate-lavf-ismv: CMD = lavf_container_timecode "-an -write_tmcd 1 -c:v mpeg4 -threads 1" fate-lavf-mkv: CMD = lavf_container "" "-c:a mp2 -c:v mpeg4 -ar 44100 -threads 1" fate-lavf-mkv_attachment: CMD = lavf_container_attach "-c:a mp2 -c:v mpeg4 -threads 1 -f matroska" fate-lavf-mov: CMD = lavf_container_timecode "-movflags +faststart -c:a pcm_alaw -c:v mpeg4 -threads 1" diff --git a/tests/ref/lavf/ismv b/tests/ref/lavf/ismv index 96dc8c1c9d..865a6913cf 100644 --- a/tests/ref/lavf/ismv +++ b/tests/ref/lavf/ismv @@ -1,8 +1,8 @@ -96053075a3f60d271131fe2d0765c267 *tests/data/lavf/lavf.ismv -312542 tests/data/lavf/lavf.ismv +bd88b50defa57766619c092ea89f25a6 *tests/data/lavf/lavf.ismv +313165 tests/data/lavf/lavf.ismv tests/data/lavf/lavf.ismv CRC=0x9d9a638a -7022701b4c693bc4ffe1e9f96dd82a02 *tests/data/lavf/lavf.ismv -321448 tests/data/lavf/lavf.ismv +805a2557bf952c84835f3c10b6893e15 *tests/data/lavf/lavf.ismv +322071 tests/data/lavf/lavf.ismv tests/data/lavf/lavf.ismv CRC=0xe8130120 96053075a3f60d271131fe2d0765c267 *tests/data/lavf/lavf.ismv 312542 tests/data/lavf/lavf.ismv