1
0
mirror of https://github.com/mstorsjo/fdk-aac.git synced 2025-02-17 19:50:35 +01:00

m4a-dec: save to 32-bit wav if aac: INT_PCM==LONG (SAMPLE_BITS==32)

This commit is contained in:
Dima 2019-09-17 13:28:31 +03:00 committed by Martin Storsjo
parent 7bcf0d3d55
commit aed77c2f1b

View File

@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
void *wav = NULL; void *wav = NULL;
int output_size, ret; int output_size, ret;
uint8_t *output_buf; uint8_t *output_buf;
int16_t *decode_buf; INT_PCM *decode_buf;
HANDLE_AACDECODER handle; HANDLE_AACDECODER handle;
AAC_DECODER_ERROR err; AAC_DECODER_ERROR err;
unsigned frame_size = 0, i; unsigned frame_size = 0, i;
@ -82,9 +82,9 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
output_size = 8*2*2048; output_size = 8*sizeof(INT_PCM)*2048;
output_buf = (uint8_t*) malloc(output_size); output_buf = (uint8_t*) malloc(output_size);
decode_buf = (int16_t*) malloc(output_size); decode_buf = (INT_PCM*) malloc(output_size);
while (1) { while (1) {
UINT valid; UINT valid;
@ -126,7 +126,7 @@ int main(int argc, char *argv[]) {
} }
frame_size = info->frameSize * info->numChannels; frame_size = info->frameSize * info->numChannels;
// Note, this probably doesn't return channels > 2 in the right order for wav // Note, this probably doesn't return channels > 2 in the right order for wav
wav = wav_write_open(outfile, info->sampleRate, 16, info->numChannels); wav = wav_write_open(outfile, info->sampleRate, sizeof(INT_PCM)*8, info->numChannels);
if (!wav) { if (!wav) {
perror(outfile); perror(outfile);
status = 1; status = 1;
@ -134,11 +134,12 @@ int main(int argc, char *argv[]) {
} }
} }
for (i = 0; i < frame_size; i++) { for (i = 0; i < frame_size; i++) {
uint8_t* out = &output_buf[2*i]; uint8_t* out = &output_buf[sizeof(INT_PCM)*i];
out[0] = decode_buf[i] & 0xff; unsigned j;
out[1] = decode_buf[i] >> 8; for (j = 0; j < sizeof(INT_PCM); j++)
out[j] = (uint8_t)(decode_buf[i] >> (8*j));
} }
wav_write_data(wav, output_buf, 2*frame_size); wav_write_data(wav, output_buf, sizeof(INT_PCM)*frame_size);
} }
free(output_buf); free(output_buf);
free(decode_buf); free(decode_buf);