* the name of the module which it is implementing.
*
*/
-#include <wx/wxprec.h>
+#include "wx/wxprec.h"
#include "wx/mmedia/internal/g72x.h"
/*
* Maps G.723_40 code word to ructeconstructed scale factor normalized log
* magnitude values.
*/
-static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
- 358, 395, 429, 459, 488, 514, 539, 566,
- 566, 539, 514, 488, 459, 429, 395, 358,
- 318, 274, 224, 169, 104, 28, -66, -2048};
+static short _dqlntab[32] = {-2048, -66, 28, 104, 169, 224, 274, 318,
+ 358, 395, 429, 459, 488, 514, 539, 566,
+ 566, 539, 514, 488, 459, 429, 395, 358,
+ 318, 274, 224, 169, 104, 28, -66, -2048};
/* Maps G.723_40 code word to log of scale factor multiplier. */
-static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
- 4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272,
- 22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512,
- 3200, 1856, 1312, 1280, 1248, 768, 448, 448};
+static short _witab[32] = {448, 448, 768, 1248, 1280, 1312, 1856, 3200,
+ 4512, 5728, 7008, 8960, 11456, 14080, 16928, 22272,
+ 22272, 16928, 14080, 11456, 8960, 7008, 5728, 4512,
+ 3200, 1856, 1312, 1280, 1248, 768, 448, 448};
/*
* Maps G.723_40 code words to a set of values whose long and short
* term averages are computed and then compared to give an indication
* how stationary (steady state) the signal is.
*/
-static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
- 0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00,
- 0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200,
- 0x200, 0x200, 0x200, 0, 0, 0, 0, 0};
+static short _fitab[32] = {0, 0, 0, 0, 0, 0x200, 0x200, 0x200,
+ 0x200, 0x200, 0x400, 0x600, 0x800, 0xA00, 0xC00, 0xC00,
+ 0xC00, 0xC00, 0xA00, 0x800, 0x600, 0x400, 0x200, 0x200,
+ 0x200, 0x200, 0x200, 0, 0, 0, 0, 0};
static short qtab_723_40[15] = {-122, -16, 68, 139, 198, 250, 298, 339,
- 378, 413, 445, 475, 502, 528, 553};
+ 378, 413, 445, 475, 502, 528, 553};
/*
* g723_40_encoder()
*/
int
g723_40_encoder(
- int sl,
- int in_coding,
- struct g72x_state *state_ptr)
+ int sl,
+ int in_coding,
+ struct g72x_state *state_ptr)
{
- short sei, sezi, se, sez; /* ACCUM */
- short d; /* SUBTA */
- short y; /* MIX */
- short sr; /* ADDB */
- short dqsez; /* ADDC */
- short dq, i;
-
- switch (in_coding) { /* linearize input sample to 14-bit PCM */
- case AUDIO_ENCODING_ALAW:
- sl = alaw2linear(sl) >> 2;
- break;
- case AUDIO_ENCODING_ULAW:
- sl = ulaw2linear(sl) >> 2;
- break;
- case AUDIO_ENCODING_LINEAR:
- sl = ((short) sl) >> 2; /* sl of 14-bit dynamic range */
- break;
- default:
- return (-1);
- }
-
- sezi = predictor_zero(state_ptr);
- sez = sezi >> 1;
- sei = sezi + predictor_pole(state_ptr);
- se = sei >> 1; /* se = estimated signal */
-
- d = sl - se; /* d = estimation difference */
-
- /* quantize prediction difference */
- y = step_size(state_ptr); /* adaptive quantizer step size */
- i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */
-
- dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */
-
- sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
-
- dqsez = sr + sez - se; /* dqsez = pole prediction diff. */
-
- update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
-
- return (i);
+ short sei, sezi, se, sez; /* ACCUM */
+ short d; /* SUBTA */
+ short y; /* MIX */
+ short sr; /* ADDB */
+ short dqsez; /* ADDC */
+ short dq, i;
+
+ switch (in_coding) { /* linearize input sample to 14-bit PCM */
+ case AUDIO_ENCODING_ALAW:
+ sl = alaw2linear(sl) >> 2;
+ break;
+ case AUDIO_ENCODING_ULAW:
+ sl = ulaw2linear(sl) >> 2;
+ break;
+ case AUDIO_ENCODING_LINEAR:
+ sl = ((short) sl) >> 2; /* sl of 14-bit dynamic range */
+ break;
+ default:
+ return (-1);
+ }
+
+ sezi = predictor_zero(state_ptr);
+ sez = sezi >> 1;
+ sei = sezi + predictor_pole(state_ptr);
+ se = sei >> 1; /* se = estimated signal */
+
+ d = sl - se; /* d = estimation difference */
+
+ /* quantize prediction difference */
+ y = step_size(state_ptr); /* adaptive quantizer step size */
+ i = quantize(d, y, qtab_723_40, 15); /* i = ADPCM code */
+
+ dq = reconstruct(i & 0x10, _dqlntab[i], y); /* quantized diff */
+
+ sr = (dq < 0) ? se - (dq & 0x7FFF) : se + dq; /* reconstructed signal */
+
+ dqsez = sr + sez - se; /* dqsez = pole prediction diff. */
+
+ update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
+
+ return (i);
}
/*
*/
int
g723_40_decoder(
- int i,
- int out_coding,
- struct g72x_state *state_ptr)
+ int i,
+ int out_coding,
+ struct g72x_state *state_ptr)
{
- short sezi, sei, sez, se; /* ACCUM */
- short y; /* MIX */
- short sr; /* ADDB */
- short dq;
- short dqsez;
-
- i &= 0x1f; /* mask to get proper bits */
- sezi = predictor_zero(state_ptr);
- sez = sezi >> 1;
- sei = sezi + predictor_pole(state_ptr);
- se = sei >> 1; /* se = estimated signal */
-
- y = step_size(state_ptr); /* adaptive quantizer step size */
- dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */
-
- sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */
-
- dqsez = sr - se + sez; /* pole prediction diff. */
-
- update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
-
- switch (out_coding) {
- case AUDIO_ENCODING_ALAW:
- return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40));
- case AUDIO_ENCODING_ULAW:
- return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40));
- case AUDIO_ENCODING_LINEAR:
- return (sr << 2); /* sr was of 14-bit dynamic range */
- default:
- return (-1);
- }
+ short sezi, sei, sez, se; /* ACCUM */
+ short y; /* MIX */
+ short sr; /* ADDB */
+ short dq;
+ short dqsez;
+
+ i &= 0x1f; /* mask to get proper bits */
+ sezi = predictor_zero(state_ptr);
+ sez = sezi >> 1;
+ sei = sezi + predictor_pole(state_ptr);
+ se = sei >> 1; /* se = estimated signal */
+
+ y = step_size(state_ptr); /* adaptive quantizer step size */
+ dq = reconstruct(i & 0x10, _dqlntab[i], y); /* estimation diff. */
+
+ sr = (dq < 0) ? (se - (dq & 0x7FFF)) : (se + dq); /* reconst. signal */
+
+ dqsez = sr - se + sez; /* pole prediction diff. */
+
+ update(5, y, _witab[i], _fitab[i], dq, sr, dqsez, state_ptr);
+
+ switch (out_coding) {
+ case AUDIO_ENCODING_ALAW:
+ return (tandem_adjust_alaw(sr, se, y, i, 0x10, qtab_723_40));
+ case AUDIO_ENCODING_ULAW:
+ return (tandem_adjust_ulaw(sr, se, y, i, 0x10, qtab_723_40));
+ case AUDIO_ENCODING_LINEAR:
+ return (sr << 2); /* sr was of 14-bit dynamic range */
+ default:
+ return (-1);
+ }
}