Commit ff9fe43d authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

fixed: add S32N, rewrite FL32

parent 5505394d
...@@ -76,6 +76,13 @@ static int CreateFrom( vlc_object_t *p_this ) ...@@ -76,6 +76,13 @@ static int CreateFrom( vlc_object_t *p_this )
return VLC_SUCCESS;; return VLC_SUCCESS;;
} }
union dw
{
float f;
int32_t s;
uint32_t u;
};
/***************************************************************************** /*****************************************************************************
* F32 to S16 * F32 to S16
*****************************************************************************/ *****************************************************************************/
...@@ -139,6 +146,7 @@ static block_t *Do_F32ToS16( filter_t * p_filter, block_t * p_in_buf ) ...@@ -139,6 +146,7 @@ static block_t *Do_F32ToS16( filter_t * p_filter, block_t * p_in_buf )
/*** Conversions from decoders to FI32 */ /*** Conversions from decoders to FI32 */
static block_t *Do_FL32ToF32( filter_t *, block_t * ); static block_t *Do_FL32ToF32( filter_t *, block_t * );
static block_t *Do_S32ToF32( filter_t *, block_t * );
static block_t *Do_S16ToF32( filter_t *, block_t * ); static block_t *Do_S16ToF32( filter_t *, block_t * );
static block_t *Do_U8ToF32( filter_t *, block_t * ); static block_t *Do_U8ToF32( filter_t *, block_t * );
...@@ -157,6 +165,10 @@ static int CreateTo( vlc_object_t *p_this ) ...@@ -157,6 +165,10 @@ static int CreateTo( vlc_object_t *p_this )
p_filter->pf_audio_filter = Do_FL32ToF32; p_filter->pf_audio_filter = Do_FL32ToF32;
break; break;
case VLC_CODEC_S32N:
p_filter->pf_audio_filter = Do_S32ToF32;
break;
case VLC_CODEC_S16N: case VLC_CODEC_S16N:
p_filter->pf_audio_filter = Do_S16ToF32; p_filter->pf_audio_filter = Do_S16ToF32;
break; break;
...@@ -231,13 +243,29 @@ out: ...@@ -231,13 +243,29 @@ out:
static block_t *Do_FL32ToF32( filter_t * p_filter, block_t * p_in_buf ) static block_t *Do_FL32ToF32( filter_t * p_filter, block_t * p_in_buf )
{ {
const float * p_in = (float *)p_in_buf->p_buffer; unsigned count = p_in_buf->i_nb_samples
vlc_fixed_t * p_out = (vlc_fixed_t *)p_in_buf->p_buffer; * aout_FormatNbChannels( &p_filter->fmt_in.audio );
union dw *restrict p = (union dw *)p_in_buf->p_buffer, *end = p + count;
const float one = FIXED32_ONE;
for ( unsigned i = p_in_buf->i_nb_samples while (p < end)
* aout_FormatNbChannels( &p_filter->fmt_in.audio ) ; i-- ; ) {
p->s = (one * p->f);
p++;
}
return p_in_buf;
}
static block_t *Do_S32ToF32( filter_t * p_filter, block_t * p_in_buf )
{
unsigned count = p_in_buf->i_nb_samples
* aout_FormatNbChannels( &p_filter->fmt_in.audio );
int32_t *restrict p = (int32_t *)p_in_buf->p_buffer, *end = p + count;
while (p < end)
{ {
*p_out++ = (vlc_fixed_t)( *p_in++ * (float)FIXED32_ONE ); *p = *p >> 3;
p++;
} }
return p_in_buf; return p_in_buf;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment