Once compiled, the test executable is in the folder /test/amrnb-dec
the program input is amr file and the output is wav file.
Looking at the code, after decoding the stream, it needs to be converted to little endian for
wav format.
while (1) {
uint8_t buffer[500], littleendian[320], *ptr;
int size, i;
int16_t outbuffer[160];
/* Read the mode byte */
n = fread(buffer, 1, 1, in);
if (n <= 0)
break;
/* Find the packet size */
size = sizes[(buffer[0] >> 3) & 0x0f];
n = fread(buffer + 1, 1, size, in);
if (n != size)
break;
/* Decode the packet */
Decoder_Interface_Decode(amr, buffer, outbuffer, 0);
/* Convert to little endian and write to wav */
ptr = littleendian;
for (i = 0; i < 160; i++) {
*ptr++ = (outbuffer[i] >> 0) & 0xff;
*ptr++ = (outbuffer[i] >> 8) & 0xff;
}
wav_write_data(wav, littleendian, 320);
}
the program input is amr file and the output is wav file.
./amrnb-dec outamr8khz.amr outamr8khz.wav
Looking at the code, after decoding the stream, it needs to be converted to little endian for
wav format.
while (1) {
uint8_t buffer[500], littleendian[320], *ptr;
int size, i;
int16_t outbuffer[160];
/* Read the mode byte */
n = fread(buffer, 1, 1, in);
if (n <= 0)
break;
/* Find the packet size */
size = sizes[(buffer[0] >> 3) & 0x0f];
n = fread(buffer + 1, 1, size, in);
if (n != size)
break;
/* Decode the packet */
Decoder_Interface_Decode(amr, buffer, outbuffer, 0);
/* Convert to little endian and write to wav */
ptr = littleendian;
for (i = 0; i < 160; i++) {
*ptr++ = (outbuffer[i] >> 0) & 0xff;
*ptr++ = (outbuffer[i] >> 8) & 0xff;
}
wav_write_data(wav, littleendian, 320);
}
No comments:
Post a Comment