From 81827eb23929dfe8082909eb9ba5c190b90fe68f Mon Sep 17 00:00:00 2001 From: reimar Date: Tue, 4 Oct 2005 21:49:56 +0000 Subject: [PATCH] much simpler signed/unsigned conversion. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16665 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_format.c | 70 +++++++++++------------------------------------ 1 file changed, 16 insertions(+), 54 deletions(-) diff --git a/libaf/af_format.c b/libaf/af_format.c index 48c7e82a35..7877914539 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -35,10 +35,8 @@ long int lrintf(float); // Switch endianess static void endian(void* in, void* out, int len, int bps); -// From singed to unsigned -static void si2us(void* in, void* out, int len, int bps); -// From unsinged to signed -static void us2si(void* in, void* out, int len, int bps); +// From singed to unsigned and the other way +static void si2us(void* data, int len, int bps); // Change the number of bits per sample static void change_bps(void* in, void* out, int len, int inbps, int outbps); // From float to int signed @@ -244,13 +242,13 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) if(AF_FORMAT_A_LAW == (l->format&AF_FORMAT_SPECIAL_MASK)) to_ulaw(l->audio, l->audio, len, 1, AF_FORMAT_SI); if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) - si2us(l->audio,l->audio,len,l->bps); + si2us(l->audio,len,l->bps); } else if((c->format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_A_LAW) { from_alaw(c->audio, l->audio, len, l->bps, l->format&AF_FORMAT_POINT_MASK); if(AF_FORMAT_A_LAW == (l->format&AF_FORMAT_SPECIAL_MASK)) to_alaw(l->audio, l->audio, len, 1, AF_FORMAT_SI); if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) - si2us(l->audio,l->audio,len,l->bps); + si2us(l->audio,len,l->bps); } else if((c->format & AF_FORMAT_POINT_MASK) == AF_FORMAT_F) { switch(l->format&AF_FORMAT_SPECIAL_MASK){ case(AF_FORMAT_MU_LAW): @@ -262,7 +260,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) default: float2int(c->audio, l->audio, len, l->bps); if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) - si2us(l->audio,l->audio,len,l->bps); + si2us(l->audio,len,l->bps); break; } } else { @@ -270,10 +268,7 @@ static af_data_t* play(struct af_instance_s* af, af_data_t* data) // Change signed/unsigned if((c->format&AF_FORMAT_SIGN_MASK) != (l->format&AF_FORMAT_SIGN_MASK)){ - if((c->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US) - us2si(c->audio,c->audio,len,c->bps); - else - si2us(c->audio,c->audio,len,c->bps); + si2us(c->audio,len,c->bps); } // Convert to special formats switch(l->format&(AF_FORMAT_SPECIAL_MASK|AF_FORMAT_POINT_MASK)){ @@ -386,50 +381,17 @@ static void endian(void* in, void* out, int len, int bps) } } -static void si2us(void* in, void* out, int len, int bps) +static void si2us(void* data, int len, int bps) { - register int i; - switch(bps){ - case(1): - for(i=0;i