summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorMark Reid <mindmark@gmail.com>2016-07-22 13:30:15 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2016-07-23 13:54:12 +0200
commite47981dab7fb7c9499b959cb0125b7281301969a (patch)
tree328183d51b90f5577f949d24a5b2c7ac0d975d40 /libavformat/movenc.c
parent8ec599caa4b8ea996095810c58dfbb418c182c0a (diff)
libavformat/movenc: add dnxhr compatibility for apple players
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index d614933dff..014b465b1c 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -32,6 +32,7 @@
#include "isom.h"
#include "avc.h"
#include "libavcodec/ac3_parser.h"
+#include "libavcodec/dnxhddata.h"
#include "libavcodec/get_bits.h"
#include "libavcodec/put_bits.h"
#include "libavcodec/vc1_common.h"
@@ -1070,11 +1071,7 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
int cid;
if (track->vos_data && track->vos_len > 0x29) {
- if (track->vos_data[0] == 0x00 &&
- track->vos_data[1] == 0x00 &&
- track->vos_data[2] == 0x02 &&
- track->vos_data[3] == 0x80 &&
- (track->vos_data[4] == 0x01 || track->vos_data[4] == 0x02)) {
+ if (avpriv_dnxhd_parse_header_prefix(track->vos_data) != 0) {
/* looks like a DNxHD bit stream */
interlaced = (track->vos_data[5] & 2);
cid = AV_RB32(track->vos_data + 0x28);
@@ -1099,6 +1096,18 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
}
avio_wb32(pb, 0); /* unknown */
+ if (track->tag == MKTAG('A','V','d','h')) {
+ avio_wb32(pb, 32);
+ ffio_wfourcc(pb, "ADHR");
+ ffio_wfourcc(pb, "0001");
+ avio_wb32(pb, cid);
+ avio_wb32(pb, 0); /* unknown */
+ avio_wb32(pb, 1); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
+ avio_wb32(pb, 0); /* unknown */
+ return 0;
+ }
+
avio_wb32(pb, 24); /* size */
ffio_wfourcc(pb, "APRG");
ffio_wfourcc(pb, "APRG");
@@ -1384,6 +1393,15 @@ static const struct {
{ AV_PIX_FMT_RGB48BE, MKTAG('b','4','8','r'), 48 },
};
+static int mov_get_dnxhd_codec_tag(AVFormatContext *s, MOVTrack *track)
+{
+ int tag = MKTAG('A','V','d','n');
+ if (track->par->profile != FF_PROFILE_UNKNOWN &&
+ track->par->profile != FF_PROFILE_DNXHD)
+ tag = MKTAG('A','V','d','h');
+ return tag;
+}
+
static int mov_get_rawvideo_codec_tag(AVFormatContext *s, MOVTrack *track)
{
int tag = track->par->codec_tag;
@@ -1418,6 +1436,7 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
track->par->codec_id == AV_CODEC_ID_RAWVIDEO ||
track->par->codec_id == AV_CODEC_ID_H263 ||
track->par->codec_id == AV_CODEC_ID_H264 ||
+ track->par->codec_id == AV_CODEC_ID_DNXHD ||
track->par->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
av_get_bits_per_sample(track->par->codec_id)))) { // pcm audio
if (track->par->codec_id == AV_CODEC_ID_DVVIDEO)
@@ -1428,6 +1447,8 @@ static int mov_get_codec_tag(AVFormatContext *s, MOVTrack *track)
tag = mov_get_mpeg2_xdcam_codec_tag(s, track);
else if (track->par->codec_id == AV_CODEC_ID_H264)
tag = mov_get_h264_codec_tag(s, track);
+ else if (track->par->codec_id == AV_CODEC_ID_DNXHD)
+ tag = mov_get_dnxhd_codec_tag(s, track);
else if (track->par->codec_type == AVMEDIA_TYPE_VIDEO) {
tag = ff_codec_get_tag(ff_codec_movvideo_tags, track->par->codec_id);
if (!tag) { // if no mac fcc found, try with Microsoft tags