X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=alawulaw.c;h=f38fa46f441854d9409d241d6581980464bf7717;hp=72fee4bcd01fd982d555dff11f133c60a79dfe05;hb=refs%2Fheads%2Fbackup2;hpb=6bf7c7f9db360d6031417b012dcb0e90e2251cd6 diff --git a/alawulaw.c b/alawulaw.c index 72fee4b..f38fa46 100644 --- a/alawulaw.c +++ b/alawulaw.c @@ -10,9 +10,10 @@ \*****************************************************************************/ signed int *audio_law_to_s32; +unsigned char silence; /* ulaw -> signed 16-bit */ -static signed int audio_ulaw_to_s32[] = +static unsigned int audio_ulaw_to_s32[] = { 0xffff8284, 0xffff8684, 0xffff8a84, 0xffff8e84, 0xffff9284, 0xffff9684, 0xffff9a84, 0xffff9e84, @@ -81,7 +82,7 @@ static signed int audio_ulaw_to_s32[] = }; /* alaw -> signed 16-bit */ -static signed int audio_alaw_to_s32[] = +static unsigned int audio_alaw_to_s32[] = { 0x000013fc, 0xffffec04, 0x00000144, 0xfffffebc, 0x0000517c, 0xffffae84, 0x0000051c, 0xfffffae4, @@ -154,7 +155,7 @@ unsigned char audio_s16_to_law[65536]; /* table is used to generate s16_to_alaw */ -static short audio_alaw_relations[] = +static unsigned short audio_alaw_relations[] = { 0x8684, 0x55, 0x8a84, 0xd5, 0x8e84, 0x15, 0x9284, 0x95, 0x9684, 0x75, 0x9a84, 0xf5, 0x9e84, 0x35, 0xa284, 0xb5, @@ -229,31 +230,33 @@ void generate_tables(char law) int i, j; if (law == 'a') { - audio_law_to_s32=audio_alaw_to_s32; + silence = 0x2a; + audio_law_to_s32 = (signed int *)audio_alaw_to_s32; /* generating alaw-table */ i = j = 0; while(i < 65536) { - if (i-32768 > audio_alaw_relations[j<<1]) + if (i-32768 > (signed short)audio_alaw_relations[j<<1]) j++; if (j>255) j=255; audio_s16_to_law[(i-32768) & 0xffff] - = audio_alaw_relations[(j<<1)|1]; + = (signed short)audio_alaw_relations[(j<<1)|1]; i++; } } else { - audio_law_to_s32=audio_ulaw_to_s32; + silence = 0xff; + audio_law_to_s32 = (signed int *)audio_ulaw_to_s32; /* generating ulaw-table */ i = j = 0; while(i < 32768) { - if (i-32768 > audio_ulaw_to_s32[j]) + if (i-32768 > (signed int)audio_ulaw_to_s32[j]) j++; audio_s16_to_law[(i-32768) & 0xffff] = j; i++; } j = 255; while(i < 65536) { - if (i-0x32768 > audio_ulaw_to_s32[j]) + if (i-0x32768 > (signed int)audio_ulaw_to_s32[j]) j--; audio_s16_to_law[(i-32768) & 0xffff] = j; i++;