aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2008-07-27 15:11:04 +0000
committerAurelien Jacobs <aurel@gnuage.org>2008-07-27 15:11:04 +0000
commitf009e36f75bc137167a26356305d2c3eb83cac68 (patch)
tree97747c67e4c4f363cb965a64679c45e70521176b
parent18c7be650181a8532c5127e558b254ab55e351a2 (diff)
downloadffmpeg-f009e36f75bc137167a26356305d2c3eb83cac68.tar.gz
matroska: add support for V_QUICKTIME track type
Originally committed as revision 14429 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavformat/matroskadec.c10
-rw-r--r--libavformat/matroskaenc.c25
2 files changed, 32 insertions, 3 deletions
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index bea76f47d9..ba7580ac5e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -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 @@ matroska_read_header (AVFormatContext *s,
}
+ 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);
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index a13843777f..24bcfdb527 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -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 void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int
}
}
-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 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
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 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
}
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 @@ static int mkv_write_tracks(AVFormatContext *s)
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 @@ static int mkv_write_tracks(AVFormatContext *s)
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 @@ static int mkv_write_tracks(AVFormatContext *s)
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);