Loading lib_com/ivas_mcmasa_com.c +108 −0 Original line number Diff line number Diff line Loading @@ -34,8 +34,116 @@ #include "ivas_prot.h" #include "options.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif #ifdef IVAS_FLOAT_FIXED #define MCMASA_MONOBITRATIO_64k_Q31 ( 536870912 ) #define MCMASA_MONOBITRATIO_Q31 ( 644245095 ) /*--------------------------------------------------------------------------* * ivas_mcmasa_setNumTransportChannels() * * Set number of transport channels in McMASA *--------------------------------------------------------------------------*/ void ivas_mcmasa_setNumTransportChannels_fx( Word16 *nchan_transport, /* o : Pointer to number of transport channels to be set */ Word16 *element_mode, /* o : Pointer to element mode to be set */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ) { IF( GE_32( ivas_total_brate, IVAS_48k ) ) { *nchan_transport = 2; move16(); *element_mode = IVAS_CPE_MDCT; move16(); } ELSE { *nchan_transport = 1; move16(); *element_mode = IVAS_SCE; move16(); } return; } /*--------------------------------------------------------------------------* * ivas_mcmasa_set_separate_channel_mode() * * Set separate channel parameters in McMASA based on bitrate *--------------------------------------------------------------------------*/ void ivas_mcmasa_set_separate_channel_mode_fx( UWord8 *separateChannelEnabled, /* o : Pointer to separate channel toggle */ Word16 *separateChannelIndex, /* o : Pointer to separate channel index */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ) { IF( GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) ) { *separateChannelEnabled = 1; *separateChannelIndex = 2; /* Center channel */ move16(); } ELSE { *separateChannelEnabled = 0; *separateChannelIndex = 0; move16(); } return; } /*--------------------------------------------------------------------------* * ivas_mcmasa_split_brate() * * Split the total bitrate to elements in McMASA *--------------------------------------------------------------------------*/ void ivas_mcmasa_split_brate_fx( const UWord8 separateChannelEnabled, /* i : Transport running in "separate channel" mode */ const Word32 ivas_total_brate, /* i : IVAS total bitrate available to be split */ const Word16 nSCE, /* i : Number of SCEs in use (0 or 1) */ const Word16 nCPE, /* i : Number of CPEs in use (0 or 1) */ Word32 *brate_sce, /* o : Pointer to SCE element bitrate */ Word32 *brate_cpe /* o : Pointer to CPE element bitrate */ ) { IF( separateChannelEnabled ) { /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */ IF( LT_32( ivas_total_brate, IVAS_96k ) ) { *brate_sce = (Word32) ( Mpy_32_32( MCMASA_MONOBITRATIO_64k_Q31, ivas_total_brate ) ); // Q0 } ELSE { *brate_sce = (Word32) ( Mpy_32_32( MCMASA_MONOBITRATIO_Q31, ivas_total_brate ) ); // Q0 } *brate_cpe = L_sub( ivas_total_brate, *brate_sce ); } ELSE { Word16 tmp_e = 0; Word16 tmp = BASOP_Util_Divide3216_Scale( ivas_total_brate, ( add( nCPE, nSCE ) ), &tmp_e ); *brate_sce = GT_16( nSCE, 0 ) ? ( L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ) ) : 0; move32(); *brate_cpe = GT_16( nCPE, 0 ) ? ( L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ) ) : 0; move32(); } return; } #endif /*--------------------------------------------------------------------------* * ivas_mcmasa_setNumTransportChannels() * Loading lib_com/ivas_prot_fx.h +21 −0 Original line number Diff line number Diff line Loading @@ -544,4 +544,25 @@ void stereo_cng_compute_PScorr_fx( const Word16 L_frame_1 /* i : L_frame channel 1 */ ); void ivas_mcmasa_setNumTransportChannels_fx( Word16 *nchan_transport, /* o : Pointer to number of transport channels to be set */ Word16 *element_mode, /* o : Pointer to element mode to be set */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ); void ivas_mcmasa_set_separate_channel_mode_fx( UWord8 *separateChannelEnabled, /* o : Pointer to separate channel toggle */ Word16 *separateChannelIndex, /* o : Pointer to separate channel index */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ); void ivas_mcmasa_split_brate_fx( const UWord8 separateChannelEnabled, /* i : Transport running in "separate channel" mode */ const Word32 ivas_total_brate, /* i : IVAS total bitrate available to be split */ const Word16 nSCE, /* i : Number of SCEs in use (0 or 1) */ const Word16 nCPE, /* i : Number of CPEs in use (0 or 1) */ Word32 *brate_sce, /* o : Pointer to SCE element bitrate */ Word32 *brate_cpe /* o : Pointer to CPE element bitrate */ ); #endif No newline at end of file lib_dec/ivas_init_dec.c +18 −0 Original line number Diff line number Diff line Loading @@ -908,9 +908,15 @@ ivas_error ivas_init_decoder( IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #endif } ivas_renderer_select( st_ivas ); Loading @@ -927,7 +933,11 @@ ivas_error ivas_init_decoder( IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #endif IF ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) { Loading Loading @@ -1530,7 +1540,11 @@ ivas_error ivas_init_decoder( { Word32 brate_sce, brate_cpe; #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #endif IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { Loading Loading @@ -1570,7 +1584,11 @@ ivas_error ivas_init_decoder( } } #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_split_brate_fx( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); #else ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); #endif FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { Loading lib_dec/ivas_mcmasa_dec.c +9 −0 Original line number Diff line number Diff line Loading @@ -63,15 +63,24 @@ ivas_error ivas_mcmasa_dec_reconfig( #endif /* get new McMASA settings */ #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #endif /* transport channel settings may affect renderer */ ivas_renderer_select( st_ivas ); /* renderer change may affect internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #endif #ifdef IVAS_FLOAT_FIXED if ( ( error = ivas_masa_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) Loading lib_dec/ivas_mct_dec.c +9 −0 Original line number Diff line number Diff line Loading @@ -1025,7 +1025,11 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #endif if ( last_mc_mode != MC_MODE_MCMASA ) { Loading Loading @@ -1136,8 +1140,13 @@ static ivas_error ivas_mc_dec_reconfig( { uint8_t separateChannelEnabled; int16_t separateChannelIndex; #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_set_separate_channel_mode_fx( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); ivas_mcmasa_split_brate_fx( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); #else ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); ivas_mcmasa_split_brate( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); #endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { Loading Loading
lib_com/ivas_mcmasa_com.c +108 −0 Original line number Diff line number Diff line Loading @@ -34,8 +34,116 @@ #include "ivas_prot.h" #include "options.h" #include "wmc_auto.h" #ifdef IVAS_FLOAT_FIXED #include "ivas_prot_fx.h" #endif #ifdef IVAS_FLOAT_FIXED #define MCMASA_MONOBITRATIO_64k_Q31 ( 536870912 ) #define MCMASA_MONOBITRATIO_Q31 ( 644245095 ) /*--------------------------------------------------------------------------* * ivas_mcmasa_setNumTransportChannels() * * Set number of transport channels in McMASA *--------------------------------------------------------------------------*/ void ivas_mcmasa_setNumTransportChannels_fx( Word16 *nchan_transport, /* o : Pointer to number of transport channels to be set */ Word16 *element_mode, /* o : Pointer to element mode to be set */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ) { IF( GE_32( ivas_total_brate, IVAS_48k ) ) { *nchan_transport = 2; move16(); *element_mode = IVAS_CPE_MDCT; move16(); } ELSE { *nchan_transport = 1; move16(); *element_mode = IVAS_SCE; move16(); } return; } /*--------------------------------------------------------------------------* * ivas_mcmasa_set_separate_channel_mode() * * Set separate channel parameters in McMASA based on bitrate *--------------------------------------------------------------------------*/ void ivas_mcmasa_set_separate_channel_mode_fx( UWord8 *separateChannelEnabled, /* o : Pointer to separate channel toggle */ Word16 *separateChannelIndex, /* o : Pointer to separate channel index */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ) { IF( GE_32( ivas_total_brate, MCMASA_SEPARATE_BRATE ) ) { *separateChannelEnabled = 1; *separateChannelIndex = 2; /* Center channel */ move16(); } ELSE { *separateChannelEnabled = 0; *separateChannelIndex = 0; move16(); } return; } /*--------------------------------------------------------------------------* * ivas_mcmasa_split_brate() * * Split the total bitrate to elements in McMASA *--------------------------------------------------------------------------*/ void ivas_mcmasa_split_brate_fx( const UWord8 separateChannelEnabled, /* i : Transport running in "separate channel" mode */ const Word32 ivas_total_brate, /* i : IVAS total bitrate available to be split */ const Word16 nSCE, /* i : Number of SCEs in use (0 or 1) */ const Word16 nCPE, /* i : Number of CPEs in use (0 or 1) */ Word32 *brate_sce, /* o : Pointer to SCE element bitrate */ Word32 *brate_cpe /* o : Pointer to CPE element bitrate */ ) { IF( separateChannelEnabled ) { /* 25% of total bitrate is used for SCE below 96 kb/s (separated mono channel), otherwise 30% */ IF( LT_32( ivas_total_brate, IVAS_96k ) ) { *brate_sce = (Word32) ( Mpy_32_32( MCMASA_MONOBITRATIO_64k_Q31, ivas_total_brate ) ); // Q0 } ELSE { *brate_sce = (Word32) ( Mpy_32_32( MCMASA_MONOBITRATIO_Q31, ivas_total_brate ) ); // Q0 } *brate_cpe = L_sub( ivas_total_brate, *brate_sce ); } ELSE { Word16 tmp_e = 0; Word16 tmp = BASOP_Util_Divide3216_Scale( ivas_total_brate, ( add( nCPE, nSCE ) ), &tmp_e ); *brate_sce = GT_16( nSCE, 0 ) ? ( L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ) ) : 0; move32(); *brate_cpe = GT_16( nCPE, 0 ) ? ( L_shr( (Word32) tmp, negate( add( 1, tmp_e ) ) ) ) : 0; move32(); } return; } #endif /*--------------------------------------------------------------------------* * ivas_mcmasa_setNumTransportChannels() * Loading
lib_com/ivas_prot_fx.h +21 −0 Original line number Diff line number Diff line Loading @@ -544,4 +544,25 @@ void stereo_cng_compute_PScorr_fx( const Word16 L_frame_1 /* i : L_frame channel 1 */ ); void ivas_mcmasa_setNumTransportChannels_fx( Word16 *nchan_transport, /* o : Pointer to number of transport channels to be set */ Word16 *element_mode, /* o : Pointer to element mode to be set */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ); void ivas_mcmasa_set_separate_channel_mode_fx( UWord8 *separateChannelEnabled, /* o : Pointer to separate channel toggle */ Word16 *separateChannelIndex, /* o : Pointer to separate channel index */ const Word32 ivas_total_brate /* i : Total bitrate of IVAS */ ); void ivas_mcmasa_split_brate_fx( const UWord8 separateChannelEnabled, /* i : Transport running in "separate channel" mode */ const Word32 ivas_total_brate, /* i : IVAS total bitrate available to be split */ const Word16 nSCE, /* i : Number of SCEs in use (0 or 1) */ const Word16 nCPE, /* i : Number of CPEs in use (0 or 1) */ Word32 *brate_sce, /* o : Pointer to SCE element bitrate */ Word32 *brate_cpe /* o : Pointer to CPE element bitrate */ ); #endif No newline at end of file
lib_dec/ivas_init_dec.c +18 −0 Original line number Diff line number Diff line Loading @@ -908,9 +908,15 @@ ivas_error ivas_init_decoder( IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #endif } ivas_renderer_select( st_ivas ); Loading @@ -927,7 +933,11 @@ ivas_error ivas_init_decoder( IF ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_MCMASA ) { #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #endif IF ( st_ivas->hOutSetup.output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.separateChannelEnabled ) { Loading Loading @@ -1530,7 +1540,11 @@ ivas_error ivas_init_decoder( { Word32 brate_sce, brate_cpe; #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #endif IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) { Loading Loading @@ -1570,7 +1584,11 @@ ivas_error ivas_init_decoder( } } #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_split_brate_fx( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); #else ivas_mcmasa_split_brate( st_ivas->hOutSetup.separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &brate_sce, &brate_cpe ); #endif FOR ( sce_id = 0; sce_id < st_ivas->nSCE; sce_id++ ) { Loading
lib_dec/ivas_mcmasa_dec.c +9 −0 Original line number Diff line number Diff line Loading @@ -63,15 +63,24 @@ ivas_error ivas_mcmasa_dec_reconfig( #endif /* get new McMASA settings */ #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hOutSetup.separateChannelEnabled ), &( st_ivas->hOutSetup.separateChannelIndex ), ivas_total_brate ); #endif /* transport channel settings may affect renderer */ ivas_renderer_select( st_ivas ); /* renderer change may affect internal config */ ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_set_separate_channel_mode_fx( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #else ivas_mcmasa_set_separate_channel_mode( &( st_ivas->hIntSetup.separateChannelEnabled ), &( st_ivas->hIntSetup.separateChannelIndex ), ivas_total_brate ); #endif #ifdef IVAS_FLOAT_FIXED if ( ( error = ivas_masa_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) Loading
lib_dec/ivas_mct_dec.c +9 −0 Original line number Diff line number Diff line Loading @@ -1025,7 +1025,11 @@ static ivas_error ivas_mc_dec_reconfig( } else if ( st_ivas->mc_mode == MC_MODE_MCMASA ) { #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #else ivas_mcmasa_setNumTransportChannels( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); #endif if ( last_mc_mode != MC_MODE_MCMASA ) { Loading Loading @@ -1136,8 +1140,13 @@ static ivas_error ivas_mc_dec_reconfig( { uint8_t separateChannelEnabled; int16_t separateChannelIndex; #ifdef IVAS_FLOAT_FIXED ivas_mcmasa_set_separate_channel_mode_fx( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); ivas_mcmasa_split_brate_fx( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); #else ivas_mcmasa_set_separate_channel_mode( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); ivas_mcmasa_split_brate( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); #endif } else if ( st_ivas->mc_mode == MC_MODE_MCT ) { Loading