Loading lib_com/options.h 100755 → 100644 +2 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,8 @@ #define FIX_562_ISM2_64KBPS /* VA: issue 562: fix ISM2 at 64kbps issue */ #define FIX_559_EXTL_IGF_MISMATCH /* VA: issue 559: fix mismatch between st->extl and st->igf observed as crash in PlanarSBA bitrate switching */ #define FIX_QMETA_SID_5k2 /* Nokia: Issue 137: enable using full 5.2k bitrate in MASA SID */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading lib_dec/ivas_qmetadata_dec.c +86 −8 Original line number Diff line number Diff line Loading @@ -1181,6 +1181,9 @@ int16_t ivas_qmetadata_dec_sid_decode( float avg_direction_vector[3]; float direction_vector[3]; int16_t metadata_sid_bits; /* bits allocated to SID for metadata */ #ifdef FIX_QMETA_SID_5k2 int16_t bits_delta, bits_dir; #endif #ifdef DEBUG_MODE_QMETADATA static FILE *pF = NULL; static FILE *pF_azi = NULL; Loading @@ -1204,8 +1207,12 @@ int16_t ivas_qmetadata_dec_sid_decode( } else { #ifdef FIX_QMETA_SID_5k2 metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #else /* TODO: still use old sid frame size to keep bitexactness */ metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #endif } start_index = *index; Loading Loading @@ -1247,16 +1254,80 @@ int16_t ivas_qmetadata_dec_sid_decode( { q_direction->not_in_2D = 1; } #ifdef FIX_QMETA_SID_5k2 bits_dir = 0; if ( ivas_format != SBA_FORMAT ) { /* Decode diffuseness*/ for ( b = start_band; b < nbands; b++ ) { diffuseness_index[b] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ) + 4; q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[diffuseness_index[b]]; bits_dir += q_direction->band_data[b].bits_sph_idx[0]; q_direction->band_data[b].azimuth_m_alphabet[0] = no_phi_masa[q_direction->band_data[b].bits_sph_idx[0] - 1][0]; } bits_delta = metadata_sid_bits - ( start_index - *index ) - bits_dir; /* bit_diff is already read */ if ( bits_delta > 0 ) { while ( bits_delta > 0 ) { for ( b = start_band; b < nbands && ( bits_delta > 0 ); b++ ) { if ( q_direction->band_data[b].bits_sph_idx[0] < 11 ) { bits_delta -= 1; q_direction->band_data[b].bits_sph_idx[0]++; } } } if ( q_direction->not_in_2D == 0 ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } else { while ( bits_delta < 0 ) { for ( b = nbands - 1; b >= start_band && ( bits_delta < 0 ); b-- ) { if ( q_direction->band_data[b].bits_sph_idx[0] >= 4 ) { bits_delta += 1; q_direction->band_data[b].bits_sph_idx[0]--; } } if ( q_direction->not_in_2D == 0 ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } } } else { #endif /* Decode diffuseness*/ for ( b = start_band; b < nbands; b++ ) { diffuseness_index[b] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ) + 4; q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[diffuseness_index[b]]; q_direction->band_data[b].azimuth_m_alphabet[0] = no_phi_masa[q_direction->band_data[b].bits_sph_idx[0] - 1][0]; } #ifdef FIX_QMETA_SID_5k2 } #endif for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio[0] = 1.0f - diffuseness_reconstructions[diffuseness_index[b]]; Loading Loading @@ -1299,7 +1370,14 @@ int16_t ivas_qmetadata_dec_sid_decode( { for ( b = start_band; b < nbands; b++ ) { #ifdef FIX_QMETA_SID_5k2 if ( ivas_format == SBA_FORMAT ) { #endif q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ); #ifdef FIX_QMETA_SID_5k2 } #endif q_direction->band_data[b].azimuth_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, q_direction->band_data[b].azimuth_m_alphabet[0] ); q_direction->band_data[b].azimuth_index[0] = ivas_qmetadata_dereorder_generic( q_direction->band_data[b].azimuth_index[0] ) + ( q_direction->band_data[b].azimuth_m_alphabet[0] >> 1 ); avg_azimuth = 360.0f / (float) ( q_direction->band_data[b].azimuth_m_alphabet[0] ) * q_direction->band_data[b].azimuth_index[0] - 180; Loading lib_enc/ivas_qmetadata_enc.c +94 −18 Original line number Diff line number Diff line Loading @@ -833,6 +833,10 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( } #endif #ifdef FIX_QMETA_SID_5k2 q_direction->not_in_2D = 0; #endif /*Coherence */ if ( all_coherence_zero == 0 ) { Loading Loading @@ -980,7 +984,11 @@ void ivas_qmetadata_enc_sid_encode( else { /* TODO: still use old sid frame size to keep bitexactness */ #ifdef FIX_QMETA_SID_5k2 metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #else metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #endif } #ifdef DEBUG_MODE_QMETADATA Loading Loading @@ -1036,12 +1044,77 @@ void ivas_qmetadata_enc_sid_encode( /*Encode the quantized diffuseness in raw coding*/ bits_dir = 0; bits_diff = 0; #ifdef FIX_QMETA_SID_5k2 if ( ivas_format != SBA_FORMAT ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = max( q_direction->band_data[b].energy_ratio_index[0], 4 ); bits_diff += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0] - 4, DIRAC_DIFFUSE_LEVELS - 4 ); q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[q_direction->band_data[b].energy_ratio_index[0]]; if ( q_direction->not_in_2D == 0 ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); bits_dir += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].azimuth_m_alphabet[0] - 1, q_direction->band_data[b].azimuth_m_alphabet[0] ); } else { bits_dir += q_direction->band_data[b].bits_sph_idx[0]; } } /* Reduce bit demand by increasing diffuseness*/ bits_delta = metadata_sid_bits - ( hMetaData->nb_bits_tot - bit_pos_start ) - bits_diff - bits_dir; if ( bits_delta > 0 ) { while ( bits_delta > 0 ) { for ( b = start_band; b < nbands && ( bits_delta > 0 ); b++ ) { if ( q_direction->band_data[b].bits_sph_idx[0] < 11 ) { bits_delta -= 1; q_direction->band_data[b].bits_sph_idx[0]++; } } } if ( q_direction->not_in_2D == 0 ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } else { while ( bits_delta < 0 ) { for ( b = nbands - 1; b >= start_band && ( bits_delta < 0 ); b-- ) { if ( q_direction->band_data[b].bits_sph_idx[0] >= 4 ) { bits_delta += 1; q_direction->band_data[b].bits_sph_idx[0]--; if ( q_direction->not_in_2D == 0 ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } } } } else { #endif for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = max( q_direction->band_data[b].energy_ratio_index[0], 4 ); bits_diff += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0] - 4, DIRAC_DIFFUSE_LEVELS - 4 ); q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[q_direction->band_data[b].energy_ratio_index[0]]; if ( q_direction->not_in_2D == 0 ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ); Loading Loading @@ -1069,6 +1142,9 @@ void ivas_qmetadata_enc_sid_encode( } } } #ifdef FIX_QMETA_SID_5k2 } #endif assert( ( bits_delta >= 0 ) && "Bit budget in Qmetadata SID is violated!!!" ); /*Code diffuseness*/ Loading Loading
lib_com/options.h 100755 → 100644 +2 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,8 @@ #define FIX_562_ISM2_64KBPS /* VA: issue 562: fix ISM2 at 64kbps issue */ #define FIX_559_EXTL_IGF_MISMATCH /* VA: issue 559: fix mismatch between st->extl and st->igf observed as crash in PlanarSBA bitrate switching */ #define FIX_QMETA_SID_5k2 /* Nokia: Issue 137: enable using full 5.2k bitrate in MASA SID */ /* ################## End DEVELOPMENT switches ######################### */ /* clang-format on */ Loading
lib_dec/ivas_qmetadata_dec.c +86 −8 Original line number Diff line number Diff line Loading @@ -1181,6 +1181,9 @@ int16_t ivas_qmetadata_dec_sid_decode( float avg_direction_vector[3]; float direction_vector[3]; int16_t metadata_sid_bits; /* bits allocated to SID for metadata */ #ifdef FIX_QMETA_SID_5k2 int16_t bits_delta, bits_dir; #endif #ifdef DEBUG_MODE_QMETADATA static FILE *pF = NULL; static FILE *pF_azi = NULL; Loading @@ -1204,8 +1207,12 @@ int16_t ivas_qmetadata_dec_sid_decode( } else { #ifdef FIX_QMETA_SID_5k2 metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #else /* TODO: still use old sid frame size to keep bitexactness */ metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #endif } start_index = *index; Loading Loading @@ -1247,16 +1254,80 @@ int16_t ivas_qmetadata_dec_sid_decode( { q_direction->not_in_2D = 1; } #ifdef FIX_QMETA_SID_5k2 bits_dir = 0; if ( ivas_format != SBA_FORMAT ) { /* Decode diffuseness*/ for ( b = start_band; b < nbands; b++ ) { diffuseness_index[b] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ) + 4; q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[diffuseness_index[b]]; bits_dir += q_direction->band_data[b].bits_sph_idx[0]; q_direction->band_data[b].azimuth_m_alphabet[0] = no_phi_masa[q_direction->band_data[b].bits_sph_idx[0] - 1][0]; } bits_delta = metadata_sid_bits - ( start_index - *index ) - bits_dir; /* bit_diff is already read */ if ( bits_delta > 0 ) { while ( bits_delta > 0 ) { for ( b = start_band; b < nbands && ( bits_delta > 0 ); b++ ) { if ( q_direction->band_data[b].bits_sph_idx[0] < 11 ) { bits_delta -= 1; q_direction->band_data[b].bits_sph_idx[0]++; } } } if ( q_direction->not_in_2D == 0 ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } else { while ( bits_delta < 0 ) { for ( b = nbands - 1; b >= start_band && ( bits_delta < 0 ); b-- ) { if ( q_direction->band_data[b].bits_sph_idx[0] >= 4 ) { bits_delta += 1; q_direction->band_data[b].bits_sph_idx[0]--; } } if ( q_direction->not_in_2D == 0 ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } } } else { #endif /* Decode diffuseness*/ for ( b = start_band; b < nbands; b++ ) { diffuseness_index[b] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, DIRAC_DIFFUSE_LEVELS - 4 ) + 4; q_direction->band_data[b].energy_ratio_index[0] = diffuseness_index[b]; q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[diffuseness_index[b]]; q_direction->band_data[b].azimuth_m_alphabet[0] = no_phi_masa[q_direction->band_data[b].bits_sph_idx[0] - 1][0]; } #ifdef FIX_QMETA_SID_5k2 } #endif for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio[0] = 1.0f - diffuseness_reconstructions[diffuseness_index[b]]; Loading Loading @@ -1299,7 +1370,14 @@ int16_t ivas_qmetadata_dec_sid_decode( { for ( b = start_band; b < nbands; b++ ) { #ifdef FIX_QMETA_SID_5k2 if ( ivas_format == SBA_FORMAT ) { #endif q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ); #ifdef FIX_QMETA_SID_5k2 } #endif q_direction->band_data[b].azimuth_index[0] = ivas_qmetadata_DecodeQuasiUniform( bitstream, index, q_direction->band_data[b].azimuth_m_alphabet[0] ); q_direction->band_data[b].azimuth_index[0] = ivas_qmetadata_dereorder_generic( q_direction->band_data[b].azimuth_index[0] ) + ( q_direction->band_data[b].azimuth_m_alphabet[0] >> 1 ); avg_azimuth = 360.0f / (float) ( q_direction->band_data[b].azimuth_m_alphabet[0] ) * q_direction->band_data[b].azimuth_index[0] - 180; Loading
lib_enc/ivas_qmetadata_enc.c +94 −18 Original line number Diff line number Diff line Loading @@ -833,6 +833,10 @@ ivas_error ivas_qmetadata_enc_encode_hr_384_512( } #endif #ifdef FIX_QMETA_SID_5k2 q_direction->not_in_2D = 0; #endif /*Coherence */ if ( all_coherence_zero == 0 ) { Loading Loading @@ -980,7 +984,11 @@ void ivas_qmetadata_enc_sid_encode( else { /* TODO: still use old sid frame size to keep bitexactness */ #ifdef FIX_QMETA_SID_5k2 metadata_sid_bits = ( IVAS_SID_5k2 - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #else metadata_sid_bits = ( 4400 /*IVAS_SID_5k2*/ - SID_2k40 ) / FRAMES_PER_SEC - SID_FORMAT_NBITS; #endif } #ifdef DEBUG_MODE_QMETADATA Loading Loading @@ -1036,12 +1044,77 @@ void ivas_qmetadata_enc_sid_encode( /*Encode the quantized diffuseness in raw coding*/ bits_dir = 0; bits_diff = 0; #ifdef FIX_QMETA_SID_5k2 if ( ivas_format != SBA_FORMAT ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = max( q_direction->band_data[b].energy_ratio_index[0], 4 ); bits_diff += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0] - 4, DIRAC_DIFFUSE_LEVELS - 4 ); q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[q_direction->band_data[b].energy_ratio_index[0]]; if ( q_direction->not_in_2D == 0 ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); bits_dir += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].azimuth_m_alphabet[0] - 1, q_direction->band_data[b].azimuth_m_alphabet[0] ); } else { bits_dir += q_direction->band_data[b].bits_sph_idx[0]; } } /* Reduce bit demand by increasing diffuseness*/ bits_delta = metadata_sid_bits - ( hMetaData->nb_bits_tot - bit_pos_start ) - bits_diff - bits_dir; if ( bits_delta > 0 ) { while ( bits_delta > 0 ) { for ( b = start_band; b < nbands && ( bits_delta > 0 ); b++ ) { if ( q_direction->band_data[b].bits_sph_idx[0] < 11 ) { bits_delta -= 1; q_direction->band_data[b].bits_sph_idx[0]++; } } } if ( q_direction->not_in_2D == 0 ) { for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } else { while ( bits_delta < 0 ) { for ( b = nbands - 1; b >= start_band && ( bits_delta < 0 ); b-- ) { if ( q_direction->band_data[b].bits_sph_idx[0] >= 4 ) { bits_delta += 1; q_direction->band_data[b].bits_sph_idx[0]--; if ( q_direction->not_in_2D == 0 ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 8, q_direction->band_data[b].bits_sph_idx[0] ) ); } } } } } } else { #endif for ( b = start_band; b < nbands; b++ ) { q_direction->band_data[b].energy_ratio_index[0] = max( q_direction->band_data[b].energy_ratio_index[0], 4 ); bits_diff += ivas_qmetadata_encode_quasi_uniform_length( q_direction->band_data[b].energy_ratio_index[0] - 4, DIRAC_DIFFUSE_LEVELS - 4 ); q_direction->band_data[b].bits_sph_idx[0] = bits_direction_masa[q_direction->band_data[b].energy_ratio_index[0]]; if ( q_direction->not_in_2D == 0 ) { q_direction->band_data[b].azimuth_m_alphabet[0] = 1 << ( min( 5, q_direction->band_data[b].bits_sph_idx[0] ) ); Loading Loading @@ -1069,6 +1142,9 @@ void ivas_qmetadata_enc_sid_encode( } } } #ifdef FIX_QMETA_SID_5k2 } #endif assert( ( bits_delta >= 0 ) && "Bit budget in Qmetadata SID is violated!!!" ); /*Code diffuseness*/ Loading