diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-04-24 01:05:30 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-04-24 01:05:30 +0000 |
commit | ab36a0128471e7fa7104099297f9dcafdea672a1 (patch) | |
tree | 8238f7b6f052679457d8edd72eb175c94e35d2ac | |
parent | 91bf500595f33af5a5d787bf5542b8f7b87dccee (diff) | |
parent | 92bec05d2d2d342580176e493ee67a6b3cfd7ba8 (diff) | |
download | libxaac-ab36a0128471e7fa7104099297f9dcafdea672a1.tar.gz |
Snap for 6424828 from 92bec05d2d2d342580176e493ee67a6b3cfd7ba8 to rvc-release
Change-Id: Ifd09869ecfb978a85df6776a71c7607e1bf996ed
-rw-r--r-- | decoder/ixheaacd_constants.h | 3 | ||||
-rw-r--r-- | decoder/ixheaacd_decode_main.c | 32 | ||||
-rw-r--r-- | decoder/ixheaacd_sbr_dec.c | 148 |
3 files changed, 93 insertions, 90 deletions
diff --git a/decoder/ixheaacd_constants.h b/decoder/ixheaacd_constants.h index a3c2675..3ac0065 100644 --- a/decoder/ixheaacd_constants.h +++ b/decoder/ixheaacd_constants.h @@ -63,6 +63,9 @@ #define MAX_16 (WORD16)0x7fff #define MIN_16 (WORD16)0x8000 +#define MAX_24 (WORD32)0x007fffff +#define MIN_24 (WORD32)0xff800000 + #define NULLPTR ((VOID *)0) #define IT_NULL ((VOID *)0) diff --git a/decoder/ixheaacd_decode_main.c b/decoder/ixheaacd_decode_main.c index 234178b..7ee1bcd 100644 --- a/decoder/ixheaacd_decode_main.c +++ b/decoder/ixheaacd_decode_main.c @@ -20,6 +20,7 @@ #include <stdlib.h> #include <string.h> #include "ixheaacd_type_def.h" +#include "ixheaacd_constants.h" #include "ixheaacd_error_standards.h" #include "ixheaacd_memory_standards.h" #include "ixheaacd_sbrdecsettings.h" @@ -69,7 +70,7 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, WORD32 *out_bytes, WORD32 num_channel_out) { WORD32 num; WORD32 i; - WORD64 write_local; + FLOAT32 sample; WORD16 *out_buf = (WORD16 *)outbuffer; @@ -77,31 +78,30 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out, if (pcmsize == 16) { for (i = 0; i < num; i++) { - write_local = - ((WORD64)(out_samples[i % num_channel_out][i / num_channel_out])); + sample = (out_samples[i % num_channel_out][i / num_channel_out]); - if (write_local > 32767) { - write_local = 32767; + if (sample > MAX_16) { + sample = MAX_16; + } else if (sample < MIN_16) { + sample = MIN_16; } - if (write_local < -32768) { - write_local = -32768; - } - out_buf[i] = (WORD16)write_local; + out_buf[i] = (WORD16)sample; } *out_bytes = num * sizeof(WORD16); } else { WORD8 *out_24bit = (WORD8 *)out_buf; for (i = 0; i < num; i++) { - write_local = ((WORD64)( - out_samples[i % num_channel_out][i / num_channel_out] * 256)); + WORD32 write_local; + sample = (out_samples[i % num_channel_out][i / num_channel_out] * 256); - if (write_local > 8388607) { - write_local = 8388607; - } - if (write_local < -8388608) { - write_local = -8388608; + if (sample > MAX_24) { + sample = MAX_24; + } else if (sample < MIN_24) { + sample = MIN_24; } + write_local = (WORD32)sample; + *out_24bit++ = (WORD32)write_local & 0xff; *out_24bit++ = ((WORD32)write_local >> 8) & 0xff; *out_24bit++ = ((WORD32)write_local >> 16) & 0xff; diff --git a/decoder/ixheaacd_sbr_dec.c b/decoder/ixheaacd_sbr_dec.c index 684b69d..a8ac0b6 100644 --- a/decoder/ixheaacd_sbr_dec.c +++ b/decoder/ixheaacd_sbr_dec.c @@ -450,26 +450,6 @@ VOID ixheaacd_esbr_synthesis_filt_block( ia_sbr_frame_info_data_struct *ptr_frame_data, WORD32 apply_processing, FLOAT32 **qmf_buf_real, FLOAT32 **qmf_buf_imag, WORD32 stereo_config_idx, ia_sbr_tables_struct *sbr_tables_ptr, WORD32 mps_sbr_flag, WORD32 ch_fac) { - WORD32 i, k, p1; - WORD32 *ptr_filt_states; - WORD32 *ptr_filt_states_1; - WORD32 *ptr_filt_states_2; - WORD32 *filter_l; - WORD32 *ploc_qmf_buf_real; - WORD32 *ploc_qmf_buf_imag; - WORD32 out_scalefactor; - WORD32 sixty4; - WORD32 no_synthesis_channels; - WORD32 ixheaacd_drc_offset; - FLOAT32 *syn_buffer; - WORD32 *local_qmf_buffer = ptr_sbr_dec->sbr_scratch_local; - WORD32 *time_out = &(ptr_sbr_dec->sbr_scratch_local[128]); - - ia_sbr_qmf_filter_bank_struct *qmf_bank = - &ptr_sbr_dec->str_synthesis_qmf_bank; - ia_qmf_dec_tables_struct *qmf_dec_tables_ptr = - sbr_tables_ptr->qmf_dec_tables_ptr; - if (!mps_sbr_flag) { ixheaacd_esbr_synthesis_regrp(&qmf_buf_real[0][0], &qmf_buf_imag[0][0], ptr_sbr_dec, ptr_frame_data, ptr_header_data, @@ -479,74 +459,94 @@ VOID ixheaacd_esbr_synthesis_filt_block( ptr_sbr_dec, stereo_config_idx); } - out_scalefactor = 5; - qmf_bank->no_channels = 64; - qmf_bank->esbr_cos_twiddle = - (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l64; - qmf_bank->esbr_alt_sin_twiddle = - (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l64; - - qmf_bank->filter_pos_syn_32 += - qmf_dec_tables_ptr->esbr_qmf_c - qmf_bank->p_filter_32; - qmf_bank->p_filter_32 = qmf_dec_tables_ptr->esbr_qmf_c; - - sixty4 = NO_SYNTHESIS_CHANNELS; + if (stereo_config_idx <= 0) { + WORD32 i, k, p1; + WORD32 *ptr_filt_states; + WORD32 *ptr_filt_states_1; + WORD32 *ptr_filt_states_2; + WORD32 *filter_l; + WORD32 *ploc_qmf_buf_real; + WORD32 *ploc_qmf_buf_imag; + WORD32 out_scalefactor; + WORD32 sixty4; + WORD32 no_synthesis_channels; + WORD32 ixheaacd_drc_offset; + FLOAT32 *syn_buffer; + WORD32 *local_qmf_buffer = ptr_sbr_dec->sbr_scratch_local; + WORD32 *time_out = &(ptr_sbr_dec->sbr_scratch_local[128]); + ia_sbr_qmf_filter_bank_struct *qmf_bank = + &ptr_sbr_dec->str_synthesis_qmf_bank; + ia_qmf_dec_tables_struct *qmf_dec_tables_ptr = + sbr_tables_ptr->qmf_dec_tables_ptr; + out_scalefactor = 5; + qmf_bank->no_channels = 64; + qmf_bank->esbr_cos_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_sin_cos_twiddle_l64; + qmf_bank->esbr_alt_sin_twiddle = + (WORD32 *)qmf_dec_tables_ptr->esbr_alt_sin_twiddle_l64; + + qmf_bank->filter_pos_syn_32 += + qmf_dec_tables_ptr->esbr_qmf_c - qmf_bank->p_filter_32; + qmf_bank->p_filter_32 = qmf_dec_tables_ptr->esbr_qmf_c; + + sixty4 = NO_SYNTHESIS_CHANNELS; + + ptr_filt_states = qmf_bank->filter_states_32; + + no_synthesis_channels = qmf_bank->no_channels; + ptr_filt_states_1 = &ptr_filt_states[0]; + ptr_filt_states_2 = ptr_filt_states_1 + no_synthesis_channels; + + filter_l = qmf_bank->filter_pos_syn_32; + + p1 = 0; + + ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; - ptr_filt_states = qmf_bank->filter_states_32; + for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { + for (k = 0; k < 64; k++) { + local_qmf_buffer[k + 0] = (WORD32)(qmf_buf_real[i][k] * 64); + local_qmf_buffer[k + 64] = (WORD32)(qmf_buf_imag[i][k] * 64); + } + ploc_qmf_buf_real = local_qmf_buffer; + ploc_qmf_buf_imag = local_qmf_buffer + 64; - no_synthesis_channels = qmf_bank->no_channels; - ptr_filt_states_1 = &ptr_filt_states[0]; - ptr_filt_states_2 = ptr_filt_states_1 + no_synthesis_channels; + ixheaacd_esbr_inv_modulation(ploc_qmf_buf_real, + &ptr_sbr_dec->str_synthesis_qmf_bank, + sbr_tables_ptr->qmf_dec_tables_ptr); - filter_l = qmf_bank->filter_pos_syn_32; + ixheaacd_shiftrountine_with_rnd_hq(ploc_qmf_buf_real, ploc_qmf_buf_imag, + &ptr_filt_states[ixheaacd_drc_offset], + no_synthesis_channels, + out_scalefactor + 1); - p1 = 0; + ixheaacd_esbr_qmfsyn64_winadd(ptr_filt_states_1, ptr_filt_states_2, + filter_l, &time_out[0], ch_fac); - ixheaacd_drc_offset = qmf_bank->ixheaacd_drc_offset; + syn_buffer = ptr_sbr_dec->time_sample_buf + i * 64; + for (k = 0; k < 64; k++) { + syn_buffer[k] = (FLOAT32)time_out[k] / (1 << 16); + } - for (i = 0; i < ptr_sbr_dec->str_codec_qmf_bank.num_time_slots; i++) { - for (k = 0; k < 64; k++) { - local_qmf_buffer[k + 0] = (WORD32)(qmf_buf_real[i][k] * 64); - local_qmf_buffer[k + 64] = (WORD32)(qmf_buf_imag[i][k] * 64); - } - ploc_qmf_buf_real = local_qmf_buffer; - ploc_qmf_buf_imag = local_qmf_buffer + 64; + ptr_filt_states_1 += sixty4; + ptr_filt_states_2 -= sixty4; + sixty4 = -sixty4; + ixheaacd_drc_offset -= 128; - ixheaacd_esbr_inv_modulation(ploc_qmf_buf_real, - &ptr_sbr_dec->str_synthesis_qmf_bank, - sbr_tables_ptr->qmf_dec_tables_ptr); + if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; - ixheaacd_shiftrountine_with_rnd_hq(ploc_qmf_buf_real, ploc_qmf_buf_imag, - &ptr_filt_states[ixheaacd_drc_offset], - no_synthesis_channels, - out_scalefactor + 1); + filter_l += 64; - ixheaacd_esbr_qmfsyn64_winadd(ptr_filt_states_1, ptr_filt_states_2, - filter_l, &time_out[0], ch_fac); + if (filter_l == qmf_bank->p_filter_32 + 640) + filter_l = (WORD32 *)qmf_bank->p_filter_32; - syn_buffer = ptr_sbr_dec->time_sample_buf + i * 64; - for (k = 0; k < 64; k++) { - syn_buffer[k] = (FLOAT32)time_out[k] / (1 << 16); + p1 += no_synthesis_channels; } - ptr_filt_states_1 += sixty4; - ptr_filt_states_2 -= sixty4; - sixty4 = -sixty4; - ixheaacd_drc_offset -= 128; - - if (ixheaacd_drc_offset < 0) ixheaacd_drc_offset += 1280; - - filter_l += 64; - - if (filter_l == qmf_bank->p_filter_32 + 640) - filter_l = (WORD32 *)qmf_bank->p_filter_32; - - p1 += no_synthesis_channels; + qmf_bank->filter_pos_syn_32 = filter_l; + qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; } - qmf_bank->filter_pos_syn_32 = filter_l; - qmf_bank->ixheaacd_drc_offset = ixheaacd_drc_offset; - if (!mps_sbr_flag) ptr_frame_data->reset_flag = 0; if (apply_processing && !mps_sbr_flag) { |