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) {