[vlc-devel] [RFC] audio: let VLC decode more than 9 audio channels
Rémi Denis-Courmont
remi at remlab.net
Wed Oct 7 11:00:58 CEST 2015
Le 2015-10-06 18:53, Emeric Grange a écrit :
> It would probably be better to introduce a new ADEC_CHAN_MAX with an
> higher value than AOUT_CHAN_MAX, so decode can still be achieved but
> processing
> would be blocked. What do you think?
The LibVLC PCM callbacks use the audio output, so that does not make
sense and wouldn't solve anything AFAICT.
>
> ---
> include/vlc_aout.h | 14 +++++++++++++-
> include/vlc_es.h | 26
> +++++++++++++++++++++-----
> modules/codec/araw.c | 5 ++++-
> modules/demux/wav.c | 2 +-
> modules/demux/windows_audio_commons.h | 17 +++++++++++++++--
> 5 files changed, 54 insertions(+), 10 deletions(-)
>
> diff --git a/include/vlc_aout.h b/include/vlc_aout.h
> index 630be72..2d58792 100644
> --- a/include/vlc_aout.h
> +++ b/include/vlc_aout.h
> @@ -177,7 +177,19 @@ static const uint32_t pi_vlc_chan_order_wg4[] =
> AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
> AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
> AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT, AOUT_CHAN_REARCENTER,
> - AOUT_CHAN_CENTER, AOUT_CHAN_LFE, 0
> + AOUT_CHAN_CENTER, AOUT_CHAN_LFE,
> +
> + AOUT_CHAN_SIDE_LEFT,
> + AOUT_CHAN_SIDE_RIGHT,
> + AOUT_CHAN_TOP_CENTER,
> + AOUT_CHAN_TOP_FRONT_CENTER,
> + AOUT_CHAN_TOP_FRONT_LEFT,
> + AOUT_CHAN_TOP_FRONT_RIGHT,
> + AOUT_CHAN_TOP_BACK_CENTER,
> + AOUT_CHAN_TOP_BACK_LEFT,
> + AOUT_CHAN_TOP_BACK_RIGHT,
> +
> + 0
> };
>
> #define AOUT_RESTART_FILTERS 1
> diff --git a/include/vlc_es.h b/include/vlc_es.h
> index 97cdb78..bf0bc11 100644
> --- a/include/vlc_es.h
> +++ b/include/vlc_es.h
> @@ -108,13 +108,28 @@ struct audio_format_t
> #define AOUT_CHAN_REARRIGHT 0x40
> #define AOUT_CHAN_MIDDLELEFT 0x100
> #define AOUT_CHAN_MIDDLERIGHT 0x200
> -#define AOUT_CHAN_LFE 0x1000
> +
> +#define AOUT_CHAN_SIDE_LEFT 0x100
> +#define AOUT_CHAN_SIDE_RIGHT 0x200
> +#define AOUT_CHAN_TOP_CENTER 0x400
> +#define AOUT_CHAN_TOP_FRONT_CENTER 0x800
> +#define AOUT_CHAN_TOP_FRONT_LEFT 0x1000
> +#define AOUT_CHAN_TOP_FRONT_RIGHT 0x2000
> +#define AOUT_CHAN_TOP_BACK_CENTER 0x4000
> +#define AOUT_CHAN_TOP_BACK_LEFT 0x8000
> +#define AOUT_CHAN_TOP_BACK_RIGHT 0x10000
> +
> +#define AOUT_CHAN_LFE 0x80000
>
> #define AOUT_CHANS_FRONT (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT)
> #define AOUT_CHANS_MIDDLE (AOUT_CHAN_MIDDLELEFT |
> AOUT_CHAN_MIDDLERIGHT)
> #define AOUT_CHANS_REAR (AOUT_CHAN_REARLEFT |
> AOUT_CHAN_REARRIGHT)
> #define AOUT_CHANS_CENTER (AOUT_CHAN_CENTER |
> AOUT_CHAN_REARCENTER)
>
> +#define AOUT_CHANS_TOP_FRONT (AOUT_CHAN_TOP_FRONT_LEFT |
> AOUT_CHAN_TOP_FRONT_RIGHT)
> +#define AOUT_CHANS_TOP_REAR (AOUT_CHAN_TOP_BACK_LEFT |
> AOUT_CHAN_TOP_BACK_LEFT)
> +#define AOUT_CHANS_TOP_CENTER (AOUT_CHAN_TOP_CENTER |
> AOUT_CHAN_TOP_FRONT_CENTER | AOUT_CHAN_TOP_BACK_CENTER)
> +
> #define AOUT_CHANS_STEREO AOUT_CHANS_2_0
> #define AOUT_CHANS_2_0 (AOUT_CHANS_FRONT)
> #define AOUT_CHANS_2_1 (AOUT_CHANS_FRONT | AOUT_CHAN_LFE)
> @@ -128,6 +143,7 @@ struct audio_format_t
> #define AOUT_CHANS_7_0 (AOUT_CHANS_6_0 | AOUT_CHAN_CENTER)
> #define AOUT_CHANS_7_1 (AOUT_CHANS_5_1 | AOUT_CHANS_MIDDLE)
> #define AOUT_CHANS_8_1 (AOUT_CHANS_7_1 | AOUT_CHAN_REARCENTER)
> +#define AOUT_CHANS_16_0 (AOUT_CHANS_8_1 | AOUT_CHANS_TOP_FRONT |
> AOUT_CHANS_TOP_REAR | AOUT_CHANS_TOP_CENTER)
Is 16.0 actually defined anywhere? I thought 22.2 was the current full
set of speakers.
>
> #define AOUT_CHANS_4_0_MIDDLE (AOUT_CHANS_FRONT | AOUT_CHANS_MIDDLE)
> #define AOUT_CHANS_4_CENTER_REAR (AOUT_CHANS_FRONT |
> AOUT_CHANS_CENTER)
> @@ -135,12 +151,12 @@ struct audio_format_t
> #define AOUT_CHANS_6_1_MIDDLE (AOUT_CHANS_5_0_MIDDLE |
> AOUT_CHAN_REARCENTER | AOUT_CHAN_LFE)
>
> /* Values available for original channels only */
> -#define AOUT_CHAN_DOLBYSTEREO 0x10000
> -#define AOUT_CHAN_DUALMONO 0x20000
> -#define AOUT_CHAN_REVERSESTEREO 0x40000
> +#define AOUT_CHAN_DOLBYSTEREO 0x100000
> +#define AOUT_CHAN_DUALMONO 0x200000
> +#define AOUT_CHAN_REVERSESTEREO 0x400000
You'll need to fix whatever it breaks according to J-B if you want more
channels than 15.1.
But then I'd move the flags bits all the way to bits 28-30.
> #define AOUT_CHAN_PHYSMASK 0xFFFF
Needs fixing, or:
#define AOUT_CHAN_PHYSMASK ((1u << AOUT_CHAN_MAX) - 1u)
> -#define AOUT_CHAN_MAX 9
> +#define AOUT_CHAN_MAX 18
>
> /**
> * Picture orientation.
> diff --git a/modules/codec/araw.c b/modules/codec/araw.c
> index 0746a5e..c85e121 100644
> --- a/modules/codec/araw.c
> +++ b/modules/codec/araw.c
> @@ -81,6 +81,9 @@ static const uint16_t pi_channels_maps[] =
> AOUT_CHAN_CENTER, AOUT_CHANS_2_0, AOUT_CHANS_3_0,
> AOUT_CHANS_4_0, AOUT_CHANS_5_0, AOUT_CHANS_5_1,
> AOUT_CHANS_7_0, AOUT_CHANS_7_1, AOUT_CHANS_8_1,
> + 0, 0, 0,
> + 0, 0, 0,
> + AOUT_CHANS_16_0, 0, 0,
I'd use indexed initialization.
> };
>
> static void S8Decode( void *, const uint8_t *, unsigned );
> @@ -246,7 +249,7 @@ static int DecoderOpen( vlc_object_t *p_this )
> if( p_dec->fmt_in.audio.i_channels <= 0 ||
> p_dec->fmt_in.audio.i_channels > AOUT_CHAN_MAX )
> {
> - msg_Err( p_dec, "bad channels count (1-9): %i",
> + msg_Err( p_dec, "bad channels count (1-18): %i",
> p_dec->fmt_in.audio.i_channels );
Could pass AOUT_CHAN_MAX as format string paramater. Also separate
patch.
> return VLC_EGENERIC;
> }
> diff --git a/modules/demux/wav.c b/modules/demux/wav.c
> index 827bf72..5a0fe79 100644
> --- a/modules/demux/wav.c
> +++ b/modules/demux/wav.c
> @@ -272,7 +272,7 @@ static int Open( vlc_object_t * p_this )
> }
> }
> else if( GetWLE( &p_wf->wFormatTag ) == WAVE_FORMAT_PCM &&
> - p_sys->fmt.audio.i_channels > 2 &&
> p_sys->fmt.audio.i_channels <= 9 )
> + p_sys->fmt.audio.i_channels > 2 &&
> p_sys->fmt.audio.i_channels <= AOUT_CHAN_MAX )
Correct but separate patch IMHO.
> {
> for( int i = 0; i < p_sys->fmt.audio.i_channels; i++ )
> p_sys->i_channel_mask |= pi_channels_aout[i];
> diff --git a/modules/demux/windows_audio_commons.h
> b/modules/demux/windows_audio_commons.h
> index 80aa5cb..8cf069f 100644
> --- a/modules/demux/windows_audio_commons.h
> +++ b/modules/demux/windows_audio_commons.h
> @@ -29,11 +29,24 @@
> static const uint32_t pi_channels_src[] = { WAVE_SPEAKER_FRONT_LEFT,
> WAVE_SPEAKER_FRONT_RIGHT, WAVE_SPEAKER_FRONT_CENTER,
> WAVE_SPEAKER_LOW_FREQUENCY, WAVE_SPEAKER_BACK_LEFT,
> WAVE_SPEAKER_BACK_RIGHT,
> - WAVE_SPEAKER_BACK_CENTER, WAVE_SPEAKER_SIDE_LEFT,
> WAVE_SPEAKER_SIDE_RIGHT, 0 };
> + WAVE_SPEAKER_FRONT_LEFT_OF_CENTER,
> WAVE_SPEAKER_FRONT_RIGHT_OF_CENTER,
> + WAVE_SPEAKER_BACK_CENTER, WAVE_SPEAKER_SIDE_LEFT,
> WAVE_SPEAKER_SIDE_RIGHT,
> + WAVE_SPEAKER_TOP_CENTER,
> + WAVE_SPEAKER_TOP_FRONT_LEFT, WAVE_SPEAKER_TOP_FRONT_CENTER,
> WAVE_SPEAKER_TOP_FRONT_RIGHT,
> + WAVE_SPEAKER_TOP_BACK_LEFT, WAVE_SPEAKER_TOP_BACK_CENTER,
> WAVE_SPEAKER_TOP_BACK_RIGHT,
> + 0,
> +};
>
> static const uint32_t pi_channels_aout[] = { AOUT_CHAN_LEFT,
> AOUT_CHAN_RIGHT,
> AOUT_CHAN_CENTER, AOUT_CHAN_LFE, AOUT_CHAN_REARLEFT,
> AOUT_CHAN_REARRIGHT,
> - AOUT_CHAN_REARCENTER, AOUT_CHAN_MIDDLELEFT,
> AOUT_CHAN_MIDDLERIGHT, 0 };
> + AOUT_CHAN_MIDDLELEFT, AOUT_CHAN_MIDDLERIGHT,
> + AOUT_CHAN_REARCENTER,
> + AOUT_CHAN_SIDE_LEFT, AOUT_CHAN_SIDE_RIGHT,
> + AOUT_CHAN_TOP_CENTER,
> + AOUT_CHAN_TOP_FRONT_LEFT, AOUT_CHAN_TOP_FRONT_CENTER,
> AOUT_CHAN_TOP_FRONT_RIGHT,
> + AOUT_CHAN_TOP_BACK_LEFT, AOUT_CHAN_TOP_BACK_CENTER,
> AOUT_CHAN_TOP_BACK_RIGHT,
> + 0,
> +};
>
> static inline unsigned getChannelMask( uint32_t * wvfextChannelMask,
> int i_channels, int * i_match )
> {
> --
> 2.3.8 (Apple Git-58)
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list