Loading lib_enc/ivas_qmetadata_enc.c +1 −100 Original line number Diff line number Diff line Loading @@ -49,8 +49,8 @@ #ifdef DEBUG_MODE_QMETADATA static float direction_distance( float elevation[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], float azimuth[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], IVAS_QDIRECTION *q_direction, const int16_t dim1, const int16_t dim2, float mat_dist[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] ); #endif #endif static void ivas_qmetadata_quantize_diffuseness_nrg_ratios( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, int16_t *nbits_diff, int16_t *dfRatioBits, const int16_t hodirac_flag ); static int16_t ivas_qmetadata_entropy_encode_diffuseness( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ); Loading Loading @@ -115,8 +115,6 @@ static void transform_azimuth_dir2( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *d static int16_t calc_var_azi( const IVAS_QDIRECTION *q_direction, const int16_t diffuseness_index_max_ec_frame, const float avg_azimuth, float *avg_azimuth_out ); static int16_t ivas_qmetadata_entropy_encode_diffuseness_hr( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ); static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, const int16_t bits_dir_hr, BSTR_ENC_HANDLE hMetaData ); static int16_t encode_surround_coherence_hr( IVAS_QMETADATA *hQMetaData, BSTR_ENC_HANDLE hMetaData ); Loading Loading @@ -1454,103 +1452,6 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( } /*------------------------------------------------------------------------- * ivas_qmetadata_entropy_encode_diffuseness() * * encode diffuseness *------------------------------------------------------------------------*/ static int16_t ivas_qmetadata_entropy_encode_diffuseness_hr( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ) { int16_t start_bit_pos; int16_t diffuseness_bits_raw; int16_t b; int16_t min_diffuseness_m_index, max_diffuseness_m_index; int16_t nbands; int16_t start_band; nbands = q_direction->cfg.nbands; start_band = q_direction->cfg.start_band; start_bit_pos = hMetaData->nb_bits_tot; if ( nbands == 1 ) { /* If there is only one band, diffuseness should be coded directly as raw with no signaling. */ push_next_indice( hMetaData, q_direction->band_data[0].energy_ratio_index[0], MASA_BITS_ER_HR ); *diffuseness_index_max_ec_frame = 10; return ( hMetaData->nb_bits_tot - start_bit_pos ); } /* compute the number of raw coding bits */ diffuseness_bits_raw = 0; for ( b = start_band; b < nbands; b++ ) { diffuseness_bits_raw += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0], HR_MASA_ER_LEVELS ); } min_diffuseness_m_index = q_direction->band_data[start_band].energy_ratio_index[0]; max_diffuseness_m_index = q_direction->band_data[start_band].energy_ratio_index[0]; for ( b = start_band; b < nbands; b++ ) { if ( q_direction->band_data[b].energy_ratio_index[0] < min_diffuseness_m_index ) { min_diffuseness_m_index = q_direction->band_data[b].energy_ratio_index[0]; } if ( q_direction->band_data[b].energy_ratio_index[0] > max_diffuseness_m_index ) { max_diffuseness_m_index = q_direction->band_data[b].energy_ratio_index[0]; } } /* Use similarity coding approach or raw coding when there is a low number of bands. */ /* one bit is used to indicate whether diffuseness values are entropy coded or coded raw */ if ( min_diffuseness_m_index == max_diffuseness_m_index ) /* all values are equal */ { push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */ push_next_indice( hMetaData, 1, 1 ); /* dif_have_unique_value */ ivas_qmetadata_encode_quasi_uniform( hMetaData, min_diffuseness_m_index, HR_MASA_ER_LEVELS ); /* dif_unique_value */ } else if ( min_diffuseness_m_index + 1 == max_diffuseness_m_index ) /* only two consecutive values are present */ { push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */ push_next_indice( hMetaData, 0, 1 ); /* dif_have_unique_value */ ivas_qmetadata_encode_quasi_uniform( hMetaData, min_diffuseness_m_index, HR_MASA_ER_LEVELS - 1 ); /* dif_min_value */ for ( b = start_band; b < nbands; b++ ) { push_next_indice( hMetaData, q_direction->band_data[b].energy_ratio_index[0] - min_diffuseness_m_index, 1 ); /* dif_bit_offset_values */ } } else /* raw coding */ { push_next_indice( hMetaData, 1, 1 ); /* dif_use_raw_coding */ for ( b = start_band; b < nbands; b++ ) { ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[b].energy_ratio_index[0], HR_MASA_ER_LEVELS ); /* dif_values */ } } *diffuseness_index_max_ec_frame = 10; /* adaptively select the diffuseness_index_max_ec threshold */ if ( min_diffuseness_m_index > 10 ) { *diffuseness_index_max_ec_frame = HR_MASA_ER_LEVELS - 1; } #ifdef DEBUGGING assert( ( hMetaData->nb_bits_tot - start_bit_pos ) <= 1 + diffuseness_bits_raw ); #endif return ( hMetaData->nb_bits_tot - start_bit_pos ); } /*------------------------------------------------------------------------- * ivas_qmetadata_quantize_diffuseness_nrg_ratios() * Loading Loading
lib_enc/ivas_qmetadata_enc.c +1 −100 Original line number Diff line number Diff line Loading @@ -49,8 +49,8 @@ #ifdef DEBUG_MODE_QMETADATA static float direction_distance( float elevation[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], float azimuth[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES], IVAS_QDIRECTION *q_direction, const int16_t dim1, const int16_t dim2, float mat_dist[DIRAC_MAX_NBANDS][MAX_PARAM_SPATIAL_SUBFRAMES] ); #endif #endif static void ivas_qmetadata_quantize_diffuseness_nrg_ratios( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, int16_t *nbits_diff, int16_t *dfRatioBits, const int16_t hodirac_flag ); static int16_t ivas_qmetadata_entropy_encode_diffuseness( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ); Loading Loading @@ -115,8 +115,6 @@ static void transform_azimuth_dir2( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *d static int16_t calc_var_azi( const IVAS_QDIRECTION *q_direction, const int16_t diffuseness_index_max_ec_frame, const float avg_azimuth, float *avg_azimuth_out ); static int16_t ivas_qmetadata_entropy_encode_diffuseness_hr( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ); static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( IVAS_QMETADATA_HANDLE hQMetaData, int16_t *needed_bits, const int16_t bits_dir_hr, BSTR_ENC_HANDLE hMetaData ); static int16_t encode_surround_coherence_hr( IVAS_QMETADATA *hQMetaData, BSTR_ENC_HANDLE hMetaData ); Loading Loading @@ -1454,103 +1452,6 @@ static void ivas_qmetadata_quantize_diffuseness_nrg_ratios_hr_512( } /*------------------------------------------------------------------------- * ivas_qmetadata_entropy_encode_diffuseness() * * encode diffuseness *------------------------------------------------------------------------*/ static int16_t ivas_qmetadata_entropy_encode_diffuseness_hr( BSTR_ENC_HANDLE hMetaData, IVAS_QDIRECTION *q_direction, uint16_t *diffuseness_index_max_ec_frame ) { int16_t start_bit_pos; int16_t diffuseness_bits_raw; int16_t b; int16_t min_diffuseness_m_index, max_diffuseness_m_index; int16_t nbands; int16_t start_band; nbands = q_direction->cfg.nbands; start_band = q_direction->cfg.start_band; start_bit_pos = hMetaData->nb_bits_tot; if ( nbands == 1 ) { /* If there is only one band, diffuseness should be coded directly as raw with no signaling. */ push_next_indice( hMetaData, q_direction->band_data[0].energy_ratio_index[0], MASA_BITS_ER_HR ); *diffuseness_index_max_ec_frame = 10; return ( hMetaData->nb_bits_tot - start_bit_pos ); } /* compute the number of raw coding bits */ diffuseness_bits_raw = 0; for ( b = start_band; b < nbands; b++ ) { diffuseness_bits_raw += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0], HR_MASA_ER_LEVELS ); } min_diffuseness_m_index = q_direction->band_data[start_band].energy_ratio_index[0]; max_diffuseness_m_index = q_direction->band_data[start_band].energy_ratio_index[0]; for ( b = start_band; b < nbands; b++ ) { if ( q_direction->band_data[b].energy_ratio_index[0] < min_diffuseness_m_index ) { min_diffuseness_m_index = q_direction->band_data[b].energy_ratio_index[0]; } if ( q_direction->band_data[b].energy_ratio_index[0] > max_diffuseness_m_index ) { max_diffuseness_m_index = q_direction->band_data[b].energy_ratio_index[0]; } } /* Use similarity coding approach or raw coding when there is a low number of bands. */ /* one bit is used to indicate whether diffuseness values are entropy coded or coded raw */ if ( min_diffuseness_m_index == max_diffuseness_m_index ) /* all values are equal */ { push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */ push_next_indice( hMetaData, 1, 1 ); /* dif_have_unique_value */ ivas_qmetadata_encode_quasi_uniform( hMetaData, min_diffuseness_m_index, HR_MASA_ER_LEVELS ); /* dif_unique_value */ } else if ( min_diffuseness_m_index + 1 == max_diffuseness_m_index ) /* only two consecutive values are present */ { push_next_indice( hMetaData, 0, 1 ); /* dif_use_raw_coding */ push_next_indice( hMetaData, 0, 1 ); /* dif_have_unique_value */ ivas_qmetadata_encode_quasi_uniform( hMetaData, min_diffuseness_m_index, HR_MASA_ER_LEVELS - 1 ); /* dif_min_value */ for ( b = start_band; b < nbands; b++ ) { push_next_indice( hMetaData, q_direction->band_data[b].energy_ratio_index[0] - min_diffuseness_m_index, 1 ); /* dif_bit_offset_values */ } } else /* raw coding */ { push_next_indice( hMetaData, 1, 1 ); /* dif_use_raw_coding */ for ( b = start_band; b < nbands; b++ ) { ivas_qmetadata_encode_quasi_uniform( hMetaData, q_direction->band_data[b].energy_ratio_index[0], HR_MASA_ER_LEVELS ); /* dif_values */ } } *diffuseness_index_max_ec_frame = 10; /* adaptively select the diffuseness_index_max_ec threshold */ if ( min_diffuseness_m_index > 10 ) { *diffuseness_index_max_ec_frame = HR_MASA_ER_LEVELS - 1; } #ifdef DEBUGGING assert( ( hMetaData->nb_bits_tot - start_bit_pos ) <= 1 + diffuseness_bits_raw ); #endif return ( hMetaData->nb_bits_tot - start_bit_pos ); } /*------------------------------------------------------------------------- * ivas_qmetadata_quantize_diffuseness_nrg_ratios() * Loading