diff options
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r-- | libavformat/movenc.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 46d66c29c2..263649f1da 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -867,20 +867,27 @@ static int mov_write_dmlp_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *track) { - uint32_t layout_tag, bitmap; + uint32_t layout_tag, bitmap, *channel_desc; int64_t pos = avio_tell(pb); + int num_desc, ret; - layout_tag = ff_mov_get_channel_layout_tag(track->par->codec_id, - &track->par->ch_layout, - &bitmap); - if (!layout_tag) { - av_log(s, AV_LOG_WARNING, "not writing 'chan' tag due to " - "lack of channel information\n"); + if (track->multichannel_as_mono) return 0; + + ret = ff_mov_get_channel_layout_tag(track->par, &layout_tag, + &bitmap, &channel_desc); + + if (ret < 0) { + if (ret == AVERROR(ENOSYS)) { + av_log(s, AV_LOG_WARNING, "not writing 'chan' tag due to " + "lack of channel information\n"); + ret = 0; + } + + return ret; } - if (track->multichannel_as_mono) - return 0; + num_desc = layout_tag ? 0 : track->par->ch_layout.nb_channels; avio_wb32(pb, 0); // Size ffio_wfourcc(pb, "chan"); // Type @@ -888,7 +895,17 @@ static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra avio_wb24(pb, 0); // Flags avio_wb32(pb, layout_tag); // mChannelLayoutTag avio_wb32(pb, bitmap); // mChannelBitmap - avio_wb32(pb, 0); // mNumberChannelDescriptions + avio_wb32(pb, num_desc); // mNumberChannelDescriptions + + for (int i = 0; i < num_desc; i++) { + avio_wb32(pb, channel_desc[i]); // mChannelLabel + avio_wb32(pb, 0); // mChannelFlags + avio_wl32(pb, 0); // mCoordinates[0] + avio_wl32(pb, 0); // mCoordinates[1] + avio_wl32(pb, 0); // mCoordinates[2] + } + + av_free(channel_desc); return update_size(pb, pos); } |