[vlc-devel] [PATCH] spacialaudio: discard non diegetic channels
Pierre Lamot
pierre at videolabs.io
Mon May 28 16:29:52 CEST 2018
---
modules/audio_filter/channel_mixer/spatialaudio.cpp | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index 6448585e37..f12350333d 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -123,6 +123,7 @@ struct filter_spatialaudio
mtime_t i_inputPTS;
mtime_t i_last_input_pts;
unsigned i_order;
+ unsigned i_nondiegetic;
float** inBuf;
float** outBuf;
@@ -220,7 +221,7 @@ static block_t *Mix( filter_t *p_filter, block_t *p_buf )
CBFormat inData;
inData.Configure(p_sys->i_order, true, AMB_BLOCK_TIME_LEN);
- for (unsigned i = 0; i < p_sys->i_inputNb; ++i)
+ for (unsigned i = 0; i < p_sys->i_inputNb - p_sys->i_nondiegetic; ++i)
inData.InsertStream(p_sys->inBuf[i], i, AMB_BLOCK_TIME_LEN);
Orientation ori(p_sys->f_teta, p_sys->f_phi, p_sys->f_roll);
@@ -402,6 +403,13 @@ static int Open(vlc_object_t *p_this)
if (infmt->i_format != VLC_CODEC_FL32 || outfmt->i_format != VLC_CODEC_FL32)
return VLC_EGENERIC;
+ //support order 1 to 3
+ if ( infmt->i_channels < 4 || infmt->i_channels > 18 )
+ {
+ msg_Err(p_filter, "Unsupported number of Ambisonics channels");
+ return VLC_EGENERIC;
+ }
+
filter_spatialaudio *p_sys = new(std::nothrow)filter_spatialaudio();
if (p_sys == NULL)
return VLC_ENOMEM;
@@ -419,16 +427,17 @@ static int Open(vlc_object_t *p_this)
return VLC_ENOMEM;
}
- p_sys->i_order = sqrt(infmt->i_channels) - 1;
+ p_sys->i_order = floor(sqrt(infmt->i_channels)) - 1;
+ p_sys->i_nondiegetic = infmt->i_channels - ( (p_sys->i_order + 1) * (p_sys->i_order + 1) );
- if (p_sys->i_order < 1)
+ if ( p_sys->i_nondiegetic != 0 && p_sys->i_nondiegetic != 2 )
{
- msg_Err(p_filter, "Invalid number of Ambisonics channels");
+ msg_Err(p_filter, "Invalid number of non-diegetic Ambisonics channels %i", p_sys->i_nondiegetic);
delete p_sys;
return VLC_EGENERIC;
}
- msg_Dbg(p_filter, "Order: %d %d", p_sys->i_order, infmt->i_channels);
+ msg_Dbg(p_filter, "Order: %d %d %d", p_sys->i_order, p_sys->i_nondiegetic, infmt->i_channels);
static const char *const options[] = { "headphones", NULL };
config_ChainParse(p_filter, CFG_PREFIX, options, p_filter->p_cfg);
--
2.14.1
More information about the vlc-devel
mailing list