Commit a98a038a authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Fixes for few high MLD issues and float code cleanup

[x] lib_rend.c cleanup
[x] Integration of ivas_dirac_dec_decorr_process fixed function
[x] Few warnings fixes
parent 0819a635
Loading
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1549,7 +1549,11 @@ int main(
        {
            if ( args.delayCompensationEnabled )
            {
#ifdef IVAS_FLOAT_FIXED
                IF( IVAS_REND_GetDelay_fx( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK )
#else
                if ( IVAS_REND_GetDelay( hIvasRend, &delayNumSamples, &delayTimeScale ) != IVAS_ERR_OK )
#endif // IVAS_FLOAT_FIXED
                {
                    fprintf( stderr, "\nUnable to get delay of renderer!\n" );
                    exit( -1 );
+12 −3
Original line number Diff line number Diff line
@@ -6170,7 +6170,7 @@ void ivas_clear_band_coeff_idx(
/*----------------------------------------------------------------------------------*
 * MASA prototypes
 *----------------------------------------------------------------------------------*/

#ifndef IVAS_FLOAT_FIXED
ivas_error ivas_masa_dec_open(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                             */
);
@@ -6178,6 +6178,7 @@ ivas_error ivas_masa_dec_open(
void ivas_masa_dec_close(
    MASA_DECODER_HANDLE *hMasa                                  /* i/o: MASA metadata structure                         */
);
#endif

ivas_error ivas_masa_decode(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder struct                             */
@@ -6828,7 +6829,15 @@ void ivas_mono_stereo_downmix_mcmasa(
    float *output_f[],                                          /* i/o: synthesized core-coder transport channels/mono or stereo output */
    int16_t output_frame                                        /* i  : output frame length per channel                                 */
);

#ifdef IVAS_FLOAT_FIXED
void ivas_lfe_synth_with_filters_fx(
    MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth, /* i/o: LFE synthesis structure for McMASA  */
    Word32 *data_f[],                            /* o  : output signals                      */
    const Word16 output_frame,                 /* i  : output frame length per channel     */
    const Word16 separateChannelIndex,         /* i  : separate channel index              */
    const Word16 lfeChannelIndex               /* i  : LFE channel index                   */
);
#else
void ivas_lfe_synth_with_filters(
    MCMASA_LFE_SYNTH_DATA_HANDLE hMasaLfeSynth,                 /* i/o: LFE synthesis structure for McMASA              */
    float *data_f[],                                            /* o  : output signals                                  */
@@ -6836,7 +6845,7 @@ void ivas_lfe_synth_with_filters(
    const int16_t separateChannelIndex,                         /* i  : separate channel index                          */
    const int16_t lfeChannelIndex                               /* i  : LFE channel index                               */
);

#endif

/*----------------------------------------------------------------------------------*
 * LFE encoder low pass filter prototypes
+0 −6
Original line number Diff line number Diff line
@@ -2309,12 +2309,6 @@ void ivas_binaural_add_LFE_fx(
    Word32 *output_fx[]      /* o  : synthesized core-coder transport channels/DirAC output */
)
{
#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED
    IF( st_ivas->hCrendWrapper != NULL )
    {
        st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe_fx = (Word16)(st_ivas->hCrendWrapper->hHrtfCrend->gain_lfe * ( ONE_IN_Q14 ));
    }
#endif
    Word16 render_lfe, idx_lfe;
    Word16 gain_fx;

+53 −15
Original line number Diff line number Diff line
@@ -3626,6 +3626,7 @@ void ivas_dirac_dec_render_sf_fx(
    Word32 Cldfb_ImagBuffer_Binaural_fx[BINAURAL_CHANNELS][MAX_PARAM_SPATIAL_SUBFRAMES][CLDFB_NO_CHANNELS_MAX];
    set_zero_fx(surCohRatio_fx, CLDFB_NO_CHANNELS_MAX);
    Word16 q_cldfb, q_temp_cldfb = 0;
    Word16 proto_length = 0;
    //Word32 proto_frame_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX];

    Word32 proto_direct_buffer_f_fx[2 * MAX_OUTPUT_CHANNELS * CLDFB_SLOTS_PER_SUBFRAME * CLDFB_NO_CHANNELS_MAX];
@@ -3750,15 +3751,6 @@ void ivas_dirac_dec_render_sf_fx(
        floatToFixed_arrL32( st_ivas->cldfbAnaDec[1]->cldfb_state, st_ivas->cldfbAnaDec[1]->cldfb_state_fx, Q11, ( st_ivas->cldfbAnaDec[1]->p_filter_length - st_ivas->cldfbAnaDec[1]->no_channels ) );
    }

    IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) && !hDirACRend->hOutSetup.separateChannelEnabled && !( EQ_16( hDirACRend->hOutSetup.output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && EQ_16( hDirACRend->hOutSetup.num_lfe, 0 ) ) )
    {
        st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth, st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_q );
        st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth, st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_q );
        f2me( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth, &st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_fx, &st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q );
        st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q = sub( 31, st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q );
        st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_fx = floatToFixed_32( st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth, st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_q );
    }

    IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) )
    {
        floatToFixed_arrL32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) );
@@ -4325,10 +4317,6 @@ void ivas_dirac_dec_render_sf_fx(
              }
              fixedToFloat_arrL32( Cldfb_RealBuffer_fx[MAX_OUTPUT_CHANNELS - 1][slot_idx], Cldfb_RealBuffer[MAX_OUTPUT_CHANNELS - 1][slot_idx], Q6, CLDFB_NO_CHANNELS_MAX );
              fixedToFloat_arrL32( Cldfb_ImagBuffer_fx[MAX_OUTPUT_CHANNELS - 1][slot_idx], Cldfb_ImagBuffer[MAX_OUTPUT_CHANNELS - 1][slot_idx], Q6, CLDFB_NO_CHANNELS_MAX );
              st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->transportEneSmooth_q );
              st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->protoLfeEneSmooth_q );
              st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth = me2f( st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_fx, sub( 31, st_ivas->hMasa->hMasaLfeSynth->targetEneLfeSmooth_q ) );
              st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth = fixedToFloat_32( st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_fx, st_ivas->hMasa->hMasaLfeSynth->targetEneTransSmooth_q );
          }

          IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
@@ -4353,6 +4341,7 @@ void ivas_dirac_dec_render_sf_fx(
              fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) );
              fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( i_mult( i_mult( slot_idx, 2 ), hSpatParamRendCom->num_freq_bands ), 2 ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 4, hSpatParamRendCom->num_freq_bands ) );
              fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) );
              proto_length = i_mult(6, hSpatParamRendCom->num_freq_bands);
              fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands );
              IF( hDirACRend->masa_stereo_type_detect )
              {
@@ -4371,6 +4360,7 @@ void ivas_dirac_dec_render_sf_fx(
                      fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) );
                      fixedToFloat_arrL32( &proto_direct_buffer_f_fx[offset], &hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f[offset], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) );
                      fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff ) ) );
                      proto_length = i_mult(2, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_outputs_diff));
                      fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands );
                      BREAK;
                  case 2:
@@ -4389,12 +4379,14 @@ void ivas_dirac_dec_render_sf_fx(
                          }
                      }
                      fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 6, hSpatParamRendCom->num_freq_bands ) );
                      proto_length = i_mult(6, hSpatParamRendCom->num_freq_bands);
                      fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands );
                      BREAK;
                  case 1:
                      fixedToFloat_arrL32( proto_power_smooth_fx, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth, hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_q, hSpatParamRendCom->num_freq_bands );
                      fixedToFloat_arrL32( &proto_direct_buffer_f_fx[i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) )], hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f + i_mult( slot_idx, i_mult( 2, hSpatParamRendCom->num_freq_bands ) ), hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, i_mult( 2, hSpatParamRendCom->num_freq_bands ) );
                      fixedToFloat_arrL32( hDirACRend->proto_frame_f_fx, hDirACRend->proto_frame_f, hDirACRend->proto_frame_f_q, i_mult( 2, i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff ) ) );
                      proto_length = i_mult(2, i_mult(hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_diff));
                      fixedToFloat_arrL32( reference_power_fix, reference_power, DirAC_mem.reference_power_q, hSpatParamRendCom->num_freq_bands );
                      BREAK;
              }
@@ -4942,12 +4934,32 @@ void ivas_dirac_dec_render_sf_fx(
        /*-----------------------------------------------------------------*
         * frequency domain decorrelation
         *-----------------------------------------------------------------*/

        Word16 scale = 0, temp_len = 0;
        if ( hDirACRend->proto_signal_decorr_on == 1 )
        {
            /* decorrelate prototype frame */
            if ( hDirACRend->synthesisConf == DIRAC_SYNTHESIS_GAIN_SHD )
            {
#ifdef IVAS_FLOAT_FIXED
              ivas_dirac_dec_decorr_process_fx(hSpatParamRendCom->num_freq_bands,
                hDirACRend->num_outputs_diff,
                hDirACRend->num_protos_diff,
                hDirACRend->synthesisConf,
                nchan_transport,
                &proto_diffuse_buffer_f_fx [slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff],
                hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q,
                hDirACRend->num_protos_diff,
                hDirACRend->proto_index_diff,
                &proto_diffuse_buffer_f_fx[slot_idx * 2 * hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff + 2 * hSpatParamRendCom->num_freq_bands * min(4, nchan_transport)],
                &hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q,
                onset_filter_fx,
                hDirACRend->h_freq_domain_decorr_ap_params,
                hDirACRend->h_freq_domain_decorr_ap_state);
 
               
               fixedToFloat_arrL(onset_filter_fx, onset_filter, Q31, hSpatParamRendCom->num_freq_bands );

#else
                ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands,
                                               hDirACRend->num_outputs_diff,
                                               hDirACRend->num_protos_diff,
@@ -4960,6 +4972,7 @@ void ivas_dirac_dec_render_sf_fx(
                                               onset_filter,
                                               hDirACRend->h_freq_domain_decorr_ap_params,
                                               hDirACRend->h_freq_domain_decorr_ap_state );
#endif

                v_multc( onset_filter, 0.25f, onset_filter, hSpatParamRendCom->num_freq_bands );
                v_add( onset_filter, onset_filter_subframe, onset_filter_subframe, hSpatParamRendCom->num_freq_bands );
@@ -4970,8 +4983,31 @@ void ivas_dirac_dec_render_sf_fx(
                p_onset_filter_fx = onset_filter_subframe_fx;
#endif
            }
            else
            ELSE
            {
#ifdef IVAS_FLOAT_FIXED
              scale = L_norm_arr(hDirACRend->proto_frame_f_fx, proto_length);
              Scale_sig32(hDirACRend->proto_frame_f_fx, proto_length, scale);
              hDirACRend->proto_frame_f_q = add(hDirACRend->proto_frame_f_q, scale);
              ivas_dirac_dec_decorr_process_fx(hSpatParamRendCom->num_freq_bands,
                hDirACRend->num_outputs_diff,
                hDirACRend->num_protos_diff,
                hDirACRend->synthesisConf,
                nchan_transport,
                hDirACRend->proto_frame_f_fx,
                hDirACRend->proto_frame_f_q,
                hDirACRend->num_protos_diff,
                hDirACRend->proto_index_diff,
                DirAC_mem.frame_dec_f_fx,
                &DirAC_mem.frame_dec_f_q,
                onset_filter_fx,
                hDirACRend->h_freq_domain_decorr_ap_params,
                hDirACRend->h_freq_domain_decorr_ap_state);

              temp_len = DirAC_mem.frame_dec_f_len;
              fixedToFloat_arrL(onset_filter_fx, onset_filter, Q31, hSpatParamRendCom->num_freq_bands * hDirACRend->num_outputs_diff);
              me2f_buf(DirAC_mem.frame_dec_f_fx, 31- DirAC_mem.frame_dec_f_q , DirAC_mem.frame_dec_f , temp_len);
#else
                ivas_dirac_dec_decorr_process( hSpatParamRendCom->num_freq_bands,
                                               hDirACRend->num_outputs_diff,
                                               hDirACRend->num_protos_diff,
@@ -4984,9 +5020,11 @@ void ivas_dirac_dec_render_sf_fx(
                                               onset_filter,
                                               hDirACRend->h_freq_domain_decorr_ap_params,
                                               hDirACRend->h_freq_domain_decorr_ap_state );
#endif

                hDirACRend->proto_frame_dec_f = DirAC_mem.frame_dec_f;
                p_onset_filter = onset_filter;

#ifdef IVAS_FLOAT_FIXED
                hDirACRend->proto_frame_dec_f_fx = DirAC_mem.frame_dec_f_fx;
                hDirACRend->proto_frame_dec_f_q = DirAC_mem.frame_dec_f_q;
+1 −3
Original line number Diff line number Diff line
@@ -1161,7 +1161,7 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
    Word32 mixing_matrix_smooth_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS];
    Word16 mixing_matrix_smooth_e;
    Word32 mixing_matrix_res_smooth_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
    Word16 mixing_matrix_res_smooth_e;
    Word16 mixing_matrix_res_smooth_e = 0;
    Word32 mixing_matrix_buffer_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS];
    Word16 mixing_matrix_buffer_e;
    Word32 input_f_real_fx[PARAM_MC_MAX_TRANSPORT_CHANS];
@@ -1172,8 +1172,6 @@ void ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx(
    Word16 output_f_imag_e;
    Word32 diff_f_real_fx[MAX_CICP_CHANNELS];
    Word32 diff_f_imag_fx[MAX_CICP_CHANNELS];
    Word16 diff_f_real_e;
    Word16 diff_f_imag_e;

    set_zero_fx( input_f_real_fx, PARAM_MC_MAX_TRANSPORT_CHANS );
    set_zero_fx( input_f_imag_fx, PARAM_MC_MAX_TRANSPORT_CHANS );
Loading