mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avformat/movenc: don't use mono layout when a front center label is expected
On output streams where a multichannel stream needs to be stored as one track per channel, each track will have a channel layout describing the position of the channel they contain. For the track with front center, the mov muxer was using the mov layout "mono" instead of the label for the front center position. Since our channel layout API considers front center == mono, we need to do some heuristics. To achieve this, we make sure all audio tracks contain streams with a single channel, and only one of them is front center. In that case, we write the front center label instead of signaling mono layout. Fixes the last part of ticket #2865 Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
feb3b44c1c
commit
7ccc910803
@ -887,6 +887,17 @@ static int mov_write_chan_tag(AVFormatContext *s, AVIOContext *pb, MOVTrack *tra
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (layout_tag == MOV_CH_LAYOUT_MONO && track->mono_as_fc > 0) {
|
||||
av_assert0(!channel_desc);
|
||||
channel_desc = av_malloc(sizeof(*channel_desc));
|
||||
if (!channel_desc)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
layout_tag = 0;
|
||||
bitmap = 0;
|
||||
*channel_desc = 3; // channel label "Center"
|
||||
}
|
||||
|
||||
num_desc = layout_tag ? 0 : track->par->ch_layout.nb_channels;
|
||||
|
||||
avio_wb32(pb, 0); // Size
|
||||
@ -6970,6 +6981,20 @@ static int mov_write_header(AVFormatContext *s)
|
||||
if (j == i)
|
||||
continue;
|
||||
|
||||
if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
(trackj->par->ch_layout.nb_channels != 1 ||
|
||||
!av_channel_layout_compare(&trackj->par->ch_layout,
|
||||
&(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO))
|
||||
)
|
||||
track->mono_as_fc = -1;
|
||||
|
||||
if (stj->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
|
||||
av_channel_layout_compare(&trackj->par->ch_layout,
|
||||
&(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO) &&
|
||||
trackj->par->ch_layout.nb_channels == 1 && track->mono_as_fc >= 0
|
||||
)
|
||||
track->mono_as_fc++;
|
||||
|
||||
if (stj->codecpar->codec_type != AVMEDIA_TYPE_AUDIO ||
|
||||
av_channel_layout_compare(&trackj->par->ch_layout,
|
||||
&(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO) ||
|
||||
|
@ -107,6 +107,7 @@ typedef struct MOVTrack {
|
||||
int tag; ///< stsd fourcc
|
||||
AVStream *st;
|
||||
AVCodecParameters *par;
|
||||
int mono_as_fc;
|
||||
int multichannel_as_mono;
|
||||
|
||||
int vos_len;
|
||||
|
Loading…
Reference in New Issue
Block a user