From 5d2f89a23c83c690628eb7e045f2271afdfb2ee2 Mon Sep 17 00:00:00 2001 From: Piotr Bandurski Date: Sun, 5 Aug 2012 23:58:10 +0200 Subject: [PATCH] movenc: fix remuxing of svq3 --- libavformat/mov.c | 32 ++++++-------------------------- libavformat/movenc.c | 18 ++---------------- 2 files changed, 8 insertions(+), 42 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 46962d7b43..24387c88bb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -802,31 +802,6 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) return 0; } -static int mov_read_smi(MOVContext *c, AVIOContext *pb, MOVAtom atom) -{ - AVStream *st; - - if (c->fc->nb_streams < 1) - return 0; - st = c->fc->streams[c->fc->nb_streams-1]; - - if ((uint64_t)atom.size > (1<<30)) - return AVERROR_INVALIDDATA; - - // currently SVQ3 decoder expect full STSD header - so let's fake it - // this should be fixed and just SMI header should be passed - av_free(st->codec->extradata); - st->codec->extradata_size = 0; - st->codec->extradata = av_mallocz(atom.size + 0x5a + FF_INPUT_BUFFER_PADDING_SIZE); - if (!st->codec->extradata) - return AVERROR(ENOMEM); - st->codec->extradata_size = 0x5a + atom.size; - memcpy(st->codec->extradata, "SVQ3", 4); // fake - avio_read(pb, st->codec->extradata + 0x5a, atom.size); - av_dlog(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a); - return 0; -} - static int mov_read_enda(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -944,6 +919,11 @@ static int mov_read_avid(MOVContext *c, AVIOContext *pb, MOVAtom atom) return mov_read_extradata(c, pb, atom, CODEC_ID_AVUI); } +static int mov_read_svq3(MOVContext *c, AVIOContext *pb, MOVAtom atom) +{ + return mov_read_extradata(c, pb, atom, CODEC_ID_SVQ3); +} + static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; @@ -2577,7 +2557,7 @@ static const MOVParseTableEntry mov_default_parse_table[] = { { MKTAG('m','o','o','v'), mov_read_moov }, { MKTAG('m','v','e','x'), mov_read_default }, { MKTAG('m','v','h','d'), mov_read_mvhd }, -{ MKTAG('S','M','I',' '), mov_read_smi }, /* Sorenson extension ??? */ +{ MKTAG('S','M','I',' '), mov_read_svq3 }, { MKTAG('a','l','a','c'), mov_read_alac }, /* alac specific atom */ { MKTAG('a','v','c','C'), mov_read_glbl }, { MKTAG('p','a','s','p'), mov_read_pasp }, diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 910b9d4728..cd8d8f1c3b 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -712,19 +712,6 @@ static int mov_write_d263_tag(AVIOContext *pb) return 0xf; } -/* TODO: No idea about these values */ -static int mov_write_svq3_tag(AVIOContext *pb) -{ - avio_wb32(pb, 0x15); - ffio_wfourcc(pb, "SMI "); - ffio_wfourcc(pb, "SEQH"); - avio_wb32(pb, 0x5); - avio_wb32(pb, 0xe2c0211d); - avio_wb32(pb, 0xc0000000); - avio_w8(pb, 0); - return 0x15; -} - static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); @@ -1071,9 +1058,8 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track) mov_write_esds_tag(pb, track); else if(track->enc->codec_id == CODEC_ID_H263) mov_write_d263_tag(pb); - else if(track->enc->codec_id == CODEC_ID_SVQ3) - mov_write_svq3_tag(pb); - else if(track->enc->codec_id == CODEC_ID_AVUI) { + else if(track->enc->codec_id == CODEC_ID_AVUI || + track->enc->codec_id == CODEC_ID_SVQ3) { mov_write_extradata_tag(pb, track); avio_wb32(pb, 0); } else if(track->enc->codec_id == CODEC_ID_DNXHD)