Loading lib_com/ivas_masa_com.c +152 −0 Original line number Diff line number Diff line Loading @@ -478,6 +478,158 @@ void ivas_masa_set_coding_config( return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------- * ivas_masa_set_coding_config_fx() * * Sets MASA codec parameters based on bitrate, number of directions, * and other metadata properties. *---------------------------------------------------------------*/ void ivas_masa_set_coding_config_fx( MASA_CODEC_CONFIG *config, /* i/o: MASA coding config structure */ Word16 *band_mapping, /* o : Band mapping used */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 nchan_transport, /* i : number of transport channels (mono/stereo) */ const UWord8 isMcMasa /* i : toggle for selecting mcMASA specific config */ ) { Word16 i; UWord8 nbands; UWord8 nTwoDirBands; const Word16 *masa_bits_table; /* When coming into this function, these values should be already set: * joinedSubframes; * useCoherence; * numberOfDirections; */ /* Setup coding parameters based on the bitrate, transport channel count, subframe metadata information, * and number of directions in metadata. */ nbands = 0; nTwoDirBands = 0; i = 0; move16(); /* First select correct bit budget table */ masa_bits_table = masa_bits; move16(); test(); IF( isMcMasa ) { masa_bits_table = mcmasa_bits; move16(); } ELSE IF( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) ) { masa_bits_table = masa_bits_LR_stereo; move16(); } WHILE( nbands == 0 && LT_16( i, IVAS_NUM_ACTIVE_BRATES ) ) { IF( LE_32( ivas_total_brate, ivas_brate_tbl[i + SIZE_IVAS_BRATE_TBL - IVAS_NUM_ACTIVE_BRATES] ) ) { Word16 idx_bands; test(); test(); IF( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) && GT_16( i, 3 ) ) { /* because it uses the bitallocation for the lower bit rates from 'masa_bits_LR_stereo' and it has 4 elements */ i = 3; move16(); } idx_bands = i; move16(); IF( config->numberOfDirections > 1 ) { nTwoDirBands = config->joinedSubframes ? masa_twodir_bands_joined[i] : masa_twodir_bands[i]; IF( ( GT_32( ivas_total_brate, IVAS_96k ) && !config->joinedSubframes ) || ( GT_32( ivas_total_brate, IVAS_80k ) && config->joinedSubframes ) ) { idx_bands = sub( idx_bands, 1 ); } } IF( config->joinedSubframes ) { nbands = masa_joined_nbands[idx_bands]; } ELSE { nbands = masa_nbands[idx_bands]; } config->max_metadata_bits = masa_bits_table[i]; move16(); IF( EQ_32( ivas_total_brate, IVAS_64k ) && config->numberOfDirections > 1 ) { /* At 64k, we increase metadata bit budget when there is two directions present. */ config->max_metadata_bits += MASA_EXTRA_BAND_META_BITS; } IF( ( ( EQ_32( ivas_total_brate, IVAS_32k ) && EQ_16( nchan_transport, 2 ) ) || EQ_32( ivas_total_brate, IVAS_48k ) ) && config->joinedSubframes ) { /* At 32k and 48k, we increase metadata bit budget when joinedSubframes. */ config->max_metadata_bits += ( MASA_SMALL_INC_META_BITS ); } } i = add( i, 1 ); } config->numCodingBands = nbands; config->numTwoDirBands = nTwoDirBands; IF( config->joinedSubframes == TRUE ) { config->mergeRatiosOverSubframes = FALSE; } ELSE { config->mergeRatiosOverSubframes = TRUE; } /* Setup frequency band mapping based on the number of used coding bands */ SWITCH( config->numCodingBands ) { case 5: Copy( MASA_band_mapping_24_to_5, band_mapping, 5 + 1 ); BREAK; case 8: Copy( MASA_band_mapping_24_to_8, band_mapping, 8 + 1 ); BREAK; case 12: Copy( MASA_band_mapping_24_to_12, band_mapping, 12 + 1 ); BREAK; case 18: Copy( MASA_band_mapping_24_to_18, band_mapping, 18 + 1 ); BREAK; case MASA_FREQUENCY_BANDS: /* With input count of bands, no mapping is needed but for unified processing later, we store normal mapping */ FOR( i = 0; i < MASA_FREQUENCY_BANDS + 1; i++ ) { band_mapping[i] = i; move16(); } BREAK; default: assert( 0 && "Error: The number of MASA coding bands is not supported" ); } config->useCoherence = TRUE; IF( ( !isMcMasa && LT_32( ivas_total_brate, IVAS_48k ) ) || ( isMcMasa && LT_32( ivas_total_brate, IVAS_16k4 ) ) ) { config->useCoherence = FALSE; } return; } #endif /*--------------------------------------------------------------- * masa_sample_rate_band_correction() Loading lib_com/ivas_prot_fx.h +22 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,28 @@ void ivas_masa_set_elements_fx( const Word32 ism_total_brate /* i : initial ISM total bitrate */ ); void ivas_masa_set_coding_config_fx( MASA_CODEC_CONFIG *config, /* i/o: MASA coding config structure */ Word16 *band_mapping, /* o : Band mapping used */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 nchan_transport, /* i : number of transport channels (mono/stereo) */ const UWord8 isMcMasa /* i : toggle for selecting mcMASA specific config */ ); void ivas_masa_prerender_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Word32 *output_fx[], /* i/o: synthesized core-coder transport channels */ Word16 *q_shift, /* o : specifies how much the Q-factor of output has changed by. */ const Word16 output_frame, /* i : output frame length per channel */ const Word16 nchan_remapped /* i : number of transports used in core */ ); ivas_error ivas_masa_dec_reconfigure_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *data /* o : output synthesis signal */ ); Word16 ivas_jbm_dec_get_num_tc_channels_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); Loading lib_dec/ivas_init_dec.c +4 −0 Original line number Diff line number Diff line Loading @@ -181,7 +181,11 @@ ivas_error ivas_dec_setup( ELSE { #ifdef IVAS_FLOAT_FIXED IF ( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #else IF ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif { return error; } Loading lib_dec/ivas_jbm_dec.c +21 −0 Original line number Diff line number Diff line Loading @@ -495,7 +495,28 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == MASA_FORMAT ) { #ifdef IVAS_FLOAT_FIXED Word16 q_shift = 0; FOR(Word16 i = 0; i < 2; i++) { output_fx[i] = (Word32 *)malloc(output_frame * sizeof(Word32)); FOR(Word16 j = 0; j < output_frame; j++) { output_fx[i][j] = float_to_fix(p_output[i][j], Q11); } } ivas_masa_prerender_fx( st_ivas, output_fx, &q_shift, output_frame, nchan_remapped ); FOR(Word16 i = 0; i < 2; i++) { FOR(Word16 j = 0; j < output_frame; j++) { p_output[i][j] = fix_to_float(output_fx[i][j], Q11 + q_shift); } free(output_fx[i]); } #else ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); #endif } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { Loading lib_dec/ivas_masa_dec.c +388 −2 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib_com/ivas_masa_com.c +152 −0 Original line number Diff line number Diff line Loading @@ -478,6 +478,158 @@ void ivas_masa_set_coding_config( return; } #ifdef IVAS_FLOAT_FIXED /*--------------------------------------------------------------- * ivas_masa_set_coding_config_fx() * * Sets MASA codec parameters based on bitrate, number of directions, * and other metadata properties. *---------------------------------------------------------------*/ void ivas_masa_set_coding_config_fx( MASA_CODEC_CONFIG *config, /* i/o: MASA coding config structure */ Word16 *band_mapping, /* o : Band mapping used */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 nchan_transport, /* i : number of transport channels (mono/stereo) */ const UWord8 isMcMasa /* i : toggle for selecting mcMASA specific config */ ) { Word16 i; UWord8 nbands; UWord8 nTwoDirBands; const Word16 *masa_bits_table; /* When coming into this function, these values should be already set: * joinedSubframes; * useCoherence; * numberOfDirections; */ /* Setup coding parameters based on the bitrate, transport channel count, subframe metadata information, * and number of directions in metadata. */ nbands = 0; nTwoDirBands = 0; i = 0; move16(); /* First select correct bit budget table */ masa_bits_table = masa_bits; move16(); test(); IF( isMcMasa ) { masa_bits_table = mcmasa_bits; move16(); } ELSE IF( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) ) { masa_bits_table = masa_bits_LR_stereo; move16(); } WHILE( nbands == 0 && LT_16( i, IVAS_NUM_ACTIVE_BRATES ) ) { IF( LE_32( ivas_total_brate, ivas_brate_tbl[i + SIZE_IVAS_BRATE_TBL - IVAS_NUM_ACTIVE_BRATES] ) ) { Word16 idx_bands; test(); test(); IF( LT_32( ivas_total_brate, IVAS_48k ) && EQ_16( nchan_transport, 2 ) && GT_16( i, 3 ) ) { /* because it uses the bitallocation for the lower bit rates from 'masa_bits_LR_stereo' and it has 4 elements */ i = 3; move16(); } idx_bands = i; move16(); IF( config->numberOfDirections > 1 ) { nTwoDirBands = config->joinedSubframes ? masa_twodir_bands_joined[i] : masa_twodir_bands[i]; IF( ( GT_32( ivas_total_brate, IVAS_96k ) && !config->joinedSubframes ) || ( GT_32( ivas_total_brate, IVAS_80k ) && config->joinedSubframes ) ) { idx_bands = sub( idx_bands, 1 ); } } IF( config->joinedSubframes ) { nbands = masa_joined_nbands[idx_bands]; } ELSE { nbands = masa_nbands[idx_bands]; } config->max_metadata_bits = masa_bits_table[i]; move16(); IF( EQ_32( ivas_total_brate, IVAS_64k ) && config->numberOfDirections > 1 ) { /* At 64k, we increase metadata bit budget when there is two directions present. */ config->max_metadata_bits += MASA_EXTRA_BAND_META_BITS; } IF( ( ( EQ_32( ivas_total_brate, IVAS_32k ) && EQ_16( nchan_transport, 2 ) ) || EQ_32( ivas_total_brate, IVAS_48k ) ) && config->joinedSubframes ) { /* At 32k and 48k, we increase metadata bit budget when joinedSubframes. */ config->max_metadata_bits += ( MASA_SMALL_INC_META_BITS ); } } i = add( i, 1 ); } config->numCodingBands = nbands; config->numTwoDirBands = nTwoDirBands; IF( config->joinedSubframes == TRUE ) { config->mergeRatiosOverSubframes = FALSE; } ELSE { config->mergeRatiosOverSubframes = TRUE; } /* Setup frequency band mapping based on the number of used coding bands */ SWITCH( config->numCodingBands ) { case 5: Copy( MASA_band_mapping_24_to_5, band_mapping, 5 + 1 ); BREAK; case 8: Copy( MASA_band_mapping_24_to_8, band_mapping, 8 + 1 ); BREAK; case 12: Copy( MASA_band_mapping_24_to_12, band_mapping, 12 + 1 ); BREAK; case 18: Copy( MASA_band_mapping_24_to_18, band_mapping, 18 + 1 ); BREAK; case MASA_FREQUENCY_BANDS: /* With input count of bands, no mapping is needed but for unified processing later, we store normal mapping */ FOR( i = 0; i < MASA_FREQUENCY_BANDS + 1; i++ ) { band_mapping[i] = i; move16(); } BREAK; default: assert( 0 && "Error: The number of MASA coding bands is not supported" ); } config->useCoherence = TRUE; IF( ( !isMcMasa && LT_32( ivas_total_brate, IVAS_48k ) ) || ( isMcMasa && LT_32( ivas_total_brate, IVAS_16k4 ) ) ) { config->useCoherence = FALSE; } return; } #endif /*--------------------------------------------------------------- * masa_sample_rate_band_correction() Loading
lib_com/ivas_prot_fx.h +22 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,28 @@ void ivas_masa_set_elements_fx( const Word32 ism_total_brate /* i : initial ISM total bitrate */ ); void ivas_masa_set_coding_config_fx( MASA_CODEC_CONFIG *config, /* i/o: MASA coding config structure */ Word16 *band_mapping, /* o : Band mapping used */ const Word32 ivas_total_brate, /* i : IVAS total bitrate */ const Word16 nchan_transport, /* i : number of transport channels (mono/stereo) */ const UWord8 isMcMasa /* i : toggle for selecting mcMASA specific config */ ); void ivas_masa_prerender_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ Word32 *output_fx[], /* i/o: synthesized core-coder transport channels */ Word16 *q_shift, /* o : specifies how much the Q-factor of output has changed by. */ const Word16 output_frame, /* i : output frame length per channel */ const Word16 nchan_remapped /* i : number of transports used in core */ ); ivas_error ivas_masa_dec_reconfigure_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ Word16 *data /* o : output synthesis signal */ ); Word16 ivas_jbm_dec_get_num_tc_channels_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); Loading
lib_dec/ivas_init_dec.c +4 −0 Original line number Diff line number Diff line Loading @@ -181,7 +181,11 @@ ivas_error ivas_dec_setup( ELSE { #ifdef IVAS_FLOAT_FIXED IF ( ( error = ivas_masa_dec_reconfigure_fx( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #else IF ( ( error = ivas_masa_dec_reconfigure( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) #endif { return error; } Loading
lib_dec/ivas_jbm_dec.c +21 −0 Original line number Diff line number Diff line Loading @@ -495,7 +495,28 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == MASA_FORMAT ) { #ifdef IVAS_FLOAT_FIXED Word16 q_shift = 0; FOR(Word16 i = 0; i < 2; i++) { output_fx[i] = (Word32 *)malloc(output_frame * sizeof(Word32)); FOR(Word16 j = 0; j < output_frame; j++) { output_fx[i][j] = float_to_fix(p_output[i][j], Q11); } } ivas_masa_prerender_fx( st_ivas, output_fx, &q_shift, output_frame, nchan_remapped ); FOR(Word16 i = 0; i < 2; i++) { FOR(Word16 j = 0; j < output_frame; j++) { p_output[i][j] = fix_to_float(output_fx[i][j], Q11 + q_shift); } free(output_fx[i]); } #else ivas_masa_prerender( st_ivas, p_output, output_frame, nchan_remapped ); #endif } else if ( st_ivas->ivas_format == SBA_FORMAT && ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { Loading
lib_dec/ivas_masa_dec.c +388 −2 File changed.Preview size limit exceeded, changes collapsed. Show changes