diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 87981b316e34de2cc1bff517928633e81bc3d411..ecf4e35a2b62dda53eb914b2af3c3d5d915ad321 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4247,27 +4247,13 @@ int16_t ivas_map_num_decd_r_to_idx( const int16_t num_quant_points_decd_r ); /* Quantization utilities */ void ivas_quantise_real_values( -#ifdef QUANTISE_REAL_FCN_CLEAN_UP - const float *values, -#else - float **values, -#endif - const int16_t q_levels, - const float min_value, - const float max_value, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP - int16_t *index, - float *quant, -#else - int16_t **index, - float **quant, -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP + const float *values, + const int16_t q_levels, + const float min_value, + const float max_value, + int16_t *index, + float *quant, const int16_t dim -#else - const int16_t dim1, - const int16_t dim2 -#endif ); diff --git a/lib_com/ivas_spar_com_quant_util.c b/lib_com/ivas_spar_com_quant_util.c index 4feca8c98ae5e332fdafd3d0e257af7bbfea698a..c095e2010791f4b6865dadd13ad60c51f781b51a 100644 --- a/lib_com/ivas_spar_com_quant_util.c +++ b/lib_com/ivas_spar_com_quant_util.c @@ -41,31 +41,6 @@ #include "ivas_rom_com.h" #include #include "wmops.h" -#ifndef QUANTISE_REAL_FCN_CLEAN_UP -/*-----------------------------------------------------------------------------------------* - * Function ivas_limit_values() - * - * Limit values within given range - *-----------------------------------------------------------------------------------------*/ - -static void ivas_limit_values( - float **ppValues, - const float min_value, - const float max_value, - const int16_t dim1, - const int16_t dim2 ) -{ - int16_t i, j; - for ( i = 0; i < dim1; i++ ) - { - for ( j = 0; j < dim2; j++ ) - { - ppValues[i][j] = max( min_value, min( ppValues[i][j], max_value ) ); - } - } - return; -} -#endif /*-----------------------------------------------------------------------------------------* * Function ivas_quantise_real_values() @@ -73,72 +48,28 @@ static void ivas_limit_values( * Quantize real values *-----------------------------------------------------------------------------------------*/ void ivas_quantise_real_values( -#ifdef QUANTISE_REAL_FCN_CLEAN_UP const float *values, -#else - float **values, -#endif const int16_t q_levels, const float min_value, const float max_value, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP int16_t *index, float *quant, -#else - int16_t **index, - float **quant, -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP - const int16_t dim -#else - const int16_t dim1, - const int16_t dim2 -#endif -) + const int16_t dim ) { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - int16_t i, j; -#else int16_t i; -#endif float q_step, one_by_q_step; if ( q_levels == 1 ) { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim1; i++ ) - { - for ( j = 0; j < dim2; j++ ) - { - - quant[i][j] = 0; - index[i][j] = 0; - } - } -#else for ( i = 0; i < dim; i++ ) { quant[i] = 0; index[i] = 0; } -#endif } else if ( q_levels && max_value != min_value ) { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ivas_limit_values( values, min_value, max_value, dim1, dim2 ); -#endif q_step = ( max_value - min_value ) / ( q_levels - 1 ); one_by_q_step = ( q_levels - 1 ) / ( max_value - min_value ); -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim1; i++ ) - { - for ( j = 0; j < dim2; j++ ) - { - index[i][j] = (int16_t) round( one_by_q_step * values[i][j] ); - quant[i][j] = index[i][j] * q_step; - } - } -#else float val; for ( i = 0; i < dim; i++ ) { @@ -146,24 +77,13 @@ void ivas_quantise_real_values( index[i] = (int16_t) round( one_by_q_step * val ); quant[i] = index[i] * q_step; } -#endif } else { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim1; i++ ) - { - for ( j = 0; j < dim2; j++ ) - { - quant[i][j] = values[i][j]; - } - } -#else for ( i = 0; i < dim; i++ ) { quant[i] = values[i]; } -#endif } return; } @@ -425,7 +345,6 @@ void ivas_clear_band_coeff_idx( for ( i = 0; i < num_bands; i++ ) { set_s( pband_coeff_idx[i].pred_index_re, 0, ( IVAS_SPAR_MAX_CH - 1 ) ); - set_s( pband_coeff_idx[i].drct_index_re, 0, IVAS_SPAR_MAX_C_COEFF ); set_s( pband_coeff_idx[i].decd_index_re, 0, ( IVAS_SPAR_MAX_CH - 1 ) ); } diff --git a/lib_com/options.h b/lib_com/options.h index c27d1aa3eb4a910baf1d06216734dcefc1eb242a..ff89003349cd5700fe4b0f9978064b061e0d3cbd 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -147,12 +147,8 @@ /*#define FIX_I1_113*/ /* under review : MCT bit distribution optimization for SBA high bitrates*/ #define SPAR_SCALING_HARMONIZATION /* Issue 80: Changes to harmonize scaling in spar */ -#define SBA_INTERN_CONFIG_FIX_HOA2 /* Issue 99 : Fix for incorrect internal_config when output format is HOA2 or FOA*/ #define FIX_I98_HANDLES_TO_NULL /* Issue 98: do the setting of all handles to NULL in one place */ -#define QUANTISE_REAL_FCN_CLEAN_UP /*Clean up the ivas_quantise_real_values() function*/ - - #define FIX_I74_BW_LIMITATION_ALT /* issue 74: Propagate bitrate induced BW limitation to hEncoderConfig. Ensures BE between explicit BW limitation using "-max_band " and BW limited by bitrate; alternative fix */ #define FIX_I74_CLEANING /* issue 74: remove redundant function call in ivas_cpe_enc() */ diff --git a/lib_dec/ivas_output_init.c b/lib_dec/ivas_output_init.c index e1d96ff57d8924f6225f1e4ebd0ea1d05daf6595..b7af93286173241a6d8055a0a018d00163326288 100644 --- a/lib_dec/ivas_output_init.c +++ b/lib_dec/ivas_output_init.c @@ -511,7 +511,6 @@ void ivas_renderer_select( if ( st_ivas->ivas_format == SBA_FORMAT && st_ivas->sba_mode == SBA_MODE_SPAR && ( output_config != AUDIO_CONFIG_5_1 && output_config != AUDIO_CONFIG_5_1_2 && output_config != AUDIO_CONFIG_5_1_4 && output_config != AUDIO_CONFIG_7_1 && output_config != AUDIO_CONFIG_7_1_4 && output_config != AUDIO_CONFIG_LS_CUSTOM ) ) { -#ifdef SBA_INTERN_CONFIG_FIX_HOA2 if ( output_config == AUDIO_CONFIG_HOA2 || output_config == AUDIO_CONFIG_FOA ) { *internal_config = output_config; @@ -520,9 +519,6 @@ void ivas_renderer_select( { *internal_config = AUDIO_CONFIG_HOA3; } -#else - *internal_config = AUDIO_CONFIG_HOA3; -#endif st_ivas->renderer_type = RENDERER_SBA_LINEAR_DEC; } else if ( ( st_ivas->ivas_format == MASA_FORMAT && output_config == AUDIO_CONFIG_MONO && st_ivas->nchan_transport == 1 ) || diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index f4ac432bf4b40cce9f16b961c36f8e82854d8895..c0682c58a23e1f22f245bfbb91b88b7fef1099fe 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -82,11 +82,7 @@ static void ivas_spar_md_fill_invalid_bands( ivas_spar_dec_matrices_t *pSpar_coe static ivas_error ivas_spar_set_dec_config( ivas_spar_md_dec_state_t *hMdDec, const int16_t nchan_transport, float *pFC ); static void ivas_parse_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, Decoder_State *st, const int16_t bw, const int16_t num_bands, int16_t *num_dmx_per_band, int16_t *num_dec_per_band ); -#ifdef QUANTISE_REAL_FCN_CLEAN_UP static ivas_error ivas_deindex_real_index( const int16_t *index, const int16_t q_levels, const float min_value, const float max_value, float *quant, const int16_t num_ch_dim2 ); -#else -static ivas_error ivas_deindex_real_index( int16_t **index, const int16_t q_levels, const float min_value, const float max_value, float **quant, const int16_t num_ch, const int16_t dim2 ); -#endif static void ivas_spar_dec_parse_md_bs( ivas_spar_md_dec_state_t *hMdDec, Decoder_State *st, int16_t *nB, int16_t *bands_bw, int16_t *dtx_vad, const int32_t ivas_total_brate, const int16_t use_planar_coeff, const int16_t sba_inactive_mode ); @@ -983,15 +979,15 @@ static void ivas_get_spar_matrices( #ifdef SPAR_HOA_DBG /*for (b = 0; b < BANDS_12; b++) { - for (i = 0; i < IVAS_SPAR_MAX_CH - 1; i++) - { - hMdDec->spar_md.band_coeffs[b].pred_re[i] = (float)(i + 1)/10; - for (j = 0; j < IVAS_SPAR_MAX_CH - 1; j++) + for (i = 0; i < IVAS_SPAR_MAX_CH - 1; i++) { - hMdDec->spar_md.band_coeffs[b].C_re[i][j] = (float)(i + j * 20 + 1)/10; - hMdDec->spar_md.band_coeffs[b].P_re[i][j] = (float)(i + j * 20 + 1)/10; + hMdDec->spar_md.band_coeffs[b].pred_re[i] = (float)(i + 1)/10; + for (j = 0; j < IVAS_SPAR_MAX_CH - 1; j++) + { + hMdDec->spar_md.band_coeffs[b].C_re[i][j] = (float)(i + j * 20 + 1)/10; + hMdDec->spar_md.band_coeffs[b].P_re[i][j] = (float)(i + j * 20 + 1)/10; + } } - } }*/ #endif @@ -1149,21 +1145,21 @@ static void ivas_get_spar_matrices( /*fprintf(stdout, "C matrix1: %d x %d\n\n", numch_out, dmx_ch); for (j = 0; j < numch_out; j++) { - for (k = 0; k < dmx_ch; k++) - { - fprintf(stdout, "%f, ", tmpC_re[j][k]); - } - fprintf(stdout, "\n"); + for (k = 0; k < dmx_ch; k++) + { + fprintf(stdout, "%f, ", tmpC_re[j][k]); + } + fprintf(stdout, "\n"); } fprintf(stdout, "Mixer Mat: %d x %d\n\n", numch_out, numch_out); for ( j = 0; j < numch_out; j++) { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); - } - fprintf(stdout, "\n"); + for (k = 0; k < numch_out; k++) + { + fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); + } + fprintf(stdout, "\n"); }*/ #endif @@ -1184,26 +1180,26 @@ static void ivas_get_spar_matrices( #ifdef SPAR_HOA_DBG /*if (b == 0) { - fprintf(stdout, "tmp_P matrix: %d x %d\n\n", numch_out, dmx_ch); - for (j = 0; j < numch_out; j++) - { - for (k = 0; k < numch_out; k++) + fprintf(stdout, "tmp_P matrix: %d x %d\n\n", numch_out, dmx_ch); + for (j = 0; j < numch_out; j++) { - fprintf(stdout, "%f, ", tmpP_re[j][k]); - } - fprintf(stdout, "\n"); + for (k = 0; k < numch_out; k++) + { + fprintf(stdout, "%f, ", tmpP_re[j][k]); + } + fprintf(stdout, "\n"); - } - fprintf(stdout, "Mixer Mat: %d x %d\n\n", numch_out, numch_out); - for (j = 0; j < numch_out; j++) - { - for (k = 0; k < numch_out; k++) - { - fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); } - fprintf(stdout, "\n"); + fprintf(stdout, "Mixer Mat: %d x %d\n\n", numch_out, numch_out); + for (j = 0; j < numch_out; j++) + { + for (k = 0; k < numch_out; k++) + { + fprintf(stdout, "%f, ", hMdDec->mixer_mat[j][k][0][b]); + } + fprintf(stdout, "\n"); - } + } }*/ #endif for ( j = 1; j < numch_out; j++ ) @@ -1234,11 +1230,11 @@ static void ivas_get_spar_matrices( /*fprintf(stdout, "C matrix1: %d x %d\n\n", numch_out, dmx_ch); for (j = 0; j < numch_out; j++) { - for (k = 0; k < dmx_ch; k++) - { - fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); - } - fprintf(stdout, "\n"); + for (k = 0; k < dmx_ch; k++) + { + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); + } + fprintf(stdout, "\n"); }*/ #endif @@ -1249,27 +1245,27 @@ static void ivas_get_spar_matrices( #ifdef SPAR_HOA_DBG /* for (b = 0; b < 1; b++) { - fprintf(stdout, "C matrix: %d x %d band %d\n\n", numch_out, dmx_ch, b); - for (j = 0; j < numch_out; j++) - { - for (k = 0; k < numch_out; k++) + fprintf(stdout, "C matrix: %d x %d band %d\n\n", numch_out, dmx_ch, b); + for (j = 0; j < numch_out; j++) { - fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); - } - fprintf(stdout, "\n"); + for (k = 0; k < numch_out; k++) + { + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.C_re[j][k][b]); + } + fprintf(stdout, "\n"); - } - fprintf(stdout, "\nP matrix: %d x %d\n\n", numch_out, numch_out); + } + fprintf(stdout, "\nP matrix: %d x %d\n\n", numch_out, numch_out); - for (j = 0; j < numch_out; j++) - { - for (k = 0; k < numch_out; k++) + for (j = 0; j < numch_out; j++) { - fprintf(stdout, "%f, ", hMdDec->spar_coeffs.P_re[j][k][b]); - } - fprintf(stdout, "\n"); + for (k = 0; k < numch_out; k++) + { + fprintf(stdout, "%f, ", hMdDec->spar_coeffs.P_re[j][k][b]); + } + fprintf(stdout, "\n"); - } + } }*/ #endif @@ -1399,16 +1395,16 @@ void ivas_spar_dec_gen_umx_mat( /* for ( b = 0; b < 1; b++) { - fprintf( stdout, "\n\nMixer Matrix band %d\n\n", b ); - for ( i = 0; i < num_out_ch; i++ ) - { - for ( j = 0; j < num_out_ch; j++ ) + fprintf( stdout, "\n\nMixer Matrix band %d\n\n", b ); + for ( i = 0; i < num_out_ch; i++ ) { - fprintf( stdout, "%.2f,\t", hMdDec->mixer_mat[i][j][0][b] ); + for ( j = 0; j < num_out_ch; j++ ) + { + fprintf( stdout, "%.2f,\t", hMdDec->mixer_mat[i][j][0][b] ); + } + fprintf( stdout, "\n" ); } fprintf( stdout, "\n" ); - } - fprintf( stdout, "\n" ); }*/ #endif @@ -1607,59 +1603,12 @@ static void ivas_spar_dec_parse_md_bs( for ( i = 0; i < *nB; i++ ) { int16_t ii, jj; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - int16_t *index_scratch[IVAS_SPAR_P_LOWERTRI]; - float *quant_scratch[IVAS_SPAR_P_LOWERTRI]; -#endif int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * i]; int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * i]; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - int16_t **index = (int16_t **) &index_scratch[0]; - float **quant = (float **) &quant_scratch[0]; - float coeff_decd[IVAS_SPAR_MAX_CH - 1]; - float coeff_decx_re[IVAS_SPAR_P_LOWERTRI]; - int16_t decx_index_re[IVAS_SPAR_P_LOWERTRI]; - int16_t pred_index_re[IVAS_SPAR_MAX_CH - 1]; - int16_t drct_index_re[IVAS_SPAR_MAX_C_COEFF]; - int16_t decd_index_re[IVAS_SPAR_MAX_CH - 1]; -#else float quant[IVAS_SPAR_MAX_C_COEFF]; -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - - for ( j = 0; j < ndm + ndec - 1; j++ ) - { - pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j]; - } - - for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) - { - drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j]; - } - for ( j = 0; j < ndec; j++ ) - { - decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j]; - } -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - index[0] = &pred_index_re[0]; - quant[0] = &hMdDec->spar_md.band_coeffs[i].pred_re[0]; -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].pred_index_re, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, hMdDec->spar_md.band_coeffs[i].pred_re, ndm + ndec - 1 ); -#else - ivas_deindex_real_index( index, qs.PR.q_levels[0], qs.PR.min, qs.PR.max, quant, 1, ndm + ndec - 1 ); - for ( ii = 0; ii < ndec; ii++ ) - { - for ( jj = 0; jj < ndm - 1; jj++ ) - { - hMdDec->spar_md.band_coeffs[i].C_re[ii][jj] = 0; - } - } -#endif j = 0; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP for ( ii = 0; ii < ndec; ii++ ) { for ( jj = 0; jj < ndm - 1; jj++ ) @@ -1668,23 +1617,7 @@ static void ivas_spar_dec_parse_md_bs( j++; } } -#else - for ( ii = 0; ii < ndec; ii++ ) - { - for ( jj = 0; jj < ndm - 1; jj++ ) - { - index[j] = &drct_index_re[j]; - quant[j] = &hMdDec->spar_md.band_coeffs[i].C_re[ii][jj]; - j++; - } - } -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].drct_index_re, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ) ); -#else - ivas_deindex_real_index( index, qs.C.q_levels[0], qs.C.min, qs.C.max, quant, ndec * ( ndm - 1 ), 1 ); -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP j = 0; for ( ii = 0; ii < ndec; ii++ ) { @@ -1694,70 +1627,20 @@ static void ivas_spar_dec_parse_md_bs( j++; } } -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - index[0] = &decd_index_re[0]; - quant[0] = &coeff_decd[0]; -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_deindex_real_index( hMdDec->spar_md.band_coeffs_idx[i].decd_index_re, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, hMdDec->spar_md.band_coeffs[i].P_re, ndm + ndec - 1 ); -#else - ivas_deindex_real_index( index, qs.P_r.q_levels[0], qs.P_r.min, qs.P_r.max, quant, 1, ndm + ndec - 1 ); -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - index[0] = &decx_index_re[0]; - quant[0] = &coeff_decx_re[0]; -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ivas_deindex_real_index( index, qs.P_c.q_levels[0], qs.P_c.min, qs.P_c.max, quant, 1, ndec * ( ndec - 1 ) >> 2 ); -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP /* Store prior coefficient indices */ for ( j = 0; j < ndm + ndec - 1; j++ ) { hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].pred_index_re[j]; } -#else - /* Store prior coefficient indices */ - for ( j = 0; j < ndm + ndec - 1; j++ ) - { - hMdDec->spar_md_prev.band_coeffs_idx[i].pred_index_re[j] = pred_index_re[j]; - } -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) { hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].drct_index_re[j]; } -#else - for ( j = 0; j < ndec * ( ndm - 1 ); j++ ) - { - hMdDec->spar_md_prev.band_coeffs_idx[i].drct_index_re[j] = drct_index_re[j]; - } -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP for ( j = 0; j < ndec; j++ ) { hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = hMdDec->spar_md.band_coeffs_idx[i].decd_index_re[j]; } -#else - for ( j = 0; j < ndec; j++ ) - { - hMdDec->spar_md_prev.band_coeffs_idx[i].decd_index_re[j] = decd_index_re[j]; - } -#endif - -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( k = 0; k < ndec; k++ ) - { - hMdDec->spar_md.band_coeffs[i].P_re[k] = 0; - } - for ( j = 0; j < ndec; j++ ) - { - /* Don't bother adding in the decx parameters */ - hMdDec->spar_md.band_coeffs[i].P_re[j] = coeff_decd[j]; - } -#endif hMdDec->valid_bands[i] |= ( do_diff[i] == 0 ) ? 1 : 0; } } @@ -1775,42 +1658,42 @@ static void ivas_spar_dec_parse_md_bs( #ifdef SPAR_HOA_DBG int16_t b; b = 0; - /* if (0) + /*if ( 0 ) { for ( b = 0; b < *nB; b++ ) { - int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[(*bands_bw) * b]; - int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[(*bands_bw) * b]; - fprintf(stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi); - for (i = 0; i < ndm + ndec - 1; i++) + int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * b]; + int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * b]; + fprintf( stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi ); + for ( i = 0; i < ndm + ndec - 1; i++ ) { - fprintf(stdout, "i: %d -- %f\t %d\t %d\n", i, - hMdDec->spar_md.band_coeffs[b].pred_re[i], - hMdDec->spar_md_prev.band_coeffs_idx[b].pred_index_re[i], - hMdDec->spar_md.band_coeffs_idx[b].pred_index_re[i]); + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, + hMdDec->spar_md.band_coeffs[b].pred_re[i], + hMdDec->spar_md_prev.band_coeffs_idx[b].pred_index_re[i], + hMdDec->spar_md.band_coeffs_idx[b].pred_index_re[i] ); } - fprintf(stdout, "\n\n METADATA C: band %d\n\n", b); + fprintf( stdout, "\n\n METADATA C: band %d\n\n", b ); k = 0; - for (i = 0; i < ndec; i++) + for ( i = 0; i < ndec; i++ ) { - for (j = 0; j < (ndm - 1); j++) + for ( j = 0; j < ( ndm - 1 ); j++ ) { - fprintf(stdout, "i: %d -- %f\t %d\t %d\n", i, - hMdDec->spar_md.band_coeffs[b].C_re[i][j], - hMdDec->spar_md_prev.band_coeffs_idx[b].drct_index_re[k], - hMdDec->spar_md.band_coeffs_idx[b].drct_index_re[k]); + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, + hMdDec->spar_md.band_coeffs[b].C_re[i][j], + hMdDec->spar_md_prev.band_coeffs_idx[b].drct_index_re[k], + hMdDec->spar_md.band_coeffs_idx[b].drct_index_re[k] ); k++; } } - fprintf(stdout, "\n\n METADATA Pd: band %d\n\n", b); - for (i = 0; i < ndec; i++) + fprintf( stdout, "\n\n METADATA Pd: band %d\n\n", b ); + for ( i = 0; i < ndec; i++ ) { - fprintf(stdout, "i: %d -- %f\t %d\t %d\n", i, - hMdDec->spar_md.band_coeffs[b].P_re[i][i], - hMdDec->spar_md_prev.band_coeffs_idx[b].decd_index_re[i], - hMdDec->spar_md.band_coeffs_idx[b].decd_index_re[i]); + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, + hMdDec->spar_md.band_coeffs[b].P_re[i][i], + hMdDec->spar_md_prev.band_coeffs_idx[b].decd_index_re[i], + hMdDec->spar_md.band_coeffs_idx[b].decd_index_re[i] ); } - fprintf(stdout, "\n\n"); + fprintf( stdout, "\n\n" ); int16_t ndec = hMdDec->spar_md_cfg.num_decorr_per_band[( *bands_bw ) * b]; int16_t ndm = hMdDec->spar_md_cfg.num_dmx_chans_per_band[( *bands_bw ) * b]; fprintf( stdout, "\n\n Metadata PR (15x1), C(15x15), P(15x15): band %d\n", b ); @@ -2401,58 +2284,28 @@ static void ivas_spar_unquant_dtx_indicies( { int16_t i, b; int16_t q_lvl; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float **ppVal, *pVal, val; - int16_t **ppIdx, *pIdx, idx; -#else float val; int16_t idx; -#endif float pr_min_max[2]; pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppVal = (float **) &pVal; - ppIdx = (int16_t **) &pIdx; - - ppVal[0] = (float *) &val; - ppIdx[0] = (int16_t *) &idx; -#endif for ( b = 0; b < nB; b++ ) { for ( i = 0; i < FOA_CHANNELS - 1; i++ ) { q_lvl = dtx_pr_real_q_levels[ndm_per_band[bw * b] - 1][i]; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppIdx[0][0] = pSpar_md->band_coeffs_idx[b].pred_index_re[i]; -#else idx = pSpar_md->band_coeffs_idx[b].pred_index_re[i]; -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_deindex_real_index( &idx, q_lvl, pr_min_max[0], pr_min_max[1], &val, 1 ); pSpar_md->band_coeffs[b].pred_re[i] = val; -#else - ivas_deindex_real_index( ppIdx, q_lvl, pr_min_max[0], pr_min_max[1], ppVal, 1, 1 ); - pSpar_md->band_coeffs[b].pred_re[i] = ppVal[0][0]; -#endif } for ( i = 0; i < FOA_CHANNELS - ndm_per_band[bw * b]; i++ ) { q_lvl = dtx_pd_real_q_levels[ndm_per_band[bw * b] - 1][i]; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppIdx[0][0] = pSpar_md->band_coeffs_idx[b].decd_index_re[i]; -#else idx = pSpar_md->band_coeffs_idx[b].decd_index_re[i]; -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_deindex_real_index( &idx, q_lvl, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &val, 1 ); pSpar_md->band_coeffs[b].P_re[i] = val; -#else - ivas_deindex_real_index( ppIdx, q_lvl, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], ppVal, 1, 1 ); - pSpar_md->band_coeffs[b].P_re[i] = ppVal[0][0]; -#endif } } @@ -2475,25 +2328,13 @@ static void ivas_parse_parameter_bitstream_dtx( int16_t *num_dec_per_band ) { int16_t i, j; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP float val; int16_t idx; -#else - float **ppVal, *pVal, val; - int16_t **ppIdx, *pIdx, idx; -#endif float pr_min_max[2]; int16_t pr_q_lvls, pr, pd, pd_q_lvls, pr_pd_bits; int16_t pr_q_lvls1, pr_q_lvls2, pr_idx1, pr_idx2, pr_pr_bits; int16_t zero_pad_bits, sid_bits_len; sid_bits_len = st0->next_bit_pos; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppVal = (float **) &pVal; - ppIdx = (int16_t **) &pIdx; - - ppVal[0] = (float *) &val; - ppIdx[0] = (int16_t *) &idx; -#endif pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -2533,26 +2374,13 @@ static void ivas_parse_parameter_bitstream_dtx( pr = (int16_t) floor( value / pd_q_lvls ); pd = value - pr * pd_q_lvls; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP val = dtx_pd_real_min_max[0]; ivas_quantise_real_values( &val, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &idx, &val, 1 ); -#else - ppVal[0][0] = dtx_pd_real_min_max[0]; - ivas_quantise_real_values( ppVal, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], ppIdx, ppVal, 1, 1 ); -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP pd = pd + idx; val = pr_min_max[0]; ivas_quantise_real_values( &val, pr_q_lvls, pr_min_max[0], pr_min_max[1], &idx, &val, 1 ); pr = pr + idx; -#else - pd = pd + ppIdx[0][0]; - - ppVal[0][0] = pr_min_max[0]; - ivas_quantise_real_values( ppVal, pr_q_lvls, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - pr = pr + ppIdx[0][0]; -#endif if ( ( j + 1 ) <= ndec ) { @@ -2572,7 +2400,6 @@ static void ivas_parse_parameter_bitstream_dtx( pr_idx2 = (int16_t) floor( value / pr_q_lvls1 ); pr_idx1 = value - pr_idx2 * pr_q_lvls1; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP val = pr_min_max[0]; ivas_quantise_real_values( &val, pr_q_lvls1, pr_min_max[0], pr_min_max[1], &idx, &val, 1 ); @@ -2582,17 +2409,6 @@ static void ivas_parse_parameter_bitstream_dtx( ivas_quantise_real_values( &val, pr_q_lvls2, pr_min_max[0], pr_min_max[1], &idx, &val, 1 ); pr_idx2 += idx; -#else - ppVal[0][0] = pr_min_max[0]; - ivas_quantise_real_values( ppVal, pr_q_lvls1, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - - pr_idx1 += ppIdx[0][0]; - - ppVal[0][0] = pr_min_max[0]; - ivas_quantise_real_values( ppVal, pr_q_lvls2, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - - pr_idx2 += ppIdx[0][0]; -#endif pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_1 - 1] = pr_idx1; pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_2 - 1] = pr_idx2; } @@ -2621,32 +2437,14 @@ static void ivas_parse_parameter_bitstream_dtx( *-----------------------------------------------------------------------------------------*/ static ivas_error ivas_deindex_real_index( -#ifdef QUANTISE_REAL_FCN_CLEAN_UP const int16_t *index, -#else - int16_t **index, -#endif const int16_t q_levels, const float min_value, const float max_value, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP float *quant, -#else - float **quant, -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP - const int16_t dim -#else - const int16_t num_ch, - const int16_t dim2 -#endif -) + const int16_t dim ) { -#ifdef QUANTISE_REAL_FCN_CLEAN_UP int16_t i; -#else - int16_t i, j; -#endif float q_step; if ( q_levels == 0 ) @@ -2656,38 +2454,18 @@ static ivas_error ivas_deindex_real_index( if ( q_levels == 1 ) { -#ifdef QUANTISE_REAL_FCN_CLEAN_UP for ( i = 0; i < dim; i++ ) { quant[i] = 0; } -#else - for ( i = 0; i < num_ch; i++ ) - { - for ( j = 0; j < dim2; j++ ) - { - quant[i][j] = 0; - } - } -#endif } else { q_step = ( max_value - min_value ) / ( q_levels - 1 ); -#ifdef QUANTISE_REAL_FCN_CLEAN_UP for ( i = 0; i < dim; i++ ) { quant[i] = index[i] * q_step; } -#else - for ( i = 0; i < num_ch; i++ ) - { - for ( j = 0; j < dim2; j++ ) - { - quant[i][j] = index[i][j] * q_step; - } - } -#endif } return IVAS_ERR_OK; diff --git a/lib_enc/ivas_spar_md_enc.c b/lib_enc/ivas_spar_md_enc.c index 78028deef23d3b0ba9d927985d4155773e324b3b..ed0d3f7e7e5bc951ff365355f4c0b2c30fbb9029 100644 --- a/lib_enc/ivas_spar_md_enc.c +++ b/lib_enc/ivas_spar_md_enc.c @@ -85,16 +85,8 @@ static void ivas_store_prior_coeffs( ivas_spar_md_enc_state_t *hMdEnc, const int static void ivas_write_parameter_bitstream( ivas_spar_md_enc_state_t *hMdEnc, const int16_t nB, const int16_t bands_bw, BSTR_ENC_HANDLE hMetaData, const int32_t ivas_total_brate, const int16_t dtx_silence_mode, const int16_t strat, const int16_t qsi, const int16_t planarCP ); static ivas_error ivas_spar_md_enc_init( ivas_spar_md_enc_state_t *hMdEnc, const ENCODER_CONFIG_HANDLE hEncoderConfig, const int16_t sba_order ); -#ifdef QUANTISE_REAL_FCN_CLEAN_UP static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, const float *pValues, const int16_t ndm, int16_t *pIndex, const int16_t dim1, float *pQuant ); -#else -static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, float **ppValues, const int16_t ndm, int16_t **ppIndex, const int16_t dim1, float **ppQuant ); -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP static void ivas_quant_p_per_band_dtx( float *pP_mat, const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, float *pP_out, const int16_t num_ch ); -#else -static void ivas_quant_p_per_band_dtx( float **ppP_mat, const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, float **ppP_out, const int16_t num_ch ); -#endif static void ivas_write_parameter_bitstream_dtx( ivas_spar_md_t *pSpar_md, BSTR_ENC_HANDLE hMetaData, int16_t *num_dmx, int16_t *num_dec, const int16_t num_bands ); static void ivas_quant_p_per_band( ivas_band_coeffs_t *pband_coeffs, ivas_band_coeffs_ind_t *pBand_coeffs_idx, ivas_quant_strat_t *pQs, const int16_t num_ch ); @@ -339,15 +331,15 @@ static ivas_error ivas_spar_md_enc_init( ivas_spar_set_enc_config( hMdEnc, hMdEnc->spar_md_cfg.max_freq_per_chan, hMdEnc->spar_md_cfg.nchan_transport, pFC, num_channels ); /* if(hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].C.q_levels[1] == 0 - || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[1] == 0 - || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[1] == 0 - || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[1] == 0) + || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].PR.q_levels[1] == 0 + || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_c.q_levels[1] == 0 + || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[0] == 0 || hMdEnc->spar_md_cfg.quant_strat[0].P_r.q_levels[1] == 0) { - hMdEnc->spar_md_cfg.gen_bs = 0; + hMdEnc->spar_md_cfg.gen_bs = 0; } else if(0 != hMdEnc->spar_md_cfg.gen_bs) { - hMdEnc->spar_md_cfg.quant_strat_bits = ivas_get_bits_to_encode(MAX_QUANT_STRATS); + hMdEnc->spar_md_cfg.quant_strat_bits = ivas_get_bits_to_encode(MAX_QUANT_STRATS); } */ @@ -686,11 +678,11 @@ ivas_error ivas_spar_md_enc_process( for (i = 0; i < ndec; i++) { - for (j = 0; j < ndec; j++) - { - fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].P_re[i][j]);//, hMdEnc->spar_md.band_coeffs[b].P_im[i][j]); - } - fprintf(stderr, "\n"); + for (j = 0; j < ndec; j++) + { + fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].P_re[i][j]);//, hMdEnc->spar_md.band_coeffs[b].P_im[i][j]); + } + fprintf(stderr, "\n"); } fprintf(stderr, "\n\n"); */ #endif @@ -709,11 +701,11 @@ ivas_error ivas_spar_md_enc_process( /*fprintf(stderr, "\n\n Planar P coefficients: band %d\n", b); for (i = 0; i < ndec; i++) { - for (j = 0; j < ndec; j++) - { - fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].P_re[i][j]); //, hMdEnc->spar_md.band_coeffs[b].C_im[i][j]); - } - fprintf(stderr, "\n"); + for (j = 0; j < ndec; j++) + { + fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].P_re[i][j]); //, hMdEnc->spar_md.band_coeffs[b].C_im[i][j]); + } + fprintf(stderr, "\n"); } fprintf(stderr, "\n\n"); */ #endif @@ -726,51 +718,16 @@ ivas_error ivas_spar_md_enc_process( } else { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float **ppPred_re, **ppPred_quant, *pPred_re, *pPred_quant; - int16_t **ppPred_idx, *pPred_re_idx; -#endif if ( ndm != num_ch ) { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float *P_re[IVAS_SPAR_MAX_CH - 1], *P_re_quant[IVAS_SPAR_MAX_CH - 1]; - float **ppP_re = (float **) &P_re[0]; - float **ppP_re_quant = (float **) &P_re_quant[0]; -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - int16_t *ppP_idx = &hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[0]; - - for ( i = 0; i < ndec; i++ ) - { - - ppP_re[i] = hMdEnc->spar_md.band_coeffs[b].P_re; - ppP_re_quant[i] = hMdEnc->spar_md.band_coeffs[b].P_quant_re; - } -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_quant_p_per_band_dtx( hMdEnc->spar_md.band_coeffs[b].P_re, ndec, ndm, &hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[0], hMdEnc->spar_md.band_coeffs[b].P_quant_re, num_ch ); -#else - ivas_quant_p_per_band_dtx( ppP_re, ndec, ndm, ppP_idx, ppP_re_quant, num_ch ); -#endif } -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppPred_idx = (int16_t **) &pPred_re_idx; - ppPred_re = (float **) &pPred_re; - ppPred_quant = (float **) &pPred_quant; - ppPred_re[0] = hMdEnc->spar_md.band_coeffs[b].pred_re; - ppPred_idx[0] = hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re; - ppPred_quant[0] = hMdEnc->spar_md.band_coeffs[b].pred_quant_re; -#endif for ( i = 0; i < num_ch - 1; i++ ) { hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i] = 0; } -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_spar_quant_pred_coeffs_dtx( &hMdEnc->spar_md, hMdEnc->spar_md.band_coeffs[b].pred_re, ndm, hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re, num_ch - 1, hMdEnc->spar_md.band_coeffs[b].pred_quant_re ); -#else - ivas_spar_quant_pred_coeffs_dtx( &hMdEnc->spar_md, ppPred_re, ndm, ppPred_idx, num_ch - 1, ppPred_quant ); -#endif } } @@ -802,11 +759,11 @@ ivas_error ivas_spar_md_enc_process( for (i = 0; i < num_ch - ndm; i++) { - for (j = 0; j < ndm - 1; j++) - { - fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].C_re[i][j]); - } - fprintf(stderr, "\n"); + for (j = 0; j < ndm - 1; j++) + { + fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].C_re[i][j]); + } + fprintf(stderr, "\n"); } fprintf(stderr, "\n\n"); */ #endif @@ -827,11 +784,11 @@ ivas_error ivas_spar_md_enc_process( for (i = 0; i < num_ch - ndm; i++) { - for (j = 0; j < ndm - 1; j++) - { - fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].C_re[i][j]); // , hMdEnc->spar_md.band_coeffs[band_idx].C_im[i][j]); - } - fprintf(stderr, "\n"); + for (j = 0; j < ndm - 1; j++) + { + fprintf(stderr, "%f, ", hMdEnc->spar_md.band_coeffs[b].C_re[i][j]); // , hMdEnc->spar_md.band_coeffs[band_idx].C_im[i][j]); + } + fprintf(stderr, "\n"); } fprintf(stderr, "\n\n"); */ #endif @@ -844,7 +801,7 @@ ivas_error ivas_spar_md_enc_process( for (i = 0; i < ndec * (ndm-1); i++) { - fprintf(stderr, "%d, ", hMdEnc->spar_md.band_coeffs_idx[b].drct_index_re[i]); + fprintf(stderr, "%d, ", hMdEnc->spar_md.band_coeffs_idx[b].drct_index_re[i]); } fprintf(stderr, "\n\n");*/ #endif @@ -912,40 +869,40 @@ ivas_error ivas_spar_md_enc_process( #ifdef SPAR_HOA_DBG /*if ( strat >= 4 ) { - for ( b = 0; b < nB; b++ ) - { - b = 0; - fprintf( stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi ); - for ( i = 0; i < num_ch - 1; i++ ) - { - fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].pred_re[i], - hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i], - hMdEnc->spar_md_prior.band_coeffs_idx[b].pred_index_re[i], - hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re[i] ); - } - fprintf( stdout, "\n\n METADATA C: band %d\n\n", b ); - int16_t k = 0; - for ( i = 0; i < ndec; i++ ) + for ( b = 0; b < nB; b++ ) { - for ( j = 0; j < ( ndm - 1 ); j++ ) - { - fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, // hMdEnc->spar_md.band_coeffs[b].C_re[i][j], - hMdEnc->spar_md.band_coeffs[b].C_quant_re[i][j], - hMdEnc->spar_md_prior.band_coeffs_idx[b].drct_index_re[k], - hMdEnc->spar_md.band_coeffs_idx[b].drct_index_re[k] ); - k++; - } - } - fprintf( stdout, "\n\n METADATA Pd: band %d\n\n", b ); - for ( i = 0; i < num_ch - ndm; i++ ) - { - fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].P_re[i][i], - hMdEnc->spar_md.band_coeffs[b].P_quant_re[i][i], - hMdEnc->spar_md_prior.band_coeffs_idx[b].decd_index_re[i], - hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[i] ); + b = 0; + fprintf( stdout, "\n\nMETADATA PR: band %d, qsi %d\n\n", b, qsi ); + for ( i = 0; i < num_ch - 1; i++ ) + { + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].pred_re[i], + hMdEnc->spar_md.band_coeffs[b].pred_quant_re[i], + hMdEnc->spar_md_prior.band_coeffs_idx[b].pred_index_re[i], + hMdEnc->spar_md.band_coeffs_idx[b].pred_index_re[i] ); + } + fprintf( stdout, "\n\n METADATA C: band %d\n\n", b ); + int16_t k = 0; + for ( i = 0; i < ndec; i++ ) + { + for ( j = 0; j < ( ndm - 1 ); j++ ) + { + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, // hMdEnc->spar_md.band_coeffs[b].C_re[i][j], + hMdEnc->spar_md.band_coeffs[b].C_quant_re[i][j], + hMdEnc->spar_md_prior.band_coeffs_idx[b].drct_index_re[k], + hMdEnc->spar_md.band_coeffs_idx[b].drct_index_re[k] ); + k++; + } + } + fprintf( stdout, "\n\n METADATA Pd: band %d\n\n", b ); + for ( i = 0; i < num_ch - ndm; i++ ) + { + fprintf( stdout, "i: %d -- %f\t %d\t %d\n", i, //hMdEnc->spar_md.band_coeffs[b].P_re[i][i], + hMdEnc->spar_md.band_coeffs[b].P_quant_re[i][i], + hMdEnc->spar_md_prior.band_coeffs_idx[b].decd_index_re[i], + hMdEnc->spar_md.band_coeffs_idx[b].decd_index_re[i] ); + } + fprintf( stdout, "\n\n" ); } - fprintf( stdout, "\n\n" ); - } }*/ b = 0; ndm = hMdEnc->spar_md_cfg.num_dmx_chans_per_band[b * bands_bw]; @@ -1382,7 +1339,7 @@ static void ivas_get_arith_coded_bs( #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n band_indexes:\n"); for (int16_t j = 1; j < drct_cell_dims[0].dim1 * drct_cell_dims[0].dim2; j++) - fprintf(stderr, "%d, ", hMdEnc->spar_md.band_coeffs_idx[0].drct_index_re[j]); + fprintf(stderr, "%d, ", hMdEnc->spar_md.band_coeffs_idx[0].drct_index_re[j]); fprintf(stderr, "\n\n"); */ #endif ivas_copy_band_coeffs_idx_to_arr( hMdEnc->spar_md.band_coeffs_idx, nB, symbol_arr_re, drct_cell_dims, DRCT_COEFF, planarCP ); @@ -1542,60 +1499,22 @@ static void ivas_store_prior_coeffs( static void ivas_spar_quant_pred_coeffs_dtx( ivas_spar_md_t *pSpar_md, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP const float *pValues, -#else - float **ppValues, -#endif const int16_t ndm, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP int16_t *pIndex, -#else - int16_t **ppIndex, -#endif const int16_t dim1, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP - float *pQuant -#else - float **ppQuant -#endif -) + float *pQuant ) { int16_t i; int16_t q_lvl; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float *pVal, val, **ppVal; - int16_t *pIdx, idx, **ppIdx; -#endif float pr_min_max[2]; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - - ppVal = (float **) &pVal; - ppIdx = (int16_t **) &pIdx; - - ppVal[0] = (float *) &val; - ppIdx[0] = (int16_t *) &idx; -#endif pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; - -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim1; i++ ) - { - q_lvl = dtx_pr_real_q_levels[ndm - 1][i]; - ppVal[0][0] = ppValues[0][i]; - - ivas_quantise_real_values( ppVal, q_lvl, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - ppIndex[0][i] = ppIdx[0][0]; - ppQuant[0][i] = ppVal[0][0]; - } -#else for ( i = 0; i < dim1; i++ ) { q_lvl = dtx_pr_real_q_levels[ndm - 1][i]; ivas_quantise_real_values( &pValues[i], q_lvl, pr_min_max[0], pr_min_max[1], &pIndex[i], &pQuant[i], 1 ); } -#endif return; } @@ -1607,48 +1526,23 @@ static void ivas_spar_quant_pred_coeffs_dtx( *-----------------------------------------------------------------------------------------*/ static void ivas_quant_p_per_band_dtx( -#ifdef QUANTISE_REAL_FCN_CLEAN_UP float *pP_mat, -#else - float **ppP_mat, -#endif const int16_t num_dec, const int16_t num_dmx, int16_t *ppIdx_pd, -#ifdef QUANTISE_REAL_FCN_CLEAN_UP float *pP_out, -#else - float **ppP_out, -#endif const int16_t num_ch ) { int16_t i; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float **ppPd, *pPd, pd; - int16_t **ppIdx, *pIdx, idx; -#endif int16_t dim = num_ch - num_dmx; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppPd = (float **) &pPd; - ppIdx = (int16_t **) &pIdx; - ppPd[0] = (float *) &pd; - ppIdx[0] = (int16_t *) &idx; -#endif if ( num_dec == num_ch - 1 ) { for ( i = 0; i < dim; i++ ) { -#ifdef QUANTISE_REAL_FCN_CLEAN_UP if ( pP_mat[i] < pr_boost_range[1] && pP_mat[i] > pr_boost_range[0] ) { pP_mat[i] = pr_boost_range[1]; } -#else - if ( ppP_mat[i][i] < pr_boost_range[1] && ppP_mat[i][i] > pr_boost_range[0] ) - { - ppP_mat[i][i] = pr_boost_range[1]; - } -#endif } } @@ -1656,20 +1550,10 @@ static void ivas_quant_p_per_band_dtx( { assert( !"Not Supported!" ); } -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim; i++ ) - { - ppPd[0][0] = ppP_mat[i][i]; - ivas_quantise_real_values( ppPd, dtx_pd_real_q_levels[num_ch - num_dec - 1][i], dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], ppIdx, ppPd, 1, 1 ); - ppP_out[i][i] = ppPd[0][0]; - ppIdx_pd[i] = ppIdx[0][0]; - } -#else for ( i = 0; i < dim; i++ ) { ivas_quantise_real_values( &pP_mat[i], dtx_pd_real_q_levels[num_ch - num_dec - 1][i], dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &ppIdx_pd[i], &pP_out[i], 1 ); } -#endif return; } @@ -1687,23 +1571,11 @@ static void ivas_write_parameter_bitstream_dtx( const int16_t num_bands ) { int16_t i, j; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP float val; int16_t idx; -#else - float **ppVal, *pVal, val; - int16_t **ppIdx, *pIdx, idx; -#endif float pr_min_max[2]; int16_t zero_pad_bits, sid_bits_len; sid_bits_len = hMetaData->nb_bits_tot; -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - ppVal = (float **) &pVal; - ppIdx = (int16_t **) &pIdx; - - ppVal[0] = (float *) &val; - ppIdx[0] = (int16_t *) &idx; -#endif pr_min_max[0] = pSpar_md->min_max[0]; pr_min_max[1] = pSpar_md->min_max[1]; @@ -1741,7 +1613,6 @@ static void ivas_write_parameter_bitstream_dtx( pd_q_lvls = dtx_pd_real_q_levels[ndm - 1][pd_idx_2 - 1]; pd = pSpar_md->band_coeffs_idx[i].decd_index_re[pd_idx_2 - 1]; } -#ifdef QUANTISE_REAL_FCN_CLEAN_UP val = dtx_pd_real_min_max[0]; ivas_quantise_real_values( &val, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], &idx, &val, 1 ); @@ -1751,17 +1622,6 @@ static void ivas_write_parameter_bitstream_dtx( ivas_quantise_real_values( &val, pr_q_lvls, pr_min_max[0], pr_min_max[1], &idx, &val, 1 ); pr -= idx; -#else - ppVal[0][0] = dtx_pd_real_min_max[0]; - ivas_quantise_real_values( ppVal, pd_q_lvls, dtx_pd_real_min_max[0], dtx_pd_real_min_max[1], ppIdx, ppVal, 1, 1 ); - - pd -= ppIdx[0][0]; - - ppVal[0][0] = pr_min_max[0]; - ivas_quantise_real_values( ppVal, pr_q_lvls, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - - pr -= ppIdx[0][0]; -#endif pr_pd_bits = ivas_get_bits_to_encode( pd_q_lvls * pr_q_lvls ); value = (uint16_t) ( pr * pd_q_lvls + pd ); @@ -1774,7 +1634,6 @@ static void ivas_write_parameter_bitstream_dtx( int16_t pr_idx1, pr_idx2, pr_pr_bits; pr_q_lvls1 = dtx_pr_real_q_levels[ndm - 1][pr_idx_1 - 1]; pr_q_lvls2 = dtx_pr_real_q_levels[ndm - 1][pr_idx_2 - 1]; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP val = pr_min_max[0]; ivas_quantise_real_values( &val, pr_q_lvls1, pr_min_max[0], pr_min_max[1], &idx, &val, 1 ); @@ -1788,21 +1647,6 @@ static void ivas_write_parameter_bitstream_dtx( pr_idx2 = pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_2 - 1]; pr_idx2 -= idx; -#else - ppVal[0][0] = pr_min_max[0]; - ivas_quantise_real_values( ppVal, pr_q_lvls1, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - - pr_idx1 = pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_1 - 1]; - - pr_idx1 -= ppIdx[0][0]; - - ppVal[0][0] = pr_min_max[0]; - ivas_quantise_real_values( ppVal, pr_q_lvls2, pr_min_max[0], pr_min_max[1], ppIdx, ppVal, 1, 1 ); - - pr_idx2 = pSpar_md->band_coeffs_idx[i].pred_index_re[pr_idx_2 - 1]; - - pr_idx2 -= ppIdx[0][0]; -#endif value = (uint16_t) ( pr_idx2 * pr_q_lvls1 + pr_idx1 ); pr_pr_bits = ivas_get_bits_to_encode( pr_q_lvls1 * pr_q_lvls2 ); @@ -1839,22 +1683,7 @@ static void ivas_quant_pred_coeffs_per_band( ivas_quant_strat_t *pQs, const int16_t num_ch ) { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float *pQuant_re, *pCoeff_re; - int16_t *pIdx_re; - float **ppPred_coeffs_re = (float **) &pCoeff_re; - float **ppPred_quant_re = (float **) &pQuant_re; - int16_t **ppPred_idx_re = (int16_t **) &pIdx_re; - - ppPred_idx_re[0] = &pBand_coeffs_idx->pred_index_re[0]; - ppPred_coeffs_re[0] = &pband_coeffs->pred_re[0]; - ppPred_quant_re[0] = &pband_coeffs->pred_quant_re[0]; -#endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_quantise_real_values( pband_coeffs->pred_re, pQs->PR.q_levels[0], pQs->PR.min, pQs->PR.max, pBand_coeffs_idx->pred_index_re, pband_coeffs->pred_quant_re, ( num_ch - 1 ) ); -#else - ivas_quantise_real_values( ppPred_coeffs_re, pQs->PR.q_levels[0], pQs->PR.min, pQs->PR.max, ppPred_idx_re, ppPred_quant_re, 1, ( num_ch - 1 ) ); -#endif return; } @@ -1875,29 +1704,6 @@ static void ivas_quant_c_per_band( int16_t i; int16_t j, k; float C_re[IVAS_SPAR_MAX_C_COEFF]; -#ifdef QUANTISE_REAL_FCN_CLEAN_UP - - k = 0; - for ( i = 0; i < ndec; i++ ) - { - for ( j = 0; j < ndm - 1; j++ ) - { - C_re[k] = pband_coeffs->C_re[i][j]; - k++; - } - } -#else - float *pC_re[IVAS_SPAR_MAX_C_COEFF]; - int16_t *pIdx_re[IVAS_SPAR_MAX_C_COEFF]; - float **ppC_re = (float **) &pC_re[0]; - int16_t **ppIdx_re = (int16_t **) &pIdx_re[0]; - - for ( i = 0; i < ndec * ( ndm - 1 ); i++ ) - { - ppC_re[i] = &C_re[i]; - ppIdx_re[i] = &pBand_coeffs_idx->drct_index_re[i]; - } - k = 0; for ( i = 0; i < ndec; i++ ) { @@ -1907,21 +1713,16 @@ static void ivas_quant_c_per_band( k++; } } -#endif #ifdef SPAR_HOA_DBG /*for (i = 0; i < ndec; i++) { - for (j = 0; j < ndm - 1; j++) - { - ppIdx_re[i][j] = 100; - } + for (j = 0; j < ndm - 1; j++) + { + ppIdx_re[i][j] = 100; + } }*/ #endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_quantise_real_values( C_re, pQs->C.q_levels[0], pQs->C.min, pQs->C.max, pBand_coeffs_idx->drct_index_re, C_re, ndec * ( ndm - 1 ) ); -#else - ivas_quantise_real_values( ppC_re, pQs->C.q_levels[0], pQs->C.min, pQs->C.max, ppIdx_re, ppC_re, ndec * ( ndm - 1 ), 1 ); -#endif k = 0; for ( i = 0; i < ndec; i++ ) { @@ -1936,11 +1737,11 @@ static void ivas_quant_c_per_band( k = 0; for (i = 0; i < ndec; i++) { - for (j = 0; j < ndm - 1; j++) - { - fprintf(stderr, "%d,%d: %f, %f, %d\n", i, j, pband_coeffs->C_re[i][j], pband_coeffs->C_quant_re[i][j], pBand_coeffs_idx->drct_index_re[k]); - k++; - } + for (j = 0; j < ndm - 1; j++) + { + fprintf(stderr, "%d,%d: %f, %f, %d\n", i, j, pband_coeffs->C_re[i][j], pband_coeffs->C_quant_re[i][j], pBand_coeffs_idx->drct_index_re[k]); + k++; + } }*/ #endif @@ -1960,46 +1761,14 @@ static void ivas_quant_p_per_band( ivas_quant_strat_t *pQs, const int16_t num_ch ) { -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - float P_re_diag[IVAS_SPAR_MAX_CH - 1]; - int16_t i; - int16_t dim = num_ch - 1; - float *pP_diag[IVAS_SPAR_MAX_CH - 1]; - int16_t *pDecd_idx[IVAS_SPAR_MAX_CH - 1]; - float **ppP_diag = (float **) &pP_diag[0]; - int16_t **ppDecd_idx = (int16_t **) &pDecd_idx[0]; -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim; i++ ) - { - ppP_diag[i] = &P_re_diag[i]; - ppDecd_idx[i] = &pBand_coeffs_idx->decd_index_re[i]; - } -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim; i++ ) - { - P_re_diag[i] = pband_coeffs->P_re[i]; - } -#endif #ifdef SPAR_HOA_DBG /*fprintf(stderr, "\n\n P_d:\n"); for (i = 0; i < dim; i++) { - fprintf(stderr, "%f, ", P_re_diag[i]); + fprintf(stderr, "%f, ", P_re_diag[i]); } fprintf(stderr, "\n\n");*/ #endif -#ifdef QUANTISE_REAL_FCN_CLEAN_UP ivas_quantise_real_values( pband_coeffs->P_re, pQs->P_r.q_levels[0], pQs->P_r.min, pQs->P_r.max, pBand_coeffs_idx->decd_index_re, pband_coeffs->P_quant_re, num_ch - 1 ); -#else - ivas_quantise_real_values( ppP_diag, pQs->P_r.q_levels[0], pQs->P_r.min, pQs->P_r.max, ppDecd_idx, ppP_diag, num_ch - 1, 1 ); -#endif -#ifndef QUANTISE_REAL_FCN_CLEAN_UP - for ( i = 0; i < dim; i++ ) - { - pband_coeffs->P_quant_re[i] = P_re_diag[i]; - } -#endif return; }