Loading Workspace_msvc/lib_dec.vcxproj +1 −0 Original line number Diff line number Diff line Loading @@ -290,6 +290,7 @@ <ClCompile Include="..\lib_dec\ivas_mc_param_dec.c" /> <ClCompile Include="..\lib_dec\ivas_mdct_core_dec.c" /> <ClCompile Include="..\lib_dec\ivas_mono_dmx_renderer.c" /> <ClCompile Include="..\lib_dec\ivas_omasa_dec.c" /> <ClCompile Include="..\lib_dec\ivas_out_setup_conversion.c" /> <ClCompile Include="..\lib_dec\ivas_pca_dec.c" /> <ClCompile Include="..\lib_dec\ivas_post_proc.c" /> Loading Workspace_msvc/lib_dec.vcxproj.filters +3 −0 Original line number Diff line number Diff line Loading @@ -503,6 +503,9 @@ <ClCompile Include="..\lib_dec\ivas_mcmasa_dec.c"> <Filter>dec_ivas_c</Filter> </ClCompile> <ClCompile Include="..\lib_dec\ivas_omasa_dec.c"> <Filter>dec_ivas_c</Filter> </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\lib_dec\jbm_jb4_inputbuffer.h"> Loading lib_com/bitstream.c +34 −0 Original line number Diff line number Diff line Loading @@ -1812,6 +1812,12 @@ ivas_error preview_indices( else { st_ivas->ivas_format = MASA_FORMAT; #ifdef MASA_AND_OBJECTS_VE if ( bit_stream[3] ) { st_ivas->ivas_format = MASA_ISM_FORMAT; } #endif } break; } Loading Loading @@ -1968,6 +1974,34 @@ ivas_error preview_indices( ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } #ifdef MASA_AND_OBJECTS_VE else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { /* read number of objects from the bitstream */ st_ivas->nchan_transport = 0; if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA ) { st_ivas->ism_mode = ivas_omasa_ism_mode_select( total_brate, st_ivas->nchan_ism ); if ( st_ivas->ism_mode == ISM_MASA_MODE_ONE_OBJ ) { st_ivas->nchan_transport = 0; } else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { st_ivas->nchan_transport = 2 * st_ivas->bit_stream[total_brate / FRAMES_PER_SEC - 2] + st_ivas->bit_stream[total_brate / FRAMES_PER_SEC - 3] + 1; } k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 ); { st_ivas->nchan_transport++; k--; } } } #endif } st_ivas->hDecoderConfig->ivas_total_brate = total_brate; Loading lib_com/ivas_cnst.h +4 −1 Original line number Diff line number Diff line Loading @@ -300,7 +300,7 @@ typedef enum /*----------------------------------------------------------------------------------* * ISm Constants * ISM Constants *----------------------------------------------------------------------------------*/ #define ISM_NB_BITS_METADATA_NOMINAL ( ( SCE_CORE_16k_LOW_LIMIT - ACELP_16k_LOW_LIMIT ) / FRAMES_PER_SEC ) /* nominal number of metadata bits - used for configuration of Core-Coder modules */ Loading @@ -308,6 +308,9 @@ typedef enum #define ISM_METADATA_VAD_FLAG_BITS 1 #define ISM_METADATA_FLAG_BITS 2 #ifdef OMASA_BRATE #define ISM_INACTIVE_IMP 0 /* == ISM_NO_META */ #endif #define ISM_NO_META 0 #define ISM_LOW_IMP 1 #define ISM_MEDIUM_IMP 2 Loading lib_com/ivas_ism_config.c +179 −3 Original line number Diff line number Diff line Loading @@ -63,7 +63,11 @@ * Convert bit-budget to bitrate *-------------------------------------------------------------------*/ #ifdef OMASA_BRATE void bitbudget_to_brate( #else static void bitbudget_to_brate( #endif const int16_t x[], /* i : bitbudgets */ int32_t y[], /* o : bitrates */ const int16_t N /* i : number of entries to be converted */ Loading Loading @@ -98,7 +102,7 @@ ivas_error ivas_ism_config( int16_t nb_bits_metadata[] /* i/o: number of metadata bits */ #ifdef MASA_AND_OBJECTS , int16_t masa_ism_flag /* i : flag indicating ISM MASA format */ const int16_t combined_format_flag /* i : flag indicating combined format */ #endif ) { Loading @@ -114,7 +118,7 @@ ivas_error ivas_ism_config( error = IVAS_ERR_OK; #ifdef MASA_AND_OBJECTS if ( masa_ism_flag == 1 ) if ( combined_format_flag == 1 ) { n_ISms = num_obj; } Loading @@ -137,6 +141,40 @@ ivas_error ivas_ism_config( } } #ifdef OMASA_BRATE /* decision about bitrates per channel */ if ( combined_format_flag ) { /* combined format: decision about bitrates per channel - variable during the session (at one ivas_total_brate) */ bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND ); set_s( bits_element, bits_ism / n_ISms, n_ISms ); bits_element[n_ISms - 1] += bits_ism % n_ISms; /* ISM common signaling bits are counted in MASA MD bit-budget */ } else { /* ISM format: decision about bitrates per channel - constant during the session (at one ivas_total_brate) */ bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND ); set_s( bits_element, bits_ism / n_ISms, n_ISms ); bits_element[n_ISms - 1] += bits_ism % n_ISms; bitbudget_to_brate( bits_element, element_brate, n_ISms ); /* count ISm common signaling bits */ if ( hIsmMeta != NULL ) { nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS + num_obj; for ( ch = 0; ch < n_ISms; ch++ ) { if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { nb_bits_metadata[0] += ISM_METADATA_VAD_FLAG_BITS; } } } } #else /* decision about bitrates per channel - constant during the session (at one ivas_total_brate) */ bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND ); set_s( bits_element, bits_ism / n_ISms, n_ISms ); Loading @@ -148,7 +186,7 @@ ivas_error ivas_ism_config( { #ifdef MASA_AND_OBJECTS nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS; if ( masa_ism_flag == 0 ) if ( combined_format_flag == 0 ) { /* the bits for writing the number of objects are counted here for pure ISM modes */ nb_bits_metadata[0] += num_obj; Loading @@ -165,6 +203,7 @@ ivas_error ivas_ism_config( } } } #endif /* split metadata bitbudget equally between channels */ if ( nb_bits_metadata != NULL ) Loading Loading @@ -322,6 +361,31 @@ ivas_error ivas_ism_config( } } #ifdef OMASA_BRATE if ( combined_format_flag == 1 ) { if ( diff > 0 ) { for ( ch = 0; ch < n_ISms; ch++ ) { if ( ism_imp[ch] <= ISM_MEDIUM_IMP ) { if ( diff > limit_high ) { diff += bits_CoreCoder[ch] - limit_high; bits_CoreCoder[ch] = limit_high; } else { bits_CoreCoder[ch] += diff; break; } } } } } #endif bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); } Loading @@ -330,7 +394,11 @@ ivas_error ivas_ism_config( { int32_t tmpL; tmpL = sum_l( total_brate, n_ISms ) + bits_side * FRMS_PER_SECOND; #ifdef OMASA_BRATE if ( ism_total_brate != tmpL ) #else if ( sum_l( element_brate, n_ISms ) != tmpL ) #endif { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: Mismatch in ISm bit-budget distribution. Exiting!\n" ); } Loading Loading @@ -603,4 +671,112 @@ ISM_MODE ivas_omasa_ism_mode_select( return ism_mode; } #ifdef OMASA_BRATE /*--------------------------------------------------------------- * ivas_interformat_brate() * * Bit-budget distribution in case of combined-format coding * ---------------------------------------------------------------*/ #define GAMMA_ISM_LOW_IMP 0.8f #define GAMMA_ISM_MEDIUM_IMP 1.2f #define GAMMA_ISM_HIGH_IMP 1.4f /*! r: adjusted bitrate */ int32_t ivas_interformat_brate( const int32_t element_brate, /* i : element bitrate */ const int16_t ism_imp /* i : ISM importance flag */ ) { int32_t element_brate_out; int16_t nBits, limit_low, limit_high; nBits = (int16_t) ( element_brate / FRAMES_PER_SEC ); if ( ism_imp == ISM_INACTIVE_IMP ) { nBits = BITS_ISM_INACTIVE; } else if ( ism_imp == ISM_LOW_IMP ) { nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP ); } else if ( ism_imp == ISM_MEDIUM_IMP ) { nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP ); } else /* ISM_HIGH_IMP */ { nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP ); } limit_low = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC; if ( ism_imp == ISM_INACTIVE_IMP ) { limit_low = BITS_ISM_INACTIVE; } else if ( element_brate >= SCE_CORE_16k_LOW_LIMIT ) { limit_low = SCE_CORE_16k_LOW_LIMIT / FRAMES_PER_SEC; } limit_high = IVAS_512k / FRAMES_PER_SEC; if ( element_brate < SCE_CORE_16k_LOW_LIMIT ) { limit_high = ACELP_12k8_HIGH_LIMIT / FRMS_PER_SECOND; } nBits = check_bounds_s( nBits, limit_low, limit_high ); element_brate_out = nBits * FRAMES_PER_SEC; return element_brate_out; } #endif #ifdef OMASA_BRATE_FIX /*--------------------------------------------------------------- * ivas_combined_format_brate_sanity() * * * ---------------------------------------------------------------*/ void ivas_combined_format_brate_sanity( const int32_t element_brate, /* i : element bitrate */ const int32_t brate_surplus, /* i : surplus bitrate */ int16_t nb_bits_metadata[], /* i/o: number of metadata bits */ const int16_t nchan_ism, /* i : number of objects */ int16_t *diff_nBits /* o : number of differential bits */ ) { /* sanity check: at lowest IVAS bit-rates and one ISM channel coded by low-rate core-coder mode, it can happen that the CPE (MASA) bit-budget for core-coding @12.8 kHz is too high => increase the ISM low-rate mode bit-rate */ int16_t nBits_CPE; nBits_CPE = (int16_t) ( element_brate / FRAMES_PER_SEC ); nBits_CPE -= nb_bits_metadata[0]; nBits_CPE += (int16_t) ( brate_surplus / FRAMES_PER_SEC ); nBits_CPE -= ( WB_TBE_0k35 / FRAMES_PER_SEC ); nBits_CPE -= nb_bits_metadata[1]; nBits_CPE -= 14; *diff_nBits = 0; if ( nchan_ism == 1 && element_brate < ACELP_12k8_HIGH_LIMIT ) { int16_t limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC; *diff_nBits = nBits_CPE - limit_high; if ( *diff_nBits > 0 ) { nb_bits_metadata[0] += *diff_nBits; } } return; } #endif #endif Loading
Workspace_msvc/lib_dec.vcxproj +1 −0 Original line number Diff line number Diff line Loading @@ -290,6 +290,7 @@ <ClCompile Include="..\lib_dec\ivas_mc_param_dec.c" /> <ClCompile Include="..\lib_dec\ivas_mdct_core_dec.c" /> <ClCompile Include="..\lib_dec\ivas_mono_dmx_renderer.c" /> <ClCompile Include="..\lib_dec\ivas_omasa_dec.c" /> <ClCompile Include="..\lib_dec\ivas_out_setup_conversion.c" /> <ClCompile Include="..\lib_dec\ivas_pca_dec.c" /> <ClCompile Include="..\lib_dec\ivas_post_proc.c" /> Loading
Workspace_msvc/lib_dec.vcxproj.filters +3 −0 Original line number Diff line number Diff line Loading @@ -503,6 +503,9 @@ <ClCompile Include="..\lib_dec\ivas_mcmasa_dec.c"> <Filter>dec_ivas_c</Filter> </ClCompile> <ClCompile Include="..\lib_dec\ivas_omasa_dec.c"> <Filter>dec_ivas_c</Filter> </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\lib_dec\jbm_jb4_inputbuffer.h"> Loading
lib_com/bitstream.c +34 −0 Original line number Diff line number Diff line Loading @@ -1812,6 +1812,12 @@ ivas_error preview_indices( else { st_ivas->ivas_format = MASA_FORMAT; #ifdef MASA_AND_OBJECTS_VE if ( bit_stream[3] ) { st_ivas->ivas_format = MASA_ISM_FORMAT; } #endif } break; } Loading Loading @@ -1968,6 +1974,34 @@ ivas_error preview_indices( ivas_sba_config( total_brate, st_ivas->sba_analysis_order, -1, &( st_ivas->nchan_transport ), st_ivas->sba_planar, &( st_ivas->nSCE ), &( st_ivas->nCPE ), &( st_ivas->element_mode_init ) ); } #ifdef MASA_AND_OBJECTS_VE else if ( st_ivas->ivas_format == MASA_ISM_FORMAT ) { /* read number of objects from the bitstream */ st_ivas->nchan_transport = 0; if ( total_brate != SID_2k40 && total_brate != FRAME_NO_DATA ) { st_ivas->ism_mode = ivas_omasa_ism_mode_select( total_brate, st_ivas->nchan_ism ); if ( st_ivas->ism_mode == ISM_MASA_MODE_ONE_OBJ ) { st_ivas->nchan_transport = 0; } else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC ) { st_ivas->nchan_transport = 2 * st_ivas->bit_stream[total_brate / FRAMES_PER_SEC - 2] + st_ivas->bit_stream[total_brate / FRAMES_PER_SEC - 3] + 1; } k = (int16_t) ( ( total_brate / FRAMES_PER_SEC ) - 1 ); { st_ivas->nchan_transport++; k--; } } } #endif } st_ivas->hDecoderConfig->ivas_total_brate = total_brate; Loading
lib_com/ivas_cnst.h +4 −1 Original line number Diff line number Diff line Loading @@ -300,7 +300,7 @@ typedef enum /*----------------------------------------------------------------------------------* * ISm Constants * ISM Constants *----------------------------------------------------------------------------------*/ #define ISM_NB_BITS_METADATA_NOMINAL ( ( SCE_CORE_16k_LOW_LIMIT - ACELP_16k_LOW_LIMIT ) / FRAMES_PER_SEC ) /* nominal number of metadata bits - used for configuration of Core-Coder modules */ Loading @@ -308,6 +308,9 @@ typedef enum #define ISM_METADATA_VAD_FLAG_BITS 1 #define ISM_METADATA_FLAG_BITS 2 #ifdef OMASA_BRATE #define ISM_INACTIVE_IMP 0 /* == ISM_NO_META */ #endif #define ISM_NO_META 0 #define ISM_LOW_IMP 1 #define ISM_MEDIUM_IMP 2 Loading
lib_com/ivas_ism_config.c +179 −3 Original line number Diff line number Diff line Loading @@ -63,7 +63,11 @@ * Convert bit-budget to bitrate *-------------------------------------------------------------------*/ #ifdef OMASA_BRATE void bitbudget_to_brate( #else static void bitbudget_to_brate( #endif const int16_t x[], /* i : bitbudgets */ int32_t y[], /* o : bitrates */ const int16_t N /* i : number of entries to be converted */ Loading Loading @@ -98,7 +102,7 @@ ivas_error ivas_ism_config( int16_t nb_bits_metadata[] /* i/o: number of metadata bits */ #ifdef MASA_AND_OBJECTS , int16_t masa_ism_flag /* i : flag indicating ISM MASA format */ const int16_t combined_format_flag /* i : flag indicating combined format */ #endif ) { Loading @@ -114,7 +118,7 @@ ivas_error ivas_ism_config( error = IVAS_ERR_OK; #ifdef MASA_AND_OBJECTS if ( masa_ism_flag == 1 ) if ( combined_format_flag == 1 ) { n_ISms = num_obj; } Loading @@ -137,6 +141,40 @@ ivas_error ivas_ism_config( } } #ifdef OMASA_BRATE /* decision about bitrates per channel */ if ( combined_format_flag ) { /* combined format: decision about bitrates per channel - variable during the session (at one ivas_total_brate) */ bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND ); set_s( bits_element, bits_ism / n_ISms, n_ISms ); bits_element[n_ISms - 1] += bits_ism % n_ISms; /* ISM common signaling bits are counted in MASA MD bit-budget */ } else { /* ISM format: decision about bitrates per channel - constant during the session (at one ivas_total_brate) */ bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND ); set_s( bits_element, bits_ism / n_ISms, n_ISms ); bits_element[n_ISms - 1] += bits_ism % n_ISms; bitbudget_to_brate( bits_element, element_brate, n_ISms ); /* count ISm common signaling bits */ if ( hIsmMeta != NULL ) { nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS + num_obj; for ( ch = 0; ch < n_ISms; ch++ ) { if ( hIsmMeta[ch]->ism_metadata_flag == 0 ) { nb_bits_metadata[0] += ISM_METADATA_VAD_FLAG_BITS; } } } } #else /* decision about bitrates per channel - constant during the session (at one ivas_total_brate) */ bits_ism = (int16_t) ( ism_total_brate / FRMS_PER_SECOND ); set_s( bits_element, bits_ism / n_ISms, n_ISms ); Loading @@ -148,7 +186,7 @@ ivas_error ivas_ism_config( { #ifdef MASA_AND_OBJECTS nb_bits_metadata[0] += n_ISms * ISM_METADATA_FLAG_BITS; if ( masa_ism_flag == 0 ) if ( combined_format_flag == 0 ) { /* the bits for writing the number of objects are counted here for pure ISM modes */ nb_bits_metadata[0] += num_obj; Loading @@ -165,6 +203,7 @@ ivas_error ivas_ism_config( } } } #endif /* split metadata bitbudget equally between channels */ if ( nb_bits_metadata != NULL ) Loading Loading @@ -322,6 +361,31 @@ ivas_error ivas_ism_config( } } #ifdef OMASA_BRATE if ( combined_format_flag == 1 ) { if ( diff > 0 ) { for ( ch = 0; ch < n_ISms; ch++ ) { if ( ism_imp[ch] <= ISM_MEDIUM_IMP ) { if ( diff > limit_high ) { diff += bits_CoreCoder[ch] - limit_high; bits_CoreCoder[ch] = limit_high; } else { bits_CoreCoder[ch] += diff; break; } } } } } #endif bitbudget_to_brate( bits_CoreCoder, total_brate, n_ISms ); } Loading @@ -330,7 +394,11 @@ ivas_error ivas_ism_config( { int32_t tmpL; tmpL = sum_l( total_brate, n_ISms ) + bits_side * FRMS_PER_SECOND; #ifdef OMASA_BRATE if ( ism_total_brate != tmpL ) #else if ( sum_l( element_brate, n_ISms ) != tmpL ) #endif { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "\nError: Mismatch in ISm bit-budget distribution. Exiting!\n" ); } Loading Loading @@ -603,4 +671,112 @@ ISM_MODE ivas_omasa_ism_mode_select( return ism_mode; } #ifdef OMASA_BRATE /*--------------------------------------------------------------- * ivas_interformat_brate() * * Bit-budget distribution in case of combined-format coding * ---------------------------------------------------------------*/ #define GAMMA_ISM_LOW_IMP 0.8f #define GAMMA_ISM_MEDIUM_IMP 1.2f #define GAMMA_ISM_HIGH_IMP 1.4f /*! r: adjusted bitrate */ int32_t ivas_interformat_brate( const int32_t element_brate, /* i : element bitrate */ const int16_t ism_imp /* i : ISM importance flag */ ) { int32_t element_brate_out; int16_t nBits, limit_low, limit_high; nBits = (int16_t) ( element_brate / FRAMES_PER_SEC ); if ( ism_imp == ISM_INACTIVE_IMP ) { nBits = BITS_ISM_INACTIVE; } else if ( ism_imp == ISM_LOW_IMP ) { nBits = (int16_t) ( nBits * GAMMA_ISM_LOW_IMP ); } else if ( ism_imp == ISM_MEDIUM_IMP ) { nBits = (int16_t) ( nBits * GAMMA_ISM_MEDIUM_IMP ); } else /* ISM_HIGH_IMP */ { nBits = (int16_t) ( nBits * GAMMA_ISM_HIGH_IMP ); } limit_low = MIN_BRATE_SWB_BWE / FRAMES_PER_SEC; if ( ism_imp == ISM_INACTIVE_IMP ) { limit_low = BITS_ISM_INACTIVE; } else if ( element_brate >= SCE_CORE_16k_LOW_LIMIT ) { limit_low = SCE_CORE_16k_LOW_LIMIT / FRAMES_PER_SEC; } limit_high = IVAS_512k / FRAMES_PER_SEC; if ( element_brate < SCE_CORE_16k_LOW_LIMIT ) { limit_high = ACELP_12k8_HIGH_LIMIT / FRMS_PER_SECOND; } nBits = check_bounds_s( nBits, limit_low, limit_high ); element_brate_out = nBits * FRAMES_PER_SEC; return element_brate_out; } #endif #ifdef OMASA_BRATE_FIX /*--------------------------------------------------------------- * ivas_combined_format_brate_sanity() * * * ---------------------------------------------------------------*/ void ivas_combined_format_brate_sanity( const int32_t element_brate, /* i : element bitrate */ const int32_t brate_surplus, /* i : surplus bitrate */ int16_t nb_bits_metadata[], /* i/o: number of metadata bits */ const int16_t nchan_ism, /* i : number of objects */ int16_t *diff_nBits /* o : number of differential bits */ ) { /* sanity check: at lowest IVAS bit-rates and one ISM channel coded by low-rate core-coder mode, it can happen that the CPE (MASA) bit-budget for core-coding @12.8 kHz is too high => increase the ISM low-rate mode bit-rate */ int16_t nBits_CPE; nBits_CPE = (int16_t) ( element_brate / FRAMES_PER_SEC ); nBits_CPE -= nb_bits_metadata[0]; nBits_CPE += (int16_t) ( brate_surplus / FRAMES_PER_SEC ); nBits_CPE -= ( WB_TBE_0k35 / FRAMES_PER_SEC ); nBits_CPE -= nb_bits_metadata[1]; nBits_CPE -= 14; *diff_nBits = 0; if ( nchan_ism == 1 && element_brate < ACELP_12k8_HIGH_LIMIT ) { int16_t limit_high = ACELP_12k8_HIGH_LIMIT / FRAMES_PER_SEC; *diff_nBits = nBits_CPE - limit_high; if ( *diff_nBits > 0 ) { nb_bits_metadata[0] += *diff_nBits; } } return; } #endif #endif