Commit 36647037 authored by Kevin Wheatley's avatar Kevin Wheatley Committed by Michael Niedermayer

avformat/movenc: Fix writing ACLR atoms for DNxHD

Using the copy codec ACLR atoms where incorrectly written

During the creation of the ACLR atom we are assuming the vos_data
contains the DNxHD header. This change makes this explicit and
ensures we don't over write the stream with the extra_data.
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 847daac5
...@@ -1033,6 +1033,27 @@ static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack *track) ...@@ -1033,6 +1033,27 @@ static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack *track)
static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
{ {
int i; int i;
int interlaced;
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)) {
/* looks like a DNxHD bit stream */
interlaced = (track->vos_data[5] & 2);
cid = AV_RB32(track->vos_data + 0x28);
} else {
av_log(NULL, AV_LOG_WARNING, "Could not locate DNxHD bit stream in vos_data\n");
return 0;
}
} else {
av_log(NULL, AV_LOG_WARNING, "Could not locate DNxHD bit stream, vos_data too small\n");
return 0;
}
avio_wb32(pb, 24); /* size */ avio_wb32(pb, 24); /* size */
ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "ACLR");
ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "ACLR");
...@@ -1056,10 +1077,10 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) ...@@ -1056,10 +1077,10 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "ARES");
ffio_wfourcc(pb, "ARES"); ffio_wfourcc(pb, "ARES");
ffio_wfourcc(pb, "0001"); ffio_wfourcc(pb, "0001");
avio_wb32(pb, AV_RB32(track->vos_data + 0x28)); /* dnxhd cid, some id ? */ avio_wb32(pb, cid); /* dnxhd cid, some id ? */
avio_wb32(pb, track->enc->width); avio_wb32(pb, track->enc->width);
/* values below are based on samples created with quicktime and avid codecs */ /* values below are based on samples created with quicktime and avid codecs */
if (track->vos_data[5] & 2) { // interlaced if (interlaced) {
avio_wb32(pb, track->enc->height / 2); avio_wb32(pb, track->enc->height / 2);
avio_wb32(pb, 2); /* unknown */ avio_wb32(pb, 2); /* unknown */
avio_wb32(pb, 0); /* unknown */ avio_wb32(pb, 0); /* unknown */
...@@ -4165,7 +4186,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -4165,7 +4186,9 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
samples_in_chunk = 1; samples_in_chunk = 1;
/* copy extradata if it exists */ /* copy extradata if it exists */
if (trk->vos_len == 0 && enc->extradata_size > 0 && !TAG_IS_AVCI(trk->tag)) { if (trk->vos_len == 0 && enc->extradata_size > 0 &&
!TAG_IS_AVCI(trk->tag) &&
(enc->codec_id != AV_CODEC_ID_DNXHD)) {
trk->vos_len = enc->extradata_size; trk->vos_len = enc->extradata_size;
trk->vos_data = av_malloc(trk->vos_len); trk->vos_data = av_malloc(trk->vos_len);
if (!trk->vos_data) { if (!trk->vos_data) {
...@@ -4952,7 +4975,7 @@ static int mov_write_header(AVFormatContext *s) ...@@ -4952,7 +4975,7 @@ static int mov_write_header(AVFormatContext *s)
if (st->codec->extradata_size) { if (st->codec->extradata_size) {
if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE) if (st->codec->codec_id == AV_CODEC_ID_DVD_SUBTITLE)
mov_create_dvd_sub_decoder_specific_info(track, st); mov_create_dvd_sub_decoder_specific_info(track, st);
else if (!TAG_IS_AVCI(track->tag)){ else if (!TAG_IS_AVCI(track->tag) && st->codec->codec_id != AV_CODEC_ID_DNXHD) {
track->vos_len = st->codec->extradata_size; track->vos_len = st->codec->extradata_size;
track->vos_data = av_malloc(track->vos_len); track->vos_data = av_malloc(track->vos_len);
if (!track->vos_data) { if (!track->vos_data) {
......
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