/*****************************************************************************
* fixed32tos16.c : converter from fixed32 to signed 16 bits integer
*****************************************************************************
- * Copyright (C) 2002 VideoLAN
- * $Id: fixed32tos16.c,v 1.6 2002/09/30 21:32:32 massiot Exp $
+ * Copyright (C) 2002 the VideoLAN team
+ * $Id$
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include <errno.h>
#include <stdlib.h> /* malloc(), free() */
#include <string.h>
* Module descriptor
*****************************************************************************/
vlc_module_begin();
+ set_category( CAT_AUDIO );
+ set_subcategory( SUBCAT_AUDIO_MISC );
set_description( _("audio filter for fixed32->s16 conversion") );
set_capability( "audio filter", 10 );
set_callbacks( Create, NULL );
#define VLC_F_FRACBITS 28
# if VLC_F_FRACBITS == 28
-# define VLC_F(x) ((vlc_fixed_t) (x##L))
+# define VLC_F(x) ((vlc_fixed_t) (x##L))
# endif
-# define VLC_F_ONE VLC_F(0x10000000)
+# define VLC_F_ONE VLC_F(0x10000000)
struct audio_dither {
vlc_fixed_t error[3];
* NAME: mpg321_s24_to_s16_pcm()
* DESCRIPTION: generic linear sample quantize and dither routine
********************************************************************/
-static inline s16 mpg321_s24_to_s16_pcm(unsigned int bits, vlc_fixed_t sample,
- struct audio_dither *dither)
+static inline int16_t mpg321_s24_to_s16_pcm(unsigned int bits, vlc_fixed_t sample,
+ struct audio_dither *dither)
{
unsigned int scalebits;
vlc_fixed_t output, mask, random;
/*****************************************************************************
* s24_to_s16_pcm: Scale a 24 bit pcm sample to a 16 bit pcm sample.
*****************************************************************************/
-static inline s16 s24_to_s16_pcm(vlc_fixed_t sample)
+static inline int16_t s24_to_s16_pcm(vlc_fixed_t sample)
{
/* round */
sample += (1L << (VLC_F_FRACBITS - 16));
{
int i;
vlc_fixed_t * p_in = (vlc_fixed_t *)p_in_buf->p_buffer;
- s16 * p_out = (s16 *)p_out_buf->p_buffer;
- s16 sample;
-// static struct audio_dither dither;
+ int16_t * p_out = (int16_t *)p_out_buf->p_buffer;
+#if 0
+ static struct audio_dither dither;
+#endif
- for ( i = p_in_buf->i_nb_samples * p_filter->input.i_channels ; i-- ; )
+ for ( i = p_in_buf->i_nb_samples
+ * aout_FormatNbChannels( &p_filter->input ) ; i-- ; )
{
+#if 0
/* Accurate scaling */
-// p_out = mpg321_s24_to_s16_pcm(16, *p_in++, &dither);
- /* Fast Scaling */
- sample = s24_to_s16_pcm(*p_in++);
-
-#ifndef WORDS_BIGENDIAN
- *p_out++ = (s16) (sample >> 0);
- *p_out++ = (s16) (sample >> 8);
-#else
- *p_out++ = (s16) (sample >> 8);
- *p_out++ = (s16) (sample >> 0);
+ *p_out++ = mpg321_s24_to_s16_pcm(16, *p_in++, &dither);
#endif
-// p_in++; p_out++;
+ /* Fast Scaling */
+ *p_out++ = s24_to_s16_pcm(*p_in++);
}
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes / 2;