#include #include #define MINLINEAR -8159 #define MAXLINEAR 8159 extern int UlawToLinear(int in); extern int LinearToUlaw(int x); void main() { int i, j, linearSum; int pcmINX, pcmINY; for (pcmINY=0; pcmINY<=255; pcmINY++) { /* For all Y samples... */ for (i=0; i<=15; i++) { /* Construct output file in rows of 16. */ printf("%04x:", pcmINY*256 + i*16); for (j=0; j<=15; j++) { /* For all X samples... */ pcmINX = i*16 + j; linearSum = UlawToLinear(pcmINX) + UlawToLinear(pcmINY); /* The next two lines perform "clipping" on overflow. */ if (linearSum < MINLINEAR) linearSum = MINLINEAR; if (linearSum > MAXLINEAR) linearSum = MAXLINEAR; printf(" %02x", LinearToUlaw(linearSum)); } printf("\n"); } } }