}
}
flush_put_bits(&pbc);
- size = put_bits_count(&pbc) >> 3;
+ size = put_bytes_output(&pbc);
avio_wb32(pb, size + 8);
ffio_wfourcc(pb, "dec3");
static int mov_write_dops_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
+ int channels, channel_map;
avio_wb32(pb, 0);
ffio_wfourcc(pb, "dOps");
avio_w8(pb, 0); /* Version */
/* extradata contains an Ogg OpusHead, other than byte-ordering and
OpusHead's preceeding magic/version, OpusSpecificBox is currently
identical. */
- avio_w8(pb, AV_RB8(track->par->extradata + 9)); /* OuputChannelCount */
+ channels = AV_RB8(track->par->extradata + 9);
+ channel_map = AV_RB8(track->par->extradata + 18);
+
+ avio_w8(pb, channels); /* OuputChannelCount */
avio_wb16(pb, AV_RL16(track->par->extradata + 10)); /* PreSkip */
avio_wb32(pb, AV_RL32(track->par->extradata + 12)); /* InputSampleRate */
avio_wb16(pb, AV_RL16(track->par->extradata + 16)); /* OutputGain */
+ avio_w8(pb, channel_map); /* ChannelMappingFamily */
/* Write the rest of the header out without byte-swapping. */
- avio_write(pb, track->par->extradata + 18, track->par->extradata_size - 18);
+ if (channel_map) {
+ if (track->par->extradata_size < 21 + channels) {
+ av_log(s, AV_LOG_ERROR, "invalid extradata size\n");
+ return AVERROR_INVALIDDATA;
+ }
+ avio_write(pb, track->par->extradata + 19, 2 + channels); /* ChannelMappingTable */
+ }
return update_size(pb, pos);
}
return AVERROR(EINVAL);
#endif
} else {
- frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.num, track->st->avg_frame_rate.den);
- nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.den, track->st->avg_frame_rate.num);
+ frame_duration = av_rescale(track->timescale, track->st->avg_frame_rate.den, track->st->avg_frame_rate.num);
+ nb_frames = ROUNDED_DIV(track->st->avg_frame_rate.num, track->st->avg_frame_rate.den);
}
if (nb_frames > 255) {
AV_ROUND_UP);
int version = duration < INT32_MAX ? 0 : 1;
int flags = MOV_TKHD_FLAG_IN_MOVIE;
- int rotation = 0;
int group = 0;
uint32_t *display_matrix = NULL;
avio_wb16(pb, 0); /* reserved */
/* Matrix structure */
-#if FF_API_OLD_ROTATE_API
- if (st && st->metadata) {
- AVDictionaryEntry *rot = av_dict_get(st->metadata, "rotate", NULL, 0);
- rotation = (rot && rot->value) ? atoi(rot->value) : 0;
- }
-#endif
if (display_matrix) {
for (i = 0; i < 9; i++)
avio_wb32(pb, display_matrix[i]);
-#if FF_API_OLD_ROTATE_API
- } else if (rotation == 90) {
- write_matrix(pb, 0, 1, -1, 0, track->par->height, 0);
- } else if (rotation == 180) {
- write_matrix(pb, -1, 0, 0, -1, track->par->width, track->par->height);
- } else if (rotation == 270) {
- write_matrix(pb, 0, -1, 1, 0, 0, track->par->width);
-#endif
} else {
write_matrix(pb, 1, 0, 0, 1, 0, 0);
}
if (trk->entry >= trk->cluster_capacity) {
unsigned new_capacity = trk->entry + MOV_INDEX_CLUSTER_SIZE;
- if (av_reallocp_array(&trk->cluster, new_capacity,
- sizeof(*trk->cluster))) {
+ void *cluster = av_realloc_array(trk->cluster, new_capacity, sizeof(*trk->cluster));
+ if (!cluster) {
ret = AVERROR(ENOMEM);
goto err;
}
+ trk->cluster = cluster;
trk->cluster_capacity = new_capacity;
}
return AVERROR(ENOMEM);
track->par->codec_type = AVMEDIA_TYPE_DATA;
track->par->codec_tag = track->tag;
- track->st->avg_frame_rate = av_inv_q(rate);
+ track->st->avg_frame_rate = rate;
/* the tmcd track just contains one packet with the frame number */
pkt->data = data;