diff options
author | James Almer <jamrial@gmail.com> | 2022-03-28 11:24:27 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-04-05 09:19:59 -0300 |
commit | c2c5f3484399281e7eb74f5fdcc1f2eab8b9f62d (patch) | |
tree | 5aecf369d5ad90cabb1df3ea2fa36589082dac02 /libavformat/movenc.c | |
parent | b4373bc4226426e4c2498e0c914520806764776e (diff) | |
download | ffmpeg-c2c5f3484399281e7eb74f5fdcc1f2eab8b9f62d.tar.gz |
avformat/movenc: write channel descriptions when a known layout or a bitmap can't be used
Fixes part of ticket #2865
Signed-off-by: James Almer <jamrial@gmail.com>
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); } |