Loading lib_com/cnst.h +3 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,9 @@ #define MAX16B_FLT 32767.0f #define MIN16B_FLT ( -32768.0f ) #define PCM16_TO_FLT_FAC 32768.0f #ifdef IVAS_FLOAT_FIXED #define PCM16_TO_FLT_FAC_FX 32768 #endif // IVAS_FLOAT_FIXED #define MDFT_NORM_SCALING ( 1.0f / PCM16_TO_FLT_FAC ) #define MAX_FRAME_COUNTER 200 #define MAX_BITS_PER_FRAME 10240 /* Bits per frame for max. bitrate 512kbps, == IVAS_MAX_BITS_PER_FRAME */ Loading lib_com/float_to_fix_ops.c +13 −0 Original line number Diff line number Diff line Loading @@ -26,7 +26,20 @@ void floatToFixed_arrL(float *f, Word32 *i, Word16 Q, Word16 l) { for (int j = 0; j < l; j++) { #if 0 i[j] = floatToFixed(f[j], Q); #else Word64 i64_val = floatToFixed( f[j], Q ); IF( i64_val > MAX_32 ) { i64_val = MAX_32; } ELSE IF( i64_val < MIN_32 ) { i64_val = MIN_32; } i[j] = (Word32) i64_val; #endif } } void floatToFixed_arr(float *f, Word16 *i, Word16 Q, Word16 l) Loading lib_com/ivas_prot.h +60 −0 Original line number Diff line number Diff line Loading @@ -3944,6 +3944,13 @@ void ivas_sba_getTCs( ); /*! r: SBA DirAC stereo flag */ #ifdef IVAS_FLOAT_FIXED Word16 ivas_sba_remapTCs_fx( Word32 *sba_data[], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ const Word16 output_frame /* i : frame length */ ); #endif // IVAS_FLOAT_FIXED int16_t ivas_sba_remapTCs( float *sba_data[], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ Loading Loading @@ -4651,6 +4658,17 @@ ivas_error ivas_sba_linear_renderer( const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ ); #ifdef IVAS_FLOAT_FIXED void ivas_sba_mix_matrix_determiner_fx( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ Word32 *output_fx[], /* i/o: transport/output audio channels */ const Word16 bfi, /* i : BFI flag */ const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ const Word16 output_frame, /* i : output frame length */ const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix */ Word16* Q_mixer_mat ); #endif // IVAS_FLOAT_FIXED void ivas_sba_mix_matrix_determiner( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ Loading Loading @@ -5058,6 +5076,16 @@ void ivas_spar_setup_md_smoothing( const int16_t num_bands_out, /* i : number of output bands */ const int16_t num_md_sub_frames /* i : number of metadata subframes */ ); #ifdef IVAS_FLOAT_FIXED void ivas_spar_dec_gen_umx_mat_fx( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const Word16 nchan_transport, /* i : number of transport channels */ const Word16 num_bands_out, /* i : number of output bands */ const Word16 bfi, /* i : bad frame indicator */ const Word16 num_md_sub_frames, Word16 * Q_mixer_mat ); #endif // IVAS_FLOAT_FIXED void ivas_spar_dec_gen_umx_mat( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ Loading Loading @@ -5763,6 +5791,16 @@ void ivas_ism_get_stereo_gains( float *left_gain, /* o : left channel gain */ float *right_gain /* o : right channel gain */ ); #ifdef IVAS_FLOAT_FIXED void ivas_mc2sba_fx( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ Word32 *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ Word32 *buffer_td[], /* i/o: MC signals (on input) and the HOA3 (on output) */ const Word16 output_frame, /* i : output frame length per channel */ const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word16 gain_lfe /* i : gain for LFE, 0 = ignore LFE */ ); #endif // IVAS_FLOAT_FIXED void ivas_mc2sba( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ Loading @@ -5772,6 +5810,17 @@ void ivas_mc2sba( const int16_t sba_order, /* i : SBA order */ const float gain_lfe /* i : gain for LFE, 0=ignore LFE */ ); #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_mc2sba_cldfb_fx( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ Word32 *hoa_encoder, /* i : HOA3 encoder for the transported MC format */ const Word16 slot_idx, /* i : current slot in the subframe */ Word32 Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ const Word16 nBands, /* i : number of synth CLDFB bands */ const Word16 gain_lfe /* i : gain applied to LFE */ ); #endif // IVAS_FLOAT_FIXED void ivas_param_mc_mc2sba_cldfb( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ Loading @@ -5783,6 +5832,17 @@ void ivas_param_mc_mc2sba_cldfb( const float gain_lfe /* i : gain applied to LFE */ ); #ifdef IVAS_FLOAT_FIXED void ivas_ism2sba_sf_fx( Word32 *buffer_in_fx[], /* i : TC buffer */ Word32 *buffer_out_fx[], /* o : TD signal buffers */ ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ const Word16 num_objects, /* i : number of objects */ const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word16 offset, /* i : offset for the interpolatr */ const Word16 sba_order /* i : Ambisonic (SBA) order */ ); #endif // IVAS_FLOAT_FIXED void ivas_ism2sba_sf( float *buffer_in[], /* i : TC buffer */ float *buffer_out[], /* o : TD signal buffers */ Loading lib_dec/ivas_jbm_dec.c +314 −0 Original line number Diff line number Diff line Loading @@ -929,7 +929,41 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == SBA_FORMAT ) { #ifdef IVAS_FLOAT_FIXED #if 1 Word32* p_output_fx[12]; Word16 Q_sba = 31; FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } FOR( Word16 i = 2; i <= 3; i++ ) { Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); } FOR( Word16 i = 2; i <= 3; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif nchan_remapped = ivas_sba_remapTCs_fx(p_output_fx, st_ivas, output_frame ); FOR( Word16 i = 2; i <= 3; i++ ) { fixedToFloat_arrL(p_output_fx[i], p_output[i], Q_sba, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #else nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); #endif // IVAS_FLOAT_FIXED if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { Loading Loading @@ -1295,13 +1329,176 @@ ivas_error ivas_jbm_dec_tc( hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[12]; Word16 Q_sba = 31; FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); } FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #else nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); #endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); #ifdef IVAS_FLOAT_FIXED #if 1 Word16 ch, i; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; Word16 num_bands_out, nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; Word32 *output_fx[12]; FOR( Word16 c = 0; c < nchan_transport; c++ ) { output_fx[c] = malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); } FOR( ch = 0; ch < nchan_transport; ch++ ) { FOR( i = 0; i < output_frame; i++ ) { output_fx[ch][i] = floatToFixed( p_output[sba_ch_idx + ch][i], Q_p_output ); } } Word16 j, b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; Word16 Q_C_re_fx = 31, Q_P_re_fx = 31, Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < num_in_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { Q_mixer_mat = s_min( Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); } } } } FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < nchan_transport; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); } } } } FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = nchan_transport; j < num_out_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); } } } } Q_mixer_mat = s_min( Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < num_in_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < nchan_transport; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = nchan_transport; j < num_out_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } } #endif ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ,&Q_mixer_mat); #if 1 /*Fixed to float changes */ FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < num_in_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } } FOR( Word16 c = 0; c < nchan_transport; c++ ) { FOR( j = 0; j < output_frame; j++ ) { p_output[sba_ch_idx+c][j] = (float) output_fx[c][j]; } } FOR( Word16 c = 0; c < nchan_transport; c++ ) { free( output_fx[c] ); } #endif #else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); #endif // IVAS_FLOAT_FIXED } else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) { Loading Loading @@ -1398,7 +1595,43 @@ ivas_error ivas_jbm_dec_tc( { if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) { #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[12]; FOR ( Word16 lp = 0; lp < 12; lp++ ) { IF ( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_in_buffer_td = 31, i; FOR( i = 0; i < st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; i++ ) { Q_in_buffer_td = s_min( Q_in_buffer_td, Q_factor_arrL( p_output[i], output_frame ) ); } FOR( i = 0; i < st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_in_buffer_td, output_frame ); } #endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); #if 1 FOR ( i = 0; i < ( st_ivas->hIntSetup.ambisonics_order + 1 ) * ( st_ivas->hIntSetup.ambisonics_order + 1 ); i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { IF ( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #endif #else ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); #endif // IVAS_FLOAT_FIXED } } Loading Loading @@ -2288,7 +2521,43 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* Convert CICP19 -> Ambisonics */ #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[20]; FOR( Word16 lp = 0; lp < 20; lp++ ) { IF ( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_in_buffer_td = 31, i; FOR( i = 0; i < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { Q_in_buffer_td = s_min( Q_in_buffer_td, Q_factor_arrL( p_output[i], *nSamplesRendered ) ); } FOR( i = 0; i < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_in_buffer_td, *nSamplesRendered ); } #endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); #if 1 FOR( i = 0; i < (st_ivas->hOutSetup.ambisonics_order + 1 ) * (st_ivas->hOutSetup.ambisonics_order + 1 ); i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, *nSamplesRendered); } FOR( Word16 lp = 0; lp < 20; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #endif #else ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); #endif // IVAS_FLOAT_FIXED } } } Loading Loading @@ -2403,7 +2672,52 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */ #ifdef IVAS_FLOAT_FIXED FOR( i = 0; i < *nSamplesRendered + st_ivas->hTcBuffer->n_samples_rendered; i++ ) { st_ivas->hIsmRendererData->interpolator_fx[i] = (Word16) float_to_fix16( st_ivas->hIsmRendererData->interpolator[i], 15 ); } FOR( i = 0; i < 15; i++ ) { FOR( j = 0; j < 16; j++ ) { st_ivas->hIsmRendererData->gains_fx[i][j] = floatToFixed( st_ivas->hIsmRendererData->gains[i][j], Q29 ); st_ivas->hIsmRendererData->prev_gains_fx[i][j] = floatToFixed( st_ivas->hIsmRendererData->prev_gains[i][j], Q29 ); } } Word32 *p_output_fx[20]; FOR( Word16 lp = 0; lp < 20; lp++ ) { IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_buffer_in = 31; FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { Q_buffer_in = s_min( Q_buffer_in, Q_factor_arrL( st_ivas->hTcBuffer->tc[i], L_FRAME48k ) ); } FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q_buffer_in, L_FRAME48k ); } ivas_ism2sba_sf_fx( st_ivas->hTcBuffer->tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) ); FOR( j = 0; j < sba_num_chans; j++ ) { fixedToFloat_arrL( p_output_fx[j], p_output[j], Q_buffer_in + 29 - 31, *nSamplesRendered ); } FOR( Word16 lp = 0; lp < 20; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #else ivas_ism2sba_sf( st_ivas->hTcBuffer->tc, p_output, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); #endif // IVAS_FLOAT_FIXED } /* Binaural rendering */ Loading lib_dec/ivas_mc_param_dec.c +29 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
lib_com/cnst.h +3 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,9 @@ #define MAX16B_FLT 32767.0f #define MIN16B_FLT ( -32768.0f ) #define PCM16_TO_FLT_FAC 32768.0f #ifdef IVAS_FLOAT_FIXED #define PCM16_TO_FLT_FAC_FX 32768 #endif // IVAS_FLOAT_FIXED #define MDFT_NORM_SCALING ( 1.0f / PCM16_TO_FLT_FAC ) #define MAX_FRAME_COUNTER 200 #define MAX_BITS_PER_FRAME 10240 /* Bits per frame for max. bitrate 512kbps, == IVAS_MAX_BITS_PER_FRAME */ Loading
lib_com/float_to_fix_ops.c +13 −0 Original line number Diff line number Diff line Loading @@ -26,7 +26,20 @@ void floatToFixed_arrL(float *f, Word32 *i, Word16 Q, Word16 l) { for (int j = 0; j < l; j++) { #if 0 i[j] = floatToFixed(f[j], Q); #else Word64 i64_val = floatToFixed( f[j], Q ); IF( i64_val > MAX_32 ) { i64_val = MAX_32; } ELSE IF( i64_val < MIN_32 ) { i64_val = MIN_32; } i[j] = (Word32) i64_val; #endif } } void floatToFixed_arr(float *f, Word16 *i, Word16 Q, Word16 l) Loading
lib_com/ivas_prot.h +60 −0 Original line number Diff line number Diff line Loading @@ -3944,6 +3944,13 @@ void ivas_sba_getTCs( ); /*! r: SBA DirAC stereo flag */ #ifdef IVAS_FLOAT_FIXED Word16 ivas_sba_remapTCs_fx( Word32 *sba_data[], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ const Word16 output_frame /* i : frame length */ ); #endif // IVAS_FLOAT_FIXED int16_t ivas_sba_remapTCs( float *sba_data[], /* i/o: SBA signals */ Decoder_Struct *st_ivas, /* i/o: decoder struct */ Loading Loading @@ -4651,6 +4658,17 @@ ivas_error ivas_sba_linear_renderer( const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ ); #ifdef IVAS_FLOAT_FIXED void ivas_sba_mix_matrix_determiner_fx( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ Word32 *output_fx[], /* i/o: transport/output audio channels */ const Word16 bfi, /* i : BFI flag */ const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ const Word16 output_frame, /* i : output frame length */ const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix */ Word16* Q_mixer_mat ); #endif // IVAS_FLOAT_FIXED void ivas_sba_mix_matrix_determiner( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ Loading Loading @@ -5058,6 +5076,16 @@ void ivas_spar_setup_md_smoothing( const int16_t num_bands_out, /* i : number of output bands */ const int16_t num_md_sub_frames /* i : number of metadata subframes */ ); #ifdef IVAS_FLOAT_FIXED void ivas_spar_dec_gen_umx_mat_fx( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ const Word16 nchan_transport, /* i : number of transport channels */ const Word16 num_bands_out, /* i : number of output bands */ const Word16 bfi, /* i : bad frame indicator */ const Word16 num_md_sub_frames, Word16 * Q_mixer_mat ); #endif // IVAS_FLOAT_FIXED void ivas_spar_dec_gen_umx_mat( ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD decoder handle */ Loading Loading @@ -5763,6 +5791,16 @@ void ivas_ism_get_stereo_gains( float *left_gain, /* o : left channel gain */ float *right_gain /* o : right channel gain */ ); #ifdef IVAS_FLOAT_FIXED void ivas_mc2sba_fx( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ Word32 *in_buffer_td[], /* i : MC signals (on input) and the HOA3 (on output) */ Word32 *buffer_td[], /* i/o: MC signals (on input) and the HOA3 (on output) */ const Word16 output_frame, /* i : output frame length per channel */ const Word16 sba_order, /* i : Ambisonic (SBA) order */ const Word16 gain_lfe /* i : gain for LFE, 0 = ignore LFE */ ); #endif // IVAS_FLOAT_FIXED void ivas_mc2sba( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ Loading @@ -5772,6 +5810,17 @@ void ivas_mc2sba( const int16_t sba_order, /* i : SBA order */ const float gain_lfe /* i : gain for LFE, 0=ignore LFE */ ); #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_mc2sba_cldfb_fx( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ Word32 *hoa_encoder, /* i : HOA3 encoder for the transported MC format */ const Word16 slot_idx, /* i : current slot in the subframe */ Word32 Cldfb_RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ Word32 Cldfb_ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ const Word16 nBands, /* i : number of synth CLDFB bands */ const Word16 gain_lfe /* i : gain applied to LFE */ ); #endif // IVAS_FLOAT_FIXED void ivas_param_mc_mc2sba_cldfb( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ Loading @@ -5783,6 +5832,17 @@ void ivas_param_mc_mc2sba_cldfb( const float gain_lfe /* i : gain applied to LFE */ ); #ifdef IVAS_FLOAT_FIXED void ivas_ism2sba_sf_fx( Word32 *buffer_in_fx[], /* i : TC buffer */ Word32 *buffer_out_fx[], /* o : TD signal buffers */ ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ const Word16 num_objects, /* i : number of objects */ const Word16 n_samples_to_render, /* i : output frame length per channel */ const Word16 offset, /* i : offset for the interpolatr */ const Word16 sba_order /* i : Ambisonic (SBA) order */ ); #endif // IVAS_FLOAT_FIXED void ivas_ism2sba_sf( float *buffer_in[], /* i : TC buffer */ float *buffer_out[], /* o : TD signal buffers */ Loading
lib_dec/ivas_jbm_dec.c +314 −0 Original line number Diff line number Diff line Loading @@ -929,7 +929,41 @@ ivas_error ivas_jbm_dec_tc( if ( st_ivas->ivas_format == SBA_FORMAT ) { #ifdef IVAS_FLOAT_FIXED #if 1 Word32* p_output_fx[12]; Word16 Q_sba = 31; FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } FOR( Word16 i = 2; i <= 3; i++ ) { Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); } FOR( Word16 i = 2; i <= 3; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif nchan_remapped = ivas_sba_remapTCs_fx(p_output_fx, st_ivas, output_frame ); FOR( Word16 i = 2; i <= 3; i++ ) { fixedToFloat_arrL(p_output_fx[i], p_output[i], Q_sba, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #else nchan_remapped = ivas_sba_remapTCs( p_output, st_ivas, output_frame ); #endif // IVAS_FLOAT_FIXED if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { Loading Loading @@ -1295,13 +1329,176 @@ ivas_error ivas_jbm_dec_tc( hp20_flt( p_output[n], output_frame, st_ivas->mem_hp20_out[n], output_Fs ); } #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[12]; Word16 Q_sba = 31; FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { Q_sba = s_min( Q_sba, Q_factor_arrL( p_output[i], output_frame ) ); } FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_sba, output_frame ); } #endif nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); FOR( Word16 i = sba_ch_idx + 2; i <= sba_ch_idx + 3; i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_sba, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #else nchan_remapped = ivas_sba_remapTCs( &p_output[sba_ch_idx], st_ivas, output_frame ); #endif if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); #ifdef IVAS_FLOAT_FIXED #if 1 Word16 ch, i; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 Q_p_output = 14; Word16 num_bands_out, nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; Word32 *output_fx[12]; FOR( Word16 c = 0; c < nchan_transport; c++ ) { output_fx[c] = malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ); } FOR( ch = 0; ch < nchan_transport; ch++ ) { FOR( i = 0; i < output_frame; i++ ) { output_fx[ch][i] = floatToFixed( p_output[sba_ch_idx + ch][i], Q_p_output ); } } Word16 j, b, i_ts, num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; Word16 Q_C_re_fx = 31, Q_P_re_fx = 31, Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < num_in_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { Q_mixer_mat = s_min( Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); } } } } FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < nchan_transport; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); } } } } FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = nchan_transport; j < num_out_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); } } } } Q_mixer_mat = s_min( Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < num_in_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < nchan_transport; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = nchan_transport; j < num_out_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } } #endif ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ,&Q_mixer_mat); #if 1 /*Fixed to float changes */ FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) { FOR( i = 0; i < num_out_ch; i++ ) { FOR( j = 0; j < num_in_ch; j++ ) { FOR( b = 0; b < num_bands_out; b++ ) { hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], Q_mixer_mat ); } } } } FOR( Word16 c = 0; c < nchan_transport; c++ ) { FOR( j = 0; j < output_frame; j++ ) { p_output[sba_ch_idx+c][j] = (float) output_fx[c][j]; } } FOR( Word16 c = 0; c < nchan_transport; c++ ) { free( output_fx[c] ); } #endif #else ivas_sba_mix_matrix_determiner( st_ivas->hSpar, &p_output[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); #endif // IVAS_FLOAT_FIXED } else if ( st_ivas->renderer_type != RENDERER_DISABLE && !st_ivas->sba_dirac_stereo_flag ) { Loading Loading @@ -1398,7 +1595,43 @@ ivas_error ivas_jbm_dec_tc( { if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) >= ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) ) { #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[12]; FOR ( Word16 lp = 0; lp < 12; lp++ ) { IF ( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_in_buffer_td = 31, i; FOR( i = 0; i < st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; i++ ) { Q_in_buffer_td = s_min( Q_in_buffer_td, Q_factor_arrL( p_output[i], output_frame ) ); } FOR( i = 0; i < st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_in_buffer_td, output_frame ); } #endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); #if 1 FOR ( i = 0; i < ( st_ivas->hIntSetup.ambisonics_order + 1 ) * ( st_ivas->hIntSetup.ambisonics_order + 1 ); i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, output_frame ); } FOR( Word16 lp = 0; lp < 12; lp++ ) { IF ( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #endif #else ivas_mc2sba( st_ivas->hTransSetup, p_output, p_output, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE ); #endif // IVAS_FLOAT_FIXED } } Loading Loading @@ -2288,7 +2521,43 @@ ivas_error ivas_jbm_dec_render( if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) { /* Convert CICP19 -> Ambisonics */ #ifdef IVAS_FLOAT_FIXED #if 1 Word32 *p_output_fx[20]; FOR( Word16 lp = 0; lp < 20; lp++ ) { IF ( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_in_buffer_td = 31, i; FOR( i = 0; i < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { Q_in_buffer_td = s_min( Q_in_buffer_td, Q_factor_arrL( p_output[i], *nSamplesRendered ) ); } FOR( i = 0; i < st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; i++ ) { floatToFixed_arrL( p_output[i], p_output_fx[i], Q_in_buffer_td, *nSamplesRendered ); } #endif // IVAS_FLOAT_FIXED ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); #if 1 FOR( i = 0; i < (st_ivas->hOutSetup.ambisonics_order + 1 ) * (st_ivas->hOutSetup.ambisonics_order + 1 ); i++ ) { fixedToFloat_arrL( p_output_fx[i], p_output[i], Q_in_buffer_td - 3, *nSamplesRendered); } FOR( Word16 lp = 0; lp < 20; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #endif #else ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f ); #endif // IVAS_FLOAT_FIXED } } } Loading Loading @@ -2403,7 +2672,52 @@ ivas_error ivas_jbm_dec_render( else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ) { /* Convert to Ambisonics; used also for ISM->HOA3->binaural rendering */ #ifdef IVAS_FLOAT_FIXED FOR( i = 0; i < *nSamplesRendered + st_ivas->hTcBuffer->n_samples_rendered; i++ ) { st_ivas->hIsmRendererData->interpolator_fx[i] = (Word16) float_to_fix16( st_ivas->hIsmRendererData->interpolator[i], 15 ); } FOR( i = 0; i < 15; i++ ) { FOR( j = 0; j < 16; j++ ) { st_ivas->hIsmRendererData->gains_fx[i][j] = floatToFixed( st_ivas->hIsmRendererData->gains[i][j], Q29 ); st_ivas->hIsmRendererData->prev_gains_fx[i][j] = floatToFixed( st_ivas->hIsmRendererData->prev_gains[i][j], Q29 ); } } Word32 *p_output_fx[20]; FOR( Word16 lp = 0; lp < 20; lp++ ) { IF( p_output[lp] != NULL ) { p_output_fx[lp] = (Word32 *) malloc( sizeof( Word32 ) * L_FRAME48k ); } } Word16 Q_buffer_in = 31; FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { Q_buffer_in = s_min( Q_buffer_in, Q_factor_arrL( st_ivas->hTcBuffer->tc[i], L_FRAME48k ) ); } FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { floatToFixed_arrL( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q_buffer_in, L_FRAME48k ); } ivas_ism2sba_sf_fx( st_ivas->hTcBuffer->tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) ); FOR( j = 0; j < sba_num_chans; j++ ) { fixedToFloat_arrL( p_output_fx[j], p_output[j], Q_buffer_in + 29 - 31, *nSamplesRendered ); } FOR( Word16 lp = 0; lp < 20; lp++ ) { IF( p_output[lp] != NULL ) { free( p_output_fx[lp] ); } } #else ivas_ism2sba_sf( st_ivas->hTcBuffer->tc, p_output, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); #endif // IVAS_FLOAT_FIXED } /* Binaural rendering */ Loading
lib_dec/ivas_mc_param_dec.c +29 −0 File changed.Preview size limit exceeded, changes collapsed. Show changes