Commit f009e36f authored by Aurelien Jacobs's avatar Aurelien Jacobs

matroska: add support for V_QUICKTIME track type

Originally committed as revision 14429 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 18c7be65
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "avformat.h" #include "avformat.h"
/* For codec_get_id(). */ /* For codec_get_id(). */
#include "riff.h" #include "riff.h"
#include "isom.h"
#include "matroska.h" #include "matroska.h"
#include "libavcodec/mpeg4audio.h" #include "libavcodec/mpeg4audio.h"
#include "libavutil/intfloat_readwrite.h" #include "libavutil/intfloat_readwrite.h"
...@@ -2550,6 +2551,15 @@ matroska_read_header (AVFormatContext *s, ...@@ -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) { else if (codec_id == CODEC_ID_AAC && !track->codec_priv_size) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track; MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
int profile = matroska_aac_profile(track->codec_id); int profile = matroska_aac_profile(track->codec_id);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "avformat.h" #include "avformat.h"
#include "riff.h" #include "riff.h"
#include "isom.h"
#include "matroska.h" #include "matroska.h"
#include "avc.h" #include "avc.h"
#include "libavutil/md5.h" #include "libavutil/md5.h"
...@@ -467,7 +468,7 @@ static void get_aac_sample_rates(AVFormatContext *s, AVCodecContext *codec, int ...@@ -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; ByteIOContext *dyn_cp;
uint8_t *codecpriv; uint8_t *codecpriv;
...@@ -487,6 +488,12 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec ...@@ -487,6 +488,12 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
else if (codec->extradata_size) else if (codec->extradata_size)
put_buffer(dyn_cp, codec->extradata, codec->extradata_size); put_buffer(dyn_cp, codec->extradata, codec->extradata_size);
} else if (codec->codec_type == CODEC_TYPE_VIDEO) { } 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) if (!codec->codec_tag)
codec->codec_tag = codec_get_tag(codec_bmp_tags, codec->codec_id); codec->codec_tag = codec_get_tag(codec_bmp_tags, codec->codec_id);
if (!codec->codec_tag) { if (!codec->codec_tag) {
...@@ -495,6 +502,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec ...@@ -495,6 +502,7 @@ static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodec
} }
put_bmp_header(dyn_cp, codec, codec_bmp_tags, 0); put_bmp_header(dyn_cp, codec, codec_bmp_tags, 0);
}
} else if (codec->codec_type == CODEC_TYPE_AUDIO) { } else if (codec->codec_type == CODEC_TYPE_AUDIO) {
if (!codec->codec_tag) if (!codec->codec_tag)
...@@ -530,6 +538,7 @@ static int mkv_write_tracks(AVFormatContext *s) ...@@ -530,6 +538,7 @@ static int mkv_write_tracks(AVFormatContext *s)
AVCodecContext *codec = st->codec; AVCodecContext *codec = st->codec;
ebml_master subinfo, track; ebml_master subinfo, track;
int native_id = 0; int native_id = 0;
int qt_id = 0;
int bit_depth = av_get_bits_per_sample(codec->codec_id); int bit_depth = av_get_bits_per_sample(codec->codec_id);
int sample_rate = codec->sample_rate; int sample_rate = codec->sample_rate;
int output_sample_rate = 0; int output_sample_rate = 0;
...@@ -566,7 +575,17 @@ static int mkv_write_tracks(AVFormatContext *s) ...@@ -566,7 +575,17 @@ static int mkv_write_tracks(AVFormatContext *s)
case CODEC_TYPE_VIDEO: case CODEC_TYPE_VIDEO:
put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_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 // if there is no mkv-specific codec ID, use VFW mode
put_ebml_string(pb, MATROSKA_ID_CODECID, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC); put_ebml_string(pb, MATROSKA_ID_CODECID, MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC);
...@@ -607,7 +626,7 @@ static int mkv_write_tracks(AVFormatContext *s) ...@@ -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."); av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.");
break; 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; if (ret < 0) return ret;
end_ebml_master(pb, track); end_ebml_master(pb, track);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment