diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index 18ab4ccf98497fcfcecde82d3939f1d8b7a7269b..6005aa67c6054ea54dd31477e523c957f5cdaf95 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -6145,7 +6145,7 @@ ivas_error ivas_sba_dec_render_fx( const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_fx[], /* o : rendered time signal */ + Word32 *output_fx[], /* o : rendered time signal Q11*/ Word16 out_len/*Store the length of values in each channel*/ ); #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index a8b1bacadbb9f09b3a7348cdb54051f1baf69913..0c636f741629164d779beaec31958d4ccd9e612e 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -707,8 +707,8 @@ ivas_error ivas_sba_dec_reconfigure( ivas_error ivas_sba_dec_reconfigure_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - UWord16 *nSamplesFlushed, /* o : number of samples flushed */ - Word16 *data /* o : output synthesis signal */ + UWord16 *nSamplesFlushed, /* o : number of samples flushed Q0*/ + Word16 *data /* o : output synthesis signal Q0*/ ) { Word16 nchan_transport_old, nSCE_old, nCPE_old, nchan_hp20_old; @@ -776,7 +776,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( *nSamplesFlushed = 0; move16(); - granularity_new = st_ivas->hTcBuffer->n_samples_granularity; + granularity_new = st_ivas->hTcBuffer->n_samples_granularity; /*Q0*/ move16(); /* we may need to flush only for binaural and OSBA and TSM */ @@ -821,23 +821,23 @@ ivas_error ivas_sba_dec_reconfigure_fx( } /* determine new granularity */ - granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + granularity_new = NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); /* this will change anyway only with binaural */ test(); IF( EQ_16( renderer_type_new, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - granularity_new = i_mult( granularity_new, JBM_CLDFB_SLOTS_IN_SUBFRAME ); + granularity_new = i_mult( granularity_new, JBM_CLDFB_SLOTS_IN_SUBFRAME ); /*Q0*/ } /* flush renderer on granularity change form 5ms to 1.25ms, again only possible for binaural rendering */ IF( LT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) { /* write back info for correct rendering of the flushable samples */ - st_ivas->sba_analysis_order = sba_analysis_order_old_flush; + st_ivas->sba_analysis_order = sba_analysis_order_old_flush; /*Q0*/ move16(); - st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; + st_ivas->hDecoderConfig->ivas_total_brate = last_ivas_total_brate; /*Q0*/ move32(); if ( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, granularity_new, st_ivas->renderer_type, st_ivas->intern_config, &st_ivas->hIntSetup, st_ivas->mc_mode, ism_mode_old, nSamplesFlushed, data ) ), IVAS_ERR_OK ) ) @@ -848,7 +848,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* restore correct values for the current frame*/ st_ivas->sba_analysis_order = ivas_sba_get_analysis_order_fx( ivas_total_brate, st_ivas->sba_order ); move16(); - st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; + st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate; /*Q0*/ move32(); } ELSE IF( GT_16( granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) ) @@ -861,10 +861,10 @@ ivas_error ivas_sba_dec_reconfigure_fx( /* make sure the changed number of slots in the last subframe is not lost in the following steps */ IF( st_ivas->hSpatParamRendCom != NULL ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + st_ivas->hSpatParamRendCom->subframe_nbslots[st_ivas->hSpatParamRendCom->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; /*Q0*/ move32(); } - st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; + st_ivas->hSpar->subframe_nbslots[st_ivas->hSpar->nb_subframes - 1] = st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1]; /*Q0*/ move32(); } } @@ -883,7 +883,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( move16(); st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpar->subframes_rendered; move16(); - Copy( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( st_ivas->hSpar->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ } ELSE IF( st_ivas->hSpatParamRendCom != NULL ) { @@ -895,7 +895,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( move16(); st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; move16(); - Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ } } @@ -907,7 +907,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( SPAR_DEC_HANDLE hSpar; hSpar = st_ivas->hSpar; - sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); + sba_order_internal = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); /*Q0*/ IF( hSpar != NULL ) { @@ -935,7 +935,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( } ELSE IF( LT_32( last_ivas_total_brate, IVAS_24k4 ) && GE_32( ivas_total_brate, IVAS_24k4 ) ) { - num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; + num_channels = st_ivas->hSpar->hMdDec->spar_md_cfg.num_umx_chs; /*Q0*/ move16(); ivas_spar_md_dec_matrix_close_fx( st_ivas->hSpar->hMdDec, num_channels ); @@ -1059,14 +1059,14 @@ ivas_error ivas_sba_dec_reconfigure_fx( { Word16 band_grouping[IVAS_MAX_NUM_BANDS + 1]; - st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); + st_ivas->hSpar->enc_param_start_band = s_min( IVAS_MAX_NUM_BANDS, SPAR_DIRAC_SPLIT_START_BAND ); /*Q0*/ move16(); IF( ivas_get_hodirac_flag_fx( ivas_total_brate, st_ivas->sba_analysis_order ) ) { st_ivas->hSpar->enc_param_start_band = 0; move16(); - set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); + set_c( (Word8 *) st_ivas->hQMetaData->twoDirBands, (Word8) 1, st_ivas->hQMetaData->q_direction[0].cfg.nbands ); /*Q0*/ st_ivas->hQMetaData->numTwoDirBands = (UWord8) st_ivas->hQMetaData->q_direction[0].cfg.nbands; move16(); } @@ -1174,7 +1174,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( return error; } - st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) ); + st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) ); /*Q0*/ move16(); } ELSE IF( EQ_16( ism_mode_old, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->ism_mode, ISM_MODE_NONE ) ) @@ -1193,19 +1193,19 @@ ivas_error ivas_sba_dec_reconfigure_fx( st_ivas->hHrtfTD = NULL; } } - nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); + nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); /*Q0*/ st_ivas->ism_mode = ISM_MODE_NONE; move16(); } ELSE IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) ); + st_ivas->nCPE = add( st_ivas->nCPE, shr( add( st_ivas->nchan_ism, 1 ), 1 ) ); /*Q0*/ move16(); nCPE_old = st_ivas->nCPE; move16(); nchan_transport_old = st_ivas->nchan_transport; move16(); - nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); + nchan_transport_old = add( nchan_transport_old, st_ivas->nchan_ism ); /*Q0*/ } } @@ -1253,8 +1253,8 @@ ivas_error ivas_sba_dec_reconfigure_fx( tc_buffer_mode = TC_BUFFER_MODE_RENDERER; move16(); - tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); - tc_nchan_to_allocate = tc_nchan_tc; + tc_nchan_tc = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); /*Q0*/ + tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/ move16(); test(); test(); @@ -1266,31 +1266,31 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) { - tc_nchan_tc = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); - tc_nchan_to_allocate = tc_nchan_tc; + tc_nchan_tc = add( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); /*Q0*/ + tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/ move16(); } ELSE { tc_buffer_mode = TC_BUFFER_MODE_BUFFER; move16(); - tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out; + tc_nchan_tc = st_ivas->hDecoderConfig->nchan_out; /*Q0*/ move16(); - tc_nchan_to_allocate = tc_nchan_tc; + tc_nchan_to_allocate = tc_nchan_tc; /*Q0*/ move16(); } } ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { - tc_nchan_to_allocate = shl( BINAURAL_CHANNELS, 1 ); + tc_nchan_to_allocate = shl( BINAURAL_CHANNELS, 1 ); /*2 * BINAURAL_CHANNELS*/ } ELSE IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { - tc_nchan_to_allocate = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + tc_nchan_to_allocate = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - tc_nchan_to_allocate = add( tc_nchan_to_allocate, st_ivas->nchan_ism ); + tc_nchan_to_allocate = add( tc_nchan_to_allocate, st_ivas->nchan_ism ); /*Q0*/ } } ELSE @@ -1321,13 +1321,13 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( st_ivas->hSpatParamRendCom != NULL && EQ_16( st_ivas->hSpatParamRendCom->slot_size, st_ivas->hTcBuffer->n_samples_granularity ) ) { - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; move16(); st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; move16(); } - Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpar->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); /*Q0*/ st_ivas->hSpar->nb_subframes = st_ivas->hTcBuffer->nb_subframes; move16(); st_ivas->hSpar->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; @@ -1337,11 +1337,11 @@ ivas_error ivas_sba_dec_reconfigure_fx( test(); IF( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) { - Word16 granularityMultiplier = idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ); + Word16 granularityMultiplier = idiv1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hSpatParamRendCom->slot_size ); /*Q0*/ Word16 n; FOR( n = 0; n < MAX_JBM_SUBFRAMES_5MS; n++ ) { - st_ivas->hSpatParamRendCom->subframe_nbslots[n] = i_mult( st_ivas->hTcBuffer->subframe_nbslots[n], granularityMultiplier ); + st_ivas->hSpatParamRendCom->subframe_nbslots[n] = i_mult( st_ivas->hTcBuffer->subframe_nbslots[n], granularityMultiplier ); /*Q0*/ move16(); st_ivas->hSpar->subframe_nbslots[n] = st_ivas->hSpatParamRendCom->subframe_nbslots[n]; move16(); @@ -1352,7 +1352,7 @@ ivas_error ivas_sba_dec_reconfigure_fx( * floating-point output audio buffers *-----------------------------------------------------------------*/ - nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + nchan_out_buff = ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); /*Q0*/ if ( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) ) { @@ -1661,8 +1661,8 @@ void ivas_sba_dec_digest_tc( #ifdef IVAS_FLOAT_FIXED void ivas_sba_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const Word16 nCldfbSlots, /* i : number of CLDFB slots */ - const Word16 nSamplesForRendering /* i : number of samples provided */ + const Word16 nCldfbSlots, /* i : number of CLDFB slots Q0*/ + const Word16 nSamplesForRendering /* i : number of samples provided Q0*/ ) { Word16 ch_idx, nchan_transport; @@ -1685,21 +1685,21 @@ void ivas_sba_dec_digest_tc_fx( Word32 *p_tc[2 * BINAURAL_CHANNELS]; /* default_frame = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / FRAMES_PER_SEC ); */ - default_frame = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); - nSamplesLeftForTD = nSamplesForRendering; + default_frame = extract_l( Mpy_32_32( st_ivas->hDecoderConfig->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ); /*Q0*/ + nSamplesLeftForTD = nSamplesForRendering; /*Q0*/ move16(); FOR( ch_idx = 0; ch_idx < BINAURAL_CHANNELS; ch_idx++ ) { - decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc_fx[add( ch_idx, BINAURAL_CHANNELS )]; + decorr_signal[ch_idx] = st_ivas->hTcBuffer->tc_fx[( ch_idx + BINAURAL_CHANNELS )]; /*Q11*/ move32(); - p_tc[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx]; + p_tc[ch_idx] = st_ivas->hTcBuffer->tc_fx[ch_idx]; /*Q11*/ move32(); } WHILE( nSamplesLeftForTD ) { - Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); + Word16 nSamplesToDecorr = s_min( nSamplesLeftForTD, default_frame ); /*Q0*/ IF( st_ivas->hDiracDecBin->hTdDecorr ) { @@ -1711,12 +1711,12 @@ void ivas_sba_dec_digest_tc_fx( decorr_signal[ch_idx] += nSamplesToDecorr; p_tc[ch_idx] += nSamplesToDecorr; } - nSamplesLeftForTD = sub( nSamplesLeftForTD, nSamplesToDecorr ); + nSamplesLeftForTD = sub( nSamplesLeftForTD, nSamplesToDecorr ); /*Q0*/ } } /* if we have a late CNG generation, do it here */ - nchan_transport = st_ivas->nchan_transport; + nchan_transport = st_ivas->nchan_transport; /*Q0*/ move16(); test(); @@ -1745,7 +1745,7 @@ void ivas_sba_dec_digest_tc_fx( ( ( EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) ) && ( EQ_16( nchan_transport, 1 ) && NE_16( st_ivas->nchan_transport, 2 ) && st_ivas->hSCE[0]->hCoreCoder[0] != NULL && st_ivas->hSCE[0]->hCoreCoder[0]->cng_sba_flag ) ) ) { Decoder_State *st = st_ivas->hSCE[0]->hCoreCoder[0]; - Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 2 ) ); + Scale_sig( st->hFdCngDec->hFdCngCom->A_cng, M + 1, sub( norm_s( sub( st->hFdCngDec->hFdCngCom->A_cng[0], 1 ) ), 2 ) ); /*Q12 -> Q13*/ generate_masking_noise_lb_dirac_fx( st->hFdCngDec->hFdCngCom, st_ivas->hTcBuffer->tc_fx[1], nCldfbSlots, st->cna_dirac_flag && st->flag_cna ); } @@ -1763,10 +1763,10 @@ void ivas_sba_dec_digest_tc_fx( #ifdef IVAS_FLOAT_FIXED ivas_error ivas_sba_dec_render_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_fx[], /* o : rendered time signal */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested Q0*/ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered Q0*/ + UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render Q0*/ + Word32 *output_fx[], /* o : rendered time signal Q11*/ Word16 out_len /*Store the length of values in each channel*/ ) { @@ -1784,38 +1784,38 @@ ivas_error ivas_sba_dec_render_fx( hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); + nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); /*Q0*/ FOR( ch = 0; ch < nchan_out; ch++ ) { - output_f_local_fx[ch] = output_fx[ch]; + output_f_local_fx[ch] = output_fx[ch]; /*Q11*/ } - slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); + slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ move16(); /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ - slots_to_render = s_min( sub( hSpar->num_slots, hSpar->slots_rendered ), idiv1616( nSamplesAsked, slot_size ) ); - *nSamplesRendered = imult1616( slots_to_render, slot_size ); + slots_to_render = s_min( sub( hSpar->num_slots, hSpar->slots_rendered ), idiv1616( nSamplesAsked, slot_size ) ); /*Q0*/ + *nSamplesRendered = imult1616( slots_to_render, slot_size ); /*Q0*/ move16(); - first_sf = hSpar->subframes_rendered; - last_sf = first_sf; + first_sf = hSpar->subframes_rendered; /*Q0*/ + last_sf = first_sf; /*Q0*/ move16(); move16(); WHILE( slots_to_render > 0 ) { - slots_to_render = sub( slots_to_render, hSpar->subframe_nbslots[last_sf] ); + slots_to_render = sub( slots_to_render, hSpar->subframe_nbslots[last_sf] ); /*Q0*/ last_sf = add( last_sf, 1 ); } FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - Word16 n_samples_sf = imult1616( slot_size, hSpar->subframe_nbslots[subframe_idx] ); + Word16 n_samples_sf = imult1616( slot_size, hSpar->subframe_nbslots[subframe_idx] ); /*Q0*/ ivas_spar_dec_upmixer_sf_fx( st_ivas, output_f_local_fx, nchan_internal, output_f_local_len ); FOR( ch = 0; ch < nchan_out; ch++ ) { - output_f_local_fx[ch] = output_f_local_fx[ch] + n_samples_sf; + output_f_local_fx[ch] = output_f_local_fx[ch] + n_samples_sf; /*Q11*/ } output_f_local_len = sub( output_f_local_len, n_samples_sf ); @@ -1835,18 +1835,18 @@ ivas_error ivas_sba_dec_render_fx( { IF( EQ_16( st_ivas->hDirAC->hConfig->dec_param_estim, 1 ) ) { - hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_CLDFB_TIMESLOTS ) % hSpatParamRendCom->dirac_md_buffer_length; + hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_CLDFB_TIMESLOTS ) % hSpatParamRendCom->dirac_md_buffer_length; /*Q0*/ move16(); } ELSE { - hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; + hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; /*Q0*/ move16(); } move16(); } - *nSamplesAvailableNext = imult1616( sub( hSpar->num_slots, hSpar->slots_rendered ), slot_size ); + *nSamplesAvailableNext = imult1616( sub( hSpar->num_slots, hSpar->slots_rendered ), slot_size ); /*Q0*/ move16(); return IVAS_ERR_OK; diff --git a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c index ae190e4283b43ce9d09d5fc9ca3fa2745ae03763..787646041b15f38d099243603091b2fa8428ce82 100644 --- a/lib_dec/ivas_sba_dirac_stereo_dec_fx.c +++ b/lib_dec/ivas_sba_dirac_stereo_dec_fx.c @@ -143,9 +143,9 @@ void ivas_sba_dirac_stereo_config( *-------------------------------------------------------------------*/ static Word16 ivas_sba_dirac_stereo_band_config( - Word16 *band_limits, /* o : DFT band limits */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 NFFT, /* i : analysis/synthesis window length */ + Word16 *band_limits, /* o : DFT band limits Q0*/ + const Word32 output_Fs, /* i : output sampling rate Q0*/ + const Word16 NFFT, /* i : analysis/synthesis window length Q0*/ const Word16 spar_flag /* i : SPAR or DirAC band grouping */ ) { @@ -191,7 +191,7 @@ static Word16 ivas_sba_dirac_stereo_band_config( assert( 0 ); } - bins_per_cldfb_band = idiv1616( NFFT, shl( num_cldfb_bands, 1 ) ); + bins_per_cldfb_band = idiv1616( NFFT, shl( num_cldfb_bands, 1 ) /*( 2 * num_cldfb_bands )*/ ); /*Q0*/ move16(); band_limits[0] = 1; move16(); @@ -199,22 +199,22 @@ static Word16 ivas_sba_dirac_stereo_band_config( { IF( spar_flag ) { - band_limits[i] = i_mult( DirAC_band_grouping_12[i], bins_per_cldfb_band ); + band_limits[i] = i_mult( DirAC_band_grouping_12[i], bins_per_cldfb_band ); /*Q0*/ move16(); } ELSE { - band_limits[i] = i_mult( DirAC_band_grouping_5[i], bins_per_cldfb_band ); + band_limits[i] = i_mult( DirAC_band_grouping_5[i], bins_per_cldfb_band ); /*Q0*/ move16(); } - IF( GE_16( band_limits[i], shr( NFFT, 1 ) ) ) + IF( GE_16( band_limits[i], shr( NFFT, 1 ) /* NFFT / 2 */ ) ) { nbands = i; move16(); BREAK; } } - band_limits[nbands] = shr( NFFT, 1 ); + band_limits[nbands] = shr( NFFT, 1 ); /* NFFT / 2 */ move16(); return nbands; @@ -225,34 +225,34 @@ static Word16 get_panning_tangent_gain( { Word16 tbl_len = sizeof( ivas_sine_panning_tbl_fx ) / sizeof( ivas_sine_panning_tbl_fx[0] ); // Not using BASOP because size can be calculted at compile-time. move16(); - Word16 idx = shr( tbl_len, 1 ); + Word16 idx = shr( tbl_len, 1 ); /*Q0*/ move16(); - const Word16 *ptr_sin = &ivas_sine_panning_tbl_fx[0]; - const Word16 *ptr_tan = &ivas_tan_panning_gain_dirac_tbl_fx[0]; + const Word16 *ptr_sin = &ivas_sine_panning_tbl_fx[0]; /*Q15*/ + const Word16 *ptr_tan = &ivas_tan_panning_gain_dirac_tbl_fx[0]; /*Q15*/ Word16 lim_l = 0; move16(); - Word16 lim_r = tbl_len; + Word16 lim_r = tbl_len; /*Q0*/ move16(); WHILE( 1 ) { - idx = shr( add( lim_l, lim_r ), 1 ); + idx = shr( add( lim_l, lim_r ), 1 ); /*Q0*/ IF( GE_16( idx, tbl_len ) ) { - return ptr_tan[tbl_len - 1]; + return ptr_tan[tbl_len - 1]; /*Q15*/ } ELSE IF( idx <= 0 ) { - return ptr_tan[0]; + return ptr_tan[0]; /*Q15*/ } ELSE IF( LE_16( sinAngleMapped, ptr_sin[idx + 1] ) && GE_16( sinAngleMapped, ptr_sin[idx] ) ) { IF( EQ_16( sinAngleMapped, ptr_sin[idx + 1] ) ) { - return ptr_tan[idx + 1]; + return ptr_tan[idx + 1]; /*Q15*/ } ELSE IF( EQ_16( sinAngleMapped, ptr_sin[idx] ) ) { - return ptr_tan[idx]; + return ptr_tan[idx]; /*Q15*/ } ELSE { @@ -260,70 +260,71 @@ static Word16 get_panning_tangent_gain( move16(); IF( LE_16( sinAngleMapped, mid ) ) { - return ptr_tan[idx]; + return ptr_tan[idx]; /*Q15*/ } ELSE { - return ptr_tan[idx + 1]; + return ptr_tan[idx + 1]; /*Q15*/ } } } ELSE IF( GT_16( sinAngleMapped, ptr_sin[idx] ) ) { - lim_l = add( idx, 1 ); + lim_l = add( idx, 1 ); /*Q0*/ } ELSE IF( LT_16( sinAngleMapped, ptr_sin[idx] ) ) { - lim_r = sub( idx, 1 ); + lim_r = sub( idx, 1 ); /*Q0*/ } } } static Word16 get_panning( - const Word16 aziDeg, - const Word16 eleDeg ) + const Word16 aziDeg, /*Q0*/ + const Word16 eleDeg /*Q0*/ +) { Word16 panning = 0; move16(); - Word16 azAddEl = aziDeg + eleDeg; - move16(); - Word16 azSubEl = aziDeg - eleDeg; - move16(); + Word16 azAddEl = add( aziDeg, eleDeg ); /*Q0*/ + + Word16 azSubEl = sub( aziDeg, eleDeg ); /*Q0*/ + const Word16 *ptr_sin_az = &ivas_sin_az_fx[180]; WHILE( GT_16( azAddEl, 180 ) ) { - azAddEl = sub( azAddEl, 360 ); + azAddEl = sub( azAddEl, 360 ); /*Q0*/ } WHILE( LT_16( azAddEl, negate( 180 ) ) ) { - azAddEl = add( azAddEl, 360 ); + azAddEl = add( azAddEl, 360 ); /*Q0*/ } WHILE( GT_16( azSubEl, 180 ) ) { - azSubEl = sub( azSubEl, 360 ); + azSubEl = sub( azSubEl, 360 ); /*Q0*/ } WHILE( LT_16( azSubEl, negate( 180 ) ) ) { - azSubEl = add( azSubEl, 360 ); + azSubEl = add( azSubEl, 360 ); /*Q0*/ } /*sin(az)cos(el) = 0.5 * (sin(az + el) + sin(az - el)) */ - Word16 sin_az_cos_el = add( shr( ptr_sin_az[azAddEl], 1 ), shr( ptr_sin_az[azSubEl], 1 ) ); + Word16 sin_az_cos_el = add( shr( ptr_sin_az[azAddEl], 1 ), shr( ptr_sin_az[azSubEl], 1 ) ); /*Q15*/ move16(); IF( GE_32( sin_az_cos_el, SIN_30_DEGREES_Q15 ) ) - { /* Left side */ - panning = (Word16) 0x7fff; + { /* Left side */ + panning = (Word16) 0x7fff; /*Q15*/ move16(); } ELSE IF( LE_32( sin_az_cos_el, SIN_NEG_30_DEGREES_Q15 ) ) - { /* Right side */ - panning = (Word16) 0x8000; + { /* Right side */ + panning = (Word16) 0x8000; /*Q15*/ move16(); } ELSE - { /* Tangent panning law */ - panning = get_panning_tangent_gain( sin_az_cos_el ); + { /* Tangent panning law */ + panning = get_panning_tangent_gain( sin_az_cos_el ); /*Q15*/ } - return panning; + return panning; /*Q15*/ } @@ -336,11 +337,11 @@ static Word16 get_panning( static void map_params_dirac_to_stereo( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ const IVAS_QMETADATA_HANDLE hQMetaData, /* i : frame of MASA q_metadata */ - Word32 synth[], /* i : decoded downmix signal */ - Word32 DFT[STEREO_DFT_BUF_MAX], /* i/o: DFT buffer */ - const UWord8 b_wide_panning, /* i : flag indicating wider panning */ - const Word16 L_frame, /* i : core signal length */ - const Word16 mcmasa, /* i : McMASA flag */ + Word32 synth[], /* i : decoded downmix signal q_synth*/ + Word32 DFT[STEREO_DFT_BUF_MAX], /* i/o: DFT buffer hStereoDft->q_dft*/ + const UWord8 b_wide_panning, /* i : flag indicating wider panning Q0*/ + const Word16 L_frame, /* i : core signal length Q0*/ + const Word16 mcmasa, /* i : McMASA flag Q0*/ const Word16 q_synth ) { Word16 i, b, k; @@ -363,21 +364,21 @@ static void map_params_dirac_to_stereo( Word32 *side_gain, *res_pred_gain; IVAS_QDIRECTION *q_direction; Word16 q_div, q_sqrt; - const Word16 *ptr_sin_az = &ivas_sin_az_fx[180]; - const Word16 *ptr_cos_el = &ivas_sin_az_fx[270]; + const Word16 *ptr_sin_az = &ivas_sin_az_fx[180]; /*Q15*/ + const Word16 *ptr_cos_el = &ivas_sin_az_fx[270]; /*Q15*/ nBlocks = MAX_PARAM_SPATIAL_SUBFRAMES; move16(); - nbands = hStereoDft->nbands; + nbands = hStereoDft->nbands; /*Q15*/ move16(); k_offset = STEREO_DFT_OFFSET; move16(); - side_gain = hStereoDft->side_gain_fx + i_mult( k_offset, STEREO_DFT_BAND_MAX ); - res_pred_gain = hStereoDft->res_pred_gain_fx + i_mult( k_offset, STEREO_DFT_BAND_MAX ); + side_gain = hStereoDft->side_gain_fx + i_mult( k_offset, STEREO_DFT_BAND_MAX ); /*Q31*/ + res_pred_gain = hStereoDft->res_pred_gain_fx + i_mult( k_offset, STEREO_DFT_BAND_MAX ); /*Q31*/ q_direction = &( hQMetaData->q_direction[0] ); /* gain smoothing factor */ - pDFT = DFT; + pDFT = DFT; /*q_dft*/ q_nrg = hStereoDft->q_dft; move16(); FOR( k = 0; k < NB_DIV; k++ ) @@ -391,20 +392,20 @@ static void map_params_dirac_to_stereo( FOR( i = hStereoDft->band_limits[b]; i < hStereoDft->band_limits[b + 1]; i++ ) { tmp64 = W_add( tmp64, W_add( W_mult0_32_32( pDFT[2 * i], pDFT[2 * i] ), - W_mult0_32_32( pDFT[add( 2 * i, 1 )], pDFT[add( 2 * i, 1 )] ) ) ); + W_mult0_32_32( pDFT[( 2 * i + 1 )], pDFT[( 2 * i + 1 )] ) ) ); /* 2*q_nrg */ move64(); } - subframe_band_nrg[k][b] = W_extract_h( W_shl( tmp64, 1 ) ); + subframe_band_nrg[k][b] = W_extract_h( W_shl( tmp64, 1 ) ); /* 2*q_nrg-31 */ move32(); q_nrg = sub( Q31, sub( shl( hStereoDft->q_dft, 1 ), Q31 ) ); - subframe_band_nrg[k][b] = Sqrt32( subframe_band_nrg[k][b], &q_nrg ); + subframe_band_nrg[k][b] = Sqrt32( subframe_band_nrg[k][b], &q_nrg ); /* Q31 - q_nrg */ move32(); IF( NE_16( sub( Q31, q_nrg ), hStereoDft->q_smooth_buf_fx ) ) { - subframe_band_nrg[k][b] = L_shl( subframe_band_nrg[k][b], sub( hStereoDft->q_smooth_buf_fx, sub( Q31, q_nrg ) ) ); + subframe_band_nrg[k][b] = L_shl( subframe_band_nrg[k][b], sub( hStereoDft->q_smooth_buf_fx, sub( Q31, q_nrg ) ) ); /*hStereoDft->q_smooth_buf_fx*/ move32(); } - hStereoDft->smooth_buf_fx[b][NB_DIV - 1 - k] = subframe_band_nrg[k][b]; + hStereoDft->smooth_buf_fx[b][NB_DIV - 1 - k] = subframe_band_nrg[k][b]; /*hStereoDft->q_smooth_buf_fx*/ move32(); /* calculate short and long energy averages */ @@ -413,17 +414,17 @@ static void map_params_dirac_to_stereo( smooth_long_avg[k][b] = 0; move32(); /* Multiplying and adding avoids overflow */ - FOR( i = sub( sub( NB_DIV, 1 ), k ); i < add( sub( add( SBA_DIRAC_NRG_SMOOTH_SHORT, NB_DIV ), 1 ), k ); i++ ) + FOR( i = ( ( NB_DIV - 1 ) - k ); i < ( ( ( SBA_DIRAC_NRG_SMOOTH_SHORT + NB_DIV ) - 1 ) - k ); i++ ) { - smooth_short_avg[k][b] = Madd_32_16( smooth_short_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x2AAB ); /* 1/ 3 in Q15*/ + smooth_short_avg[k][b] = Madd_32_16( smooth_short_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x2AAB ); /* 1/ 3 in Q15*/ /*hStereoDft->q_smooth_buf_fx*/ move32(); - smooth_long_avg[k][b] = Madd_32_16( smooth_long_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x0CCD ); /* 1/ 10 in Q15*/ + smooth_long_avg[k][b] = Madd_32_16( smooth_long_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x0CCD ); /* 1/ 10 in Q15*/ /*hStereoDft->q_smooth_buf_fx*/ move32(); } - FOR( i = sub( add( sub( NB_DIV, 1 ), SBA_DIRAC_NRG_SMOOTH_SHORT ), k ); i < sub( sub( add( SBA_DIRAC_NRG_SMOOTH_LONG, NB_DIV ), 1 ), k ); i++ ) + FOR( i = ( ( ( NB_DIV - 1 ) + SBA_DIRAC_NRG_SMOOTH_SHORT ) - k ); i < ( ( ( SBA_DIRAC_NRG_SMOOTH_LONG + NB_DIV ) - 1 ) - k ); i++ ) { - smooth_long_avg[k][b] = Madd_32_16( smooth_long_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x0CCD ); + smooth_long_avg[k][b] = Madd_32_16( smooth_long_avg[k][b], hStereoDft->smooth_buf_fx[b][i], (Word16) 0x0CCD ); /* 1/ 10 in Q15*/ /*hStereoDft->q_smooth_buf_fx*/ move32(); } @@ -431,16 +432,16 @@ static void map_params_dirac_to_stereo( /* reduce factor for higher short-term energy */ IF( smooth_long_avg[k][b] ) { - hStereoDft->smooth_fac_fx[k][b] = extract_l( s_min( MAX_16, BASOP_Util_Divide3232_Scale( smooth_long_avg[k][b], smooth_short_avg[k][b], &q_div ) ) ); + hStereoDft->smooth_fac_fx[k][b] = extract_l( s_min( MAX_16, BASOP_Util_Divide3232_Scale( smooth_long_avg[k][b], smooth_short_avg[k][b], &q_div ) ) ); /*15 - q_div*/ move32(); IF( GT_16( q_div, norm_s( hStereoDft->smooth_fac_fx[k][b] ) ) ) { - hStereoDft->smooth_fac_fx[k][b] = MAX_16; + hStereoDft->smooth_fac_fx[k][b] = MAX_16; /*Q15*/ move32(); } ELSE { - hStereoDft->smooth_fac_fx[k][b] = shl( hStereoDft->smooth_fac_fx[k][b], q_div ); + hStereoDft->smooth_fac_fx[k][b] = shl( hStereoDft->smooth_fac_fx[k][b], q_div ); /*Q15*/ move32(); q_div = 0; move16(); @@ -453,7 +454,7 @@ static void map_params_dirac_to_stereo( } /* map factor to range [0;1] */ - hStereoDft->smooth_fac_fx[k][b] = s_max( 0, extract_l( L_shr( Mpy_32_16_1( SBA_DIRAC_NRG_SMOOTH_LONG_BY_LONG_SHORT_FX, sub( hStereoDft->smooth_fac_fx[k][b], SBA_DIRAC_NRG_SMOOTH_SHORT_BY_LONG_FX ) ), Q15 ) ) ); + hStereoDft->smooth_fac_fx[k][b] = s_max( 0, extract_l( L_shr( Mpy_32_16_1( SBA_DIRAC_NRG_SMOOTH_LONG_BY_LONG_SHORT_FX, sub( hStereoDft->smooth_fac_fx[k][b], SBA_DIRAC_NRG_SMOOTH_SHORT_BY_LONG_FX ) ), Q15 ) ) ); /*Q15*/ move16(); /* compress factor (higher compression in lowest bands) */ q_sqrt = 0; @@ -461,21 +462,21 @@ static void map_params_dirac_to_stereo( IF( LT_16( b, 2 ) ) { Word16 tmp_val = Sqrt16( hStereoDft->smooth_fac_fx[k][b], &q_sqrt ); - hStereoDft->smooth_fac_fx[k][b] = Sqrt16( tmp_val, &q_sqrt ); + hStereoDft->smooth_fac_fx[k][b] = Sqrt16( tmp_val, &q_sqrt ); /*q_sqrt*/ move16(); } ELSE { - hStereoDft->smooth_fac_fx[k][b] = Sqrt16( hStereoDft->smooth_fac_fx[k][b], &q_sqrt ); + hStereoDft->smooth_fac_fx[k][b] = Sqrt16( hStereoDft->smooth_fac_fx[k][b], &q_sqrt ); /*q_sqrt*/ move16(); } - hStereoDft->smooth_fac_fx[k][b] = shl( hStereoDft->smooth_fac_fx[k][b], q_sqrt ); + hStereoDft->smooth_fac_fx[k][b] = shl( hStereoDft->smooth_fac_fx[k][b], q_sqrt ); /*q_sqrt*/ move16(); /* apply upper bounds depending on band */ - hStereoDft->smooth_fac_fx[0][b] = s_max( hStereoDft->min_smooth_gains_fx[b], s_min( hStereoDft->max_smooth_gains_fx[b], hStereoDft->smooth_fac_fx[0][b] ) ); + hStereoDft->smooth_fac_fx[0][b] = s_max( hStereoDft->min_smooth_gains_fx[b], s_min( hStereoDft->max_smooth_gains_fx[b], hStereoDft->smooth_fac_fx[0][b] ) ); /*Q15*/ move16(); - hStereoDft->smooth_fac_fx[1][b] = s_max( hStereoDft->min_smooth_gains_fx[b], s_min( hStereoDft->max_smooth_gains_fx[b], hStereoDft->smooth_fac_fx[1][b] ) ); + hStereoDft->smooth_fac_fx[1][b] = s_max( hStereoDft->min_smooth_gains_fx[b], s_min( hStereoDft->max_smooth_gains_fx[b], hStereoDft->smooth_fac_fx[1][b] ) ); /*Q15*/ move16(); } pDFT += STEREO_DFT32MS_N_MAX; @@ -485,39 +486,39 @@ static void map_params_dirac_to_stereo( { Word16 q_div1; /* calculate block energies for side gain weighting (combine angles of 2 DirAC blocks to side gain for 1 DFT Stereo subframe; 4 blocks and 2 subframes overall) */ - pSynth = synth; - block_len = idiv1616( L_frame, nBlocks ); + pSynth = synth; /*q_synth*/ + block_len = idiv1616( L_frame, nBlocks ); /*Q0*/ FOR( block = 0; block < nBlocks; block++ ) { block_nrg[block] = 0; move32(); FOR( i = 0; i < block_len; i++ ) { - block_nrg[block] = Madd_32_32( block_nrg[block], pSynth[i], pSynth[i] ); + block_nrg[block] = Madd_32_32( block_nrg[block], pSynth[i], pSynth[i] ); /*2*q_synth-31*/ move32(); } q_nrg = sub( Q31, sub( shl( q_synth, 1 ), Q31 ) ); - block_nrg[block] = Sqrt32( block_nrg[block], &q_nrg ); + block_nrg[block] = Sqrt32( block_nrg[block], &q_nrg ); /*Q31 - q_nrg*/ move32(); IF( NE_16( sub( Q31, q_nrg ), q_synth ) ) { - block_nrg[block] = L_shl( block_nrg[block], sub( q_synth, sub( Q31, q_nrg ) ) ); + block_nrg[block] = L_shl( block_nrg[block], sub( q_synth, sub( Q31, q_nrg ) ) ); /*q_synth*/ move32(); } pSynth += block_len; } - nrg_norm1 = L_add( block_nrg[0], L_add( block_nrg[1], EPSILON_FIX ) ); - nrg_norm2 = L_add( block_nrg[2], L_add( block_nrg[3], EPSILON_FIX ) ); + nrg_norm1 = L_add( block_nrg[0], L_add( block_nrg[1], EPSILON_FIX ) ); /*Q31 - q_nrg*/ + nrg_norm2 = L_add( block_nrg[2], L_add( block_nrg[3], EPSILON_FIX ) ); /*Q31 - q_nrg*/ /* extract DirAC parameters from metadata */ FOR( b = 0; b < nbands; b++ ) { - diffuseness[b] = L_shl( L_sub( ONE_IN_Q30, q_direction->band_data[b].energy_ratio_fx[0] ), 1 ); + diffuseness[b] = L_shl( L_sub( ONE_IN_Q30, q_direction->band_data[b].energy_ratio_fx[0] ), 1 ); /*Q31*/ move32(); IF( hQMetaData->surcoh_band_data != NULL ) { - surrCoh[b] = extract_h( imult3216( (Word32) 0x00808080, hQMetaData->surcoh_band_data[b].surround_coherence[0] ) ); + surrCoh[b] = extract_h( imult3216( (Word32) 0x00808080 /*1/255.0f in Q31*/, hQMetaData->surcoh_band_data[b].surround_coherence[0] ) ); /*Q15*/ move32(); } ELSE @@ -542,7 +543,7 @@ static void map_params_dirac_to_stereo( } IF( q_direction->band_data[b].azimuth_fx[block_metadata] < 0 ) { - q_direction->band_data[b].azimuth_fx[block_metadata] = L_add( (Word32) 0x5A000000, q_direction->band_data[b].azimuth_fx[block_metadata] ); + q_direction->band_data[b].azimuth_fx[block_metadata] = L_add( (Word32) 0x5A000000 /*360.f in Q22*/, q_direction->band_data[b].azimuth_fx[block_metadata] ); /*Q22*/ move16(); } /* @@ -550,9 +551,9 @@ static void map_params_dirac_to_stereo( * Before converting rounding is done. */ - azimuth[block][b] = extract_l( L_shr( L_add( q_direction->band_data[b].azimuth_fx[block_metadata], ONE_IN_Q21 ), Q22 ) ); + azimuth[block][b] = extract_l( L_shr( L_add( q_direction->band_data[b].azimuth_fx[block_metadata], ONE_IN_Q21 ), Q22 ) ); /*Q0*/ move16(); - elevation[block][b] = extract_l( L_shr( L_add( q_direction->band_data[b].elevation_fx[block_metadata], ONE_IN_Q21 ), Q22 ) ); + elevation[block][b] = extract_l( L_shr( L_add( q_direction->band_data[b].elevation_fx[block_metadata], ONE_IN_Q21 ), Q22 ) ); /*Q0*/ move16(); } } @@ -563,7 +564,7 @@ static void map_params_dirac_to_stereo( /* combine angles of first 2 blocks to side gain of first subframe */ side_gain[b] = 0; move32(); - FOR( block = 0; block < shr( nBlocks, 1 ); block++ ) + FOR( block = 0; block < ( nBlocks / 2 ); block++ ) { /* * The floating point version of the code computes @@ -572,23 +573,23 @@ static void map_params_dirac_to_stereo( */ IF( EQ_16( b_wide_panning, 1 ) ) { - Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm1, &q_div1 ), get_panning( azimuth[block][b], elevation[block][b] ) ); + Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm1, &q_div1 ), get_panning( azimuth[block][b], elevation[block][b] ) ); /*Q31 - q_div1*/ IF( q_div1 ) { - temp = L_shl_sat( temp, q_div1 ); + temp = L_shl_sat( temp, q_div1 ); /*Q31*/ } /* panning between left and ride, saturate at the stereo ls positions (+/- 30deg azi) */ - side_gain[b] = L_add_sat( side_gain[b], temp ); + side_gain[b] = L_add_sat( side_gain[b], temp ); /*Q31*/ move32(); } ELSE { - Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm1, &q_div1 ), mult( ptr_sin_az[azimuth[block][b]], ptr_cos_el[elevation[block][b]] ) ); + Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm1, &q_div1 ), mult( ptr_sin_az[azimuth[block][b]], ptr_cos_el[elevation[block][b]] ) ); /*Q31 - q_div1*/ IF( q_div1 ) { - temp = L_shl_sat( temp, q_div1 ); + temp = L_shl_sat( temp, q_div1 ); /*Q31*/ } - side_gain[b] = L_add_sat( side_gain[b], temp ); + side_gain[b] = L_add_sat( side_gain[b], temp ); /*Q31*/ move32(); } } @@ -600,47 +601,47 @@ static void map_params_dirac_to_stereo( { IF( EQ_16( b_wide_panning, 1 ) ) { - Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm2, &q_div1 ), get_panning( azimuth[block][b], elevation[block][b] ) ); + Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm2, &q_div1 ), get_panning( azimuth[block][b], elevation[block][b] ) ); /*Q31 - q_div1*/ IF( q_div1 ) { - temp = L_shl_sat( temp, q_div1 ); + temp = L_shl_sat( temp, q_div1 ); /*Q31*/ } /* panning between left and ride, saturate at the stereo ls positions (+/- 30deg azi) */ - side_gain[b + STEREO_DFT_BAND_MAX] = L_add_sat( side_gain[b + STEREO_DFT_BAND_MAX], temp ); + side_gain[b + STEREO_DFT_BAND_MAX] = L_add_sat( side_gain[b + STEREO_DFT_BAND_MAX], temp ); /*Q31*/ move32(); } ELSE { - Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm2, &q_div1 ), mult( ptr_sin_az[azimuth[block][b]], ptr_cos_el[elevation[block][b]] ) ); + Word32 temp = L_mult( BASOP_Util_Divide3232_Scale( block_nrg[block], nrg_norm2, &q_div1 ), mult( ptr_sin_az[azimuth[block][b]], ptr_cos_el[elevation[block][b]] ) ); /*Q31 - q_div1*/ IF( q_div1 ) { - temp = L_shl_sat( temp, q_div1 ); + temp = L_shl_sat( temp, q_div1 ); /*Q31*/ } - side_gain[b + STEREO_DFT_BAND_MAX] = L_add_sat( side_gain[b + STEREO_DFT_BAND_MAX], temp ); + side_gain[b + STEREO_DFT_BAND_MAX] = L_add_sat( side_gain[b + STEREO_DFT_BAND_MAX], temp ); /*Q31*/ move32(); } } q_sqrt = 0; move16(); - side_gain[b] = Mpy_32_32( side_gain[b], Sqrt32( L_sub( MAX_32, diffuseness[b] ), &q_sqrt ) ); + side_gain[b] = Mpy_32_32( side_gain[b], Sqrt32( L_sub( MAX_32, diffuseness[b] ), &q_sqrt ) ); /*Q31 - q_sqrt*/ move32(); IF( q_sqrt ) { - side_gain[b] = L_shl( side_gain[b], q_sqrt ); + side_gain[b] = L_shl( side_gain[b], q_sqrt ); /*Q31*/ q_sqrt = 0; move16(); } - side_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_32( side_gain[b + STEREO_DFT_BAND_MAX], Sqrt32( L_sub( MAX_32, diffuseness[b] ), &q_sqrt ) ); + side_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_32( side_gain[b + STEREO_DFT_BAND_MAX], Sqrt32( L_sub( MAX_32, diffuseness[b] ), &q_sqrt ) ); /*Q31 - q_sqrt*/ move32(); IF( q_sqrt ) { - side_gain[b + STEREO_DFT_BAND_MAX] = L_shl( side_gain[b], q_sqrt ); + side_gain[b + STEREO_DFT_BAND_MAX] = L_shl( side_gain[b], q_sqrt ); /*Q31*/ q_sqrt = 0; move16(); } - res_pred_gain[b] = Mpy_32_16_1( diffuseness[b], sub( MAX_16, surrCoh[b] ) ); + res_pred_gain[b] = Mpy_32_16_1( diffuseness[b], sub( MAX_16, surrCoh[b] ) ); /*Q31*/ move32(); - res_pred_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_16_1( diffuseness[b], sub( MAX_16, surrCoh[b] ) ); + res_pred_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_16_1( diffuseness[b], sub( MAX_16, surrCoh[b] ) ); /*Q31*/ move32(); } } @@ -664,10 +665,10 @@ static void map_params_dirac_to_stereo( static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 hb_synth[L_FRAME48k], /* i : HB signal */ - const Word16 core, /* i : core decision */ - const Word16 output_frame, /* i : output frame length per channel */ - const Word16 fd_cng_flag, /* i : FD-CNG indicator */ + const Word32 hb_synth[L_FRAME48k], /* i : HB signal q_hb_synth*/ + const Word16 core, /* i : core decision Q0*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 fd_cng_flag, /* i : FD-CNG indicator Q0*/ const Word16 q_hb_synth ) { Word16 i; @@ -682,10 +683,10 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( { FOR( i = 0; i < shr( output_frame, 2 ); i++ ) { - hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); + hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); /*2*q_hb_synth-31*/ } - hStereoDft->hb_nrg_subr_fx[0] = hb_nrg2; + hStereoDft->hb_nrg_subr_fx[0] = hb_nrg2; /*2*q_hb_synth-31*/ move32(); hStereoDft->q_hb_nrg_subr = sub( shl( q_hb_synth, 1 ), 31 ); move32(); @@ -696,29 +697,29 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( FOR( ; i < output_frame; i++ ) { - hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); + hb_nrg2 = Madd_32_32( hb_nrg2, hb_synth[i], hb_synth[i] ); /*2*q_hb_synth-31*/ } - hStereoDft->hb_nrg_subr_fx[1] = hb_nrg2; + hStereoDft->hb_nrg_subr_fx[1] = hb_nrg2; /*2*q_hb_synth-31*/ move32(); hb_nrg = L_add( hb_nrg, hb_nrg2 ); IF( EQ_16( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ) ) { - Copy32( hb_synth, hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); + Copy32( hb_synth, hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); /*q_hb_synth*/ } ELSE { IF( GT_16( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ) ) { - v_shr( hStereoDft->hb_stefi_sig_fx, sub( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ), hStereoDft->hb_stefi_sig_fx, idiv1616( sizeof( hStereoDft->hb_stefi_sig_fx ), sizeof( hStereoDft->hb_stefi_sig_fx[0] ) ) ); + v_shr( hStereoDft->hb_stefi_sig_fx, sub( hStereoDft->q_hb_stefi_sig_fx, q_hb_synth ), hStereoDft->hb_stefi_sig_fx, idiv1616( sizeof( hStereoDft->hb_stefi_sig_fx ), sizeof( hStereoDft->hb_stefi_sig_fx[0] ) ) ); /*q_hb_synth*/ hStereoDft->q_hb_stefi_sig_fx = q_hb_synth; move16(); - Copy32( hb_synth, hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); + Copy32( hb_synth, hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); /*q_hb_synth*/ } ELSE { - v_shr( hb_synth, sub( q_hb_synth, hStereoDft->q_hb_stefi_sig_fx ), hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); + v_shr( hb_synth, sub( q_hb_synth, hStereoDft->q_hb_stefi_sig_fx ), hStereoDft->hb_stefi_sig_fx + hStereoDft->hb_stefi_delay, output_frame ); /*hStereoDft->q_hb_stefi_sig_fx*/ } } } @@ -732,9 +733,9 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( move32(); #endif // MSAN_FIX } - hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); + hStereoDft->hb_nrg_subr_fx[0] = hStereoDft->hb_nrg_subr_fx[0]; // imult3216(hStereoDft->hb_nrg_subr_fx[0] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/ move32(); - hStereoDft->hb_nrg_subr_fx[1] = hStereoDft->hb_nrg_subr_fx[1]; // imult3216(hStereoDft->hb_nrg_subr_fx[1] , shr(hStereoDft->NFFT, 1)); + hStereoDft->hb_nrg_subr_fx[1] = hStereoDft->hb_nrg_subr_fx[1]; // imult3216(hStereoDft->hb_nrg_subr_fx[1] , shr(hStereoDft->NFFT, 1)); /*hStereoDft->q_hb_nrg_subr*/ move32(); hStereoDft->hb_nrg_fx[0] = hb_nrg; move32(); @@ -760,7 +761,7 @@ static void ivas_sba_dirac_stereo_compute_td_stefi_nrgs( static void ivas_sba_dirac_stereo_compute_hb_gain( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - Word32 hb_gain[NB_DIV] /* o : side gains for HB signal */ + Word32 hb_gain[NB_DIV] /* o : side gains for HB signal Q31*/ ) { Word16 k_offset; @@ -769,9 +770,9 @@ static void ivas_sba_dirac_stereo_compute_hb_gain( move16(); /* last band covers whole HB range, no averaging needed */ - hb_gain[0] = hStereoDft->side_gain_fx[sub( add( i_mult( k_offset, STEREO_DFT_BAND_MAX ), hStereoDft->nbands ), 1 )]; + hb_gain[0] = hStereoDft->side_gain_fx[( ( ( k_offset * STEREO_DFT_BAND_MAX ) + hStereoDft->nbands ) - 1 )]; /*Q31*/ move32(); - hb_gain[1] = hStereoDft->side_gain_fx[sub( add( i_mult( add( k_offset, 1 ), STEREO_DFT_BAND_MAX ), hStereoDft->nbands ), 1 )]; + hb_gain[1] = hStereoDft->side_gain_fx[( ( ( ( k_offset + 1 ) * STEREO_DFT_BAND_MAX ) + hStereoDft->nbands ) - 1 )]; /*Q31*/ move32(); return; @@ -785,13 +786,13 @@ static void ivas_sba_dirac_stereo_compute_hb_gain( *-------------------------------------------------------------------*/ static void ivas_sba_dirac_stereo_upmix_hb( - Word32 hb_stereo_synth[CPE_CHANNELS][L_FRAME48k], /* i/o: stereo HB synthesis signal */ - Word32 hb_synth[L_FRAME48k], /* i : HB signal */ - Word32 hb_gain[NB_DIV], /* i : side gains for HB signal */ - const Word16 output_frame, /* i : output frame length per channel */ - const Word16 mcmasa, /* i : McMASA flag */ - const Word16 sba_mono_flag, /* i : flag for mono output */ - const Word16 bwidth, /* i : bandwidth of signal */ + Word32 hb_stereo_synth[CPE_CHANNELS][L_FRAME48k], /* i/o: stereo HB synthesis signal Qx*/ + Word32 hb_synth[L_FRAME48k], /* i : HB signal Qx*/ + Word32 hb_gain[NB_DIV], /* i : side gains for HB signal Q31*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 mcmasa, /* i : McMASA flag Q0*/ + const Word16 sba_mono_flag, /* i : flag for mono output Q0*/ + const Word16 bwidth, /* i : bandwidth of signal Q0*/ const STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i : Stereo DFT handle for mixing matrix */ ) { @@ -801,11 +802,11 @@ static void ivas_sba_dirac_stereo_upmix_hb( IF( !mcmasa ) { - gain_fac = (Word32) 0x2A3D; /* last matrix element not used for SWB, divide by 3 instead of 4*/ + gain_fac = (Word32) 0x2A3D; /* last matrix element not used for SWB, divide by 3 instead of 4*/ /*Q15*/ move16(); if ( EQ_16( bwidth, FB ) ) { - gain_fac = (Word32) 0x2000; + gain_fac = (Word32) 0x2000; /*Q15*/ move16(); } @@ -813,46 +814,46 @@ static void ivas_sba_dirac_stereo_upmix_hb( { gp = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8], gain_fac ), Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9], gain_fac ), - hStereoDft->mixer_mat_smooth_fx[0][0][10], gain_fac ) ); + hStereoDft->mixer_mat_smooth_fx[0][0][10], gain_fac ) ); /*Q31*/ IF( EQ_16( bwidth, FB ) ) { - gp = Madd_32_16( gp, hStereoDft->mixer_mat_smooth_fx[0][0][11], gain_fac ); + gp = Madd_32_16( gp, hStereoDft->mixer_mat_smooth_fx[0][0][11], gain_fac ); /*Q31*/ } FOR( i = 0; i < shr( output_frame, 1 ); i++ ) { - hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); + hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); /*Qx*/ move32(); } gp = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8 + IVAS_MAX_NUM_BANDS], gain_fac ), Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9 + IVAS_MAX_NUM_BANDS], gain_fac ), - hStereoDft->mixer_mat_smooth_fx[0][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ); + hStereoDft->mixer_mat_smooth_fx[0][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ); /*Q31*/ IF( EQ_16( bwidth, FB ) ) { - gp = Madd_32_16( gp, hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ); + gp = Madd_32_16( gp, hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ); /*Q31*/ } FOR( i = shr( output_frame, 1 ); i < output_frame; i++ ) { - hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); + hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); /*Qx*/ move32(); } } ELSE { /* Accounting for the 0.5 multiplication */ - gain_fac = shr( gain_fac, 1 ); + gain_fac = shr( gain_fac, 1 ); /*Q15*/ gp = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8], gain_fac ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][0][8], gain_fac ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9], gain_fac ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][0][9], gain_fac ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][10], gain_fac ), - Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][0][10], gain_fac ) ) ) ) ) ); + Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][0][10], gain_fac ) ) ) ) ) ); /*Q31*/ IF( EQ_32( bwidth, FB ) ) { gp = L_add( gp, Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][11], gain_fac ), - hStereoDft->mixer_mat_smooth_fx[1][0][11], gain_fac ) ); + hStereoDft->mixer_mat_smooth_fx[1][0][11], gain_fac ) ); /*Q31*/ } gm = L_add( Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8], gain_fac ), @@ -860,18 +861,18 @@ static void ivas_sba_dirac_stereo_upmix_hb( L_add( Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][9], gain_fac ), Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][10], gain_fac ), - hStereoDft->mixer_mat_smooth_fx[1][0][10], gain_fac ) ) ); + hStereoDft->mixer_mat_smooth_fx[1][0][10], gain_fac ) ) ); /*Q31*/ IF( EQ_32( bwidth, FB ) ) { gm = L_add( gm, Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][11], gain_fac ), - hStereoDft->mixer_mat_smooth_fx[1][0][11], gain_fac ) ); + hStereoDft->mixer_mat_smooth_fx[1][0][11], gain_fac ) ); /*Q31*/ } FOR( i = 0; i < shr( output_frame, 1 ); i++ ) { - hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); + hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); /*Qx*/ move32(); - hb_stereo_synth[1][i] = Mpy_32_32( hb_synth[i], gm ); + hb_stereo_synth[1][i] = Mpy_32_32( hb_synth[i], gm ); /*Qx*/ move32(); } @@ -880,25 +881,25 @@ static void ivas_sba_dirac_stereo_upmix_hb( L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9 + IVAS_MAX_NUM_BANDS], gain_fac ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][0][9 + IVAS_MAX_NUM_BANDS], gain_fac ), Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ), - hStereoDft->mixer_mat_smooth_fx[1][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ) ) ) ); + hStereoDft->mixer_mat_smooth_fx[1][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ) ) ) ); /*Q31*/ IF( EQ_32( bwidth, FB ) ) { - gp = L_add( gp, Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ) ); + gp = L_add( gp, Madd_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ) ); /*Q31*/ } gm = L_add( Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][8 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][8 + IVAS_MAX_NUM_BANDS], gain_fac ), L_add( Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][9 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][9 + IVAS_MAX_NUM_BANDS], gain_fac ), - Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ) ); + Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][10 + IVAS_MAX_NUM_BANDS], gain_fac ) ) ); /*Q31*/ IF( EQ_32( bwidth, FB ) ) { - gm = L_add( gm, Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ) ); + gm = L_add( gm, Msub_32_16( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ), hStereoDft->mixer_mat_smooth_fx[1][0][11 + IVAS_MAX_NUM_BANDS], gain_fac ) ); /*Q31*/ } FOR( i = shr( output_frame, 1 ); i < output_frame; i++ ) { - hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); + hb_stereo_synth[0][i] = Mpy_32_32( hb_synth[i], gp ); /*Qx*/ move32(); - hb_stereo_synth[1][i] = Mpy_32_32( hb_synth[i], gm ); + hb_stereo_synth[1][i] = Mpy_32_32( hb_synth[i], gm ); /*Qx*/ move32(); } } @@ -907,17 +908,17 @@ static void ivas_sba_dirac_stereo_upmix_hb( { FOR( i = 0; i < L_shr( output_frame, 1 ); i++ ) { - hb_stereo_synth[0][i] = L_add( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[0], hb_synth[i] ), 1 ) ); + hb_stereo_synth[0][i] = L_add( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[0], hb_synth[i] ), 1 ) ); /*Qx*/ move32(); - hb_stereo_synth[1][i] = L_sub( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[0], hb_synth[i] ), 1 ) ); + hb_stereo_synth[1][i] = L_sub( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[0], hb_synth[i] ), 1 ) ); /*Qx*/ move32(); } FOR( i = shr( output_frame, 1 ); i < output_frame; i++ ) { - hb_stereo_synth[0][i] = L_add( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[1], hb_synth[i] ), 1 ) ); + hb_stereo_synth[0][i] = L_add( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[1], hb_synth[i] ), 1 ) ); /*Qx*/ move32(); - hb_stereo_synth[1][i] = L_sub( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[1], hb_synth[i] ), 1 ) ); + hb_stereo_synth[1][i] = L_sub( L_shr( hb_synth[i], 1 ), L_shr( Mpy_32_32( hb_gain[1], hb_synth[i] ), 1 ) ); /*Qx*/ move32(); } } @@ -934,9 +935,9 @@ static void ivas_sba_dirac_stereo_upmix_hb( static void ivas_sba_dirac_stereo_apply_td_stefi( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : output frame length per channel */ - const Word16 spar_flag /* i : SPAR flag */ + Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal hStereoDft->q_dft*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 spar_flag /* i : SPAR flag Q0*/ ) { Word16 i; @@ -947,8 +948,8 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( IF( spar_flag ) { - win_dft = hStereoDft->win32ms_fx; - dftOvlLen = hStereoDft->dft32ms_ovl; + win_dft = hStereoDft->win32ms_fx; /*Q15*/ + dftOvlLen = hStereoDft->dft32ms_ovl; /*Q0*/ Word32 g_W_1, g_Y_1; Word32 g_W_2, g_Y_2; @@ -963,7 +964,7 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][3][9], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][1][10], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][2][10], 0x147B ), - Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][3][10], 0x147B ) ) ) ) ) ) ) ) ); + Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][3][10], 0x147B ) ) ) ) ) ) ) ) ); /*Q31*/ g_Y_1 = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][1][8], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][2][8], 0x147B ), @@ -973,7 +974,7 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][3][9], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][1][10], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][2][10], 0x147B ), - Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][3][10], 0x147B ) ) ) ) ) ) ) ) ); + Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][3][10], 0x147B ) ) ) ) ) ) ) ) ); /*Q31*/ g_W_2 = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][1][8 + IVAS_MAX_NUM_BANDS], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][2][8 + IVAS_MAX_NUM_BANDS], 0x147B ), @@ -983,7 +984,7 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][3][9 + IVAS_MAX_NUM_BANDS], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][1][10 + IVAS_MAX_NUM_BANDS], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][2][10 + IVAS_MAX_NUM_BANDS], 0x147B ), - Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][3][10 + IVAS_MAX_NUM_BANDS], 0x147B ) ) ) ) ) ) ) ) ); + Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[0][3][10 + IVAS_MAX_NUM_BANDS], 0x147B ) ) ) ) ) ) ) ) ); /*Q31*/ g_Y_2 = L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][1][8 + IVAS_MAX_NUM_BANDS], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][2][8 + IVAS_MAX_NUM_BANDS], 0x147B ), @@ -993,61 +994,61 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][3][9 + IVAS_MAX_NUM_BANDS], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][1][10 + IVAS_MAX_NUM_BANDS], 0x147B ), L_add( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][2][10 + IVAS_MAX_NUM_BANDS], 0x147B ), - Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][3][10 + IVAS_MAX_NUM_BANDS], 0x147B ) ) ) ) ) ) ) ) ); + Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[1][3][10 + IVAS_MAX_NUM_BANDS], 0x147B ) ) ) ) ) ) ) ) ); /*Q31*/ - g_L = L_sub( L_add( g_W_1, g_W_2 ), L_add( g_Y_1, g_Y_2 ) ); /* 0x147B = 0.16 in Q15 */ - g_R = L_add( L_add( g_W_1, g_W_2 ), L_add( g_Y_1, g_Y_2 ) ); /* 0x147B = 0.16 in Q15 */ + g_L = L_sub( L_add( g_W_1, g_W_2 ), L_add( g_Y_1, g_Y_2 ) ); /* 0x147B = 0.16 in Q15 */ /*Q31*/ + g_R = L_add( L_add( g_W_1, g_W_2 ), L_add( g_Y_1, g_Y_2 ) ); /* 0x147B = 0.16 in Q15 */ /*Q31*/ FOR( i = 0; i < dftOvlLen; i++ ) { - win_in = mult_r( win_dft[STEREO_DFT32MS_STEP * i], win_dft[STEREO_DFT32MS_STEP * i] ); - win_out = sub( MAX_16, win_in ); + win_in = mult_r( win_dft[STEREO_DFT32MS_STEP * i], win_dft[STEREO_DFT32MS_STEP * i] ); /*Q15*/ + win_out = sub( MAX_16, win_in ); /*Q15*/ - stefi_L = L_shr( Mpy_32_32( Madd_32_16( Mpy_32_32( win_out, hStereoDft->g_L_prev_fx ), g_L, win_in ), hStereoDft->hb_stefi_sig_fx[i] ), 1 ); - stefi_R = L_shr( Mpy_32_32( Madd_32_16( Mpy_32_32( win_out, hStereoDft->g_R_prev_fx ), g_R, win_in ), hStereoDft->hb_stefi_sig_fx[i] ), 1 ); + stefi_L = L_shr( Mpy_32_32( Madd_32_16( Mpy_32_32( win_out, hStereoDft->g_L_prev_fx ), g_L, win_in ), hStereoDft->hb_stefi_sig_fx[i] ), 1 ); /*hStereoDft->q_hb_stefi_sig_fx*/ + stefi_R = L_shr( Mpy_32_32( Madd_32_16( Mpy_32_32( win_out, hStereoDft->g_R_prev_fx ), g_R, win_in ), hStereoDft->hb_stefi_sig_fx[i] ), 1 ); /*hStereoDft->q_hb_stefi_sig_fx*/ - output[0][i] = L_add( output[0][i], L_shr( stefi_L, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[0][i] = L_add( output[0][i], L_shr( stefi_L, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft*/ move32(); - output[1][i] = L_add( output[1][i], L_shr( stefi_R, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[1][i] = L_add( output[1][i], L_shr( stefi_R, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft*/ move32(); } FOR( i = dftOvlLen; i < output_frame; i++ ) { - stefi_L = L_shr( Mpy_32_32( g_L, hStereoDft->hb_stefi_sig_fx[i] ), 1 ); - stefi_R = L_shr( Mpy_32_32( g_R, hStereoDft->hb_stefi_sig_fx[i] ), 1 ); + stefi_L = L_shr( Mpy_32_32( g_L, hStereoDft->hb_stefi_sig_fx[i] ), 1 ); /*hStereoDft->q_hb_stefi_sig_fx*/ + stefi_R = L_shr( Mpy_32_32( g_R, hStereoDft->hb_stefi_sig_fx[i] ), 1 ); /*hStereoDft->q_hb_stefi_sig_fx*/ - output[0][i] = L_add( output[0][i], L_shr( stefi_L, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[0][i] = L_add( output[0][i], L_shr( stefi_L, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft*/ move32(); - output[1][i] = L_add( output[1][i], L_shr( stefi_R, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[1][i] = L_add( output[1][i], L_shr( stefi_R, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft*/ move32(); } - hStereoDft->g_L_prev_fx = g_L; + hStereoDft->g_L_prev_fx = g_L; /*Q31*/ move32(); - hStereoDft->g_R_prev_fx = g_R; + hStereoDft->g_R_prev_fx = g_R; /*Q31*/ move32(); } ELSE IF( L_max( hStereoDft->td_gain_fx[0], hStereoDft->td_gain_fx[1] ) > 0 ) { - win_dft = hStereoDft->win32ms_fx; - dftOvlLen = hStereoDft->dft32ms_ovl; + win_dft = hStereoDft->win32ms_fx; /*Q15*/ + dftOvlLen = hStereoDft->dft32ms_ovl; /*Q0*/ FOR( i = 0; i < dftOvlLen; i++ ) { - win_in = mult( win_dft[STEREO_DFT32MS_STEP * i], win_dft[STEREO_DFT32MS_STEP * i] ); - win_out = sub( MAX_16, win_in ); - tmp = L_shr( Mpy_32_32( Madd_32_16( Mpy_32_16_1( hStereoDft->td_gain_fx[0], win_in ), hStereoDft->td_gain_fx[1], win_out ), hStereoDft->hb_stefi_sig_fx[i] ), 1 ); + win_in = mult( win_dft[STEREO_DFT32MS_STEP * i], win_dft[STEREO_DFT32MS_STEP * i] ); /*Q15*/ + win_out = sub( MAX_16, win_in ); /*Q15*/ + tmp = L_shr( Mpy_32_32( Madd_32_16( Mpy_32_16_1( hStereoDft->td_gain_fx[0], win_in ), hStereoDft->td_gain_fx[1], win_out ), hStereoDft->hb_stefi_sig_fx[i] ), 1 ); /*hStereoDft->q_hb_stefi_sig_fx*/ - output[0][i] = L_add( output[0][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[0][i] = L_add( output[0][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft*/ move32(); - output[1][i] = L_sub( output[1][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[1][i] = L_sub( output[1][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft*/ move32(); } FOR( i = dftOvlLen; i < output_frame; i++ ) { - tmp = L_shr( Mpy_32_32( hStereoDft->hb_stefi_sig_fx[i], hStereoDft->td_gain_fx[0] ), 1 ); - output[0][i] = L_add( output[0][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + tmp = L_shr( Mpy_32_32( hStereoDft->hb_stefi_sig_fx[i], hStereoDft->td_gain_fx[0] ), 1 ); /*hStereoDft->q_hb_stefi_sig_fx + hStereoDft->q_td_gain - 31*/ + output[0][i] = L_add( output[0][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft + hStereoDft->q_td_gain - 31*/ move32(); - output[1][i] = L_sub( output[1][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); + output[1][i] = L_sub( output[1][i], L_shr( tmp, sub( hStereoDft->q_hb_stefi_sig_fx, hStereoDft->q_dft ) ) ); /*hStereoDft->q_dft + hStereoDft->q_td_gain - 31*/ move32(); } } @@ -1065,9 +1066,9 @@ static void ivas_sba_dirac_stereo_apply_td_stefi( void ivas_sba_dirac_stereo_smooth_parameters_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ ivas_spar_md_dec_state_t *hMdDec, /* i/o: SPAR MD handle for upmixing */ - const Word16 cross_fade_start_offset, /* i : SPAR mixer delay compensation */ - const Word32 output_Fs, /* i : Fs for delay calculation */ - const Word16 num_md_sub_frames /* i : number of subframes in mixing matrix */ + const Word16 cross_fade_start_offset, /* i : SPAR mixer delay compensation Q0*/ + const Word32 output_Fs, /* i : Fs for delay calculation Q0*/ + const Word16 num_md_sub_frames /* i : number of subframes in mixing matrix Q0*/ ) { Word16 i, j, k, i_sf; @@ -1078,10 +1079,10 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( k_offset = STEREO_DFT_OFFSET; move16(); - prev_side_gain = hStereoDft->side_gain_fx; - side_gain = hStereoDft->side_gain_fx + k_offset * STEREO_DFT_BAND_MAX; - prev_res_pred_gain = hStereoDft->res_pred_gain_fx; - res_pred_gain = hStereoDft->res_pred_gain_fx + k_offset * STEREO_DFT_BAND_MAX; + prev_side_gain = hStereoDft->side_gain_fx; /*Q31*/ + side_gain = hStereoDft->side_gain_fx + k_offset * STEREO_DFT_BAND_MAX; /*Q31*/ + prev_res_pred_gain = hStereoDft->res_pred_gain_fx; /*Q31*/ + res_pred_gain = hStereoDft->res_pred_gain_fx + k_offset * STEREO_DFT_BAND_MAX; /*Q31*/ IF( !hMdDec ) { @@ -1090,27 +1091,27 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( { IF( hStereoDft->attackPresent ) { - res_pred_gain[b] = Mpy_32_16_1( res_pred_gain[b], (Word16) 0x6666 ); + res_pred_gain[b] = Mpy_32_16_1( res_pred_gain[b], (Word16) 0x6666 /*0.8f in Q15*/ ); /*Q31*/ move32(); - res_pred_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_16_1( res_pred_gain[b + STEREO_DFT_BAND_MAX], (Word16) 0x6666 ); + res_pred_gain[b + STEREO_DFT_BAND_MAX] = Mpy_32_16_1( res_pred_gain[b + STEREO_DFT_BAND_MAX], (Word16) 0x6666 /*0.8f in Q15*/ ); /*Q31*/ move32(); } ELSE { side_gain[b] = Madd_32_16( Mpy_32_16_1( prev_side_gain[b], hStereoDft->smooth_fac_fx[0][b] ), - side_gain[b], sub( (Word16) 0x7FFF, hStereoDft->smooth_fac_fx[0][b] ) ); + side_gain[b], sub( (Word16) 0x7FFF /*1.0f in Q15*/, hStereoDft->smooth_fac_fx[0][b] ) ); /*Q31*/ move32(); side_gain[b + STEREO_DFT_BAND_MAX] = Madd_32_16( Mpy_32_16_1( side_gain[b], hStereoDft->smooth_fac_fx[1][b] ), side_gain[b + STEREO_DFT_BAND_MAX], - sub( (Word16) 0x7FFF, hStereoDft->smooth_fac_fx[1][b] ) ); + sub( (Word16) 0x7FFF /*1.0f in Q15*/, hStereoDft->smooth_fac_fx[1][b] ) ); /*Q31*/ move32(); res_pred_gain[b] = Madd_32_16( Mpy_32_16_1( prev_res_pred_gain[b], hStereoDft->smooth_fac_fx[0][b] ), res_pred_gain[b], - sub( (Word16) 0x7FFF, hStereoDft->smooth_fac_fx[0][b] ) ); + sub( (Word16) 0x7FFF /*1.0f in Q15*/, hStereoDft->smooth_fac_fx[0][b] ) ); /*Q31*/ move32(); res_pred_gain[b + STEREO_DFT_BAND_MAX] = Madd_32_16( Mpy_32_16_1( res_pred_gain[b], hStereoDft->smooth_fac_fx[1][b] ), res_pred_gain[b + STEREO_DFT_BAND_MAX], - sub( (Word16) 0x7FFF, hStereoDft->smooth_fac_fx[1][b] ) ); + sub( (Word16) 0x7FFF /*1.0f in Q15*/, hStereoDft->smooth_fac_fx[1][b] ) ); /*Q31*/ move32(); } } @@ -1128,20 +1129,20 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( 64-bit container is needed for storing the result in the previous step. ToDo: Replace the 64-bit division below with appropriate BASOP */ - xfade_delay_subframes = (Word16) ( xfade_start_ns / W_mult_32_32( ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ), output_Fs ) ); + xfade_delay_subframes = (Word16) ( xfade_start_ns / W_mult_32_32( ( FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES ), output_Fs ) ); /*Q0*/ move16(); - i_hist = sub( (Word16) 4, xfade_delay_subframes ); + i_hist = sub( (Word16) 4, xfade_delay_subframes ); /*Q0*/ move16(); FOR( k = 0; k < 2; k++ ) { - FOR( i_sf = shl( k, 1 ); i_sf < shl( add( k, 1 ), 1 ); i_sf++ ) + FOR( i_sf = ( k * 2 ); i_sf < ( k + 1 ) * 2; i_sf++ ) { md_sf = 0; move16(); IF( EQ_16( num_md_sub_frames, MAX_PARAM_SPATIAL_SUBFRAMES ) ) { - md_sf = i_sf; + md_sf = i_sf; /*Q0*/ move16(); } IF( hStereoDft->first_frame ) @@ -1153,12 +1154,12 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( FOR( b = 0; b < hStereoDft->nbands; b++ ) { // The Q format of mixer_mat_fx is Q30 so applying the left shift. - hStereoDft->mixer_mat_smooth_fx[i][j][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( hMdDec->mixer_mat_fx[i][j][b], 1 ); + hStereoDft->mixer_mat_smooth_fx[i][j][( b + ( k * IVAS_MAX_NUM_BANDS ) )] = L_shl_sat( hMdDec->mixer_mat_fx[i][j][b], 1 ); /*Q31*/ move32(); } FOR( ; b < IVAS_MAX_NUM_BANDS; b++ ) { - hStereoDft->mixer_mat_smooth_fx[i][j][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )] = 0; + hStereoDft->mixer_mat_smooth_fx[i][j][( b + ( k * IVAS_MAX_NUM_BANDS ) )] = 0; move32(); } } @@ -1172,22 +1173,22 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( { FOR( b = 0; b < hStereoDft->nbands; b++ ) { - Word16 beta = hStereoDft->smooth_fac_fx[k][b]; + Word16 beta = hStereoDft->smooth_fac_fx[k][b]; /*Q15*/ move16(); // The Q format of mixer_mat_prev_fx is Q30 so applying the left shift. hStereoDft->mixer_mat_smooth_fx[i][j][b + k * IVAS_MAX_NUM_BANDS] = - L_add_sat( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[i][j][add( b, i_mult( k, IVAS_MAX_NUM_BANDS ) )], beta ), - L_shl_sat( Mpy_32_16_1( hMdDec->mixer_mat_prev_fx[i_hist][i][j][b], sub( (Word16) 0x7FFF, beta ) ), Q1 ) ); + L_add_sat( Mpy_32_16_1( hStereoDft->mixer_mat_smooth_fx[i][j][( b + ( k * IVAS_MAX_NUM_BANDS ) )], beta ), + L_shl_sat( Mpy_32_16_1( hMdDec->mixer_mat_prev_fx[i_hist][i][j][b], sub( (Word16) 0x7FFF, beta ) ), Q1 ) ); /*Q31*/ move32(); } } } } - Copy32( hMdDec->mixer_mat_prev_fx[1][0][0], hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - Copy32( hMdDec->mixer_mat_prev_fx[2][0][0], hMdDec->mixer_mat_prev_fx[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - Copy32( hMdDec->mixer_mat_prev_fx[3][0][0], hMdDec->mixer_mat_prev_fx[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); - Copy32( hMdDec->mixer_mat_prev_fx[4][0][0], hMdDec->mixer_mat_prev_fx[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); + Copy32( hMdDec->mixer_mat_prev_fx[1][0][0], hMdDec->mixer_mat_prev_fx[0][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hMdDec->Q_mixer_mat*/ + Copy32( hMdDec->mixer_mat_prev_fx[2][0][0], hMdDec->mixer_mat_prev_fx[1][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hMdDec->Q_mixer_mat*/ + Copy32( hMdDec->mixer_mat_prev_fx[3][0][0], hMdDec->mixer_mat_prev_fx[2][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hMdDec->Q_mixer_mat*/ + Copy32( hMdDec->mixer_mat_prev_fx[4][0][0], hMdDec->mixer_mat_prev_fx[3][0][0], IVAS_MAX_FB_MIXER_OUT_CH * IVAS_MAX_SPAR_FB_MIXER_IN_CH * IVAS_MAX_NUM_BANDS ); /*hMdDec->Q_mixer_mat*/ FOR( i = 0; i < 2; i++ ) { @@ -1195,7 +1196,7 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( { FOR( b = 0; b < hStereoDft->nbands; b++ ) { - hMdDec->mixer_mat_prev_fx[4][i][j][b] = hMdDec->mixer_mat_fx[i][j][add( b, i_mult( md_sf, IVAS_MAX_NUM_BANDS ) )]; + hMdDec->mixer_mat_prev_fx[4][i][j][b] = hMdDec->mixer_mat_fx[i][j][( b + ( md_sf * IVAS_MAX_NUM_BANDS ) )]; /*hMdDec->Q_mixer_mat*/ move32(); } } @@ -1220,8 +1221,8 @@ void ivas_sba_dirac_stereo_smooth_parameters_fx( void ivas_sba_dirac_stereo_dec_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output[CPE_CHANNELS], /* i/o: output synthesis signal */ - const Word16 output_frame, /* i : output frame length per channel */ - const Word16 mcmasa /* i : McMASA flag */ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 mcmasa /* i : McMASA flag Q0*/ ) { Word16 dtx_flag, fd_cng_flag; @@ -1251,14 +1252,14 @@ void ivas_sba_dirac_stereo_dec_fx( move16(); #ifdef MSAN_FIX - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ #else Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); #endif IF( hSCE != NULL ) { #ifdef MSAN_FIX - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), negate( sub( Q11, hCPE->hStereoDft->q_dft ) ) ); /*hSCE->q_prev_hb_synth_fx + hCPE->hStereoDft->q_dft - Q11*/ #else Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), -( Q11 - hCPE->hStereoDft->q_dft ) ); #endif // MSAN_FIX @@ -1276,10 +1277,10 @@ void ivas_sba_dirac_stereo_dec_fx( } ELSE { - dtx_flag = (Word16) LE_32( hSCE->hCoreCoder[0]->core_brate, SID_2k40 ); + dtx_flag = (Word16) LE_32( hSCE->hCoreCoder[0]->core_brate, SID_2k40 ); /*Q0*/ move16(); test(); - fd_cng_flag = ( dtx_flag && EQ_16( hSCE->hCoreCoder[0]->cng_type, FD_CNG ) ); + fd_cng_flag = ( dtx_flag && EQ_16( hSCE->hCoreCoder[0]->cng_type, FD_CNG ) ); /*Q0*/ move16(); } sba_mono_flag = (Word16) EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ); @@ -1306,14 +1307,14 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_compute_td_stefi_nrgs( hStereoDft, hSCE->save_hb_synth_fx, hSCE->hCoreCoder[0]->core, output_frame, fd_cng_flag, hSCE->q_save_synth_fx ); /* do DFT Stereo core switching (including DFT analysis) here as CPE element was not available in SCE decoder */ - Copy32( hSCE->save_synth_fx, tmp_synth, hSCE->hCoreCoder[0]->L_frame ); + Copy32( hSCE->save_synth_fx, tmp_synth, hSCE->hCoreCoder[0]->L_frame ); /*hSCE->q_save_synth_fx*/ stereo_dft_dec_core_switching_fx( hCPE, output[0] /*hSCE->save_output*/, hSCE->save_synth_fx, hSCE->save_hb_synth_fx, DFT, output_frame, 0, dtx_flag, &q, &q_dft[0] ); /* do updates here after skipping this in SCE decoder (needs to be done after core switching) */ ivas_updt_dec_common_fx( hSCE->hCoreCoder[0], NORMAL_HQ_CORE, -1, hSCE->save_synth_fx, q ); q_synth = sub( getScaleFactor32( tmp_synth, hSCE->hCoreCoder[0]->L_frame ), 10 ); - scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth ); + scale_sig32( tmp_synth, hSCE->hCoreCoder[0]->L_frame, q_synth ); /*hSCE->q_save_synth_fx + q_synth*/ q_synth = add( q_synth, hSCE->q_save_synth_fx ); } @@ -1328,7 +1329,7 @@ void ivas_sba_dirac_stereo_dec_fx( IF( ( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) && !mcmasa ) { - set32_fx( hStereoDft->res_pred_gain_fx, MAX_32, 3 * STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->res_pred_gain_fx, MAX_32, 3 * STEREO_DFT_BAND_MAX ); /*Q31*/ } /* DFT Stereo upmix */ @@ -1347,17 +1348,17 @@ void ivas_sba_dirac_stereo_dec_fx( /* output scaling */ IF( !sba_mono_flag ) { - v_shr( output[0], 1, output[0], output_frame ); - v_shr( output[1], 1, output[1], output_frame ); + v_shr( output[0], 1, output[0], output_frame ); /*0.5f*/ + v_shr( output[1], 1, output[1], output_frame ); /*0.5f*/ } /* delay HB synth */ IF( EQ_16( st_ivas->nchan_transport, 1 ) ) { - Copy32( hSCE->save_hb_synth_fx + output_frame - memOffset, tmp_buf, memOffset ); - Copy32( hSCE->save_hb_synth_fx, hSCE->save_hb_synth_fx + memOffset, sub( output_frame, memOffset ) ); - Copy32( hSCE->prev_hb_synth_fx, hSCE->save_hb_synth_fx, memOffset ); - v_shr( tmp_buf, sub( hSCE->q_prev_hb_synth_fx, hSCE->q_save_hb_synth_fx ), hSCE->prev_hb_synth_fx, memOffset ); + Copy32( hSCE->save_hb_synth_fx + output_frame - memOffset, tmp_buf, memOffset ); /*hSCE->q_save_hb_synth_fx*/ + Copy32( hSCE->save_hb_synth_fx, hSCE->save_hb_synth_fx + memOffset, sub( output_frame, memOffset ) ); /*hSCE->q_save_hb_synth_fx*/ + Copy32( hSCE->prev_hb_synth_fx, hSCE->save_hb_synth_fx, memOffset ); /*hSCE->q_prev_hb_synth_fx*/ + v_shr( tmp_buf, sub( hSCE->q_prev_hb_synth_fx, hSCE->q_save_hb_synth_fx ), hSCE->prev_hb_synth_fx, memOffset ); /*hSCE->q_prev_hb_synth_fx*/ } test(); @@ -1373,10 +1374,10 @@ void ivas_sba_dirac_stereo_dec_fx( ivas_sba_dirac_stereo_upmix_hb( hb_synth_stereo, hSCE->save_hb_synth_fx, hb_gain, output_frame, ( ( NE_16( st_ivas->ivas_format, SBA_FORMAT ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) || mcmasa ), sba_mono_flag, hSCE->hCoreCoder[0]->bwidth, hStereoDft ); /* add HB to ACELP core */ - v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); + v_add_fx( output[0], hb_synth_stereo[0], output[0], output_frame ); /*q*/ IF( !sba_mono_flag ) { - v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); + v_add_fx( output[1], hb_synth_stereo[1], output[1], output_frame ); /*q*/ /* apply TD Stereo Filling as is done in ICBWE */ test(); @@ -1392,14 +1393,14 @@ void ivas_sba_dirac_stereo_dec_fx( } #ifdef MSAN_FIX - Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ #else Scale_sig32( hCPE->prev_hb_synth_fx[0], NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); #endif IF( hSCE != NULL ) { #ifdef MSAN_FIX - Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); + Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); /*hSCE->q_prev_hb_synth_fx + Q11 - hCPE->hStereoDft->q_dft*/ #else Scale_sig32( hSCE->prev_hb_synth_fx, NS2SA_FX2( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ), ( Q11 - hCPE->hStereoDft->q_dft ) ); #endif // MSAN_FIX diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 7379ca1d6cedc65bfd0919f6151b1457b9fcd669..36562cc4db10060cccd10b27afa04a6e85a1201c 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -125,10 +125,10 @@ void ivas_sba2mc_cldfb_fixed( IVAS_OUTPUT_SETUP hInSetup, /* i : Format of input layout */ Word32 RealBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb real part (Q_real) */ Word32 ImagBuffer[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: cldfb imag part (Q_imag) */ - const Word16 nb_channels_out, /* i : nb of output channels */ - const Word16 nb_bands, /* i : nb of CLDFB bands to process */ - const Word16 nb_timeslots, /* i : number of time slots to process */ - const Word32 *hoa_dec_mtx /* i : HOA decoding mtx */ + const Word16 nb_channels_out, /* i : nb of output channels Q0*/ + const Word16 nb_bands, /* i : nb of CLDFB bands to process Q0*/ + const Word16 nb_timeslots, /* i : number of time slots to process Q0*/ + const Word32 *hoa_dec_mtx /* i : HOA decoding mtx Q29*/ ) { Word16 iBlock, iBand, n, m; @@ -138,25 +138,25 @@ void ivas_sba2mc_cldfb_fixed( Word16 nb_channels_in; push_wmops( "ivas_sba2mc_cldfb_fixed" ); - nb_channels_in = hInSetup.nchan_out_woLFE; + nb_channels_in = hInSetup.nchan_out_woLFE; /*Q0*/ move16(); assert( EQ_16( nb_channels_in, 16 ) && EQ_16( nb_channels_out, 11 ) && "ivas_sba2mc_cldfb_fixed; only HOA3 to CICP19 is for now supported!" ); FOR( n = 0; n < nb_channels_out; n++ ) { - set32_fx( realOut_fx[n], 0, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, nb_bands ) ); - set32_fx( imagOut_fx[n], 0, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, nb_bands ) ); + set32_fx( realOut_fx[n], 0, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, nb_bands ) ); /*Q_real*/ + set32_fx( imagOut_fx[n], 0, i_mult( MAX_PARAM_SPATIAL_SUBFRAMES, nb_bands ) ); /*Q_imag*/ FOR( m = 0; m < nb_channels_in; m++ ) { - g_fx = hoa_dec_mtx[add( imult1616( SBA_NHARM_HOA3, n ), m )]; // Q29 + g_fx = hoa_dec_mtx[( ( SBA_NHARM_HOA3 * n ) + m )]; // Q29 p_realOut_fx = realOut_fx[n]; p_imagOut_fx = imagOut_fx[n]; FOR( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) { - p_real_fx = RealBuffer[m][iBlock]; - p_imag_fx = ImagBuffer[m][iBlock]; + p_real_fx = RealBuffer[m][iBlock]; /*Q_real*/ + p_imag_fx = ImagBuffer[m][iBlock]; /*Q_imag*/ FOR( iBand = 0; iBand < nb_bands; iBand++ ) { *p_realOut_fx = L_add( *p_realOut_fx, Mpy_32_32( L_shl_sat( g_fx, Q2 ), *( p_real_fx++ ) ) ); // Q_real @@ -172,13 +172,13 @@ void ivas_sba2mc_cldfb_fixed( FOR( n = 0; n < nb_channels_out; n++ ) { - p_realOut_fx = realOut_fx[n]; - p_imagOut_fx = imagOut_fx[n]; + p_realOut_fx = realOut_fx[n]; /*Q_real*/ + p_imagOut_fx = imagOut_fx[n]; /*Q_imag*/ FOR( iBlock = 0; iBlock < nb_timeslots; iBlock++ ) { - p_real_fx = RealBuffer[n][iBlock]; - p_imag_fx = ImagBuffer[n][iBlock]; + p_real_fx = RealBuffer[n][iBlock]; /*Q_real*/ + p_imag_fx = ImagBuffer[n][iBlock]; /*Q_imag*/ FOR( iBand = 0; iBand < nb_bands; iBand++ ) { *( p_real_fx++ ) = *p_realOut_fx++; @@ -205,10 +205,10 @@ void ivas_mc2sba_fx( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ Word32 *in_buffer_td_fx[], /* i : MC signals (on input) and the HOA3 (on output) */ /*Q*/ - Word32 *buffer_td_fx[], /* 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_fx /* i : gain for LFE, 0 = ignore LFE */ + Word32 *buffer_td_fx[], /* i/o: MC signals (on input) and the HOA3 (on output) Q*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 sba_order, /* i : Ambisonic (SBA) order Q0*/ + const Word16 gain_lfe_fx /* i : gain for LFE, 0 = ignore LFE Q14*/ ) { Word16 i, j, k; @@ -231,7 +231,7 @@ void ivas_mc2sba_fx( idx_in = 0; move16(); move16(); - FOR( i = 0; i < add( hIntSetup.nchan_out_woLFE, hIntSetup.num_lfe ); i++ ) + FOR( i = 0; i < ( hIntSetup.nchan_out_woLFE + hIntSetup.num_lfe ); i++ ) { test(); IF( ( hIntSetup.num_lfe > 0 ) && EQ_16( i, hIntSetup.index_lfe[idx_lfe] ) ) @@ -248,16 +248,16 @@ void ivas_mc2sba_fx( if ( LT_16( idx_lfe, sub( hIntSetup.num_lfe, 1 ) ) ) { - idx_lfe = add( idx_lfe, 1 ); + idx_lfe = add( idx_lfe, 1 ); /*Q0*/ } } ELSE { - azimuth = extract_l( L_shr( hIntSetup.ls_azimuth_fx[idx_in], Q22 ) ); + azimuth = extract_l( L_shr( hIntSetup.ls_azimuth_fx[idx_in], Q22 ) ); /*Q0*/ move16(); - elevation = extract_l( L_shr( hIntSetup.ls_elevation_fx[idx_in], Q22 ) ); + elevation = extract_l( L_shr( hIntSetup.ls_elevation_fx[idx_in], Q22 ) ); /*Q0*/ move16(); - idx_in = add( idx_in, 1 ); + idx_in = add( idx_in, 1 ); /*Q0*/ ivas_dirac_dec_get_response_fx( azimuth, elevation, @@ -279,7 +279,7 @@ void ivas_mc2sba_fx( FOR( j = 0; j < sba_num_chans; j++ ) { - Copy32( buffer_tmp_fx[j], buffer_td_fx[j], output_frame ); + Copy32( buffer_tmp_fx[j], buffer_td_fx[j], output_frame ); /*Q*/ } return; @@ -372,12 +372,12 @@ void ivas_mc2sba( #ifdef IVAS_FLOAT_FIXED void ivas_param_mc_mc2sba_cldfb_fx( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ - Word32 *hoa_encoder_fx, /* i : HOA3 encoder for the transported MC format */ - const Word16 slot_idx, /* i : current slot in the subframe */ - Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) */ - Word32 Cldfb_ImagBuffer_fx[][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_fx /* i : gain applied to LFE */ + Word32 *hoa_encoder_fx, /* i : HOA3 encoder for the transported MC format Q31*/ + const Word16 slot_idx, /* i : current slot in the subframe Q0*/ + Word32 Cldfb_RealBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) Q_Cldfb_RealBuffer*/ + Word32 Cldfb_ImagBuffer_fx[][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX], /* i/o: Contains the MC signals (on input) and the HOA3 (on output) Q_Cldfb_ImagBuffer*/ + const Word16 nBands, /* i : number of synth CLDFB bands Q0*/ + const Word16 gain_lfe_fx /* i : gain applied to LFE Q14*/ ) { Word16 idx_ch, idx_band; @@ -401,7 +401,7 @@ void ivas_param_mc_mc2sba_cldfb_fx( move16(); move16(); - FOR( idx_ch = 0; idx_ch < add( hTransSetup.nchan_out_woLFE, hTransSetup.num_lfe ); idx_ch++ ) + FOR( idx_ch = 0; idx_ch < ( hTransSetup.nchan_out_woLFE + hTransSetup.num_lfe ); idx_ch++ ) { test(); IF( ( hTransSetup.num_lfe > 0 ) && EQ_16( idx_ch, hTransSetup.index_lfe[idx_lfe] ) ) @@ -409,38 +409,38 @@ void ivas_param_mc_mc2sba_cldfb_fx( IF( gain_lfe_fx > 0 ) { /* Add LFE to Omni Channel i.e. W (Just first Band) */ - Cldfb_RealBuffer_tmp_fx[0][0] = L_add_sat( Cldfb_RealBuffer_tmp_fx[0][0], Mult_32_16( L_shl( Cldfb_RealBuffer_fx[idx_ch][slot_idx][0], 1 ), gain_lfe_fx ) ); + Cldfb_RealBuffer_tmp_fx[0][0] = L_add_sat( Cldfb_RealBuffer_tmp_fx[0][0], Mult_32_16( L_shl( Cldfb_RealBuffer_fx[idx_ch][slot_idx][0], 1 ), gain_lfe_fx ) ); /*Q_Cldfb_RealBuffer*/ move32(); - Cldfb_ImagBuffer_tmp_fx[0][0] = L_add_sat( Cldfb_ImagBuffer_tmp_fx[0][0], Mult_32_16( L_shl( Cldfb_ImagBuffer_fx[idx_ch][slot_idx][0], 1 ), gain_lfe_fx ) ); + Cldfb_ImagBuffer_tmp_fx[0][0] = L_add_sat( Cldfb_ImagBuffer_tmp_fx[0][0], Mult_32_16( L_shl( Cldfb_ImagBuffer_fx[idx_ch][slot_idx][0], 1 ), gain_lfe_fx ) ); /*Q_Cldfb_ImagBuffer*/ move32(); } if ( LT_16( idx_lfe, sub( hTransSetup.num_lfe, 1 ) ) ) { - idx_lfe = add( idx_lfe, 1 ); + idx_lfe = add( idx_lfe, 1 ); /*Q0*/ } } ELSE { - gains_fx = hoa_encoder_fx + imult1616( idx_in, sba_num_chans ); /*Pointer addition*/ + gains_fx = hoa_encoder_fx + imult1616( idx_in, sba_num_chans ); /*Pointer addition*/ /*Q31*/ FOR( idx_out = 0; idx_out < sba_num_chans; idx_out++ ) { FOR( idx_band = 0; idx_band < nBands; idx_band++ ) { - Cldfb_RealBuffer_tmp_fx[idx_out][idx_band] = L_add( Cldfb_RealBuffer_tmp_fx[idx_out][idx_band], Mult_32_32( ( *gains_fx ), Cldfb_RealBuffer_fx[idx_ch][slot_idx][idx_band] ) ); + Cldfb_RealBuffer_tmp_fx[idx_out][idx_band] = L_add( Cldfb_RealBuffer_tmp_fx[idx_out][idx_band], Mult_32_32( ( *gains_fx ), Cldfb_RealBuffer_fx[idx_ch][slot_idx][idx_band] ) ); /*Q_Cldfb_RealBuffer*/ move32(); - Cldfb_ImagBuffer_tmp_fx[idx_out][idx_band] = L_add( Cldfb_ImagBuffer_tmp_fx[idx_out][idx_band], Mult_32_32( ( *gains_fx ), Cldfb_ImagBuffer_fx[idx_ch][slot_idx][idx_band] ) ); + Cldfb_ImagBuffer_tmp_fx[idx_out][idx_band] = L_add( Cldfb_ImagBuffer_tmp_fx[idx_out][idx_band], Mult_32_32( ( *gains_fx ), Cldfb_ImagBuffer_fx[idx_ch][slot_idx][idx_band] ) ); /*Q_Cldfb_ImagBuffer*/ move32(); } gains_fx++; } - idx_in = add( idx_in, 1 ); + idx_in = add( idx_in, 1 ); /*Q0*/ } } FOR( idx_ch = 0; idx_ch < sba_num_chans; idx_ch++ ) { - Copy32( Cldfb_RealBuffer_tmp_fx[idx_ch], Cldfb_RealBuffer_fx[idx_ch][slot_idx], nBands ); - Copy32( Cldfb_ImagBuffer_tmp_fx[idx_ch], Cldfb_ImagBuffer_fx[idx_ch][slot_idx], nBands ); + Copy32( Cldfb_RealBuffer_tmp_fx[idx_ch], Cldfb_RealBuffer_fx[idx_ch][slot_idx], nBands ); /*Q_Cldfb_RealBuffer*/ + Copy32( Cldfb_ImagBuffer_tmp_fx[idx_ch], Cldfb_ImagBuffer_fx[idx_ch][slot_idx], nBands ); /*Q_Cldfb_ImagBuffer*/ } return; @@ -527,20 +527,20 @@ void ivas_param_mc_mc2sba_cldfb( /*! r: SBA DirAC stereo flag */ #ifdef IVAS_FLOAT_FIXED Word16 ivas_sba_remapTCs_fx( - Word32 *sba_data_fx[], /* i/o: SBA signals */ + Word32 *sba_data_fx[], /* i/o: SBA signals Q11*/ Decoder_Struct *st_ivas, /* i/o: decoder struct */ - const Word16 output_frame /* i : frame length */ + const Word16 output_frame /* i : frame length Q0*/ ) { Word16 nchan_remapped; - nchan_remapped = st_ivas->nchan_transport; + nchan_remapped = st_ivas->nchan_transport; /*Q0*/ move16(); IF( EQ_16( nchan_remapped, 3 ) ) { - nchan_remapped = add( nchan_remapped, 1 ); + nchan_remapped = add( nchan_remapped, 1 ); /*Q0*/ IF( EQ_16( nchan_remapped, 4 ) ) { - Copy32( sba_data_fx[2], sba_data_fx[3], output_frame ); + Copy32( sba_data_fx[2], sba_data_fx[3], output_frame ); /*Q11*/ } } IF( GT_16( st_ivas->nchan_transport, 3 ) ) @@ -552,11 +552,11 @@ Word16 ivas_sba_remapTCs_fx( /*convert WYXZ downmix to WYZX*/ FOR( i = 0; i < output_frame; i++ ) { - temp_fx = sba_data_fx[2][i]; + temp_fx = sba_data_fx[2][i]; /*Q11*/ move32(); - sba_data_fx[2][i] = sba_data_fx[3][i]; + sba_data_fx[2][i] = sba_data_fx[3][i]; /*Q11*/ move32(); - sba_data_fx[3][i] = temp_fx; + sba_data_fx[3][i] = temp_fx; /*Q11*/ move32(); if ( EQ_16( st_ivas->nchan_transport, 3 ) ) @@ -623,12 +623,12 @@ int16_t ivas_sba_remapTCs( void ivas_ism2sba_sf_fx( Word32 *buffer_in_fx[], /* i : TC buffer */ /*Q_buffer_in*/ - Word32 *buffer_out_fx[], /* o : TD signal buffers */ + Word32 *buffer_out_fx[], /* o : TD signal buffers Q_buffer_in + 29 - 31*/ 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 */ + const Word16 num_objects, /* i : number of objects Q0*/ + const Word16 n_samples_to_render, /* i : output frame length per channel Q0*/ + const Word16 offset, /* i : offset for the interpolatr Q0*/ + const Word16 sba_order /* i : Ambisonic (SBA) order Q0*/ ) { Word16 i, j, k; @@ -640,7 +640,7 @@ void ivas_ism2sba_sf_fx( assert( LE_16( sba_order, 3 ) && "Only order up to 3 is supported!" ); assert( hIsmRendererData != NULL && "hIsmRendererData not allocated!" ); /* Init*/ - sba_num_chans = imult1616( add( sba_order, 1 ), add( sba_order, 1 ) ); + sba_num_chans = imult1616( add( sba_order, 1 ), add( sba_order, 1 ) ); /*Q0*/ FOR( j = 0; j < sba_num_chans; j++ ) { set32_fx( buffer_tmp_fx[j], 0, n_samples_to_render ); @@ -649,17 +649,17 @@ void ivas_ism2sba_sf_fx( { FOR( j = 0; j < sba_num_chans; j++ ) { - g2_fx = hIsmRendererData->interpolator_fx + offset; /*Pointer addition*/ - tc_fx = buffer_in_fx[i] + offset; /*Pointer addition*/ - out_fx = buffer_tmp_fx[j]; - gain_fx = hIsmRendererData->gains_fx[i][j]; + g2_fx = hIsmRendererData->interpolator_fx + offset; /*Pointer addition*/ /*Q15*/ + tc_fx = buffer_in_fx[i] + offset; /*Pointer addition*/ /*Q_buffer_in*/ + out_fx = buffer_tmp_fx[j]; /*Q_buffer_in + 29 - 31*/ + gain_fx = hIsmRendererData->gains_fx[i][j]; /*Q29*/ move32(); - prev_gain_fx = hIsmRendererData->prev_gains_fx[i][j]; + prev_gain_fx = hIsmRendererData->prev_gains_fx[i][j]; /*Q29*/ move32(); #ifdef IVAS_ENH32_CADENCE_CHANGES FOR( k = 0; k < n_samples_to_render; k++ ) { - g1_fx = sub( 32767, *g2_fx ); + g1_fx = sub( 32767, *g2_fx ); /*Q15*/ *( out_fx ) = Madd_32_32( *( out_fx ), Madd_32_16( Mult_32_16( gain_fx, ( *( g2_fx ) ) ), prev_gain_fx, g1_fx ), ( *( tc_fx ) ) ); /*Q_buffer_in + 29 - 31*/ move32(); g2_fx++; @@ -681,7 +681,7 @@ void ivas_ism2sba_sf_fx( } FOR( j = 0; j < sba_num_chans; j++ ) { - Copy32( buffer_tmp_fx[j], buffer_out_fx[j], n_samples_to_render ); + Copy32( buffer_tmp_fx[j], buffer_out_fx[j], n_samples_to_render ); /*Q_buffer_in + 29 - 31*/ } return; } @@ -749,10 +749,10 @@ void ivas_ism2sba_sf( Float to fixed conversion required for:output_f *************************/ ivas_error ivas_sba_linear_renderer_fx( - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const Word16 output_frame, /* i : output frame length per channel */ - const Word16 nchan_in, /* i : number of input ambisonics channels */ - const Word16 nchan_ism, /* i : number of objects */ + Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 nchan_in, /* i : number of input ambisonics channels Q0*/ + const Word16 nchan_ism, /* i : number of objects Q0*/ const AUDIO_CONFIG output_config, /* i : output audio configuration */ const IVAS_OUTPUT_SETUP output_setup /* i : output format setup */ ) @@ -765,7 +765,7 @@ ivas_error ivas_sba_linear_renderer_fx( move32(); /* Number of channels of HOA depends of transport format which is mixed order xH1V*/ - nchan_hoa = nchan_in; + nchan_hoa = nchan_in; /*Q0*/ move16(); IF( EQ_16( nchan_in, 6 ) ) /*2H1V*/ @@ -792,7 +792,7 @@ ivas_error ivas_sba_linear_renderer_fx( case IVAS_AUDIO_CONFIG_EXTERNAL: FOR( i = output_setup.nchan_out_woLFE - 1; i >= nchan_ism; i-- ) { - Copy32( output_f[i - nchan_ism], output_f[i], output_frame ); + Copy32( output_f[i - nchan_ism], output_f[i], output_frame ); /*Q11*/ } FOR( ; i >= 0; i-- ) { @@ -871,11 +871,11 @@ ivas_error ivas_sba_linear_renderer( #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*/ + Word32 *output_fx[], /* i/o: transport/output audio channels Q_output*/ + const Word16 bfi, /* i : BFI flag Q0*/ + const Word16 nchan_remapped, /* i : num channels after remapping of TCs Q0*/ + const Word16 output_frame, /* i : output frame length Q0*/ + const Word16 num_md_sub_frames, /* i : number of subframes in mixing matrix Q0*/ const Word16 Q_output /* i : Q of transport/output audio channels */ ) { @@ -888,29 +888,29 @@ void ivas_sba_mix_matrix_determiner_fx( { FOR( i = 0; i < output_frame; i++ ) { - temp_fx = output_fx[ch][i]; + temp_fx = output_fx[ch][i]; /*Q_output*/ move32(); - temp_fx = L_shr( temp_fx + L_shl( 1, Q_p_output - 1 ), Q_p_output ); + temp_fx = L_shr( temp_fx + L_shl( 1, Q_p_output - 1 ), Q_p_output ); /*Q0*/ IF( GT_32( temp_fx, MAX16B ) ) { - temp_fx = MAX16B; + temp_fx = MAX16B; /*Q0*/ move32(); } ELSE IF( LT_32( temp_fx, L_negate( PCM16_TO_FLT_FAC_FX ) ) ) { - temp_fx = L_negate( PCM16_TO_FLT_FAC_FX ); + temp_fx = -( PCM16_TO_FLT_FAC_FX ); /*Q0*/ move32(); } - temp_fx = Mult_32_32( MAX_32 / PCM16_TO_FLT_FAC_FX, L_shl( temp_fx, Q_p_output ) ); - output_fx[ch][i] = temp_fx; + temp_fx = Mult_32_32( MAX_32 / PCM16_TO_FLT_FAC_FX, L_shl( temp_fx, Q_p_output ) ); /*Q_p_output*/ + output_fx[ch][i] = temp_fx; /*Q_p_output*/ move32(); } } /* AGC */ - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; /*Q0*/ move16(); - nchan_out = nchan_transport; + nchan_out = nchan_transport; /*Q0*/ move16(); ivas_agc_dec_process_fx( hSpar->hAgcDec, ( output_fx ), ( output_fx ), nchan_transport, output_frame ); Q_p_output = sub( Q_p_output, 3 ); @@ -923,12 +923,12 @@ void ivas_sba_mix_matrix_determiner_fx( { FOR( i = 0; i < output_frame; i++ ) { - output_fx[ch][i] = Mult_32_32( L_shl_sat( output_fx[ch][i], sub( 15, Q_p_output ) ), L_shl_sat( PCM16_TO_FLT_FAC_FX, 16 ) ); /* Q0 */ + output_fx[ch][i] = Mult_32_32( L_shl_sat( output_fx[ch][i], sub( 15, Q_p_output ) ), 2147483647 /* PCM16_TO_FLT_FAC_FX << 16 */ ); /* Q0 */ } } /* Mixing matrix determiner */ - num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; /*Q0*/ move16(); ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); return; diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index af484f02e4b6159e7c8d2a043360ee190e8fc112..166c9135aa042bbc9dd087670fcea41a9574ee07 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -4178,12 +4178,12 @@ static void adaptTransportSignalsHeadtracked_fx( Word16 band_idx, bin_lo, bin_hi, norm, shift = 31; Word16 q_chEneIIR = 0, q_procChEneIIR = 0; Word32 temp_div; - Word16 e_div, tmp; + Word16 e_div, tmp, is_zero, i; move16(); move16(); move16(); - FOR( Word16 i = 0; i < 6; i++ ) + FOR( i = 0; i < 6; i++ ) { FOR( Word16 j = 0; j < nSlots; j++ ) { @@ -4409,17 +4409,57 @@ static void adaptTransportSignalsHeadtracked_fx( } } - tmp = sub( s_min( getScaleFactor32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 ); - scale_sig32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp ); - scale_sig32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp ); - hHeadTrackData->q_chEneIIR = add( q_chEneIIR, tmp ); + is_zero = 1; move16(); + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + { + test(); + if ( ( hHeadTrackData->chEneIIR_fx[0][i] != 0 ) || ( hHeadTrackData->chEneIIR_fx[1][i] != 0 ) ) + { + is_zero = 0; + move16(); + BREAK; + } + } + IF( is_zero ) + { + hHeadTrackData->q_chEneIIR = 31; + move16(); + } + ELSE + { + tmp = sub( s_min( getScaleFactor32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 ); + scale_sig32( hHeadTrackData->chEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp ); + scale_sig32( hHeadTrackData->chEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp ); + hHeadTrackData->q_chEneIIR = add( q_chEneIIR, tmp ); + move16(); + } - tmp = sub( s_min( getScaleFactor32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 ); - scale_sig32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp ); - scale_sig32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp ); - hHeadTrackData->q_procChEneIIR = add( q_procChEneIIR, tmp ); + is_zero = 1; move16(); + FOR( i = 0; i < MASA_FREQUENCY_BANDS; i++ ) + { + test(); + if ( ( hHeadTrackData->procChEneIIR_fx[0][i] != 0 ) || ( hHeadTrackData->procChEneIIR_fx[1][i] != 0 ) ) + { + is_zero = 0; + move16(); + BREAK; + } + } + IF( is_zero ) + { + hHeadTrackData->q_procChEneIIR = 31; + move16(); + } + ELSE + { + tmp = sub( s_min( getScaleFactor32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS ), getScaleFactor32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS ) ), 1 ); + scale_sig32( hHeadTrackData->procChEneIIR_fx[0], MASA_FREQUENCY_BANDS, tmp ); + scale_sig32( hHeadTrackData->procChEneIIR_fx[1], MASA_FREQUENCY_BANDS, tmp ); + hHeadTrackData->q_procChEneIIR = add( q_procChEneIIR, tmp ); + move16(); + } return; }