summaryrefslogtreecommitdiffstats
path: root/libhb/audio_remap.c
diff options
context:
space:
mode:
Diffstat (limited to 'libhb/audio_remap.c')
-rw-r--r--libhb/audio_remap.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/libhb/audio_remap.c b/libhb/audio_remap.c
index afc9c3209..d0374a0a0 100644
--- a/libhb/audio_remap.c
+++ b/libhb/audio_remap.c
@@ -246,19 +246,19 @@ fail:
}
void hb_audio_remap_set_channel_layout(hb_audio_remap_t *remap,
- uint64_t channel_layout)
+ uint64_t channel_layout,
+ int channels)
{
if (remap != NULL)
{
int ii;
remap->remap_needed = 0;
- remap->nchannels = av_get_channel_layout_nb_channels(channel_layout);
// in some cases, remapping is not necessary and/or supported
- if (remap->nchannels > HB_AUDIO_REMAP_MAX_CHANNELS)
+ if (channels > HB_AUDIO_REMAP_MAX_CHANNELS)
{
hb_log("hb_audio_remap_set_channel_layout: too many channels (%d)",
- remap->nchannels);
+ channels);
return;
}
if (remap->channel_map_in == remap->channel_map_out)
@@ -266,6 +266,14 @@ void hb_audio_remap_set_channel_layout(hb_audio_remap_t *remap,
return;
}
+ // sanitize the layout
+ channel_layout = hb_ff_layout_xlat(channel_layout, channels);
+ if (channel_layout == AV_CH_LAYOUT_STEREO_DOWNMIX)
+ {
+ channel_layout = AV_CH_LAYOUT_STEREO;
+ }
+ remap->nchannels = av_get_channel_layout_nb_channels(channel_layout);
+
// build the table and check whether remapping is necessary
hb_audio_remap_build_table(remap->channel_map_out,
remap->channel_map_in, channel_layout,