Browse code

movenc: Rudimentary IODs support.

Alex Converse authored on 2011/10/05 03:44:25
Showing 5 changed files
... ...
@@ -46,6 +46,9 @@ static const AVOption options[] = {
46 46
     { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
47 47
     { "rtphint", "Add RTP hint tracks", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" },
48 48
     FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags),
49
+    { "skip_iods", "Skip writing iods atom.", offsetof(MOVMuxContext, iods_skip), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
50
+    { "iods_audio_profile", "iods audio profile atom.", offsetof(MOVMuxContext, iods_audio_profile), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
51
+    { "iods_video_profile", "iods video profile atom.", offsetof(MOVMuxContext, iods_video_profile), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 255, AV_OPT_FLAG_ENCODING_PARAM},
49 52
     { NULL },
50 53
 };
51 54
 
... ...
@@ -1407,21 +1410,34 @@ static int mov_write_trak_tag(AVIOContext *pb, MOVTrack *track, AVStream *st)
1407 1407
     return updateSize(pb, pos);
1408 1408
 }
1409 1409
 
1410
-#if 0
1411
-/* TODO: Not sorted out, but not necessary either */
1412 1410
 static int mov_write_iods_tag(AVIOContext *pb, MOVMuxContext *mov)
1413 1411
 {
1414
-    avio_wb32(pb, 0x15); /* size */
1412
+    int i, has_audio = 0, has_video = 0;
1413
+    int64_t pos = avio_tell(pb);
1414
+    int audio_profile = mov->iods_audio_profile;
1415
+    int video_profile = mov->iods_video_profile;
1416
+    for (i = 0; i < mov->nb_streams; i++) {
1417
+        if(mov->tracks[i].entry > 0) {
1418
+            has_audio |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_AUDIO;
1419
+            has_video |= mov->tracks[i].enc->codec_type == AVMEDIA_TYPE_VIDEO;
1420
+        }
1421
+    }
1422
+    if (audio_profile < 0)
1423
+        audio_profile = 0xFF - has_audio;
1424
+    if (video_profile < 0)
1425
+        video_profile = 0xFF - has_video;
1426
+    avio_wb32(pb, 0x0); /* size */
1415 1427
     ffio_wfourcc(pb, "iods");
1416 1428
     avio_wb32(pb, 0);    /* version & flags */
1417
-    avio_wb16(pb, 0x1007);
1418
-    avio_w8(pb, 0);
1419
-    avio_wb16(pb, 0x4fff);
1420
-    avio_wb16(pb, 0xfffe);
1421
-    avio_wb16(pb, 0x01ff);
1422
-    return 0x15;
1429
+    putDescr(pb, 0x10, 7);
1430
+    avio_wb16(pb, 0x004f);
1431
+    avio_w8(pb, 0xff);
1432
+    avio_w8(pb, 0xff);
1433
+    avio_w8(pb, audio_profile);
1434
+    avio_w8(pb, video_profile);
1435
+    avio_w8(pb, 0xff);
1436
+    return updateSize(pb, pos);
1423 1437
 }
1424
-#endif
1425 1438
 
1426 1439
 static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov)
1427 1440
 {
... ...
@@ -1829,7 +1845,8 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov,
1829 1829
     }
1830 1830
 
1831 1831
     mov_write_mvhd_tag(pb, mov);
1832
-    //mov_write_iods_tag(pb, mov);
1832
+    if (mov->mode != MODE_MOV && !mov->iods_skip)
1833
+        mov_write_iods_tag(pb, mov);
1833 1834
     for (i=0; i<mov->nb_streams; i++) {
1834 1835
         if(mov->tracks[i].entry > 0) {
1835 1836
             mov_write_trak_tag(pb, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL);
... ...
@@ -112,6 +112,9 @@ typedef struct MOVMuxContext {
112 112
 
113 113
     int flags;
114 114
     int rtp_flags;
115
+    int iods_skip;
116
+    int iods_video_profile;
117
+    int iods_audio_profile;
115 118
 } MOVMuxContext;
116 119
 
117 120
 #define FF_MOV_FLAG_RTP_HINT 1
... ...
@@ -1,4 +1,4 @@
1
-b25bcc7ec3f5c19cdfc01a6bbd32edb8 *./tests/data/acodec/alac.m4a
2
-389386 ./tests/data/acodec/alac.m4a
1
+8d9cb7f65c5b17c74e5f9bdc36f32b7d *./tests/data/acodec/alac.m4a
2
+389410 ./tests/data/acodec/alac.m4a
3 3
 64151e4bcc2b717aa5a8454d424d6a1f *./tests/data/alac.acodec.out.wav
4 4
 stddev:    0.00 PSNR:999.99 MAXDIFF:    0 bytes:  1058400/  1058400
... ...
@@ -1,4 +1,4 @@
1
-080e75117f8142001b096cd977ba287e *./tests/data/vsynth1/odivx.mp4
2
-540156 ./tests/data/vsynth1/odivx.mp4
1
+9251145d12150cb639098016d61fc75e *./tests/data/vsynth1/odivx.mp4
2
+540180 ./tests/data/vsynth1/odivx.mp4
3 3
 8828a375448dc5c2215163ba70656f89 *./tests/data/mpeg4.vsynth1.out.yuv
4 4
 stddev:    7.97 PSNR: 30.10 MAXDIFF:  105 bytes:  7603200/  7603200
... ...
@@ -1,4 +1,4 @@
1
-8ffbe8ce43fe126b12cf9621717d641b *./tests/data/vsynth2/odivx.mp4
2
-119809 ./tests/data/vsynth2/odivx.mp4
1
+c2ca709a0ed64833fd38f703b19e5e85 *./tests/data/vsynth2/odivx.mp4
2
+119833 ./tests/data/vsynth2/odivx.mp4
3 3
 90a3577850239083a9042bef33c50e85 *./tests/data/mpeg4.vsynth2.out.yuv
4 4
 stddev:    5.34 PSNR: 33.57 MAXDIFF:   83 bytes:  7603200/  7603200