Loading .gitlab-ci.yml +40 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ variables: OUT_FORMATS_BINAURAL: "BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB" EXIT_CODE_NON_BE: 123 EXIT_CODE_FAIL: 1 PROCESSING_SCRIPTS_BIN_DIR: "/test-bin" default: interruptible: true # Make all jobs by default interruptible Loading Loading @@ -692,6 +693,45 @@ check-first-frame-is-sid: expose_as: "logs-sidstart" expire_in: "5 days" selection-test-processing: extends: - .test-job-linux-needs-testv-dir - .rules-merge-request tags: - processing-scripts-linux stage: test needs: ["build-codec-linux-make"] script: # get processing script code - git clone https://forge.3gpp.org/rep/ivas-codec-pc/ivas-processing-scripts.git --single-branch -b main - mkdir -p ivas-processing-scripts/tests/data/testv - cp -r scripts/testv/* ivas-processing-scripts/tests/data/testv/ # copy binaries into local bin dir, those should take precendence over PATH - cp $PROCESSING_SCRIPTS_BIN_DIR/* ivas-processing-scripts/ivas_processing_scripts/bin/ # for testing with native binaries - rm ivas-processing-scripts/ivas_processing_scripts/bin/IVAS*.exe - rm ivas-processing-scripts/ivas_processing_scripts/bin/EVS*.exe # build codec and put into bin dir - make -j - cp ./IVAS_* ivas-processing-scripts/ivas_processing_scripts/bin/ # patch the use_windows_codec_binaries key (weird folding is needed so colons are accepted) - > sed -i "s/use_windows_codec_binaries: true/use_windows_codec_binaries: false/" ivas-processing-scripts/experiments/selection/*/config/*.yml # run experiments test - cd ivas-processing-scripts - python3 -m pytest tests/test_experiments.py::test_generate_test_items -n auto | tee log.txt artifacts: paths: - ivas-processing-scripts/experiments/selection/*/proc_output/*.log - log.txt when: on_failure expire_in: 1 week # --------------------------------------------------------------- # Test jobs for main branch # --------------------------------------------------------------- Loading lib_com/options.h 100755 → 100644 +2 −0 Original line number Diff line number Diff line Loading @@ -148,10 +148,12 @@ #define FIX_558_PLC_DISCONT /* FhG: issue 558: fix discontinuities in DFT Stereo when switching from TCX concealment to ACELP */ #define FIX_564 /* Nokia: Issue 564: Fix gains in JBM path for SBA with parametric binaural renderer */ #define FIX_566_2DIR_MASA_384K /* Nokia: Issued 566: Bugfix in 384k MASA metadata encoding of second direction */ #define FIX_568_ISM_BITRATE_SWITCHING /* Philips: Issue 568: Bugfix for renderer re-initialization by ISM and bitrate switching */ #define FIX_565_SBA_BURST_IN_FEC /* VA: Issue 565: Fix noise burst during FEC, due to wrong total_brate initialization */ #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_ism_dec.c +16 −1 Original line number Diff line number Diff line Loading @@ -168,7 +168,11 @@ static ivas_error ivas_ism_bitrate_switching( /* Deallocate the ParamISM struct */ ivas_param_ism_dec_close( &( st_ivas->hDirAC ), st_ivas->hDecoderConfig->output_config ); #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL ) #endif { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); Loading Loading @@ -198,7 +202,11 @@ static ivas_error ivas_ism_bitrate_switching( } } #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); Loading @@ -221,8 +229,11 @@ static ivas_error ivas_ism_bitrate_switching( { return error; } #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL ) #endif { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) Loading Loading @@ -260,7 +271,11 @@ static ivas_error ivas_ism_bitrate_switching( } } #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) 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
.gitlab-ci.yml +40 −0 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ variables: OUT_FORMATS_BINAURAL: "BINAURAL BINAURAL_ROOM_IR BINAURAL_ROOM_REVERB" EXIT_CODE_NON_BE: 123 EXIT_CODE_FAIL: 1 PROCESSING_SCRIPTS_BIN_DIR: "/test-bin" default: interruptible: true # Make all jobs by default interruptible Loading Loading @@ -692,6 +693,45 @@ check-first-frame-is-sid: expose_as: "logs-sidstart" expire_in: "5 days" selection-test-processing: extends: - .test-job-linux-needs-testv-dir - .rules-merge-request tags: - processing-scripts-linux stage: test needs: ["build-codec-linux-make"] script: # get processing script code - git clone https://forge.3gpp.org/rep/ivas-codec-pc/ivas-processing-scripts.git --single-branch -b main - mkdir -p ivas-processing-scripts/tests/data/testv - cp -r scripts/testv/* ivas-processing-scripts/tests/data/testv/ # copy binaries into local bin dir, those should take precendence over PATH - cp $PROCESSING_SCRIPTS_BIN_DIR/* ivas-processing-scripts/ivas_processing_scripts/bin/ # for testing with native binaries - rm ivas-processing-scripts/ivas_processing_scripts/bin/IVAS*.exe - rm ivas-processing-scripts/ivas_processing_scripts/bin/EVS*.exe # build codec and put into bin dir - make -j - cp ./IVAS_* ivas-processing-scripts/ivas_processing_scripts/bin/ # patch the use_windows_codec_binaries key (weird folding is needed so colons are accepted) - > sed -i "s/use_windows_codec_binaries: true/use_windows_codec_binaries: false/" ivas-processing-scripts/experiments/selection/*/config/*.yml # run experiments test - cd ivas-processing-scripts - python3 -m pytest tests/test_experiments.py::test_generate_test_items -n auto | tee log.txt artifacts: paths: - ivas-processing-scripts/experiments/selection/*/proc_output/*.log - log.txt when: on_failure expire_in: 1 week # --------------------------------------------------------------- # Test jobs for main branch # --------------------------------------------------------------- Loading
lib_com/options.h 100755 → 100644 +2 −0 Original line number Diff line number Diff line Loading @@ -148,10 +148,12 @@ #define FIX_558_PLC_DISCONT /* FhG: issue 558: fix discontinuities in DFT Stereo when switching from TCX concealment to ACELP */ #define FIX_564 /* Nokia: Issue 564: Fix gains in JBM path for SBA with parametric binaural renderer */ #define FIX_566_2DIR_MASA_384K /* Nokia: Issued 566: Bugfix in 384k MASA metadata encoding of second direction */ #define FIX_568_ISM_BITRATE_SWITCHING /* Philips: Issue 568: Bugfix for renderer re-initialization by ISM and bitrate switching */ #define FIX_565_SBA_BURST_IN_FEC /* VA: Issue 565: Fix noise burst during FEC, due to wrong total_brate initialization */ #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_ism_dec.c +16 −1 Original line number Diff line number Diff line Loading @@ -168,7 +168,11 @@ static ivas_error ivas_ism_bitrate_switching( /* Deallocate the ParamISM struct */ ivas_param_ism_dec_close( &( st_ivas->hDirAC ), st_ivas->hDecoderConfig->output_config ); #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL ) #endif { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); Loading Loading @@ -198,7 +202,11 @@ static ivas_error ivas_ism_bitrate_switching( } } #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { /* close the parametric binaural renderer */ ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); Loading @@ -221,8 +229,11 @@ static ivas_error ivas_ism_bitrate_switching( { return error; } #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL ) #endif { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) Loading Loading @@ -260,7 +271,11 @@ static ivas_error ivas_ism_bitrate_switching( } } #ifdef FIX_568_ISM_BITRATE_SWITCHING if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR ) #else if ( st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_IR || st_ivas->hOutSetup.output_config == AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) #endif { /* open the parametric binaural renderer */ if ( ( error = ivas_dirac_dec_binaural_copy_hrtfs( &st_ivas->hHrtfParambin ) ) != IVAS_ERR_OK ) 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