changeset 3601:c0955bfc27be libavformat

matroska: add support for V_QUICKTIME track type
author aurel
date Sun, 27 Jul 2008 15:11:04 +0000
parents 68e5f9adb0f4
children 70edc1aeaf68
files matroskadec.c matroskaenc.c
diffstat 2 files changed, 32 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/matroskadec.c	Sat Jul 26 18:54:26 2008 +0000
+++ b/matroskadec.c	Sun Jul 27 15:11:04 2008 +0000
@@ -31,6 +31,7 @@
 #include "avformat.h"
 /* For codec_get_id(). */
 #include "riff.h"
+#include "isom.h"
 #include "matroska.h"
 #include "libavcodec/mpeg4audio.h"
 #include "libavutil/intfloat_readwrite.h"
@@ -2550,6 +2551,15 @@
 
             }
 
+            if (!strcmp(track->codec_id, "V_QUICKTIME") &&
+                (track->codec_priv_size >= 86) &&
+                (track->codec_priv != NULL)) {
+                MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) track;
+
+                vtrack->fourcc = AV_RL32(track->codec_priv);
+                codec_id = codec_get_id(codec_movvideo_tags, vtrack->fourcc);
+            }
+
             else if (codec_id == CODEC_ID_AAC && !track->codec_priv_size) {
                 MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
                 int profile = matroska_aac_profile(track->codec_id);
--- a/matroskaenc.c	Sat Jul 26 18:54:26 2008 +0000
+++ b/matroskaenc.c	Sun Jul 27 15:11:04 2008 +0000
@@ -21,6 +21,7 @@
 
 #include "avformat.h"
 #include "riff.h"
+#include "isom.h"
 #include "matroska.h"
 #include "avc.h"
 #include "libavutil/md5.h"
@@ -467,7 +468,7 @@
     }
 }
 
-static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec, int native_id)
+static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec, int native_id, int qt_id)
 {
     ByteIOContext *dyn_cp;
     uint8_t *codecpriv;
@@ -487,6 +488,12 @@
         else if (codec->extradata_size)
             put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
     } else if (codec->codec_type == CODEC_TYPE_VIDEO) {
+        if (qt_id) {
+            if (!codec->codec_tag)
+                codec->codec_tag = codec_get_tag(codec_movvideo_tags, codec->codec_id);
+            if (codec->extradata_size)
+                put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
+        } else {
         if (!codec->codec_tag)
             codec->codec_tag = codec_get_tag(codec_bmp_tags, codec->codec_id);
         if (!codec->codec_tag) {
@@ -495,6 +502,7 @@
         }
 
         put_bmp_header(dyn_cp, codec, codec_bmp_tags, 0);
+        }
 
     } else if (codec->codec_type == CODEC_TYPE_AUDIO) {
         if (!codec->codec_tag)
@@ -530,6 +538,7 @@
         AVCodecContext *codec = st->codec;
         ebml_master subinfo, track;
         int native_id = 0;
+        int qt_id = 0;
         int bit_depth = av_get_bits_per_sample(codec->codec_id);
         int sample_rate = codec->sample_rate;
         int output_sample_rate = 0;
@@ -566,7 +575,17 @@
             case CODEC_TYPE_VIDEO:
                 put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO);
 
-                if (!native_id)
+                if (!native_id &&
+                      codec_get_tag(codec_movvideo_tags, codec->codec_id) &&
+                    (!codec_get_tag(codec_bmp_tags,      codec->codec_id)
+                     || codec->codec_id == CODEC_ID_SVQ1
+                     || codec->codec_id == CODEC_ID_SVQ3
+                     || codec->codec_id == CODEC_ID_CINEPAK))
+                    qt_id = 1;
+
+                if (qt_id)
+                    put_ebml_string(pb, MATROSKA_ID_CODECID, "V_QUICKTIME");
+                else if (!native_id)
                     // if there is no mkv-specific codec ID, use VFW mode
                     put_ebml_string(pb, MATROSKA_ID_CODECID, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
 
@@ -607,7 +626,7 @@
                 av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.");
                 break;
         }
-        ret = mkv_write_codecprivate(s, pb, codec, native_id);
+        ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id);
         if (ret < 0) return ret;
 
         end_ebml_master(pb, track);