[1/2] movenc: Support muxing VC1

Message ID 1327694369-19264-1-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Jan. 27, 2012, 7:59 p.m.
---
 libavformat/movenc.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

Patch

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 22e8d84..2b76a01 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -412,6 +412,37 @@  static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track)
     return updateSize(pb, pos);
 }
 
+static int mov_write_dvc1_tag(AVIOContext *pb, MOVTrack *track)
+{
+    uint8_t buf[7] = { 0 };
+    PutBitContext pbc;
+    init_put_bits(&pbc, buf, sizeof(buf));
+    /* TODO: This assumes vc1 advanced profile - figure out which
+     * profile is used, and write the right structs. */
+    /* VC1DecSpecStruc */
+    put_bits(&pbc, 4, 12); /* profile - advanced */
+    put_bits(&pbc, 3, 4); /* level - 4 */
+    put_bits(&pbc, 1, 0); /* reserved */
+    /* VC1AdvDecSpecStruc */
+    put_bits(&pbc, 3, 4); /* level - 4 */
+    put_bits(&pbc, 1, 0); /* cbr */
+    put_bits(&pbc, 6, 0); /* reserved */
+    put_bits(&pbc, 1, 1); /* no interlace */
+    put_bits(&pbc, 1, 0); /* no multiple seq */
+    put_bits(&pbc, 1, 0); /* no multiple entry */
+    put_bits(&pbc, 1, 1); /* no slice code */
+    put_bits(&pbc, 1, 0); /* no bframe */
+    put_bits(&pbc, 1, 0); /* reserved */
+    put_bits32(&pbc, track->enc->time_base.den); /* framerate */
+    flush_put_bits(&pbc);
+
+    avio_wb32(pb, track->vosLen + 8 + sizeof(buf));
+    ffio_wfourcc(pb, "dvc1");
+    avio_write(pb, buf, sizeof(buf));
+    avio_write(pb, track->vosData, track->vosLen);
+    return 0;
+}
+
 static int mov_write_glbl_tag(AVIOContext *pb, MOVTrack *track)
 {
     avio_wb32(pb, track->vosLen+8);
@@ -614,6 +645,7 @@  static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
     else if (track->enc->codec_id == CODEC_ID_AC3)       tag = MKTAG('a','c','-','3');
     else if (track->enc->codec_id == CODEC_ID_DIRAC)     tag = MKTAG('d','r','a','c');
     else if (track->enc->codec_id == CODEC_ID_MOV_TEXT)  tag = MKTAG('t','x','3','g');
+    else if (track->enc->codec_id == CODEC_ID_VC1)       tag = MKTAG('v','c','-','1');
     else if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO) tag = MKTAG('m','p','4','v');
     else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO) tag = MKTAG('m','p','4','a');
 
@@ -896,6 +928,8 @@  static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
             mov_write_uuid_tag_ipod(pb);
     } else if (track->enc->field_order != AV_FIELD_UNKNOWN)
         mov_write_fiel_tag(pb, track);
+    else if(track->enc->codec_id == CODEC_ID_VC1)
+        mov_write_dvc1_tag(pb, track);
     else if(track->vosLen > 0)
         mov_write_glbl_tag(pb, track);