summaryrefslogtreecommitdiffstats
path: root/libhb/audio_remap.c
diff options
context:
space:
mode:
authorRodeo <[email protected]>2012-11-21 18:53:23 +0000
committerRodeo <[email protected]>2012-11-21 18:53:23 +0000
commit5ab9b16a3f9635778f1ea07129560adb1be28cc5 (patch)
tree929fe40720d3076d82820b178ae32dd9ab9bf037 /libhb/audio_remap.c
parent282ddc84776683667e417a62186be57b97be3eab (diff)
hb_audio_remap: protect against invalid channel layouts.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5074 b64f7644-9d1e-0410-96f1-a4d463321fa5
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,