aac-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 aed77c2f1b
commit 3612e492b4
1 changed files with 9 additions and 8 deletions

View File

@ -29,7 +29,7 @@ int main(int argc, char *argv[]) {
void *wav = NULL;
int output_size;
uint8_t *output_buf;
int16_t *decode_buf;
INT_PCM *decode_buf;
HANDLE_AACDECODER handle;
int frame_size = 0;
if (argc < 3) {
@ -46,9 +46,9 @@ int main(int argc, char *argv[]) {
return 1;
}
output_size = 8*2*2048;
output_size = 8*sizeof(INT_PCM)*2048;
output_buf = (uint8_t*) malloc(output_size);
decode_buf = (int16_t*) malloc(output_size);
decode_buf = (INT_PCM*) malloc(output_size);
while (1) {
uint8_t packet[10240], *ptr = packet;
@ -89,18 +89,19 @@ int main(int argc, char *argv[]) {
}
frame_size = info->frameSize * info->numChannels;
// 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) {
perror(outfile);
break;
}
}
for (i = 0; i < frame_size; i++) {
uint8_t* out = &output_buf[2*i];
out[0] = decode_buf[i] & 0xff;
out[1] = decode_buf[i] >> 8;
uint8_t* out = &output_buf[sizeof(INT_PCM)*i];
unsigned j;
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(decode_buf);