Merge pull request #6 from ittiam-systems/mps_opt

Optimization of MPS module of USAC
This commit is contained in:
tripti-tiwari 2022-07-25 21:52:44 +05:30 • committed by GitHub
commit fdb8166ea5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 6756 additions and 4570 deletions

View file

@ -195,18 +195,6 @@ VOID(*ixheaacd_complex_fft_p2)
(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode,
WORD32 *preshift) = &ixheaacd_complex_fft_p2_armv7;
VOID(*ixheaacd_mps_complex_fft_64)
(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im,
WORD32 nlength) = &ixheaacd_mps_complex_fft_64_armv7;
VOID(*ixheaacd_mps_synt_pre_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_armv7;
VOID(*ixheaacd_mps_synt_post_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_armv7;
VOID(*ixheaacd_calc_pre_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_armv7;
@ -215,14 +203,9 @@ VOID(*ixheaacd_calc_post_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_armv7;
VOID(*ixheaacd_mps_synt_post_fft_twiddle)
(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_armv7;
VOID(*ixheaacd_mps_synt_out_calc)
(WORD32 resolution, WORD32 *out, WORD32 *state,
const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_armv7;
(WORD32 resolution, FLOAT32 *out, FLOAT32 *state,
const FLOAT32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
VOID(*ixheaacd_fft_15_ld)
(WORD32 *inp, WORD32 *op, WORD32 *fft3out,

View file

@ -193,18 +193,6 @@ VOID(*ixheaacd_complex_fft_p2)
(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode,
WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec;
VOID(*ixheaacd_mps_complex_fft_64)
(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im,
WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec;
VOID(*ixheaacd_mps_synt_pre_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec;
VOID(*ixheaacd_mps_synt_post_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec;
VOID(*ixheaacd_calc_pre_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec;
@ -213,14 +201,9 @@ VOID(*ixheaacd_calc_post_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec;
VOID(*ixheaacd_mps_synt_post_fft_twiddle)
(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec;
VOID(*ixheaacd_mps_synt_out_calc)
(WORD32 resolution, WORD32 *out, WORD32 *state,
const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
(WORD32 resolution, FLOAT32 *out, FLOAT32 *state,
const FLOAT32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
VOID(*ixheaacd_fft_15_ld)
(WORD32 *inp, WORD32 *op, WORD32 *fft3out,
@ -246,4 +229,4 @@ VOID(*ixheaacd_inv_dit_fft_8pt)
VOID(*ixheaacd_scale_factor_process)
(WORD32 *x_invquant, WORD16 *scale_fact, WORD no_band, WORD8 *width,
WORD32 *scale_tables_ptr, WORD32 total_channels, WORD32 object_type,
WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_armv8;
WORD32 aac_sf_data_resil_flag) = &ixheaacd_scale_factor_process_armv8;

View file

@ -194,18 +194,6 @@ VOID(*ixheaacd_complex_fft_p2)
(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode,
WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec;
VOID(*ixheaacd_mps_complex_fft_64)
(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im,
WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec;
VOID(*ixheaacd_mps_synt_pre_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec;
VOID(*ixheaacd_mps_synt_post_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec;
VOID(*ixheaacd_calc_pre_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec;
@ -214,14 +202,10 @@ VOID(*ixheaacd_calc_post_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec;
VOID(*ixheaacd_mps_synt_post_fft_twiddle)
(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec;
VOID(*ixheaacd_mps_synt_out_calc)
(WORD32 resolution, WORD32 *out, WORD32 *state,
const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
(WORD32 resolution, FLOAT32 *out, FLOAT32 *state,
const FLOAT32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
VOID(*ixheaacd_fft_15_ld)
(WORD32 *inp, WORD32 *op, WORD32 *fft3out,

View file

@ -71,7 +71,8 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out,
WORD32 *out_bytes, WORD32 num_channel_out) {
WORD32 num;
WORD32 i;
FLOAT32 sample;
WORD32 write_local;
FLOAT32 write_local_float;
WORD16 *out_buf = (WORD16 *)outbuffer;
@ -79,29 +80,30 @@ VOID ixheaacd_samples_sat(WORD8 *outbuffer, WORD32 num_samples_out,
if (pcmsize == 16) {
for (i = 0; i < num; i++) {
sample = (out_samples[i % num_channel_out][i / num_channel_out]);
write_local_float =
(out_samples[i % num_channel_out][i / num_channel_out]);
if (sample > MAX_16) {
sample = MAX_16;
} else if (sample < MIN_16) {
sample = MIN_16;
if (write_local_float > 32767.0f) {
write_local_float = 32767.0f;
} else if (write_local_float < -32768.0f) {
write_local_float = -32768.0f;
}
out_buf[i] = (WORD16)sample;
out_buf[i] = (WORD16)write_local_float;
}
*out_bytes = num * sizeof(WORD16);
} else {
WORD8 *out_24bit = (WORD8 *)out_buf;
for (i = 0; i < num; i++) {
WORD32 write_local;
sample = (out_samples[i % num_channel_out][i / num_channel_out] * 256);
write_local_float =
(out_samples[i % num_channel_out][i / num_channel_out] * 256);
if (sample > MAX_24) {
sample = MAX_24;
} else if (sample < MIN_24) {
sample = MIN_24;
if (write_local_float > 8388607.0f) {
write_local_float = 8388607.0f;
} else if (write_local_float < -8388608.0f) {
write_local_float = -8388608.0f;
}
write_local = (WORD32)sample;
write_local = (WORD32)write_local_float;
*out_24bit++ = (WORD32)write_local & 0xff;
*out_24bit++ = ((WORD32)write_local >> 8) & 0xff;

View file

@ -74,7 +74,7 @@ typedef struct {
WORD32 over_sampling_flag;
WORD32 pitch_in_bins;
WORD32 pvc_mode;
WORD32 cov_count;
WORD32 sbr_invf_mode_prev[MAX_NUM_NOISE_VALUES];
FLOAT32 flt_env_sf_arr[MAX_NUM_ENVELOPE_VALUES];
FLOAT32 flt_noise_floor[MAX_NUM_NOISE_VALUES];

File diff suppressed because it is too large Load diff

View file

@ -144,19 +144,6 @@ extern VOID (*ixheaacd_imdct_using_fft)(ia_aac_dec_imdct_tables_struct *,
extern VOID (*ixheaacd_complex_fft_p2)(WORD32 *xr, WORD32 *xi, WORD32 nlength,
WORD32 fft_mode, WORD32 *preshift);
extern VOID (*ixheaacd_mps_complex_fft_64)(WORD32 *ptr_x, WORD32 *fin_re,
WORD32 *fin_im, WORD32 nlength);
extern VOID (*ixheaacd_mps_synt_pre_twiddle)(WORD32 *ptr_in,
const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution);
extern VOID (*ixheaacd_mps_synt_post_twiddle)(WORD32 *ptr_in,
const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution);
extern VOID (*ixheaacd_calc_pre_twid)(WORD32 *ptr_x, WORD32 *r_ptr,
WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr,
@ -167,12 +154,9 @@ extern VOID (*ixheaacd_calc_post_twid)(WORD32 *ptr_x, WORD32 *r_ptr,
const WORD32 *cos_ptr,
const WORD32 *sin_ptr);
extern VOID (*ixheaacd_mps_synt_post_fft_twiddle)(
WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re,
const WORD32 *table_im, WORD32 *state);
extern VOID (*ixheaacd_mps_synt_out_calc)(WORD32 resolution, WORD32 *out,
WORD32 *state,
const WORD32 *filter_coeff);
extern VOID (*ixheaacd_mps_synt_out_calc)(WORD32 resolution, FLOAT32 *out,
FLOAT32 *state,
const FLOAT32 *filter_coeff);
extern VOID (*ixheaacd_fft_15_ld)(WORD32 *inp, WORD32 *op, WORD32 *fft3out,
UWORD8 *re_arr_tab_sml_240_ptr);

View file

@ -55,8 +55,7 @@ VOID ixheaacd_complex_fft_p2_dec(WORD32 *xr, WORD32 *xi, WORD32 nlength,
VOID ixheaacd_complex_fft_p2_armv7(WORD32 *xr, WORD32 *xi, WORD32 nlength,
WORD32 fft_mode, WORD32 *preshift);
VOID ixheaacd_mps_complex_fft_64_dec(WORD32 *ptr_x, WORD32 *fin_re,
WORD32 *fin_im, WORD32 nlength);
VOID ixheaacd_mps_synth_calc_fft(FLOAT32 *ptr_x, FLOAT32 *ptr_y, WORD32 nPass);
VOID ixheaacd_mps_complex_fft_64_armv7(WORD32 *ptr_x, WORD32 *fin_re,
WORD32 *fin_im, WORD32 nlength);
@ -71,18 +70,10 @@ VOID ixheaacd_complex_ifft_p2_asm(const WORD32 *table, WORD32 nlength,
VOID ixheaacd_complex_fft_p2_asm(const WORD32 *table, WORD32 nlength,
WORD32 *ptr_x, WORD32 *ptr_y);
VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution);
VOID ixheaacd_mps_synt_pre_twiddle_armv7(WORD32 *ptr_in, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution);
VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution);
VOID ixheaacd_mps_synt_post_twiddle_armv7(WORD32 *ptr_in,
const WORD32 *table_re,
const WORD32 *table_im,
@ -104,20 +95,9 @@ VOID ixheaacd_calc_post_twid_armv7(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr,
WORD32 nlength, const WORD32 *cos_ptr,
const WORD32 *sin_ptr);
VOID ixheaacd_mps_synt_post_fft_twiddle_dec(WORD32 resolution, WORD32 *fin_re,
WORD32 *fin_im,
const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state);
VOID ixheaacd_mps_synt_post_fft_twiddle_armv7(WORD32 resolution, WORD32 *fin_re,
WORD32 *fin_im,
const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state);
VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out,
WORD32 *state, const WORD32 *filter_coeff);
VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, FLOAT32 *out,
FLOAT32 *state,
const FLOAT32 *filter_coeff);
VOID ixheaacd_mps_synt_out_calc_armv7(WORD32 resolution, WORD32 *out,
WORD32 *state,

View file

@ -69,8 +69,15 @@
#include "ixheaacd_mps_hybfilter.h"
#include "ixheaacd_mps_nlc_dec.h"
#include "ixheaacd_mps_huff_tab.h"
#include "math.h"
#include <assert.h>
#include <string.h>
#include "ixheaacd_error_standards.h"
#define max(a, b) (((a) > (b)) ? (a) : (b))
extern const ia_huff_pt0_nodes_struct ixheaacd_huff_part0_nodes;
extern const ia_huff_ipd_nodes_struct ixheaacd_huff_ipd_nodes;
extern const ia_huff_lav_nodes_struct ixheaacd_huff_lav_idx_nodes;
@ -126,7 +133,7 @@ WORD32 ixheaacd_mps_create(ia_mps_dec_state_struct* self, WORD32 bs_frame_len,
if ((self->residual_coding) && (self->res_bands > 0))
ixheaacd_mps_qmf_hybrid_analysis_init(&self->hyb_filt_state[1]);
err_code = ixheaacd_mps_decor_init(&(self->mps_decor), self->hyb_band_count,
err_code = ixheaacd_mps_decor_init(&(self->mps_decor), self->hyb_band_count_max,
self->config->bs_decorr_config);
if (err_code != IA_NO_ERROR) return err_code;
@ -163,12 +170,12 @@ static const FLOAT32 ixheaacd_tsd_mul_im[] = {
VOID ixheaacd_mps_qmf_hyb_analysis(ia_mps_dec_state_struct* self) {
ixheaacd_mps_qmf_hybrid_analysis(&self->hyb_filt_state[0], self->qmf_in[0],
self->qmf_band_count, self->time_slots,
self->band_count[0], self->time_slots,
self->hyb_in[0]);
if ((self->residual_coding) && (self->res_bands > 0)) {
ixheaacd_mps_qmf_hybrid_analysis(&self->hyb_filt_state[self->in_ch_count],
self->qmf_in[1], self->qmf_band_count,
self->qmf_in[1], self->band_count[1],
self->time_slots, self->hyb_res);
}
}
@ -178,7 +185,7 @@ VOID ixheaacd_mps_qmf_hyb_synthesis(ia_mps_dec_state_struct* self) {
for (ch = 0; ch < self->out_ch_count; ch++) {
ixheaacd_mps_qmf_hybrid_synthesis(self->hyb_dir_out[ch],
self->qmf_band_count, self->time_slots,
self->band_count[0], self->time_slots,
self->qmf_out_dir[ch]);
}
}
@ -209,7 +216,7 @@ VOID ixheaacd_mps_decor(ia_mps_dec_state_struct* self) {
}
ixheaacd_mps_decor_apply(&self->mps_decor, self->v[k], self->w_diff[k],
self->time_slots);
self->time_slots, NO_RES_BANDS);
if (self->bs_tsd_enable) {
for (sb_sample = 0; sb_sample < self->time_slots; sb_sample++) {
@ -235,7 +242,7 @@ VOID ixheaacd_mps_mix_res_decor(ia_mps_dec_state_struct* self) {
WORD32 ts, qs, row, indx;
for (ts = 0; ts < self->time_slots; ts++) {
for (qs = 0; qs < self->hyb_band_count; qs++) {
for (qs = 0; qs < self->hyb_band_count_max; qs++) {
indx = self->hyb_band_to_processing_band_table[qs];
for (row = 0; row < self->dir_sig_count; row++) {
@ -246,8 +253,8 @@ VOID ixheaacd_mps_mix_res_decor(ia_mps_dec_state_struct* self) {
for (row = self->dir_sig_count;
row < (self->dir_sig_count + self->decor_sig_count); row++) {
if (indx < self->res_bands) {
self->w_dir[row][ts][qs].re = self->hyb_res[ts][qs].re;
self->w_dir[row][ts][qs].im = self->hyb_res[ts][qs].im;
self->w_dir[row][ts][qs].re = self->hyb_res[qs][ts].re;
self->w_dir[row][ts][qs].im = self->hyb_res[qs][ts].im;
} else {
self->w_dir[row][ts][qs].re = 0.0f;
self->w_dir[row][ts][qs].im = 0.0f;
@ -270,10 +277,54 @@ VOID ixheaacd_mps_mix_res_decor(ia_mps_dec_state_struct* self) {
}
}
VOID ixheaacd_mps_mix_res_decor_residual_band(ia_mps_dec_state_struct* self) {
WORD32 ts, qs, indx;
for (qs = 0; qs < self->hyb_band_count_max; qs++) {
indx = self->hyb_band_to_processing_band_table[qs];
if (indx >= self->res_bands) {
if (qs < self->hyb_band_count[1]) {
for (ts = 0; ts < self->time_slots; ts++) {
self->w_dir[1][ts][qs].re = 0.0f;
self->w_dir[1][ts][qs].im = 0.0f;
}
}
} else {
for (ts = 0; ts < self->time_slots; ts++) {
self->w_diff[1][ts][qs].re = 0.0f;
self->w_diff[1][ts][qs].im = 0.0f;
}
}
}
}
VOID ixheaacd_mps_create_w(ia_mps_dec_state_struct* self) {
ixheaacd_mps_decor(self);
ixheaacd_mps_mix_res_decor(self);
}
VOID ixheaacd_mps_qmf_hyb_analysis_no_pre_mix(ia_mps_dec_state_struct* self) {
ixheaacd_mps_qmf_hybrid_analysis_no_pre_mix(
&self->hyb_filt_state[0], self->qmf_in[0], self->band_count[0],
self->time_slots, self->w_dir[0]);
if (self->res_bands) {
ixheaacd_mps_qmf_hybrid_analysis_no_pre_mix(
&self->hyb_filt_state[1], self->qmf_in[1], self->band_count[1],
self->time_slots, self->w_dir[1]);
if (self->res_bands != 28) {
ixheaacd_mps_decor_apply(&self->mps_decor, self->w_dir[0],
self->w_diff[1], self->time_slots,
self->res_bands);
ixheaacd_mps_mix_res_decor_residual_band(self);
}
} else {
ixheaacd_mps_decor_apply(&self->mps_decor, self->w_dir[0], self->w_diff[1],
self->time_slots, NO_RES_BANDS);
}
}
WORD32 ixheaacd_mps_apply(ia_mps_dec_state_struct* self,
FLOAT32** input_buffer[4],
FLOAT32 (*output_buffer)[4096]) {
@ -281,43 +332,56 @@ WORD32 ixheaacd_mps_apply(ia_mps_dec_state_struct* self,
WORD32 time_slots = self->time_slots;
WORD32 in_ch_count = self->in_ch_count + self->res_ch_count;
WORD32 err = 0;
self->hyb_band_count[0] = self->band_count[0] - QMF_BANDS_TO_HYBRID + 10;
self->hyb_band_count[1] = self->band_count[1] - QMF_BANDS_TO_HYBRID + 10;
self->hyb_band_count_max =
max(self->hyb_band_count[0], self->hyb_band_count[1]);
self->mps_decor.decor_nrg_smooth.num_bins = self->hyb_band_count_max;
self->mps_decor.num_bins = self->hyb_band_count_max;
self->output_buffer = output_buffer;
assert(self->present_time_slot + time_slots <= self->time_slots);
for (ts = 0; ts < time_slots; ts++) {
for (ch = 0; ch < in_ch_count; ch++) {
for (qs = 0; qs < self->qmf_band_count; qs++) {
self->qmf_in[ch][self->present_time_slot + ts][qs].re =
self->input_gain * input_buffer[2 * ch][ts][qs];
self->qmf_in[ch][self->present_time_slot + ts][qs].im =
self->input_gain * input_buffer[2 * ch + 1][ts][qs];
}
}
}
self->present_time_slot += time_slots;
if (self->present_time_slot < self->time_slots) return 0;
self->present_time_slot = 0;
err = ixheaacd_mps_frame_decode(self);
if (err != 0) return err;
ixheaacd_mps_qmf_hyb_analysis(self);
ixheaacd_pre_and_mix_matrix_calculation(self);
ixheaacd_mps_pre_matrix_mix_matrix_smoothing(self);
err = ixheaacd_mps_apply_pre_matrix(self);
if (err < 0) return err;
for (ch = 0; ch < in_ch_count; ch++) {
for (ts = 0; ts < time_slots; ts++) {
for (qs = 0; qs < self->band_count[ch]; qs++) {
self->qmf_in[ch][qs][ts].re =
self->input_gain * input_buffer[2 * ch][ts][qs];
self->qmf_in[ch][qs][ts].im =
self->input_gain * input_buffer[2 * ch + 1][ts][qs];
}
}
}
ixheaacd_mps_create_w(self);
if (!(self->pre_mix_req | self->bs_tsd_enable)) {
ixheaacd_mps_qmf_hyb_analysis_no_pre_mix(self);
} else {
ixheaacd_mps_qmf_hyb_analysis(self);
err = ixheaacd_mps_apply_pre_matrix(self);
if (err < 0) return err;
ixheaacd_mps_create_w(self);
}
if ((!(self->res_bands | self->pre_mix_req)) &&
(self->config->bs_phase_coding == 0)) {
err = ixheaacd_mps_apply_mix_matrix_type1(self);
} else if (self->pre_mix_req) {
err = ixheaacd_mps_apply_mix_matrix_type2(self);
} else {
err = ixheaacd_mps_apply_mix_matrix_type3(self);
}
err = ixheaacd_mps_apply_mix_matrix(self);
if (err < 0) return err;
if (self->config->bs_temp_shape_config == 2) {

View file

@ -38,6 +38,8 @@
#define MAX_DECORR_FIL_ORDER (DECORR_FILT_0_ORD)
#define NO_RES_BANDS -1
typedef struct {
FLOAT32 re;
FLOAT32 im;
@ -107,7 +109,7 @@ typedef struct ia_mps_decor_struct {
typedef struct ia_mps_hybrid_filt_struct {
ia_cmplx_flt_struct hf_buffer[MAX_NUM_QMF_BANDS_MPS][BUFFER_LEN_HF_MPS];
ia_cmplx_w32_struct lf_buffer[QMF_BANDS_TO_HYBRID][BUFFER_LEN_LF_MPS];
ia_cmplx_flt_struct lf_buffer[QMF_BANDS_TO_HYBRID][BUFFER_LEN_LF_MPS];
} ia_mps_hybrid_filt_struct;
typedef struct ia_mps_data_struct {
@ -151,7 +153,7 @@ typedef struct ia_mps_bs_frame {
typedef struct ia_mps_smoothing_struct {
WORD32 prev_smg_time;
WORD32 inv_prev_smg_time;
FLOAT32 inv_prev_smg_time;
WORD32 prev_smg_data[MAX_PARAMETER_BANDS];
} ia_mps_smoothing_struct;
@ -188,18 +190,18 @@ typedef struct ia_mps_dec_state_struct {
WORD32 decor_sig_count;
WORD32 time_slots;
WORD32 present_time_slot;
WORD32 frame_len;
WORD32 pre_mix_req;
WORD32 temp_shape_enable_ch_stp[2];
WORD32 temp_shape_enable_ch_ges[2];
FLOAT32 env_shape_data[2][MAX_TIME_SLOTS];
WORD8 parse_nxt_frame;
WORD32 band_count[MAX_M1_INPUT];
WORD32 synth_count;
WORD32 qmf_band_count;
WORD32 hyb_band_count;
WORD32 hyb_band_count[MAX_M1_INPUT];
WORD32 hyb_band_count_max;
const WORD32 *hyb_band_to_processing_band_table;
WORD32 res_ch_count;
@ -226,7 +228,7 @@ typedef struct ia_mps_dec_state_struct {
ia_mps_bs_frame bs_frame;
WORD32 smoothing_time[MAX_PARAMETER_SETS_MPS];
WORD32 inv_smoothing_time[MAX_PARAMETER_SETS_MPS];
FLOAT32 inv_smoothing_time[MAX_PARAMETER_SETS_MPS];
WORD32 smoothing_data[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS];
WORD32 bs_tsd_enable;
@ -248,32 +250,29 @@ typedef struct ia_mps_dec_state_struct {
FLOAT32 phase_l_prev[MAX_PARAMETER_BANDS];
FLOAT32 phase_r_prev[MAX_PARAMETER_BANDS];
WORD32 phase_l_fix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS];
WORD32 phase_r_fix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS];
FLOAT32 m1_param_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
FLOAT32 m1_param_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
FLOAT32 m2_decor_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
FLOAT32 m2_decor_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
FLOAT32 m2_resid_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
FLOAT32 m2_resid_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
WORD32 m1_param_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
WORD32 m1_param_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
WORD32 m2_decor_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
WORD32 m2_decor_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
WORD32 m2_resid_re[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
WORD32 m2_resid_im[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
FLOAT32 m1_param_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
FLOAT32 m1_param_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
FLOAT32 m2_decor_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
FLOAT32 m2_decor_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
FLOAT32 m2_resid_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
FLOAT32 m2_resid_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
WORD32 m1_param_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
WORD32 m1_param_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
WORD32 m2_decor_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
WORD32 m2_decor_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
WORD32 m2_resid_re_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
WORD32 m2_resid_im_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT];
ia_cmplx_flt_struct qmf_in[2][MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS_NEW];
ia_cmplx_flt_struct hyb_in[2][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS];
ia_cmplx_flt_struct hyb_res[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS];
ia_cmplx_flt_struct qmf_in[2][MAX_NUM_QMF_BANDS_MPS_NEW][MAX_TIME_SLOTS];
ia_cmplx_flt_struct hyb_in[2][MAX_HYBRID_BANDS_MPS][MAX_TIME_SLOTS];
ia_cmplx_flt_struct hyb_res[MAX_HYBRID_BANDS_MPS][MAX_TIME_SLOTS];
ia_cmplx_flt_struct v[MAX_M1_OUTPUT][MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS];
ia_cmplx_flt_struct w_diff[MAX_M2_INPUT][MAX_TIME_SLOTS]
[MAX_HYBRID_BANDS_MPS];
@ -297,7 +296,7 @@ typedef struct ia_mps_dec_state_struct {
WORD32 bs_high_rate_mode;
WORD32 tmp_buf[84 * MAX_NUM_QMF_BANDS_SAC];
FLOAT32 tmp_buf[84 * MAX_NUM_QMF_BANDS_SAC];
FLOAT32 r_out_re_in_m1[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT];
@ -340,11 +339,9 @@ typedef struct ia_mps_dec_state_struct {
VOID ixheaacd_mps_init_pre_and_post_matrix(ia_mps_dec_state_struct *self);
VOID ixheaacd_pre_and_mix_matrix_calculation(ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_apply_pre_matrix(ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_apply_mix_matrix(ia_mps_dec_state_struct *self);
VOID ixheaacd_mps_config(ia_mps_dec_state_struct *self, WORD32 frame_len,
WORD32 residual_coding,
ia_usac_dec_mps_config_struct *mps212_config);
WORD32 ixheaacd_mps_apply_mix_matrix_type1(ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_apply_mix_matrix_type2(ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_apply_mix_matrix_type3(ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_frame_decode(ia_mps_dec_state_struct *self);
@ -359,25 +356,33 @@ VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct *self);
VOID ixheaacd_mps_par2umx_ps(ia_mps_dec_state_struct *self,
ia_mps_bs_frame *curr_bit_stream, WORD32 *h_real,
ia_mps_bs_frame *curr_bit_stream, FLOAT32 *h_real,
WORD32 param_set_idx);
VOID ixheaacd_mps_par2umx_ps_ipd_opd(ia_mps_dec_state_struct *self,
ia_mps_bs_frame *curr_bit_stream,
WORD32 *h_real, WORD32 param_set_idx);
FLOAT32 *h_real, WORD32 param_set_idx);
VOID ixheaacd_mps_par2umx_pred(ia_mps_dec_state_struct *self,
ia_mps_bs_frame *curr_bit_stream, WORD32 *h_imag,
WORD32 *h_real, WORD32 param_set_idx,
WORD32 res_bands);
ia_mps_bs_frame *curr_bit_stream,
FLOAT32 *h_imag, FLOAT32 *h_real,
WORD32 param_set_idx, WORD32 res_bands);
WORD32 ixheaacd_mps_upmix_interp(
WORD32 m_matrix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT],
WORD32 r_matrix[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT],
WORD32 m_matrix_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT],
WORD32 num_rows, WORD32 num_cols, ia_mps_dec_state_struct *self);
WORD32 ixheaacd_mps_upmix_interp_type1(
FLOAT32 m_matrix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT],
FLOAT32 r_matrix[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT],
FLOAT32 m_matrix_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT],
WORD32 num_rows, WORD32 num_cols, ia_mps_dec_state_struct *self,
WORD32 bs_high_rate_mode);
WORD32 ixheaacd_mps_upmix_interp_type2(
FLOAT32 m_matrix[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT],
FLOAT32 r_matrix[MAX_TIME_SLOTS][MAX_PARAMETER_BANDS][MAX_M_OUTPUT]
[MAX_M_INPUT],
FLOAT32 m_matrix_prev[MAX_PARAMETER_BANDS][MAX_M_OUTPUT][MAX_M_INPUT],
WORD32 num_rows, ia_mps_dec_state_struct *self, WORD32 col);
VOID ixheaacd_mps_phase_interpolation(
FLOAT32 pl[MAX_PARAMETER_SETS_MPS][MAX_PARAMETER_BANDS],

View file

@ -30,6 +30,6 @@ VOID ixheaacd_mps_decor_apply(
ia_mps_decor_struct_handle self,
ia_cmplx_flt_struct in[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
ia_cmplx_flt_struct out[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
WORD32 length);
WORD32 length, WORD32 res_bands);
#endif

View file

@ -44,6 +44,8 @@ static const WORD32 ixheaacd_qmf_split_freq_0[] = {3, 15, 24, 65};
static const WORD32 ixheaacd_qmf_split_freq_1[] = {3, 50, 65, 65};
static const WORD32 ixheaacd_qmf_split_freq_2[] = {0, 15, 65, 65};
extern const WORD32 ixheaacd_mps_gain_set_indx[29];
static const FLOAT32
ixheaacd_lattice_coeff_0_filt_den_coeff[DECORR_FILT_0_ORD + 1] = {
1.000000f, -0.314818f, -0.256828f, -0.173641f, -0.115077f, 0.000599f,
@ -141,19 +143,25 @@ static VOID ixheaacd_mps_decor_energy_adjustment(
ixheaacd_mps_decor_energy_adjust_filt_struct *handle,
ia_cmplx_flt_struct in[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
ia_cmplx_flt_struct out[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
WORD32 time_slots) {
WORD32 time_slots, WORD32 res_bands) {
ixheaacd_mps_decor_energy_adjust_filt_struct *self =
(ixheaacd_mps_decor_energy_adjust_filt_struct *)handle;
FLOAT32 in_energy[MAX_PARAMETER_BANDS] = {0};
FLOAT32 out_energy[MAX_PARAMETER_BANDS] = {0};
FLOAT32 gain[MAX_PARAMETER_BANDS];
WORD32 i, j, k;
WORD32 start_param_band = 0, start_bin = 0;
if (res_bands != NO_RES_BANDS) {
start_bin = ixheaacd_mps_gain_set_indx[res_bands];
start_param_band = res_bands;
}
for (i = 0; i < time_slots; i++) {
memset(in_energy, 0, sizeof(FLOAT32) * MAX_PARAMETER_BANDS);
memset(out_energy, 0, sizeof(FLOAT32) * MAX_PARAMETER_BANDS);
for (j = 0; j < self->num_bins; j++) {
for (j = start_bin; j < self->num_bins; j++) {
k = ixheaacd_hybrid_band_71_to_processing_band_28_map[j];
in_energy[k] += in[i][j].re * in[i][j].re + in[i][j].im * in[i][j].im;
@ -161,7 +169,7 @@ static VOID ixheaacd_mps_decor_energy_adjustment(
out[i][j].re * out[i][j].re + out[i][j].im * out[i][j].im;
}
for (k = 0; k < MAX_PARAMETER_BANDS; k++) {
for (k = start_param_band; k < MAX_PARAMETER_BANDS; k++) {
self->smooth_in_energy[k] = self->smooth_in_energy[k] * DECOR_ALPHA +
in_energy[k] * ONE_MINUS_DECOR_ALPHA;
self->smooth_out_energy[k] = self->smooth_out_energy[k] * DECOR_ALPHA +
@ -184,7 +192,7 @@ static VOID ixheaacd_mps_decor_energy_adjustment(
}
}
for (j = 0; j < self->num_bins; j++) {
for (j = start_bin; j < self->num_bins; j++) {
k = ixheaacd_hybrid_band_71_to_processing_band_28_map[j];
out[i][j].re *= gain[k];
@ -233,12 +241,14 @@ VOID ixheaacd_mps_decor_apply(
ia_mps_decor_struct_handle self,
ia_cmplx_flt_struct in[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
ia_cmplx_flt_struct out[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
WORD32 length) {
WORD32 idx, sb_sample;
WORD32 length, WORD32 res_bands) {
WORD32 idx, sb_sample, index = 0;
ia_cmplx_flt_struct scratch[MAX_TIME_SLOTS];
for (idx = 0; idx < self->num_bins; idx++) {
if (res_bands != NO_RES_BANDS) index = ixheaacd_mps_gain_set_indx[res_bands];
for (idx = index; idx < self->num_bins; idx++) {
for (sb_sample = 0; sb_sample < length; sb_sample++) {
self->decor_delay_buffer[idx][self->delay_sample_count[idx] + sb_sample]
.re = in[sb_sample][idx].re;
@ -262,6 +272,6 @@ VOID ixheaacd_mps_decor_apply(
}
}
ixheaacd_mps_decor_energy_adjustment(&self->decor_nrg_smooth, in, out,
length);
ixheaacd_mps_decor_energy_adjustment(&self->decor_nrg_smooth, in, out, length,
res_bands);
}

View file

@ -24,9 +24,15 @@ VOID ixheaacd_mps_qmf_hybrid_analysis_init(ia_mps_hybrid_filt_struct *handle);
VOID ixheaacd_mps_qmf_hybrid_analysis(
ia_mps_hybrid_filt_struct *handle,
ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS_NEW],
ia_cmplx_flt_struct in_qmf[MAX_NUM_QMF_BANDS_MPS_NEW][MAX_TIME_SLOTS],
WORD32 num_bands, WORD32 num_samples,
ia_cmplx_flt_struct out_hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]);
ia_cmplx_flt_struct out_hyb[MAX_HYBRID_BANDS_MPS][MAX_TIME_SLOTS]);
VOID ixheaacd_mps_qmf_hybrid_analysis_no_pre_mix(
ia_mps_hybrid_filt_struct *handle,
ia_cmplx_flt_struct in_qmf[MAX_NUM_QMF_BANDS_MPS_NEW][MAX_TIME_SLOTS],
WORD32 num_bands, WORD32 num_samples,
ia_cmplx_flt_struct v[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]);
VOID ixheaacd_mps_qmf_hybrid_synthesis(
ia_cmplx_flt_struct in_hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],

View file

@ -33,136 +33,177 @@
#include "ixheaacd_mps_hybfilter.h"
extern const WORD32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER];
extern const WORD32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER];
extern const WORD32 ixheaacd_cosine[8][13];
extern const WORD32 ixheaacd_sine[8][13];
extern const WORD32 ixheaacd_cosine2[2][13];
extern const FLOAT32 ixheaacd_ia_mps_hyb_filter_coeff_8[QMF_HYBRID_FILT_ORDER];
extern const FLOAT32 ixheaacd_mps_hyb_filter_coeff_2[QMF_HYBRID_FILT_ORDER];
static WORD32 ixheaacd_mps_mult32_local(WORD32 a, WORD32 b, WORD16 shift) {
WORD64 temp;
temp = (WORD64)a * (WORD64)b;
temp = temp >> shift;
return (WORD32)temp;
}
extern const FLOAT32 ixheaacd_sine[8][8];
extern const FLOAT32 ixheaacd_cosine[8][8];
static VOID ixheaacd_mps_hyb_filt_type1(
ia_cmplx_w32_struct *input, ia_cmplx_w32_struct output[8][MAX_TIME_SLOTS],
WORD32 num_samples, const WORD32 *filt_coeff)
ia_cmplx_flt_struct *input, ia_cmplx_flt_struct output[8][MAX_TIME_SLOTS],
WORD32 num_samples, const FLOAT32 *filt_coeff)
{
WORD32 i, n, q;
WORD32 modulation_fac_re, modulation_fac_im;
WORD32 in_re, in_im;
WORD32 temp;
WORD32 coeff;
WORD64 acc_re, acc_im;
WORD16 shift = 8;
FLOAT32 in_re, in_im;
FLOAT32 coeff;
FLOAT32 acc_re_l, acc_re_h, acc_im_l, acc_im_h;
for (i = 0; i < num_samples; i++) {
for (q = 0; q < 8; q++) {
acc_re = 0;
acc_im = 0;
for (n = 0; n < QMF_HYBRID_FILT_ORDER; n++) {
modulation_fac_re = ixheaacd_cosine[q][n];
modulation_fac_im = ixheaacd_sine[q][n];
FLOAT32 x0_re[13], x0_im[13], x0_1_re[8], x0_1_im[8];
FLOAT32 acc_re_val[8], acc_im_val[8];
for (n = 0; n < QMF_HYBRID_FILT_ORDER; n++) // x0 = x[n]*Cf[n]
{
in_re = input[n + i].re;
in_im = input[n + i].im;
in_re = (WORD32)(input[n + i].re);
in_im = (WORD32)(input[n + i].im);
coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
in_re = ixheaacd_shl32_sat(in_re, shift);
in_im = ixheaacd_shl32_sat(in_im, shift);
x0_re[n] = coeff * in_re;
x0_im[n] = coeff * in_im;
}
coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
// x0_2 series
temp = ixheaacd_sub32_sat(
ixheaacd_mps_mult32_local(in_re, modulation_fac_re, 30),
ixheaacd_mps_mult32_local(in_im, modulation_fac_im, 30));
x0_1_re[0] = x0_re[6];
x0_1_im[0] = x0_im[6];
if (temp >= 1073741823)
temp = 1073741823;
else if (temp <= -1073741824)
temp = -1073741824;
x0_1_re[1] = x0_re[7];
x0_1_im[1] = x0_im[7];
temp = ixheaacd_mps_mult32_local(coeff, temp, 30);
acc_re = acc_re + (WORD64)temp;
x0_1_re[2] = x0_re[8] - x0_re[0];
x0_1_im[2] = x0_im[8] - x0_im[0];
temp = ixheaacd_add32_sat(
ixheaacd_mps_mult32_local(in_im, modulation_fac_re, 30),
ixheaacd_mps_mult32_local(in_re, modulation_fac_im, 30));
x0_1_re[3] = x0_re[9] - x0_re[1];
x0_1_im[3] = x0_im[9] - x0_im[1];
if (temp >= 1073741823)
temp = 1073741823;
else if (temp <= -1073741824)
temp = -1073741824;
x0_1_re[4] = x0_re[10] - x0_re[2];
x0_1_im[4] = x0_im[10] - x0_im[2];
temp = ixheaacd_mps_mult32_local(coeff, temp, 30);
acc_im = acc_im + (WORD64)temp;
}
x0_1_re[5] = x0_re[11] - x0_re[3];
x0_1_im[5] = x0_im[11] - x0_im[3];
output[q][i].re = (WORD32)(acc_re >> shift);
output[q][i].im = (WORD32)(acc_im >> shift);
x0_1_re[6] = x0_re[12] - x0_re[4];
x0_1_im[6] = x0_im[12] - x0_im[4];
x0_1_re[7] = -(x0_re[5]);
x0_1_im[7] = -(x0_im[5]);
// acc_re_im_val
acc_re_val[0] = x0_1_re[0];
acc_re_val[1] = x0_1_re[1] - x0_1_re[7];
acc_re_val[2] = x0_1_re[2] - x0_1_re[6];
acc_re_val[3] = x0_1_re[3] - x0_1_re[5];
acc_re_val[4] = x0_1_im[1] + x0_1_im[7];
acc_re_val[5] = x0_1_im[2] + x0_1_im[6];
acc_re_val[6] = x0_1_im[3] + x0_1_im[5];
acc_re_val[7] = x0_1_im[4];
acc_im_val[0] = x0_1_im[0];
acc_im_val[1] = x0_1_im[1] - x0_1_im[7];
acc_im_val[2] = x0_1_im[2] - x0_1_im[6];
acc_im_val[3] = x0_1_im[3] - x0_1_im[5];
acc_im_val[4] = x0_1_re[1] + x0_1_re[7];
acc_im_val[5] = x0_1_re[2] + x0_1_re[6];
acc_im_val[6] = x0_1_re[3] + x0_1_re[5];
acc_im_val[7] = x0_1_re[4];
for (q = 0; q < 4; q++) {
acc_re_l = 0;
acc_im_l = 0;
acc_re_h = 0;
acc_im_h = 0;
// X_re
acc_re_l += acc_re_val[0];
acc_re_l += acc_re_val[1] * ixheaacd_cosine[q][1];
acc_re_l += acc_re_val[2] * ixheaacd_cosine[q][2];
acc_re_l += acc_re_val[3] * ixheaacd_cosine[q][3];
acc_re_h = acc_re_l;
acc_re_l -= acc_re_val[4] * ixheaacd_sine[q][1];
acc_re_l -= acc_re_val[5] * ixheaacd_sine[q][2];
acc_re_l -= acc_re_val[6] * ixheaacd_sine[q][3];
acc_re_l -= acc_re_val[7] * ixheaacd_sine[q][4];
acc_re_h = acc_re_h - (acc_re_l - acc_re_h);
// X_im
acc_im_l += acc_im_val[0];
acc_im_l += acc_im_val[1] * ixheaacd_cosine[q][1];
acc_im_l += acc_im_val[2] * ixheaacd_cosine[q][2];
acc_im_l += acc_im_val[3] * ixheaacd_cosine[q][3];
acc_im_h = acc_im_l;
acc_im_l += acc_im_val[4] * ixheaacd_sine[q][1];
acc_im_l += acc_im_val[5] * ixheaacd_sine[q][2];
acc_im_l += acc_im_val[6] * ixheaacd_sine[q][3];
acc_im_l += acc_im_val[7] * ixheaacd_sine[q][4];
acc_im_h = acc_im_h - (acc_im_l - acc_im_h);
output[q][i].re = acc_re_l;
output[q][i].im = acc_im_l;
output[7 - q][i].re = acc_re_h;
output[7 - q][i].im = acc_im_h;
}
}
}
static VOID ixheaacd_mps_hyb_filt_type2(
ia_cmplx_w32_struct *input, ia_cmplx_w32_struct output[2][MAX_TIME_SLOTS],
WORD32 num_samples, const WORD32 *filt_coeff)
ia_cmplx_flt_struct *input, ia_cmplx_flt_struct output[2][MAX_TIME_SLOTS],
WORD32 num_samples, const FLOAT32 *filt_coeff)
{
WORD32 i, n, q;
WORD32 i, n;
WORD32 modulation_fac_re;
WORD32 in_re, in_im;
WORD32 temp;
WORD32 coeff;
WORD64 acc_re, acc_im;
WORD16 shift = 8;
FLOAT32 in_re, in_im;
FLOAT32 coeff;
FLOAT32 acc_re[2], acc_im[2];
for (i = 0; i < num_samples; i++) {
for (q = 0; q < 2; q++) {
acc_re = 0;
acc_im = 0;
for (n = 0; n < QMF_HYBRID_FILT_ORDER; n++) {
modulation_fac_re = ixheaacd_cosine2[q][n];
FLOAT32 x_0_re[13], x_0_im[13];
in_re = (WORD32)(input[n + i].re);
in_im = (WORD32)(input[n + i].im);
for (n = 1; n < 6; n = n + 2) {
in_re = input[n + i].re;
in_im = input[n + i].im;
in_re = ixheaacd_shl32_sat(in_re, shift);
in_im = ixheaacd_shl32_sat(in_im, shift);
in_re += input[12 - n + i].re;
in_im += input[12 - n + i].im;
coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
temp = ixheaacd_mps_mult32_local(in_re, modulation_fac_re, 30);
if (temp >= 1073741823)
temp = 1073741823;
else if (temp <= -1073741824)
temp = -1073741824;
temp = ixheaacd_mps_mult32_local(coeff, temp, 30);
acc_re = acc_re + (WORD64)temp;
temp = ixheaacd_mps_mult32_local(in_im, modulation_fac_re, 30);
if (temp >= 1073741823)
temp = 1073741823;
else if (temp <= -1073741824)
temp = -1073741824;
temp = ixheaacd_mps_mult32_local(coeff, temp, 30);
acc_im = acc_im + (WORD64)temp;
}
output[q][i].re = (WORD32)(acc_re >> shift);
output[q][i].im = (WORD32)(acc_im >> shift);
x_0_re[n] = coeff * in_re;
x_0_im[n] = coeff * in_im;
}
n = 6;
in_re = input[n + i].re;
in_im = input[n + i].im;
coeff = filt_coeff[QMF_HYBRID_FILT_ORDER - 1 - n];
x_0_re[n] = coeff * in_re;
x_0_im[n] = coeff * in_im;
x_0_re[1] = x_0_re[1] + x_0_re[3] + x_0_re[5];
x_0_im[1] = x_0_im[1] + x_0_im[3] + x_0_im[5];
acc_re[0] = x_0_re[6] + x_0_re[1];
acc_im[0] = x_0_im[6] + x_0_im[1];
acc_re[1] = x_0_re[6] - x_0_re[1];
acc_im[1] = x_0_im[6] - x_0_im[1];
output[0][i].re = acc_re[0];
output[0][i].im = acc_im[0];
output[1][i].re = acc_re[1];
output[1][i].im = acc_im[1];
}
}
@ -173,17 +214,17 @@ VOID ixheaacd_mps_qmf_hybrid_analysis_init(ia_mps_hybrid_filt_struct *handle) {
sizeof(ia_cmplx_flt_struct));
}
VOID ixheaacd_mps_qmf_hybrid_analysis(
VOID ixheaacd_mps_qmf_hybrid_analysis_no_pre_mix(
ia_mps_hybrid_filt_struct *handle,
ia_cmplx_flt_struct in_qmf[MAX_TIME_SLOTS][MAX_NUM_QMF_BANDS_MPS_NEW],
ia_cmplx_flt_struct in_qmf[MAX_NUM_QMF_BANDS_MPS_NEW][MAX_TIME_SLOTS],
WORD32 num_bands, WORD32 num_samples,
ia_cmplx_flt_struct hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]) {
ia_cmplx_flt_struct v[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS]) {
WORD32 lf_samples_shift;
WORD32 hf_samples_shift;
WORD32 lf_qmf_bands;
WORD32 k, n;
ia_cmplx_w32_struct scratch[MAX_HYBRID_ONLY_BANDS_PER_QMF][MAX_TIME_SLOTS];
ia_cmplx_flt_struct scratch[MAX_HYBRID_ONLY_BANDS_PER_QMF][MAX_TIME_SLOTS];
lf_samples_shift = BUFFER_LEN_LF_MPS - num_samples;
hf_samples_shift = BUFFER_LEN_HF_MPS - num_samples;
@ -191,33 +232,23 @@ VOID ixheaacd_mps_qmf_hybrid_analysis(
lf_qmf_bands = QMF_BANDS_TO_HYBRID;
for (k = 0; k < lf_qmf_bands; k++) {
for (n = 0; n < lf_samples_shift; n++) {
handle->lf_buffer[k][n].re = handle->lf_buffer[k][n + num_samples].re;
handle->lf_buffer[k][n].im = handle->lf_buffer[k][n + num_samples].im;
}
memmove(&handle->lf_buffer[k][0].re, &handle->lf_buffer[k][num_samples].re,
2 * lf_samples_shift * sizeof(FLOAT32));
}
for (k = 0; k < lf_qmf_bands; k++) {
for (n = 0; n < num_samples; n++) {
handle->lf_buffer[k][n + lf_samples_shift].re = (WORD32)(in_qmf[n][k].re);
handle->lf_buffer[k][n + lf_samples_shift].im = (WORD32)(in_qmf[n][k].im);
}
memcpy(&handle->lf_buffer[k][lf_samples_shift].re, &in_qmf[k][0].re,
2 * num_samples * sizeof(FLOAT32));
}
for (k = 0; k < MAX_NUM_QMF_BANDS_SAC / 2 - lf_qmf_bands; k++) {
memmove(&handle->hf_buffer[k][0].re, &handle->hf_buffer[k][num_samples].re,
2 * hf_samples_shift * sizeof(FLOAT32));
}
for (k = 0; k < num_bands - lf_qmf_bands; k++) {
for (n = 0; n < hf_samples_shift; n++) {
handle->hf_buffer[k][n].re = handle->hf_buffer[k][n + num_samples].re;
handle->hf_buffer[k][n].im = handle->hf_buffer[k][n + num_samples].im;
}
}
for (k = 0; k < num_bands - lf_qmf_bands; k++) {
for (n = 0; n < num_samples; n++) {
handle->hf_buffer[k][n + hf_samples_shift].re =
(in_qmf[n][k + lf_qmf_bands].re);
handle->hf_buffer[k][n + hf_samples_shift].im =
(in_qmf[n][k + lf_qmf_bands].im);
}
memcpy(&handle->hf_buffer[k][hf_samples_shift].re,
&in_qmf[k + lf_qmf_bands][0].re, 2 * num_samples * sizeof(FLOAT32));
}
ixheaacd_mps_hyb_filt_type1(
@ -226,15 +257,15 @@ VOID ixheaacd_mps_qmf_hybrid_analysis(
for (k = 0; k < 2; k++) {
for (n = 0; n < num_samples; n++) {
hyb[n][k].re = (FLOAT32)scratch[k + 6][n].re;
hyb[n][k + 2].re = (FLOAT32)scratch[k][n].re;
hyb[n][k + 4].re = (FLOAT32)scratch[k + 2][n].re;
hyb[n][k + 4].re += (FLOAT32)scratch[5 - k][n].re;
v[n][k].re = scratch[k + 6][n].re;
v[n][k + 2].re = scratch[k][n].re;
v[n][k + 4].re = scratch[k + 2][n].re;
v[n][k + 4].re += scratch[5 - k][n].re;
hyb[n][k].im = (FLOAT32)scratch[k + 6][n].im;
hyb[n][k + 2].im = (FLOAT32)scratch[k][n].im;
hyb[n][k + 4].im = (FLOAT32)scratch[k + 2][n].im;
hyb[n][k + 4].im += (FLOAT32)scratch[5 - k][n].im;
v[n][k].im = scratch[k + 6][n].im;
v[n][k + 2].im = scratch[k][n].im;
v[n][k + 4].im = scratch[k + 2][n].im;
v[n][k + 4].im += scratch[5 - k][n].im;
}
}
@ -244,8 +275,8 @@ VOID ixheaacd_mps_qmf_hybrid_analysis(
for (k = 0; k < 2; k++) {
for (n = 0; n < num_samples; n++) {
hyb[n][k + 6].re = (FLOAT32)scratch[1 - k][n].re;
hyb[n][k + 6].im = (FLOAT32)scratch[1 - k][n].im;
v[n][k + 6].re = scratch[1 - k][n].re;
v[n][k + 6].im = scratch[1 - k][n].im;
}
}
@ -255,19 +286,102 @@ VOID ixheaacd_mps_qmf_hybrid_analysis(
for (k = 0; k < 2; k++) {
for (n = 0; n < num_samples; n++) {
hyb[n][k + 8].re = (FLOAT32)scratch[k][n].re;
hyb[n][k + 8].im = (FLOAT32)scratch[k][n].im;
v[n][k + 8].re = scratch[k][n].re;
v[n][k + 8].im = scratch[k][n].im;
}
}
for (k = 0; k < num_bands - lf_qmf_bands; k++) {
for (n = 0; n < num_samples; n++) {
hyb[n][k + 10].re = (handle->hf_buffer[k][n + hf_samples_shift].re);
hyb[n][k + 10].im = (handle->hf_buffer[k][n + hf_samples_shift].im);
v[n][k + 10].re = (handle->hf_buffer[k][n + hf_samples_shift].re);
v[n][k + 10].im = (handle->hf_buffer[k][n + hf_samples_shift].im);
}
}
}
VOID ixheaacd_mps_qmf_hybrid_analysis(
ia_mps_hybrid_filt_struct *handle,
ia_cmplx_flt_struct in_qmf[MAX_NUM_QMF_BANDS_MPS_NEW][MAX_TIME_SLOTS],
WORD32 num_bands, WORD32 num_samples,
ia_cmplx_flt_struct hyb[MAX_HYBRID_BANDS_MPS][MAX_TIME_SLOTS]) {
WORD32 lf_samples_shift;
WORD32 hf_samples_shift;
WORD32 lf_qmf_bands;
WORD32 k, n;
ia_cmplx_flt_struct scratch[MAX_HYBRID_ONLY_BANDS_PER_QMF][MAX_TIME_SLOTS];
lf_samples_shift = BUFFER_LEN_LF_MPS - num_samples;
hf_samples_shift = BUFFER_LEN_HF_MPS - num_samples;
lf_qmf_bands = QMF_BANDS_TO_HYBRID;
for (k = 0; k < lf_qmf_bands; k++) {
memmove(&handle->lf_buffer[k][0].re, &handle->lf_buffer[k][num_samples].re,
2 * lf_samples_shift * sizeof(FLOAT32));
}
for (k = 0; k < lf_qmf_bands; k++) {
memcpy(&handle->lf_buffer[k][lf_samples_shift].re, &in_qmf[k][0].re,
2 * num_samples * sizeof(FLOAT32));
}
for (k = 0; k < MAX_NUM_QMF_BANDS_SAC / 2 - lf_qmf_bands; k++) {
memmove(&handle->hf_buffer[k][0].re, &handle->hf_buffer[k][num_samples].re,
2 * hf_samples_shift * sizeof(FLOAT32));
}
for (k = 0; k < num_bands - lf_qmf_bands; k++) {
memcpy(&handle->hf_buffer[k][hf_samples_shift].re,
&in_qmf[k + lf_qmf_bands][0].re, 2 * num_samples * sizeof(FLOAT32));
}
ixheaacd_mps_hyb_filt_type1(
&(handle->lf_buffer[0][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]),
scratch, num_samples, ixheaacd_ia_mps_hyb_filter_coeff_8);
for (k = 0; k < 2; k++) {
for (n = 0; n < num_samples; n++) {
hyb[k][n].re = scratch[k + 6][n].re;
hyb[k + 2][n].re = scratch[k][n].re;
hyb[k + 4][n].re = scratch[k + 2][n].re;
hyb[k + 4][n].re += scratch[5 - k][n].re;
hyb[k][n].im = scratch[k + 6][n].im;
hyb[k + 2][n].im = scratch[k][n].im;
hyb[k + 4][n].im = scratch[k + 2][n].im;
hyb[k + 4][n].im += scratch[5 - k][n].im;
}
}
ixheaacd_mps_hyb_filt_type2(
&(handle->lf_buffer[1][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]),
scratch, num_samples, ixheaacd_mps_hyb_filter_coeff_2);
for (k = 0; k < 2; k++) {
for (n = 0; n < num_samples; n++) {
hyb[k + 6][n].re = scratch[1 - k][n].re;
hyb[k + 6][n].im = scratch[1 - k][n].im;
}
}
ixheaacd_mps_hyb_filt_type2(
&(handle->lf_buffer[2][lf_samples_shift + 1 - QMF_HYBRID_FILT_ORDER]),
scratch, num_samples, ixheaacd_mps_hyb_filter_coeff_2);
for (k = 0; k < 2; k++) {
for (n = 0; n < num_samples; n++) {
hyb[k + 8][n].re = scratch[k][n].re;
hyb[k + 8][n].im = scratch[k][n].im;
}
}
for (k = 0; k < num_bands - lf_qmf_bands; k++) {
memcpy(&hyb[k + 10][0].re, &handle->hf_buffer[k][hf_samples_shift].re,
2 * num_samples * sizeof(FLOAT32));
}
}
VOID ixheaacd_mps_qmf_hybrid_synthesis(
ia_cmplx_flt_struct hyb[MAX_TIME_SLOTS][MAX_HYBRID_BANDS_MPS],
WORD32 num_bands, WORD32 num_samples,
@ -289,9 +403,7 @@ VOID ixheaacd_mps_qmf_hybrid_synthesis(
in_qmf[n][2].re = hyb[n][8].re + hyb[n][9].re;
in_qmf[n][2].im = hyb[n][8].im + hyb[n][9].im;
for (k = 3; k < num_bands; k++) {
in_qmf[n][k].re = hyb[n][k - 3 + 10].re;
in_qmf[n][k].im = hyb[n][k - 3 + 10].im;
}
memcpy(&in_qmf[n][3].re, &hyb[n][10].re,
2 * (num_bands - 3) * sizeof(FLOAT32));
}
}

View file

@ -107,8 +107,8 @@ const int ixheaacd_ipd_de_quant_table_q28[] = {
1264972288, 1370386688, 1475800960, 1581215360};
static const int ixheaacd_smoothing_time_table[] = {64, 128, 256, 512};
static const int ixheaacd_inverse_smoothing_time_table_q30[] = {
16777216, 8388608, 4194304, 2097152};
static const FLOAT32 ixheaacd_inverse_smoothing_time_table[] = {
1.0f / 64.0f, 1.0f / 128.0f, 1.0f / 256.0f, 1.0f / 512.0f};
static WORD32 bound_check(WORD32 var, WORD32 lower_bound, WORD32 upper_bound) {
var = min(var, upper_bound);
@ -878,7 +878,7 @@ static VOID ixheaacd_mps_dec_and_mapframesmg(ia_mps_dec_state_struct *self) {
switch (frame->bs_smooth_mode[ps]) {
case 0:
self->smoothing_time[ps] = 256;
self->inv_smoothing_time[ps] = 4194304;
self->inv_smoothing_time[ps] = (FLOAT32)(1.0f / 256.0f);
for (pb = 0; pb < self->bs_param_bands; pb++) {
self->smoothing_data[ps][pb] = 0;
@ -908,8 +908,7 @@ static VOID ixheaacd_mps_dec_and_mapframesmg(ia_mps_dec_state_struct *self) {
self->smoothing_time[ps] =
ixheaacd_smoothing_time_table[frame->bs_smooth_time[ps]];
self->inv_smoothing_time[ps] =
ixheaacd_inverse_smoothing_time_table_q30[frame
->bs_smooth_time[ps]];
ixheaacd_inverse_smoothing_time_table[frame->bs_smooth_time[ps]];
for (pb = 0; pb < self->bs_param_bands; pb++) {
self->smoothing_data[ps][pb] = 1;
}
@ -919,8 +918,7 @@ static VOID ixheaacd_mps_dec_and_mapframesmg(ia_mps_dec_state_struct *self) {
self->smoothing_time[ps] =
ixheaacd_smoothing_time_table[frame->bs_smooth_time[ps]];
self->inv_smoothing_time[ps] =
ixheaacd_inverse_smoothing_time_table_q30[frame
->bs_smooth_time[ps]];
ixheaacd_inverse_smoothing_time_table[frame->bs_smooth_time[ps]];
ch_fac = ixheaacd_mps_stride_table[frame->bs_freq_res_stride_smg[ps]];
data_bands = (self->bs_param_bands - 1) / ch_fac + 1;
@ -994,10 +992,9 @@ WORD32 ixheaacd_mps_frame_decode(ia_mps_dec_state_struct *self) {
WORD32 ixheaacd_mps_header_decode(ia_mps_dec_state_struct *self) {
self->time_slots = self->frame_length;
self->frame_len = self->time_slots * self->qmf_band_count;
self->bs_param_bands = ixheaacd_freq_res_table[self->config->bs_freq_res];
self->hyb_band_count = self->qmf_band_count - QMF_BANDS_TO_HYBRID + 10;
self->hyb_band_count_max = self->qmf_band_count - QMF_BANDS_TO_HYBRID + 10;
switch (self->bs_param_bands) {
case 4:

View file

@ -32,22 +32,10 @@
#include "ixheaacd_basic_ops32.h"
#include "ixheaacd_function_selector.h"
extern const WORD32
ixheaacd_mps_polyphase_filter_coeff_fix[10 * MAX_NUM_QMF_BANDS_SAC / 2];
extern const WORD32 ixheaacd_mps_pre_re[64];
extern const WORD32 ixheaacd_mps_pre_im[64];
extern const WORD32 ixheaacd_mps_post_re[128];
extern const WORD32 ixheaacd_mps_post_im[128];
static PLATFORM_INLINE WORD32 ixheaacd_mult32(WORD32 a, WORD32 b) {
WORD32 result;
WORD64 temp_result;
temp_result = (WORD64)a * (WORD64)b;
result = (WORD32)(temp_result >> 31);
return (result);
}
extern const FLOAT32
ixheaacd_mps_polyphase_filter_coeff[10 * MAX_NUM_QMF_BANDS_SAC / 2];
extern const FLOAT32 ixheaacd_mps_post_twid[30];
extern const FLOAT32 ixheaacd_mps_pre_twid[64];
VOID ixheaacd_mps_synt_create(ia_mps_poly_phase_struct *kernel,
WORD32 resolution) {
@ -55,65 +43,14 @@ VOID ixheaacd_mps_synt_create(ia_mps_poly_phase_struct *kernel,
}
VOID ixheaacd_mps_synt_init(ia_mps_poly_phase_synth_struct *self) {
memset(self->state, 0, sizeof(WORD32) * 64 * 20);
memset(self->state, 0, sizeof(FLOAT32) * POLY_PHASE_SYNTH_SIZE);
}
static VOID ixheaacd_float_to_int32(FLOAT32 *in, WORD32 *out, WORD32 q_factor,
WORD32 sample) {
WORD32 loop;
UWORD32 temp = (1 << q_factor);
for (loop = 0; loop < sample; loop++) out[loop] = (WORD32)(in[loop] * temp);
}
VOID ixheaacd_mps_synt_pre_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution) {
WORD32 tmp, k;
for (k = 0; k < 2 * resolution; k += 2) {
tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_in[k], table_re[k >> 1]),
ixheaacd_mult32(ptr_in[k + 1], table_im[k >> 1]));
ptr_in[k + 1] = ixheaacd_add32_sat(
ixheaacd_mult32(ixheaacd_negate32_sat(ptr_in[k]), table_im[k >> 1]),
ixheaacd_mult32(ptr_in[k + 1], table_re[k >> 1]));
ptr_in[k] = tmp;
}
}
VOID ixheaacd_mps_synt_post_twiddle_dec(WORD32 *ptr_in, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 resolution) {
WORD32 tmp, k;
for (k = 0; k < 2 * resolution; k += 2) {
tmp = ixheaacd_add32_sat(ixheaacd_mult32(ptr_in[k], table_re[k]),
ixheaacd_mult32(ptr_in[k + 1], table_im[k]));
ptr_in[k + 1] = ixheaacd_add32_sat(
ixheaacd_mult32(ixheaacd_negate32_sat(ptr_in[k]), table_im[k]),
ixheaacd_mult32(ptr_in[k + 1], table_re[k]));
ptr_in[k] = tmp;
}
}
VOID ixheaacd_mps_synt_post_fft_twiddle_dec(WORD32 resolution, WORD32 *fin_re,
WORD32 *fin_im,
const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state) {
WORD32 l;
for (l = 0; l < 2 * resolution; l++) {
state[2 * resolution - l - 1] =
ixheaacd_add32_sat(ixheaacd_mult32(fin_re[l], table_re[l]),
ixheaacd_mult32(fin_im[l], table_im[l]));
}
}
VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out,
WORD32 *state, const WORD32 *filter_coeff) {
VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, FLOAT32 *out,
FLOAT32 *state,
const FLOAT32 *filter_coeff) {
WORD32 l, k;
WORD32 *out1, *out2, *state1, *state2;
FLOAT32 *out1, *out2, *state1, *state2;
out1 = out;
out2 = out + resolution;
state1 = state;
@ -121,8 +58,8 @@ VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out,
for (k = 0; k < 5; k++) {
for (l = 0; l < resolution; l++) {
*out1++ = (WORD32)(((WORD64)(*state1++) * (*filter_coeff++)) >> 31);
*out2++ = (WORD32)(((WORD64)(*state2++) * (*filter_coeff++)) >> 31);
*out1++ = (*state1++) * (*filter_coeff++);
*out2++ = (*state2++) * (*filter_coeff++);
}
out1 += resolution;
out2 += resolution;
@ -131,64 +68,163 @@ VOID ixheaacd_mps_synt_out_calc_dec(WORD32 resolution, WORD32 *out,
}
}
VOID ixheaacd_mps_synth_pre_twidle(FLOAT32 *out_re, FLOAT32 *out_im,
FLOAT32 *c_in, WORD32 len) {
WORD32 i;
FLOAT32 *c_s = c_in;
FLOAT32 *p_re_s = out_re;
FLOAT32 *p_im_s = out_im;
FLOAT32 *c_e = c_in + (len << 1) - 1;
FLOAT32 *p_im_e = out_im + len - 1;
FLOAT32 *p_re_e = out_re + len - 1;
const FLOAT32 *prtw = ixheaacd_mps_pre_twid;
for (i = 0; i < len; i += 4) {
*p_re_s = ((*c_s++) * (*prtw));
p_re_s++;
*p_im_s = -((*c_s--) * (*prtw));
p_im_s++;
*p_im_s = ((*c_e--) * (*prtw));
p_im_s--;
*p_re_s = ((*c_e++) * (*prtw++));
p_re_s--;
*p_im_s += ((*c_e--) * (*prtw));
p_im_s++;
*p_re_s += ((*c_e--) * (*prtw));
p_re_s++;
*p_re_s -= ((*c_s++) * (*prtw));
p_re_s++;
*p_im_s += ((*c_s++) * (*prtw++));
p_im_s++;
*p_im_e = ((*c_e--) * (*prtw));
p_im_e--;
*p_re_e = -((*c_e++) * (*prtw));
p_re_e--;
*p_re_e = ((*c_s++) * (*prtw));
p_re_e++;
*p_im_e = ((*c_s--) * (*prtw++));
p_im_e++;
*p_re_e += ((*c_s++) * (*prtw));
p_re_e--;
*p_im_e += ((*c_s++) * (*prtw));
p_im_e--;
*p_im_e -= ((*c_e--) * (*prtw));
p_im_e--;
*p_re_e += ((*c_e--) * (*prtw++));
p_re_e--;
}
}
VOID ixheaacd_mps_synth_post_twidle(FLOAT32 *state, FLOAT32 *out_re,
FLOAT32 *out_im, WORD32 len) {
WORD32 i;
{
FLOAT32 x_0, x_1, x_2, x_3;
FLOAT32 *p_re_e, *p_im_e;
const FLOAT32 *potw = ixheaacd_mps_post_twid;
FLOAT32 *p_re_s = out_re;
FLOAT32 *p_im_s = out_im;
p_re_e = p_re_s + (len - 2);
p_im_e = p_im_s + (len - 2);
x_0 = *p_re_e;
x_1 = *(p_re_e + 1);
x_2 = *p_im_e;
x_3 = *(p_im_e + 1);
*(p_re_e + 1) = -*(p_re_s + 1);
*(p_im_e + 1) = -*p_im_s;
*p_im_s = *(p_im_s + 1);
for (i = 5; i < len; i += 4) {
FLOAT32 twdr = *potw++;
FLOAT32 twdi = *potw++;
FLOAT32 tmp;
*p_re_e = (x_0 * twdi);
*p_re_e += (x_1 * twdr);
p_re_e--;
p_re_s++;
*p_re_s = (x_0 * twdr);
*p_re_s -= (x_1 * twdi);
p_re_s++;
x_1 = *p_re_e--;
x_0 = *p_re_e++;
*p_re_e = (*p_re_s++ * twdi);
*p_re_e += -(*p_re_s * twdr);
p_re_e--;
tmp = (*p_re_s-- * twdi);
*p_re_s = tmp + (*p_re_s * twdr);
*p_im_e = -(x_2 * twdr);
*p_im_e += (x_3 * twdi);
p_im_e--;
p_im_s++;
*p_im_s = -(x_2 * twdi);
*p_im_s -= (x_3 * twdr);
p_im_s++;
x_3 = *p_im_e--;
x_2 = *p_im_e++;
*p_im_e = -(*p_im_s++ * twdr);
*p_im_e -= (*p_im_s * twdi);
p_im_e--;
tmp = (*p_im_s-- * twdr);
*p_im_s = tmp - (*p_im_s * twdi);
}
*p_re_e = 0.7071067f * (x_1 + x_0);
*p_im_e = 0.7071067f * (x_3 - x_2);
*(p_re_s + 1) = -0.7071067f * (x_1 - x_0);
*(p_im_s + 1) = -0.7071067f * (x_3 + x_2);
}
for (i = 0; i < len; i++) {
state[i] = out_im[i] - out_re[i];
state[len + i] = out_im[len - i - 1] + out_re[len - i - 1];
state[len - i - 1] = out_im[len - i - 1] - out_re[len - i - 1];
state[2 * len - i - 1] = out_im[i] + out_re[i];
}
}
VOID ixheaacd_mps_synt_calc(ia_mps_dec_state_struct *self) {
WORD32 k, l, ts, ch;
WORD64 acc;
WORD32 ptr_in[128];
WORD32 fin_re[128];
WORD32 fin_im[128];
FLOAT32 temp;
WORD32 *state, *tmp_state, *out;
const WORD32 *filt_coeff;
WORD32 *tmp_buf = self->tmp_buf;
FLOAT32 *state, *tmp_state, *out;
const FLOAT32 *filt_coeff;
FLOAT32 *tmp_buf = self->tmp_buf;
FLOAT32 fin_re[64] = {0};
FLOAT32 fin_im[64] = {0};
ia_mps_poly_phase_struct kernel = self->poly_phase_filt_kernel;
WORD32 resolution = kernel.resolution;
WORD32 m_resolution = resolution >> 1;
for (ch = 0; ch < self->out_ch_count; ch++) {
tmp_state = (&self->qmf_filt_state[ch])->state;
state = &tmp_buf[self->time_slots * 2 * resolution];
memcpy(state, tmp_state, sizeof(WORD32) * 20 * resolution);
memcpy(state, tmp_state, sizeof(FLOAT32) * 18 * resolution);
out = &tmp_buf[74 * MAX_NUM_QMF_BANDS_SAC];
for (ts = 0; ts < self->time_slots; ts++) {
ixheaacd_float_to_int32(&self->qmf_out_dir[ch][ts][0].re, ptr_in, 10,
resolution * 2);
filt_coeff = ixheaacd_mps_polyphase_filter_coeff_fix;
filt_coeff = ixheaacd_mps_polyphase_filter_coeff;
state -= (2 * resolution);
(*ixheaacd_mps_synt_pre_twiddle)(ptr_in, ixheaacd_mps_pre_re,
ixheaacd_mps_pre_im, resolution);
(*ixheaacd_mps_complex_fft_64)(ptr_in, fin_re, fin_im, resolution);
ixheaacd_mps_synth_pre_twidle(
fin_re, fin_im, &self->qmf_out_dir[ch][ts][0].re, resolution);
(*ixheaacd_mps_synt_post_twiddle)(ptr_in, ixheaacd_mps_post_re,
ixheaacd_mps_post_im, resolution);
ixheaacd_mps_synth_calc_fft(fin_re, fin_im, m_resolution);
(*ixheaacd_mps_complex_fft_64)(ptr_in, &fin_re[1], &fin_im[1],
resolution);
ixheaacd_mps_synth_post_twidle(state, fin_re, fin_im, resolution);
(*ixheaacd_mps_synt_post_fft_twiddle)(resolution, fin_re, fin_im,
ixheaacd_mps_post_re,
ixheaacd_mps_post_im, state);
(*ixheaacd_mps_synt_out_calc)(resolution, out, state, filt_coeff);
for (k = 0; k < resolution; k++) {
acc = 0;
for (l = 0; l < 10; l++) {
acc = acc + out[resolution * l + k];
FLOAT32 acc = out[k];
for (l = 1; l < 10; l++) {
acc += out[resolution * l + k];
}
if (acc >= 2147483647)
temp = 1.0;
else if (acc <= -2147483647 - 1)
temp = -1.0f;
else
temp = (FLOAT32)((WORD32)acc) / ((FLOAT32)(1 << 10));
self->output_buffer[ch][self->qmf_band_count * ts + k] = (FLOAT32)temp;
self->output_buffer[ch][self->qmf_band_count * ts + k] = acc;
}
}
memcpy(tmp_state, state, sizeof(WORD32) * 20 * resolution);
memcpy(tmp_state, state, sizeof(FLOAT32) * 18 * resolution);
}
}

View file

@ -21,9 +21,10 @@
#define IXHEAACD_MPS_POLYPHASE_H
#define MAX_NUM_QMF_BANDS_SAC (128)
#define POLY_PHASE_SYNTH_SIZE (1152)
typedef struct ia_mps_poly_phase_synth_struct {
WORD32 state[1280];
FLOAT32 state[POLY_PHASE_SYNTH_SIZE];
} ia_mps_poly_phase_synth_struct;
typedef struct ia_mps_poly_phase_struct {

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,7 @@
VOID ixheaacd_mps_res_buf_copy(ia_mps_dec_state_struct* self);
VOID ixheaacd_mps_qmf_hyb_analysis(ia_mps_dec_state_struct* self);
VOID ixheaacd_mps_qmf_hyb_analysis_no_pre_mix(ia_mps_dec_state_struct* self);
VOID ixheaacd_mps_qmf_hyb_synthesis(ia_mps_dec_state_struct* self);
VOID ixheaacd_mps_decor(ia_mps_dec_state_struct* self);
VOID ixheaacd_mps_create_w(ia_mps_dec_state_struct* self);

File diff suppressed because it is too large Load diff

View file

@ -32,18 +32,20 @@
VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing(
ia_mps_dec_state_struct *self) {
int smooth_band;
int delta, one_minus_delta;
FLOAT32 delta, one_minus_delta;
#ifndef MULT
#define MULT(a, b) (a * b)
#endif
int ps = 0, pb, row, col;
int res_bands = 0;
int *p_smoothing_data;
self->pre_mix_req = 0;
if (self->residual_coding) res_bands = self->max_res_bands;
p_smoothing_data = &self->smoothing_data[ps][res_bands];
delta = self->param_slot_diff[ps] * self->inv_smoothing_time[ps];
one_minus_delta = 1073741824 - delta;
one_minus_delta = 1.0f - delta;
for (pb = res_bands; pb < self->bs_param_bands; pb++) {
smooth_band = *p_smoothing_data++;
@ -51,43 +53,32 @@ VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing(
for (row = 0; row < MAX_M_OUTPUT; row++) {
for (col = 0; col < MAX_M_INPUT; col++) {
self->m1_param_re[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m1_param_re[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m1_param_re_prev[pb][row][col]))
<< 2;
(MULT(delta, self->m1_param_re[ps][pb][row][col]) +
MULT(one_minus_delta, self->m1_param_re_prev[pb][row][col]));
self->m1_param_im[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m1_param_im[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m1_param_im_prev[pb][row][col]))
<< 2;
(MULT(delta, self->m1_param_im[ps][pb][row][col]) +
MULT(one_minus_delta, self->m1_param_im_prev[pb][row][col]));
self->m2_decor_re[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_decor_re[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_decor_re_prev[pb][row][col]))
<< 2;
(MULT(delta, self->m2_decor_re[ps][pb][row][col]) +
MULT(one_minus_delta, self->m2_decor_re_prev[pb][row][col]));
self->m2_decor_im[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_decor_im[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_decor_im_prev[pb][row][col]))
<< 2;
(MULT(delta, self->m2_decor_im[ps][pb][row][col]) +
MULT(one_minus_delta, self->m2_decor_im_prev[pb][row][col]));
self->m2_resid_re[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_resid_re[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_resid_re_prev[pb][row][col]))
<< 2;
(MULT(delta, self->m2_resid_re[ps][pb][row][col]) +
MULT(one_minus_delta, self->m2_resid_re_prev[pb][row][col]));
self->m2_resid_im[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_resid_im[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_resid_im_prev[pb][row][col]))
<< 2;
(MULT(delta, self->m2_resid_im[ps][pb][row][col]) +
MULT(one_minus_delta, self->m2_resid_im_prev[pb][row][col]));
}
}
self->pre_mix_req++;
}
}
for (ps = 1; ps < self->num_parameter_sets; ps++) {
delta = self->param_slot_diff[ps] * self->inv_smoothing_time[ps];
one_minus_delta = 1073741824 - delta;
one_minus_delta = 1.0f - delta;
p_smoothing_data = &self->smoothing_data[ps][res_bands];
@ -97,37 +88,32 @@ VOID ixheaacd_mps_pre_matrix_mix_matrix_smoothing(
for (row = 0; row < MAX_M_OUTPUT; row++) {
for (col = 0; col < MAX_M_INPUT; col++) {
self->m1_param_re[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m1_param_re[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m1_param_re[ps - 1][pb][row][col]))
<< 2;
(MULT(delta, self->m1_param_re[ps][pb][row][col]) +
MULT(one_minus_delta,
self->m1_param_re[ps - 1][pb][row][col]));
self->m1_param_im[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m1_param_im[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m1_param_im[ps - 1][pb][row][col]))
<< 2;
(MULT(delta, self->m1_param_im[ps][pb][row][col]) +
MULT(one_minus_delta,
self->m1_param_im[ps - 1][pb][row][col]));
self->m2_resid_re[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_resid_re[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_resid_re[ps - 1][pb][row][col]))
<< 2;
(MULT(delta, self->m2_resid_re[ps][pb][row][col]) +
MULT(one_minus_delta,
self->m2_resid_re[ps - 1][pb][row][col]));
self->m2_decor_re[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_decor_re[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_decor_re[ps - 1][pb][row][col]))
<< 2;
(MULT(delta, self->m2_decor_re[ps][pb][row][col]) +
MULT(one_minus_delta,
self->m2_decor_re[ps - 1][pb][row][col]));
self->m2_decor_im[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_decor_im[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_decor_im[ps - 1][pb][row][col]))
<< 2;
(MULT(delta, self->m2_decor_im[ps][pb][row][col]) +
MULT(one_minus_delta,
self->m2_decor_im[ps - 1][pb][row][col]));
self->m2_resid_im[ps][pb][row][col] =
(ixheaacd_mult32(delta, self->m2_resid_im[ps][pb][row][col]) +
ixheaacd_mult32(one_minus_delta,
self->m2_resid_im[ps - 1][pb][row][col]))
<< 2;
(MULT(delta, self->m2_resid_im[ps][pb][row][col]) +
MULT(one_minus_delta,
self->m2_resid_im[ps - 1][pb][row][col]));
}
}
self->pre_mix_req++;
}
}
}
@ -145,10 +131,15 @@ VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self) {
if (self->opd_smoothing_mode == 0) {
for (pb = 0; pb < self->bs_param_bands; pb++) {
#define Q28_VALUE (1 << 28)
self->opd_smooth.smooth_l_phase[pb] =
self->phase_l_fix[self->num_parameter_sets - 1][pb] >> 1;
((WORD32)(self->phase_l[self->num_parameter_sets - 1][pb] *
Q28_VALUE)) >>
1;
self->opd_smooth.smooth_r_phase[pb] =
self->phase_r_fix[self->num_parameter_sets - 1][pb] >> 1;
((WORD32)(self->phase_r[self->num_parameter_sets - 1][pb] *
Q28_VALUE)) >>
1;
}
return;
}
@ -162,9 +153,10 @@ VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self) {
for (pb = 0; pb < self->bs_param_bands; pb++) {
int ltemp, rtemp, tmp;
ltemp = self->phase_l_fix[ps][pb] >> 1;
rtemp = self->phase_r_fix[ps][pb] >> 1;
#define Q28_FLOAT_VAL ((float)(1 << 28))
#define ONE_BY_Q28_FLOAT_VAL (1.0 / Q28_FLOAT_VAL)
ltemp = ((WORD32)(self->phase_l[ps][pb] * Q28_FLOAT_VAL)) >> 1;
rtemp = ((WORD32)(self->phase_r[ps][pb] * Q28_FLOAT_VAL)) >> 1;
while (ltemp > self->opd_smooth.smooth_l_phase[pb] + PI_IN_Q27)
ltemp -= 2 * PI_IN_Q27;
@ -204,9 +196,14 @@ VOID ixheaacd_mps_smoothing_opd(ia_mps_dec_state_struct *self) {
self->opd_smooth.smooth_r_phase[pb] -= 2 * PI_IN_Q27;
while (self->opd_smooth.smooth_r_phase[pb] < 0)
self->opd_smooth.smooth_r_phase[pb] += 2 * PI_IN_Q27;
self->phase_l_fix[ps][pb] = self->opd_smooth.smooth_l_phase[pb] << 1;
self->phase_r_fix[ps][pb] = self->opd_smooth.smooth_r_phase[pb] << 1;
#define Q28_FLOAT_VAL ((float)(1 << 28))
#ifndef ONE_BY_Q28_FLOAT_VAL
#define ONE_BY_Q28_FLOAT_VAL (1.0f / Q28_FLOAT_VAL)
#endif
self->phase_l[ps][pb] =
(self->opd_smooth.smooth_l_phase[pb] << 1) * ONE_BY_Q28_FLOAT_VAL;
self->phase_r[ps][pb] =
(self->opd_smooth.smooth_r_phase[pb] << 1) * ONE_BY_Q28_FLOAT_VAL;
}
}
}

View file

@ -80,6 +80,8 @@ static const FLOAT32 ixheaacd_gf[BP_SIZE] = {
9.801e-005f, 0.00012321f, 0.00015625f, 0.00019881f, 0.00024964f,
0.00032041f, 0.00041209f, 0.00053824f, 0.00070756f, 0.00094249f};
extern const WORD32 ixheaacd_mps_gain_set_indx[29];
static VOID ixheaacd_mps_temp_process_scale_calc(ia_mps_dec_state_struct* self,
WORD32 ts, FLOAT32* scale) {
FLOAT32 dir_energy;
@ -182,7 +184,7 @@ static VOID ixheaacd_mps_subbandtp(ia_mps_dec_state_struct* self, WORD32 ts) {
no_scaling = !self->temp_shape_enable_ch_stp[ch];
if (no_scaling == 1) {
for (n = 0; n < self->hyb_band_count; n++) {
for (n = 0; n < self->hyb_band_count_max; n++) {
self->hyb_dir_out[ch][ts][n].re += self->hyb_diff_out[ch][ts][n].re;
self->hyb_dir_out[ch][ts][n].im += self->hyb_diff_out[ch][ts][n].im;
}
@ -202,7 +204,7 @@ static VOID ixheaacd_mps_subbandtp(ia_mps_dec_state_struct* self, WORD32 ts) {
self->hyb_dir_out[ch][ts][n].im +=
(self->hyb_diff_out[ch][ts][n].im * temp);
}
for (; n < self->hyb_band_count; n++) {
for (; n < self->hyb_band_count_max; n++) {
temp = (FLOAT32)(scale[ch]);
self->hyb_dir_out[ch][ts][n].re +=
(self->hyb_diff_out[ch][ts][n].re * temp);
@ -216,20 +218,46 @@ static VOID ixheaacd_mps_subbandtp(ia_mps_dec_state_struct* self, WORD32 ts) {
WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) {
WORD32 ch, ts, hyb;
WORD32 err = 0;
ia_sbr_frame_info_data_struct* ptr_frame_data =
(ia_sbr_frame_info_data_struct*)self->p_sbr_frame[0];
if (self->res_bands != 28) {
if (self->config->bs_temp_shape_config == 1) {
WORD32 dif_s = ((self->res_bands == 0)
? 0
: ixheaacd_mps_gain_set_indx[self->res_bands]);
for (ch = 0; ch < self->out_ch_count; ch++) {
for (ts = 0; ts < self->time_slots; ts++) {
for (hyb = dif_s; hyb < HYBRID_BAND_BORDER; hyb++) {
self->hyb_dir_out[ch][ts][hyb].re +=
self->hyb_diff_out[ch][ts][hyb].re;
self->hyb_dir_out[ch][ts][hyb].im +=
self->hyb_diff_out[ch][ts][hyb].im;
self->hyb_diff_out[ch][ts][hyb].re = 0;
self->hyb_diff_out[ch][ts][hyb].im = 0;
}
}
}
for (ch = 0; ch < self->out_ch_count; ch++) {
for (ts = 0; ts < self->time_slots; ts++) {
for (hyb = 0; hyb < HYBRID_BAND_BORDER; hyb++) {
self->hyb_dir_out[ch][ts][hyb].re += self->hyb_diff_out[ch][ts][hyb].re;
self->hyb_dir_out[ch][ts][hyb].im += self->hyb_diff_out[ch][ts][hyb].im;
self->hyb_diff_out[ch][ts][hyb].re = 0;
self->hyb_diff_out[ch][ts][hyb].im = 0;
for (ts = 0; ts < self->time_slots; ts++)
ixheaacd_mps_subbandtp(self, ts);
} else {
WORD32 dif_s = ((self->res_bands == 0)
? 0
: ixheaacd_mps_gain_set_indx[self->res_bands]);
for (ch = 0; ch < self->out_ch_count; ch++) {
for (ts = 0; ts < self->time_slots; ts++) {
for (hyb = dif_s; hyb < self->hyb_band_count_max; hyb++) {
self->hyb_dir_out[ch][ts][hyb].re +=
self->hyb_diff_out[ch][ts][hyb].re;
self->hyb_dir_out[ch][ts][hyb].im +=
self->hyb_diff_out[ch][ts][hyb].im;
}
}
}
}
}
for (ts = 0; ts < self->time_slots; ts++) ixheaacd_mps_subbandtp(self, ts);
ixheaacd_mps_qmf_hyb_synthesis(self);
for (ch = 0; ch < self->out_ch_count; ch++) {
@ -239,6 +267,13 @@ WORD32 ixheaacd_mps_temp_process(ia_mps_dec_state_struct* self) {
if (err) return err;
}
if (ptr_frame_data->mps_sbr_flag) {
self->synth_count =
ptr_frame_data->pstr_sbr_header->pstr_freq_band_data->sub_band_end;
} else {
self->synth_count = self->band_count[0];
}
ixheaacd_mps_synt_calc(self);
return err;
}

View file

@ -67,7 +67,7 @@ static VOID ixheaacd_mps_est_normalized_envelope(ia_mps_dec_state_struct *self,
case DIR_DIFF_IN:
ch_offset = 0;
for (ii = 0; ii < self->time_slots; ii++) {
for (jj = 0; jj < self->hyb_band_count; jj++) {
for (jj = 0; jj < self->hyb_band_count_max; jj++) {
slot_energy[ii]
[ixheaacd_hybrid_band_71_to_processing_band_20_map[jj]] +=
((self->hyb_dir_out[ch][ii][jj].re +
@ -83,14 +83,26 @@ static VOID ixheaacd_mps_est_normalized_envelope(ia_mps_dec_state_struct *self,
break;
case DOWNMIX_IN:
ch_offset = self->out_ch_count;
for (ii = 0; ii < self->time_slots; ii++) {
for (jj = 0; jj < self->hyb_band_count; jj++) {
slot_energy[ii]
[ixheaacd_hybrid_band_71_to_processing_band_20_map[jj]] +=
self->hyb_in[ch][ii][jj].re * self->hyb_in[ch][ii][jj].re +
self->hyb_in[ch][ii][jj].im * self->hyb_in[ch][ii][jj].im;
if ((self->pre_mix_req | self->bs_tsd_enable)) {
for (ii = 0; ii < self->time_slots; ii++) {
for (jj = 0; jj < self->hyb_band_count_max; jj++) {
slot_energy
[ii][ixheaacd_hybrid_band_71_to_processing_band_20_map[jj]] +=
self->hyb_in[ch][jj][ii].re * self->hyb_in[ch][jj][ii].re +
self->hyb_in[ch][jj][ii].im * self->hyb_in[ch][jj][ii].im;
}
}
} else {
for (ii = 0; ii < self->time_slots; ii++) {
for (jj = 0; jj < self->hyb_band_count_max; jj++) {
slot_energy
[ii][ixheaacd_hybrid_band_71_to_processing_band_20_map[jj]] +=
self->w_dir[ch][ii][jj].re * self->w_dir[ch][ii][jj].re +
self->w_dir[ch][ii][jj].im * self->w_dir[ch][ii][jj].im;
}
}
}
break;
default:
ch_offset = 0;
@ -168,7 +180,7 @@ VOID ixheaacd_mps_time_env_shaping(ia_mps_dec_state_struct *self) {
amp_direct = 0;
amp_diff = 0;
for (jj = band_start; jj < self->hyb_band_count; jj++) {
for (jj = band_start; jj < self->hyb_band_count_max; jj++) {
amp_direct += self->hyb_dir_out[ch][time_slot][jj].re *
self->hyb_dir_out[ch][time_slot][jj].re +
self->hyb_dir_out[ch][time_slot][jj].im *
@ -184,7 +196,7 @@ VOID ixheaacd_mps_time_env_shaping(ia_mps_dec_state_struct *self) {
ratio = min(max((gain + amp_ratio * (gain - 1)), 1 / LAMDA), LAMDA);
for (jj = band_start; jj < self->hyb_band_count; jj++) {
for (jj = band_start; jj < self->hyb_band_count_max; jj++) {
self->hyb_dir_out[ch][time_slot][jj].re *= ratio;
self->hyb_dir_out[ch][time_slot][jj].im *= ratio;
}

View file

@ -383,6 +383,13 @@ WORD32 ixheaacd_usac_process(ia_dec_data_struct *pstr_dec_data,
pstr_usac_data->usac_independency_flg, it_bit_buff);
if (err) return err;
p_state_aac_dec->mps_dec_handle.band_count[0] =
pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[0]
->str_sbr_dec.band_count;
p_state_aac_dec->mps_dec_handle.band_count[1] =
pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[1]
->str_sbr_dec.band_count;
for (ch = 0; ch < nr_core_coder_channels; ch++) {
ptr_inp[2 * ch] =
pstr_usac_data->pstr_esbr_dec->pstr_sbr_channel[ch]

View file

@ -453,6 +453,11 @@ const WORD32 ixheaacd_twiddle_table_fft_32x32[514] = {
0x8009de7e, 0x03242abe, 0x80058d2f, 0x025b26d7, 0x800277a6, 0x01921d1f,
0x80009dea, 0x00c90f87, 0x80000000, 0x00000000};
const FLOAT32 ixheaacd_twiddle_table_fft_flt[16] = {
1.000000f, -0.000000f, 0.980785f, -0.195090f, 0.923880f, -0.382683f,
0.831470f, -0.555570f, 0.707107f, -0.707107f, 0.555570f, -0.831470f,
0.382683f, -0.923880f, 0.195090f, -0.980785f};
const WORD32 ixheaacd_twiddle_table_3pr[1155] = {
0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7ffb9d14, 0x7fee74a1,
0x7fffffff, 0x7fee74a1, 0x7fb9d757, 0x7fffffff, 0x7fd8878c, 0x7f62368e,
@ -4291,5 +4296,4 @@ const FLOAT32 ixheaacd_dico_lsf_abs_8b_flt[16 * 256] = {
2437.3232f, 2691.4072f, 3030.3025f, 3524.1379f, 3771.7576f, 4083.2375f,
4601.1567f, 4963.4697f, 5434.8530f, 5942.8315f};
const WORD8 ixheaacd_mps_dig_rev[16] = {0, 8, 16, 24, 2, 10, 18, 26,
4, 12, 20, 28, 6, 14, 22, 30};
const WORD8 ixheaacd_mps_dig_rev[8] = {0, 4, 8, 12, 2, 6, 10, 14};

View file

@ -285,10 +285,6 @@ VOID ixheaacd_esbr_analysis_filt_block(ia_sbr_dec_struct *ptr_sbr_dec,
ptr_sbr_dec->qmf_buf_imag[op_delay + idx][z] =
((FLOAT32)ploc_qmf_buf_imag[z] * gain);
}
for (z = core_syn_ch_index; z < num_columns; z++) {
ptr_sbr_dec->qmf_buf_real[op_delay + idx][z] = (FLOAT32)0.0f;
ptr_sbr_dec->qmf_buf_imag[op_delay + idx][z] = (FLOAT32)0.0f;
}
}
pstr_qmf_anal_bank->filter_pos_32 = ptr_win_coeffs_1;
@ -735,7 +731,6 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data,
ptr_sbr_dec->p_hbe_txposer->max_stretch);
}
}
ixheaacd_qmf_enrg_calc(ptr_sbr_dec, upsample_ratio_idx, low_pow_flag);
if (!mps_sbr_flag && apply_processing) {
WORD32 err_code = 0;
@ -752,6 +747,7 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data,
ptr_pvc_data->pvc_rate = ptr_header_data->upsamp_fac;
if (sbr_mode == PVC_SBR) {
ixheaacd_qmf_enrg_calc(ptr_sbr_dec, upsample_ratio_idx, low_pow_flag);
err_code = ixheaacd_pvc_process(
ptr_pvc_data, ptr_header_data->pstr_freq_band_data->sub_band_start,
ptr_frame_data->str_pvc_frame_info.border_vec[0],
@ -788,6 +784,12 @@ WORD32 ixheaacd_sbr_dec(ia_sbr_dec_struct *ptr_sbr_dec, WORD16 *ptr_time_data,
}
}
if (!mps_sbr_flag) {
ptr_sbr_dec->band_count =
ptr_header_data->pstr_freq_band_data->sub_band_end;
} else
ptr_sbr_dec->band_count = ptr_sbr_dec->str_codec_qmf_bank.no_channels;
ixheaacd_esbr_synthesis_filt_block(
ptr_sbr_dec, ptr_header_data, ptr_frame_data, apply_processing,
pp_qmf_buf_real, pp_qmf_buf_imag, stereo_config_idx, sbr_tables_ptr,
@ -1135,6 +1137,8 @@ WORD32 ixheaacd_esbr_dec(ia_sbr_dec_struct *ptr_sbr_dec,
memset(ptr_sbr_dec->sbr_qmf_out_imag[i], 0, 64 * sizeof(FLOAT32));
}
ptr_sbr_dec->band_count = ptr_sbr_dec->str_codec_qmf_bank.no_channels;
ixheaacd_esbr_synthesis_filt_block(
ptr_sbr_dec, ptr_header_data, ptr_frame_data, apply_processing,
pp_qmf_buf_real, pp_qmf_buf_imag, stereo_config_idx, ptr_sbr_tables,
@ -1168,6 +1172,8 @@ WORD32 ixheaacd_sbr_dec_from_mps(FLOAT32 *p_mps_qmf_output, VOID *p_sbr_dec,
if (!mps_sbr_flag) {
return 0;
} else {
ptr_frame_data->cov_count = ptr_sbr_dec->str_codec_qmf_bank.no_channels;
}
no_bins = ptr_header_data->output_framesize / 64;

View file

@ -67,6 +67,7 @@ typedef struct {
ia_sbr_scale_fact_struct str_sbr_scale_fact;
WORD32 max_samp_val;
WORD32 band_count;
ia_esbr_hbe_txposer_struct *p_hbe_txposer;
FLOAT32 core_sample_buf[2624];

View file

@ -543,6 +543,7 @@ ia_handle_sbr_dec_inst_struct ixheaacd_init_sbr(
audio_object_type);
ptr_header_data[i]->status = 1;
ptr_sbr_dec[i]->band_count = 64;
if (err) {
return NULL;

View file

@ -981,7 +981,7 @@ WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64],
WORD32 pre_proc_flag = ptr_header_data->pre_proc_flag;
WORD32 is_usf_4 = ptr_header_data->is_usf_4;
WORD32 fs = ptr_header_data->out_sampling_freq;
WORD32 cov_count;
WORD32 lsb = f_master_tbl[0];
WORD32 usb = f_master_tbl[num_mf_bands];
WORD32 xover_offset = sub_band_start - f_master_tbl[0];
@ -1023,9 +1023,16 @@ WORD32 ixheaacd_generate_hf(FLOAT32 ptr_src_buf_real[][64],
}
if (sbr_patching_mode || !hbe_flag) {
FLOAT32 alpha_real[64][2], alpha_imag[64][2];
FLOAT32 alpha_real[64][2] = {{0}}, alpha_imag[64][2] = {{0}};
if (ptr_frame_data->mps_sbr_flag) {
cov_count = (f_master_tbl[0] < ptr_frame_data->cov_count)
? f_master_tbl[0]
: ptr_frame_data->cov_count;
} else {
cov_count = f_master_tbl[0];
}
for (k = 1; k < f_master_tbl[0]; k++) {
for (k = 1; k < cov_count; k++) {
ixheaacd_esbr_calc_co_variance(&str_auto_corr, &ptr_src_buf_real[0],
&ptr_src_buf_imag[0], k, co_var_len);
if (str_auto_corr.det == 0.0f) {

View file

@ -193,18 +193,6 @@ VOID(*ixheaacd_complex_fft_p2)
(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode,
WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec;
VOID(*ixheaacd_mps_complex_fft_64)
(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im,
WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec;
VOID(*ixheaacd_mps_synt_pre_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec;
VOID(*ixheaacd_mps_synt_post_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec;
VOID(*ixheaacd_calc_pre_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec;
@ -213,14 +201,9 @@ VOID(*ixheaacd_calc_post_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec;
VOID(*ixheaacd_mps_synt_post_fft_twiddle)
(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec;
VOID(*ixheaacd_mps_synt_out_calc)
(WORD32 resolution, WORD32 *out, WORD32 *state,
const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
(WORD32 resolution, FLOAT32 *out, FLOAT32 *state,
const FLOAT32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
VOID(*ixheaacd_fft_15_ld)
(WORD32 *inp, WORD32 *op, WORD32 *fft3out,

View file

@ -193,18 +193,6 @@ VOID(*ixheaacd_complex_fft_p2)
(WORD32 *xr, WORD32 *xi, WORD32 nlength, WORD32 fft_mode,
WORD32 *preshift) = &ixheaacd_complex_fft_p2_dec;
VOID(*ixheaacd_mps_complex_fft_64)
(WORD32 *ptr_x, WORD32 *fin_re, WORD32 *fin_im,
WORD32 nlength) = &ixheaacd_mps_complex_fft_64_dec;
VOID(*ixheaacd_mps_synt_pre_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_pre_twiddle_dec;
VOID(*ixheaacd_mps_synt_post_twiddle)
(WORD32 *ptr_in, const WORD32 *table_re, const WORD32 *table_im,
WORD32 resolution) = &ixheaacd_mps_synt_post_twiddle_dec;
VOID(*ixheaacd_calc_pre_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_pre_twid_dec;
@ -213,14 +201,9 @@ VOID(*ixheaacd_calc_post_twid)
(WORD32 *ptr_x, WORD32 *r_ptr, WORD32 *i_ptr, WORD32 nlength,
const WORD32 *cos_ptr, const WORD32 *sin_ptr) = &ixheaacd_calc_post_twid_dec;
VOID(*ixheaacd_mps_synt_post_fft_twiddle)
(WORD32 resolution, WORD32 *fin_re, WORD32 *fin_im, const WORD32 *table_re,
const WORD32 *table_im,
WORD32 *state) = &ixheaacd_mps_synt_post_fft_twiddle_dec;
VOID(*ixheaacd_mps_synt_out_calc)
(WORD32 resolution, WORD32 *out, WORD32 *state,
const WORD32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
(WORD32 resolution, FLOAT32 *out, FLOAT32 *state,
const FLOAT32 *filter_coeff) = &ixheaacd_mps_synt_out_calc_dec;
VOID(*ixheaacd_fft_15_ld)
(WORD32 *inp, WORD32 *op, WORD32 *fft3out,