[vlc-commits] Mix 16-bits PCM instead of fixed-point if input is 16-bits or less
Rémi Denis-Courmont
git at videolan.org
Fri Jul 8 23:01:16 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jul 8 23:56:07 2011 +0300| [bfe9c3c7a3aea5131c53b7a0843362b84ad60607] | committer: Rémi Denis-Courmont
Mix 16-bits PCM instead of fixed-point if input is 16-bits or less
Audio output should be more efficient on FPU-less devices.
Firstly the mixer should be faster with 16-bits instead of 32.
Secondly FPU-less systems usually output at 16-bits, so one sample
format conversion between the mixer and the output is now avoided.
Thirdly conversion from input format to the mixer format should
similarly be completely avoided or at least accelerated.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=bfe9c3c7a3aea5131c53b7a0843362b84ad60607
---
src/audio_output/output.c | 28 +++++++++++++++++-----------
1 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/audio_output/output.c b/src/audio_output/output.c
index 9835d3f..493ebda 100644
--- a/src/audio_output/output.c
+++ b/src/audio_output/output.c
@@ -161,20 +161,26 @@ int aout_OutputNew( aout_instance_t * p_aout,
aout_FifoInit( p_aout, &p_aout->output.fifo, p_aout->output.output.i_rate );
aout_FormatPrint( p_aout, "output", &p_aout->output.output );
- /* Calculate the resulting mixer output format. */
+ /* Choose the mixer format. */
p_aout->mixer_format = p_aout->output.output;
- if ( !AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
- {
- /* Non-S/PDIF mixer only deals with float32 or fixed32. */
- p_aout->mixer_format.i_format
- = HAVE_FPU ? VLC_CODEC_FL32 : VLC_CODEC_FI32;
- aout_FormatPrepare( &p_aout->mixer_format );
- }
- else
- {
+ if ( AOUT_FMT_NON_LINEAR(&p_aout->output.output) )
p_aout->mixer_format.i_format = p_format->i_format;
- }
+ else
+ /* Most audio filters can only deal with single-precision,
+ * so lets always use that when hardware supports floating point. */
+ if( HAVE_FPU )
+ p_aout->mixer_format.i_format = VLC_CODEC_FL32;
+ else
+ /* Otherwise, audio filters will not work. Use fixed-point if the input has
+ * more than 16-bits depth. */
+ if( p_format->i_bitspersample > 16 )
+ p_aout->mixer_format.i_format = VLC_CODEC_FI32;
+ else
+ /* Fallback to 16-bits. This avoids pointless conversion to and from
+ * 32-bits samples for the sole purpose of software mixing. */
+ p_aout->mixer_format.i_format = VLC_CODEC_S16N;
+ aout_FormatPrepare( &p_aout->mixer_format );
aout_FormatPrint( p_aout, "mixer", &p_aout->mixer_format );
/* Create filters. */
More information about the vlc-commits
mailing list