From 395cb83a0d2a3c23928105a6dbee16708d232b88 Mon Sep 17 00:00:00 2001 From: wrapper Date: Thu, 14 Aug 2025 16:41:52 +0700 Subject: [PATCH 01/11] what --- encoder/ixheaace_sbr_code_envelope_lp.c | 11 +++++++++++ encoder/ixheaace_sbr_env_est.c | 15 +++++++++++++- encoder/ixheaace_sbr_main.c | 7 +++++++ encoder/ixheaace_sbr_noise_floor_est.c | 26 ++++++++++++++++++++++--- encoder/ixheaace_sbr_ton_corr.c | 3 +++ encoder/ixheaace_sbr_write_bitstream.c | 2 ++ test/encoder/ixheaace_testbench.c | 2 +- 7 files changed, 61 insertions(+), 5 deletions(-) diff --git a/encoder/ixheaace_sbr_code_envelope_lp.c b/encoder/ixheaace_sbr_code_envelope_lp.c index 95c9adf..187a8bc 100644 --- a/encoder/ixheaace_sbr_code_envelope_lp.c +++ b/encoder/ixheaace_sbr_code_envelope_lp.c @@ -18,6 +18,7 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ +#include #include #include "ixheaac_type_def.h" @@ -138,13 +139,18 @@ IA_ERRORCODE ixheaace_code_envelope(WORD32 *ptr_sfb_energy, const ixheaace_freq_ ptr_energy = ptr_sfb_energy; current_energy = *ptr_energy; + printf("delta_f[0]: %d\n", delta_f[0]); + printf("comp_factor: %d\n", env_data_tab_comp_factor); + printf("energy[0]: %d\n", current_energy); delta_f[0] = ixheaac_shr32(current_energy, env_data_tab_comp_factor); + printf("delta_f[0] (post): %d\n", delta_f[0]); if (coupling && channel == 1) delta_f_bits = pstr_code_env->start_bits_balance; else delta_f_bits = pstr_code_env->start_bits; if (pstr_code_env->update != 0) { + printf("delta_t[0]: %d\n", delta_t[0]); delta_t[0] = ixheaac_shr32((current_energy - pstr_code_env->sfb_nrg_prev[0]), env_data_tab_comp_factor); @@ -180,6 +186,7 @@ IA_ERRORCODE ixheaace_code_envelope(WORD32 *ptr_sfb_energy, const ixheaace_freq_ last_nrg = *ptr_energy++; current_energy = *ptr_energy; delta_f[band] = ixheaac_shr32((current_energy - last_nrg), env_data_tab_comp_factor); + printf("delta_f[%d]: %d\n", band, delta_f[band]); err_code = ixheaace_compute_bits( delta_f[band], code_book_scf_lav_lvl_freq, code_book_scf_lav_bal_freq, @@ -192,8 +199,10 @@ IA_ERRORCODE ixheaace_code_envelope(WORD32 *ptr_sfb_energy, const ixheaace_freq_ if (pstr_code_env->update != 0) { delta_lcl_bits = 0; index = ixheaace_index_low2_high(offset, band, freq_res[i]); + printf("delta_t[%d] (before): %d\n", band, delta_t[band]); delta_t[band] = current_energy - pstr_code_env->sfb_nrg_prev[index]; delta_t[band] = ixheaac_shr32(delta_t[band], env_data_tab_comp_factor); + printf("delta_t[%d]: %d\n", band, delta_t[band]); ixheaace_map_low_res_energy_value(current_energy, pstr_code_env->sfb_nrg_prev, offset, band, freq_res[i]); @@ -226,9 +235,11 @@ IA_ERRORCODE ixheaace_code_envelope(WORD32 *ptr_sfb_energy, const ixheaace_freq_ if (use_dt) { ptr_dir_vec[i] = TIME; + printf("dt: 0x%08llx\n", (unsigned long long)delta_t); memcpy(ptr_sfb_energy, delta_t, no_of_bands * sizeof(ptr_sfb_energy[0])); } else { ptr_dir_vec[i] = FREQ; + printf("df: 0x%08llx\n", (unsigned long long)delta_f); memcpy(ptr_sfb_energy, delta_f, no_of_bands * sizeof(ptr_sfb_energy[0])); } if (0 == i && 1 == usac_indep_flag) { diff --git a/encoder/ixheaace_sbr_env_est.c b/encoder/ixheaace_sbr_env_est.c index 9f78654..63052e4 100644 --- a/encoder/ixheaace_sbr_env_est.c +++ b/encoder/ixheaace_sbr_env_est.c @@ -18,6 +18,7 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ +#include #include #include #include @@ -147,6 +148,7 @@ static VOID ixheaace_sbr_noise_floor_levels_quantisation(WORD32 *ptr_noise_level WORD32 tmp; tmp = ptr_flt_noise_levels[i] > 30.0f ? 30 : (WORD32)(ptr_flt_noise_levels[i] + 0.5f); + printf("noise_levels[%d]: %f\n", i, ptr_flt_noise_levels[i]); if (coupling) { tmp = tmp < -30 ? -30 : tmp; @@ -1878,6 +1880,7 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co IXHEAACE_MAX_CH_IN_BS_ELE * MAXIMUM_NUM_ENVELOPE_VALUES; ptr_noise_floor[ch] = pstr_env_ch[ch]->str_sbr_extract_env.ptr_i_buffer[0] + IXHEAACE_MAX_CH_IN_BS_ELE * MAXIMUM_NUM_ENVELOPE_VALUES * 2; + printf("ptr_noise_floor[%d][0] = %f\n", ch, ptr_noise_floor[ch][0]); ch++; } if ((pstr_sbr_cfg->sbr_codec == USAC_SBR) && (pstr_sbr_hdr->sbr_harmonic)) { @@ -2317,6 +2320,7 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co } } + printf("(pre) ptr_noise_floor[%d][0] = %f\n", ch, ptr_noise_floor[ch][0]); ixheaace_ton_corr_param_extr( &pstr_env_ch[ch]->str_ton_corr, pstr_env_ch[ch]->enc_env_data.sbr_invf_mode_vec, ptr_noise_floor[ch], &pstr_env_ch[ch]->enc_env_data.add_harmonic_flag, @@ -2324,6 +2328,7 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co pstr_const_frame_info[ch], transient_info[ch], pstr_sbr_cfg->ptr_freq_band_tab[HI], pstr_sbr_cfg->num_scf[HI], pstr_env_ch[ch]->enc_env_data.sbr_xpos_mode, ptr_sbr_scratch, pstr_sbr_cfg->is_ld_sbr); + printf("(pre) post_noise_floor[%d][0] = %f\n", ch, ptr_noise_floor[ch][0]); pstr_env_ch[ch]->enc_env_data.sbr_invf_mode = pstr_env_ch[ch]->enc_env_data.sbr_invf_mode_vec[0]; @@ -2406,8 +2411,9 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co switch (stereo_mode) { case IXHEAACE_SBR_MODE_MONO: - + printf("mono compute 1 pre: %d\n", ptr_noise_level[0][0]); ixheaace_sbr_noise_floor_levels_quantisation(ptr_noise_level[0], ptr_noise_floor[0], 0); + printf("mono compute 1: %d\n", ptr_noise_level[0][0]); err_code = ixheaace_code_envelope( ptr_noise_level[0], res, &pstr_env_ch[0]->str_sbr_code_noise_floor, @@ -2417,6 +2423,8 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co return err_code; } + printf("sfb_en1: %d\n", ptr_noise_level[0][0]); + break; case IXHEAACE_SBR_MODE_LEFT_RIGHT: @@ -2492,6 +2500,8 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co pstr_sbr_hdr->coupling = 0; pstr_env_0->balance = 0; + printf("mono compute 2\n"); + err_code = ixheaace_code_envelope( ptr_scale_factor_band_nrg[0], pstr_const_frame_info[0]->freq_res, &pstr_env_ch[0]->str_sbr_code_env, pstr_env_0->domain_vec, pstr_sbr_hdr->coupling, @@ -2627,6 +2637,7 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co i = 0; while (i < MAXIMUM_NUM_NOISE_VALUES) { pstr_env_0->noise_level[i] = ptr_noise_level[0][i]; + printf("noise_level_0: %i\n", ptr_noise_level[0][i]); i++; } @@ -2641,6 +2652,7 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co i = 0; while (i < MAXIMUM_NUM_NOISE_VALUES) { pstr_env_1->noise_level[i] = ptr_noise_level[1][i]; + printf("noise_level_1: %i\n", ptr_noise_level[1][i]); i++; } @@ -2838,6 +2850,7 @@ IA_ERRORCODE ixheaace_extract_sbr_envelope(FLOAT32 *ptr_in_time, FLOAT32 *ptr_co i = 0; while (i < MAXIMUM_NUM_NOISE_VALUES) { pstr_env_ch[ch]->enc_env_data.noise_level[i] = ptr_noise_level[ch][i]; + printf("noise_level_%d: %d\n", ch, ptr_noise_level[ch][i]); i++; } } diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index b8594e8..d13d5e8 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -18,6 +18,7 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ +#include #include #include "ixheaac_type_def.h" @@ -617,6 +618,8 @@ static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( return err_code; } + printf("k0: %d, k2: %d, fs: %d\n", k0, k2, pstr_sbr_hdr->freq_scale); + err_code = ixheaace_update_freq_scale( pstr_sbr_cfg->ptr_v_k_master, &pstr_sbr_cfg->num_master, k0, k2, pstr_sbr_hdr->freq_scale, pstr_sbr_hdr->alter_scale, pstr_sbr_hdr->sample_rate_mode); @@ -624,6 +627,7 @@ static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( return err_code; } + printf("master: %d, alter: %d, srMode: %d\n", pstr_sbr_cfg->num_master, pstr_sbr_hdr->alter_scale, pstr_sbr_hdr->sample_rate_mode); pstr_sbr_hdr->sbr_xover_band = 0; ixheaace_update_high_res(pstr_sbr_cfg->ptr_freq_band_tab[HI], &pstr_sbr_cfg->num_scf[HI], @@ -634,6 +638,9 @@ static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( ixheaace_update_low_res(pstr_sbr_cfg->ptr_freq_band_tab[LO], &pstr_sbr_cfg->num_scf[LO], pstr_sbr_cfg->ptr_freq_band_tab[HI], pstr_sbr_cfg->num_scf[HI]); + printf("hi: %d\n", pstr_sbr_cfg->ptr_freq_band_tab[HI][0]); + printf("lo: %d\n", pstr_sbr_cfg->ptr_freq_band_tab[LO][0]); + pstr_sbr_cfg->xover_freq = (pstr_sbr_cfg->ptr_freq_band_tab[LOW_RES][0] * pstr_sbr_cfg->sample_freq / num_qmf_ch + 1) >> diff --git a/encoder/ixheaace_sbr_noise_floor_est.c b/encoder/ixheaace_sbr_noise_floor_est.c index c5fcd99..e60692a 100644 --- a/encoder/ixheaace_sbr_noise_floor_est.c +++ b/encoder/ixheaace_sbr_noise_floor_est.c @@ -18,6 +18,7 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ +#include #include #include @@ -101,7 +102,10 @@ static VOID ia_enhaacplus_enc_qmf_based_noise_floor_detection( WORD32 ch, idx; FLOAT32 ton_org, ton_sbr, mean_org = 0, mean_sbr = 0, diff; + printf("start: %d, stop: %d\n", start_channel, stop_channel); + if (1 == missing_harmonic_flag) { + printf("hsbr flag\n"); for (ch = start_channel; ch < stop_channel; ch++) { ton_org = 0; ton_sbr = 0; @@ -133,13 +137,21 @@ static VOID ia_enhaacplus_enc_qmf_based_noise_floor_detection( ton_org /= (stop_index - start_index); ton_sbr /= (stop_index - start_index); + printf("mean org pre: %f\n", mean_org); mean_org += ton_org; mean_sbr += ton_sbr; } - mean_org /= (stop_channel - start_channel); - mean_sbr /= (stop_channel - start_channel); + + if ((stop_channel - start_channel) > 0) { + printf("mean_org: %f\n", mean_org); + mean_org /= (stop_channel - start_channel); + printf("mean_org 2: %f\n", mean_org); + mean_sbr /= (stop_channel - start_channel); + } } + printf("mean org index: %f\n", mean_org); + if (mean_org < SBR_TON_MEAN_P0009 && mean_sbr < SBR_TON_MEAN_P0009) { mean_org = mean_sbr = SBR_TON_MEAN_101P59; } @@ -171,6 +183,8 @@ static VOID ia_enhaacplus_enc_qmf_based_noise_floor_detection( diff = 1.0f; } + printf("diff: %f, mean_org: %f\n", diff, mean_org); + *ptr_noise_lvl = diff / mean_org; *ptr_noise_lvl *= noise_floor_offset; @@ -203,12 +217,14 @@ VOID ixheaace_sbr_noise_floor_estimate_qmf( for (env = 0; env < n_noise_envelopes; env++) { for (band = 0; band < num_of_noise_bands; band++) { + printf("noise floor detect (pre): %f\n", ptr_noise_lvls[band + env * num_of_noise_bands]); ia_enhaacplus_enc_qmf_based_noise_floor_detection( &ptr_noise_lvls[band + env * num_of_noise_bands], ptr_quota_orig, pstr_noise_floor_est_sbr->weight_fac, pstr_noise_floor_est_sbr->max_level, 1.0f, ptr_idx_vx, start_pos[env], stop_pos[env], ptr_freq_band_tab[band], ptr_freq_band_tab[band + 1], missing_harmonics_flag, pstr_noise_floor_est_sbr->thr_offset, ptr_inv_filt_levels[band]); + printf("noise floor detect (post): %f\n", ptr_noise_lvls[band + env * num_of_noise_bands]); } } @@ -316,7 +332,11 @@ ixheaace_reset_sbr_noise_floor_estimate(ixheaace_pstr_noise_flr_est_sbr pstr_noi } } - return ia_enhaacplus_enc_down_sample_lo_res(pstr_noise_floor_est_sbr->s_freq_qmf_band_tbl, + printf("estimate: %d\n", pstr_noise_floor_est_sbr->s_freq_qmf_band_tbl[0]); + WORD32 temp = ia_enhaacplus_enc_down_sample_lo_res(pstr_noise_floor_est_sbr->s_freq_qmf_band_tbl, pstr_noise_floor_est_sbr->num_of_noise_bands, ptr_freq_band_tab, num_scf); + printf("estimate after[0]: %d\n", pstr_noise_floor_est_sbr->s_freq_qmf_band_tbl[0]); + printf("estimate after[1]: %d\n", pstr_noise_floor_est_sbr->s_freq_qmf_band_tbl[1]); + return temp; } diff --git a/encoder/ixheaace_sbr_ton_corr.c b/encoder/ixheaace_sbr_ton_corr.c index 6f2fc06..d2cd9b2 100644 --- a/encoder/ixheaace_sbr_ton_corr.c +++ b/encoder/ixheaace_sbr_ton_corr.c @@ -18,6 +18,7 @@ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore */ +#include #include #include "ixheaac_type_def.h" #include "ixheaac_constants.h" @@ -107,10 +108,12 @@ VOID ixheaace_ton_corr_param_extr(ixheaace_pstr_sbr_ton_corr_est pstr_ton_corr, pstr_inf_vec_lcl = pstr_ton_corr->sbr_noise_inv_filt.prev_invf_mode; + printf("noise level: %f\n", ptr_noise_lvls[0]); ixheaace_sbr_noise_floor_estimate_qmf( &pstr_ton_corr->sbr_noise_floor_est, pstr_frame_info, ptr_noise_lvls, pstr_ton_corr->ptr_quota_mtx, pstr_ton_corr->idx_vx, *ptr_missing_harmonic_flag, pstr_ton_corr->frame_start_index, transient_frame, pstr_inf_vec_lcl, is_ld_sbr); + printf("noise level after: %f\n", ptr_noise_lvls[0]); memcpy(pstr_ton_corr->sbr_noise_inv_filt.prev_invf_mode, pstr_inf_vec, pstr_ton_corr->sbr_noise_inv_filt.no_detector_bands * sizeof(pstr_inf_vec[0])); diff --git a/encoder/ixheaace_sbr_write_bitstream.c b/encoder/ixheaace_sbr_write_bitstream.c index 1afe4d1..f38144e 100644 --- a/encoder/ixheaace_sbr_write_bitstream.c +++ b/encoder/ixheaace_sbr_write_bitstream.c @@ -19,6 +19,7 @@ */ #include +#include #include #include "ixheaac_type_def.h" #include "ixheaac_constants.h" @@ -387,6 +388,7 @@ static WORD32 ixheaace_write_noise_lvl_data(ixheaace_pstr_sbr_env_data pstr_sbr_ CODE_BCK_SCF_LAV11]); } } else { + printf("freq_c: %d, freq_l: %d\n", pstr_sbr_env_info->noise_level[j] + CODE_BCK_SCF_LAV11, pstr_sbr_env_info->noise_level[j] + CODE_BCK_SCF_LAV11); payload_cnt_bits += ixheaace_write_bits( pstr_bs_handle, pstr_sbr_env_info->ptr_huff_tab_noise_freq_c[pstr_sbr_env_info->noise_level[j] + diff --git a/test/encoder/ixheaace_testbench.c b/test/encoder/ixheaace_testbench.c index 624a9da..d2924ec 100644 --- a/test/encoder/ixheaace_testbench.c +++ b/test/encoder/ixheaace_testbench.c @@ -1418,7 +1418,7 @@ IA_ERRORCODE ia_enhaacplus_enc_main_process(ixheaace_app_context *pstr_context, /*****************************************************************************/ /* Print frame number */ /*****************************************************************************/ - fprintf(stdout, "Frames Processed [%d]\r", frame_count); + //fprintf(stdout, "Frames Processed [%d]\r", frame_count); fflush(stdout); if (i_bytes_read != input_size) { From ddcb11cbc86158269439ff2c9d234bbd89a242b6 Mon Sep 17 00:00:00 2001 From: wrapper Date: Thu, 14 Aug 2025 16:55:43 +0700 Subject: [PATCH 02/11] fix mean division by 0 --- encoder/ixheaace_sbr_noise_floor_est.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/encoder/ixheaace_sbr_noise_floor_est.c b/encoder/ixheaace_sbr_noise_floor_est.c index c5fcd99..344d2b0 100644 --- a/encoder/ixheaace_sbr_noise_floor_est.c +++ b/encoder/ixheaace_sbr_noise_floor_est.c @@ -136,8 +136,10 @@ static VOID ia_enhaacplus_enc_qmf_based_noise_floor_detection( mean_org += ton_org; mean_sbr += ton_sbr; } - mean_org /= (stop_channel - start_channel); - mean_sbr /= (stop_channel - start_channel); + if ((stop_channel - start_channel) > 0) { + mean_org /= (stop_channel - start_channel); + mean_sbr /= (stop_channel - start_channel); + } } if (mean_org < SBR_TON_MEAN_P0009 && mean_sbr < SBR_TON_MEAN_P0009) { From f398a9836342e6d57ec7eb8e837936fa6796c25e Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 15 Aug 2025 13:12:09 +0700 Subject: [PATCH 03/11] correct aot --- decoder/ixheaacd_api.c | 3 +++ decoder/ixheaacd_struct_def.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index c4ae8e0..53cb371 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -940,6 +940,7 @@ IA_ERRORCODE ixheaacd_dec_api(pVOID p_ia_xheaac_dec_obj, WORD32 i_cmd, } else { *pui_value = p_obj_exhaacplus_dec->p_state_aac->audio_object_type; } + if (*pui_value == AOT_AAC_LC) *pui_value = p_obj_exhaacplus_dec->p_state_aac->init_sbr_flag ? (p_obj_exhaacplus_dec->p_state_aac->init_ps_flag ? AOT_PS : AOT_SBR) : AOT_AAC_LC; } else { *pui_value = AOT_AAC_LC; } @@ -2530,6 +2531,8 @@ IA_ERRORCODE ixheaacd_dec_init( p_obj_exhaacplus_dec->aac_config.ui_n_channels = num_channels_1; p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; p_state_enhaacplus_dec->ui_init_done = 1; + p_state_enhaacplus_dec->init_sbr_flag = sbr_present_flag; + p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_sbr_mode == 1; memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); diff --git a/decoder/ixheaacd_struct_def.h b/decoder/ixheaacd_struct_def.h index fea3b56..8518407 100644 --- a/decoder/ixheaacd_struct_def.h +++ b/decoder/ixheaacd_struct_def.h @@ -162,6 +162,8 @@ typedef struct ia_aac_dec_state_struct { UWORD32 ui_input_over; UWORD32 header_dec_done; WORD32 frame_counter; + WORD32 init_sbr_flag; + WORD32 init_ps_flag; ia_aac_decoder_struct *pstr_aac_dec_info[MAX_BS_ELEMENT]; UWORD32 ch_config; From 90c8770efeb21a51f0707c13bfc6747b94333421 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 15 Aug 2025 14:13:18 +0700 Subject: [PATCH 04/11] fix aot detect --- decoder/ixheaacd_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 53cb371..2645d4a 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -2532,7 +2532,7 @@ IA_ERRORCODE ixheaacd_dec_init( p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; p_state_enhaacplus_dec->ui_init_done = 1; p_state_enhaacplus_dec->init_sbr_flag = sbr_present_flag; - p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_sbr_mode == 1; + p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_channel_mode == 1; memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); From 1feae4f6e0c884610b19feb65ae08c3497bb6caf Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 15 Aug 2025 14:18:49 +0700 Subject: [PATCH 05/11] again --- decoder/ixheaacd_api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder/ixheaacd_api.c b/decoder/ixheaacd_api.c index 2645d4a..3504a10 100644 --- a/decoder/ixheaacd_api.c +++ b/decoder/ixheaacd_api.c @@ -2532,7 +2532,7 @@ IA_ERRORCODE ixheaacd_dec_init( p_obj_exhaacplus_dec->aac_config.ui_samp_freq = sample_rate; p_state_enhaacplus_dec->ui_init_done = 1; p_state_enhaacplus_dec->init_sbr_flag = sbr_present_flag; - p_state_enhaacplus_dec->init_ps_flag = p_obj_exhaacplus_dec->aac_config.ui_channel_mode == 1; + p_state_enhaacplus_dec->init_ps_flag = !p_obj_exhaacplus_dec->aac_config.ui_channel_mode; memcpy(it_bit_buff, &temp_bit_buff, sizeof(struct ia_bit_buf_struct)); From ce9ef54af5d08f4ffdde2b11b8436cdf4a73d076 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 16:06:28 +0700 Subject: [PATCH 06/11] add downsampled frequency scaling --- encoder/ixheaace_sbr_freq_scaling.c | 38 +++++++++++++++++++++++++++++ encoder/ixheaace_sbr_freq_scaling.h | 4 +++ encoder/ixheaace_sbr_main.c | 13 ++++++++++ encoder/ixheaace_sbr_main.h | 2 ++ 4 files changed, 57 insertions(+) diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 1f08fbd..3df4e07 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -371,6 +371,44 @@ ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs) return result; } +WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs) { + WORD32 result; + + if (stop_freq < 0 || stop_freq > 13) { + return -1; + } + + result = ixheaace_get_stop_freq(fs, stop_freq); + + result = (result * fs / qmf_bands + 1) >> 1; + + return result; +} + +WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, + WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, + WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec) +{ + WORD32 new_stop_freq; + WORD32 stop_freq_downsampled = fs / 4; + WORD32 result; + WORD32 k0; + WORD32 k2; + + while (stop_freq && ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs) > stop_freq_downsampled) { + stop_freq--; + } + + new_stop_freq = ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs); + if (new_stop_freq > stop_freq_downsampled) return -1; + + result = ixheaace_find_start_and_stop_band(fs, qmf_bands / 2, start_freq, stop_freq, + sample_rate_mode, &k0, &k2, sbr_ratio_idx, sbr_codec); + if (result != IA_NO_ERROR) return -1; + + return stop_freq; +} + static WORD32 ixheaace_number_of_bands(WORD32 b_p_o, WORD32 start, WORD32 stop, FLOAT32 warp_fac) { WORD32 result = 0; diff --git a/encoder/ixheaace_sbr_freq_scaling.h b/encoder/ixheaace_sbr_freq_scaling.h index fe107e1..29e74b1 100644 --- a/encoder/ixheaace_sbr_freq_scaling.h +++ b/encoder/ixheaace_sbr_freq_scaling.h @@ -43,3 +43,7 @@ ixheaace_find_start_and_stop_band(const WORD32 sampling_freq, const WORD32 num_c ixheaace_sbr_codec_type sbr_codec); WORD32 ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs); +WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs); +WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, + WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, + WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec); \ No newline at end of file diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index b8594e8..273446f 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -435,6 +435,7 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD UWORD32 std_br, ixheaace_str_qmf_tabs *pstr_qmf_tab, WORD32 aot, WORD32 is_esbr_4_1) { FLAG table_found = IXHEAACE_TABLE_IDX_NOT_FOUND; + WORD32 downsample_stop; WORD32 idx_sr = 0; WORD32 idx_ch = 0; WORD32 idx_entry = 0; @@ -514,6 +515,16 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD } } + if (pstr_config->is_single_rate) { + downsample_stop = ixheaace_get_downsampled_stop_freq(pstr_config->stop_freq, IXHEAACE_QMF_CHANNELS, fs_core, + pstr_config->start_freq, IXHEAACE_SINGLE_RATE, pstr_config->sbr_ratio_idx, + pstr_config->sbr_codec); + if (downsample_stop >= 0) { + pstr_config->is_single_rate_found = 1; + pstr_config->stop_freq = downsample_stop; + } + } + if (pstr_config->sbr_codec == ELD_SBR) { pstr_config->send_header_data_time = -1; if ((num_ch == NUM_CHANS_MONO) && (bit_rate <= 22000)) { @@ -597,6 +608,8 @@ VOID ixheaace_initialize_sbr_defaults(ixheaace_pstr_sbr_cfg pstr_config) { pstr_config->sbr_harmonic = 0; pstr_config->sbr_ratio_idx = 0; // NO_SBR pstr_config->use_low_freq_res = 0; + pstr_config->is_single_rate = 0; + pstr_config->is_single_rate_found = 0; } static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( diff --git a/encoder/ixheaace_sbr_main.h b/encoder/ixheaace_sbr_main.h index f84dccd..9456ca9 100644 --- a/encoder/ixheaace_sbr_main.h +++ b/encoder/ixheaace_sbr_main.h @@ -85,6 +85,8 @@ typedef struct ixheaace_str_sbr_cfg { WORD32 hq_esbr; ixheaace_sbr_codec_type sbr_codec; WORD32 use_low_freq_res; + WORD32 is_single_rate; + WORD32 is_single_rate_found; } ixheaace_str_sbr_cfg, *ixheaace_pstr_sbr_cfg; typedef struct ixheaace_str_sbr_enc *ixheaace_pstr_sbr_enc; From c10720f05ddcff8022bf61df5ab0283be9dcdda1 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 19:34:35 +0700 Subject: [PATCH 07/11] Revert "add downsampled frequency scaling" This reverts commit ce9ef54af5d08f4ffdde2b11b8436cdf4a73d076. --- encoder/ixheaace_sbr_freq_scaling.c | 38 ----------------------------- encoder/ixheaace_sbr_freq_scaling.h | 4 --- encoder/ixheaace_sbr_main.c | 13 ---------- encoder/ixheaace_sbr_main.h | 2 -- 4 files changed, 57 deletions(-) diff --git a/encoder/ixheaace_sbr_freq_scaling.c b/encoder/ixheaace_sbr_freq_scaling.c index 3df4e07..1f08fbd 100644 --- a/encoder/ixheaace_sbr_freq_scaling.c +++ b/encoder/ixheaace_sbr_freq_scaling.c @@ -371,44 +371,6 @@ ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs) return result; } -WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs) { - WORD32 result; - - if (stop_freq < 0 || stop_freq > 13) { - return -1; - } - - result = ixheaace_get_stop_freq(fs, stop_freq); - - result = (result * fs / qmf_bands + 1) >> 1; - - return result; -} - -WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, - WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, - WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec) -{ - WORD32 new_stop_freq; - WORD32 stop_freq_downsampled = fs / 4; - WORD32 result; - WORD32 k0; - WORD32 k2; - - while (stop_freq && ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs) > stop_freq_downsampled) { - stop_freq--; - } - - new_stop_freq = ixheaace_get_sbr_stop_freq_raw(stop_freq, qmf_bands, fs); - if (new_stop_freq > stop_freq_downsampled) return -1; - - result = ixheaace_find_start_and_stop_band(fs, qmf_bands / 2, start_freq, stop_freq, - sample_rate_mode, &k0, &k2, sbr_ratio_idx, sbr_codec); - if (result != IA_NO_ERROR) return -1; - - return stop_freq; -} - static WORD32 ixheaace_number_of_bands(WORD32 b_p_o, WORD32 start, WORD32 stop, FLOAT32 warp_fac) { WORD32 result = 0; diff --git a/encoder/ixheaace_sbr_freq_scaling.h b/encoder/ixheaace_sbr_freq_scaling.h index 29e74b1..fe107e1 100644 --- a/encoder/ixheaace_sbr_freq_scaling.h +++ b/encoder/ixheaace_sbr_freq_scaling.h @@ -43,7 +43,3 @@ ixheaace_find_start_and_stop_band(const WORD32 sampling_freq, const WORD32 num_c ixheaace_sbr_codec_type sbr_codec); WORD32 ixheaace_get_sbr_start_freq_raw(WORD32 start_freq, WORD32 qmf_bands, WORD32 fs); -WORD32 ixheaace_get_sbr_stop_freq_raw(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs); -WORD32 ixheaace_get_downsampled_stop_freq(WORD32 stop_freq, WORD32 qmf_bands, WORD32 fs, - WORD32 start_freq, ixheaace_sr_mode sample_rate_mode, - WORD32 sbr_ratio_idx, ixheaace_sbr_codec_type sbr_codec); \ No newline at end of file diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index 273446f..b8594e8 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -435,7 +435,6 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD UWORD32 std_br, ixheaace_str_qmf_tabs *pstr_qmf_tab, WORD32 aot, WORD32 is_esbr_4_1) { FLAG table_found = IXHEAACE_TABLE_IDX_NOT_FOUND; - WORD32 downsample_stop; WORD32 idx_sr = 0; WORD32 idx_ch = 0; WORD32 idx_entry = 0; @@ -515,16 +514,6 @@ VOID ixheaace_adjust_sbr_settings(const ixheaace_pstr_sbr_cfg pstr_config, UWORD } } - if (pstr_config->is_single_rate) { - downsample_stop = ixheaace_get_downsampled_stop_freq(pstr_config->stop_freq, IXHEAACE_QMF_CHANNELS, fs_core, - pstr_config->start_freq, IXHEAACE_SINGLE_RATE, pstr_config->sbr_ratio_idx, - pstr_config->sbr_codec); - if (downsample_stop >= 0) { - pstr_config->is_single_rate_found = 1; - pstr_config->stop_freq = downsample_stop; - } - } - if (pstr_config->sbr_codec == ELD_SBR) { pstr_config->send_header_data_time = -1; if ((num_ch == NUM_CHANS_MONO) && (bit_rate <= 22000)) { @@ -608,8 +597,6 @@ VOID ixheaace_initialize_sbr_defaults(ixheaace_pstr_sbr_cfg pstr_config) { pstr_config->sbr_harmonic = 0; pstr_config->sbr_ratio_idx = 0; // NO_SBR pstr_config->use_low_freq_res = 0; - pstr_config->is_single_rate = 0; - pstr_config->is_single_rate_found = 0; } static IA_ERRORCODE ia_enhaacplus_enc_update_freq_band_tab( diff --git a/encoder/ixheaace_sbr_main.h b/encoder/ixheaace_sbr_main.h index 9456ca9..f84dccd 100644 --- a/encoder/ixheaace_sbr_main.h +++ b/encoder/ixheaace_sbr_main.h @@ -85,8 +85,6 @@ typedef struct ixheaace_str_sbr_cfg { WORD32 hq_esbr; ixheaace_sbr_codec_type sbr_codec; WORD32 use_low_freq_res; - WORD32 is_single_rate; - WORD32 is_single_rate_found; } ixheaace_str_sbr_cfg, *ixheaace_pstr_sbr_cfg; typedef struct ixheaace_str_sbr_enc *ixheaace_pstr_sbr_enc; From e33d5a718e134f8014cc6e4bb82ffc8c13d5ab2f Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 19:35:23 +0700 Subject: [PATCH 08/11] make dual rate unlikely --- encoder/ixheaace_sbr_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index b8594e8..f67cbad 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -967,7 +967,7 @@ ixheaace_env_open(ixheaace_pstr_sbr_enc *pstr_env_encoder, ixheaace_pstr_sbr_cfg pstr_env_enc->str_sbr_cfg.stereo_mode = (params->codec_settings.num_channels == 2) ? params->stereo_mode : IXHEAACE_SBR_MODE_MONO; - if (params->codec_settings.sample_freq <= 24000 || !params->is_ld_sbr) { + if (0) { pstr_env_enc->str_sbr_hdr.sample_rate_mode = IXHEAACE_DUAL_RATE; if (params->sbr_codec == USAC_SBR) { pstr_env_enc->str_sbr_cfg.sample_freq = 2 * params->codec_settings.sample_freq; From 29b7a4eb4c532f37e41e26c86d5f9d16ae05d9c3 Mon Sep 17 00:00:00 2001 From: wrapper Date: Fri, 22 Aug 2025 19:48:17 +0700 Subject: [PATCH 09/11] fix --- encoder/ixheaace_sbr_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_main.c b/encoder/ixheaace_sbr_main.c index f67cbad..62928da 100644 --- a/encoder/ixheaace_sbr_main.c +++ b/encoder/ixheaace_sbr_main.c @@ -967,7 +967,7 @@ ixheaace_env_open(ixheaace_pstr_sbr_enc *pstr_env_encoder, ixheaace_pstr_sbr_cfg pstr_env_enc->str_sbr_cfg.stereo_mode = (params->codec_settings.num_channels == 2) ? params->stereo_mode : IXHEAACE_SBR_MODE_MONO; - if (0) { + if (1) { pstr_env_enc->str_sbr_hdr.sample_rate_mode = IXHEAACE_DUAL_RATE; if (params->sbr_codec == USAC_SBR) { pstr_env_enc->str_sbr_cfg.sample_freq = 2 * params->codec_settings.sample_freq; From d2211d963d3b1827c00580be94f6684ebc8de2d0 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 24 Aug 2025 09:14:50 +0700 Subject: [PATCH 10/11] retweak --- encoder/ixheaace_sbr_rom.c | 144 ++++++++++++++----------------------- 1 file changed, 53 insertions(+), 91 deletions(-) diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 576b3bc..0a739ed 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -744,7 +744,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { }, #else {{{ - /*** 8000hz 1ch ***/ + /*** 8000hz 1ch SBR_AAC ***/ {8000, 10000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {11, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {14, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -753,7 +753,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {32000, 48001, {14, 15}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 8000hz 2ch ***/ + /*** 8000hz 2ch SBR_AAC ***/ {16000, 24000, {6, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {9, 11}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {11, 11}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -765,7 +765,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {0}}}, {{ - /*** 11025hz 1ch ***/ + /*** 11025hz 1ch SBR_AAC ***/ {8000, 10000, {5, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {8, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {12, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -773,10 +773,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {20000, 24000, {13, 13}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {24000, 32000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {32000, 48000, {15, 15}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 64001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 66001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 11025hz 2ch ***/ + /*** 11025hz 2ch SBR_AAC ***/ {16000, 24000, {7, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {10, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {12, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -784,11 +784,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {14, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 132301, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 12000hz 1ch ***/ + /*** 12000hz 1ch SBR_AAC ***/ {8000, 10000, {4, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {7, 11}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {11, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -796,10 +796,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {20000, 24000, {12, 12}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {24000, 32000, {13, 13}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {32000, 48000, {14, 14}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 64001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {48000, 72001, {15, 15}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 12000hz 2ch ***/ + /*** 12000hz 2ch SBR_AAC ***/ {16000, 24000, {6, 9}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {9, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {11, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -807,11 +807,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {13, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {14, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 144001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 16000hz 1ch ***/ + /*** 16000hz 1ch SBR_AAC ***/ {6000, 8000, {0, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {8000, 10000, {1, 0}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {10000, 12000, {2, 6}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -821,10 +821,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {22000, 28000, {10, 12}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {28000, 36000, {12, 13}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 44000, {14, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {44000, 64001, {15, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 96001, {15, 13}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 16000hz 2ch ***/ + /*** 16000hz 2ch SBR_AAC ***/ {16000, 24000, {4, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {8, 10}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {10, 12}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -832,11 +832,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {15, 13}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 192001, {15, 13}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 22050hz 1ch ***/ + /*** 22050hz 1ch SBR_AAC ***/ {8000, 11369, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {11369, 16000, {3, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {16000, 18000, {3, 5}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -844,12 +844,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {22000, 28000, {7, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {28000, 36000, {10, 9}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 44000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {44000, 52000, {13, 11}, 1, {2, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {52000, 68000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {68000, 96001, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 132151, {13, 12}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 22050hz 2ch ***/ + /*** 22050hz 2ch SBR_AAC ***/ {16000, 24000, {2, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {5, 6}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 32000, {5, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -858,11 +856,11 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {12, 9}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 101000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {101000, 128001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {101000, 264601, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 24000hz 1ch ***/ + /*** 24000hz 1ch SBR_AAC ***/ {8000, 12000, {1, 1}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {12000, 16000, {3, 4}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {16000, 18000, {3, 5}, 3, {1, 0, 6}, IXHEAACE_SBR_MODE_MONO}, @@ -870,12 +868,10 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {22000, 28000, {7, 8}, 2, {2, 0, 6}, IXHEAACE_SBR_MODE_MONO}, {28000, 36000, {10, 9}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 44000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {44000, 52000, {13, 11}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {52000, 68000, {15, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {68000, 96001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + {44000, 144001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 24000hz 2ch ***/ + /*** 24000hz 2ch SBR_AAC ***/ {16000, 24000, {2, 1}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {24000, 28000, {5, 6}, 3, {1, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {28000, 36000, {7, 8}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, @@ -883,92 +879,58 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { {44000, 52000, {12, 9}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {52000, 60000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {60000, 76000, {14, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 128001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {76000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 32000hz 1ch ***/ + /*** 32000hz 1ch SBR_AAC ***/ {24000, 36000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {36000, 60000, {7, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {60000, 72000, {9, 8}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {72000, 100000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {100000, 160001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 192001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 32000hz 2ch ***/ + /*** 32000hz 2ch SBR_AAC ***/ {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {60000, 80000, {11, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {80000, 112000, {12, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {112000, 144000, {13, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {144000, 256001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {60000, 80000, {7, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 384001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 44100hz 1ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {16000, 22000, {1, 1}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {22000, 30000, {2, 3}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {30000, 36000, {4, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {36000, 40000, {5, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {40000, 48000, {6, 5}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 60000, {7, 6}, 1, {3, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {60000, 72000, {9, 6}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {72000, 88000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {88000, 160001, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {160001, 288001, {13, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + /*** 44100hz 1ch SBR_AAC ***/ + {24000, 36000, {4, 4}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {7, 6}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 8}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 264601, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 44100hz 2ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {16000, 22000, {1, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {22000, 26000, {2, 1}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {26000, 30000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {30000, 34000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {34000, 38000, {4, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {38000, 44000, {5, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {44000, 52000, {6, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {52000, 60000, {8, 5}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {60000, 68000, {9, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {68000, 76000, {10, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 90000, {11, 7}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {90000, 112000, {11, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {112000, 132000, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {132000, 180000, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {180000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + /*** 44100hz 2ch SBR_AAC ***/ + {32000, 60000, {4, 4}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 529201, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}}, {{ - /*** 48000hz 1ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {16000, 22000, {1, 1}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {22000, 30000, {2, 3}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {30000, 36000, {4, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {36000, 40000, {5, 4}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {40000, 48000, {6, 5}, 0, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {48000, 60000, {7, 6}, 1, {3, 0, 3}, IXHEAACE_SBR_MODE_MONO}, - {60000, 72000, {9, 6}, 1, {3, 0, 0}, IXHEAACE_SBR_MODE_MONO}, - {72000, 88000, {10, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {88000, 160001, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, - {160001, 288001, {13, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_MONO}, + /*** 48000hz 1ch SBR_AAC ***/ + {24000, 36000, {4, 9}, 3, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {36000, 60000, {7, 10}, 2, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {60000, 72000, {9, 10}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {72000, 100000, {11, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, + {100000, 288001, {13, 11}, 1, {2, 0, 3}, IXHEAACE_SBR_MODE_MONO}, {0}}, { - /*** 48000hz 2ch ***/ - {12000, 16000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {16000, 22000, {0, 0}, 0, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {22000, 26000, {1, 1}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {26000, 30000, {2, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {30000, 34000, {3, 3}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {34000, 38000, {4, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {38000, 44000, {2, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {44000, 52000, {6, 4}, 0, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {52000, 60000, {8, 5}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {60000, 68000, {9, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {68000, 76000, {10, 6}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {76000, 90000, {11, 7}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {90000, 112000, {11, 8}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {112000, 132000, {12, 9}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {132000, 180000, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, - {180000, 288001, {15, 12}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + /*** 48000hz 2ch SBR_AAC ***/ + {32000, 60000, {4, 9}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 10}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {80000, 112000, {9, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {112000, 144000, {11, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, + {144000, 576001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {0}}} }, From 1e660479c865ba2af3f86a4bf9ccd00289817243 Mon Sep 17 00:00:00 2001 From: wrapper Date: Sun, 24 Aug 2025 13:31:40 +0700 Subject: [PATCH 11/11] fix sbr 2 --- encoder/ixheaace_sbr_rom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoder/ixheaace_sbr_rom.c b/encoder/ixheaace_sbr_rom.c index 0a739ed..bb52192 100644 --- a/encoder/ixheaace_sbr_rom.c +++ b/encoder/ixheaace_sbr_rom.c @@ -927,7 +927,7 @@ const ixheaace_str_qmf_tabs ixheaace_qmf_tab = { { /*** 48000hz 2ch SBR_AAC ***/ {32000, 60000, {4, 9}, 3, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, - {60000, 80000, {7, 10}, 2, {3, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, + {60000, 80000, {7, 10}, 2, {2, 0, -3}, IXHEAACE_SBR_MODE_SWITCH_LRC}, {80000, 112000, {9, 10}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {112000, 144000, {11, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT}, {144000, 576001, {13, 11}, 1, {3, 0, -3}, IXHEAACE_SBR_MODE_LEFT_RIGHT},