1

I am currently using two functions in my C source code to convert A-law files to PCM 16 bit and U-law files to PCM 16 bit. The conversion of U-law files to PCM 16 bit is not successfull. There is a lot of noise to the produced PCM 16 bit file.

Below there are the two functions:

short ALawToPcm16(char c)
{
    int i;
    short val;

    i = (c & 0x00FF) ^ 0x0055;

    if (i > 0x007F)
    {
        val = (short)(0x10000 - AIndexToPcm16Bit[i - 0x80]);
    }
    else
    {
        val = AIndexToPcm16Bit[i];
    }

    return(val);
}


short FctMuLawToPcm16(char c)
{
    int i;
    short val;

    i = (c & 0x00FF);

    if (i > 0x007F)
    {
        val = (short)(0x10000 - UIndexToPcm16Bit[i - 0x80]);
    }
    else
    {
        val = UIndexToPcm16Bit[i];
    }

    return(val);
}

Can anyone please tell me what is wrong with the second function? Thanks

A.Lap
  • 11
  • 2

1 Answers1

0

Try replacing i = (c & 0x00FF); with i = (c & 0x00FF) ^ 0x00FF; – Ian Abbott

Armali
  • 18,255
  • 14
  • 57
  • 171