Commit 51db2dfd authored by Tapani Pihlajakuja's avatar Tapani Pihlajakuja
Browse files

Fix BASOP issue 2571 by removing the renderer specific scalings and picking...

Fix BASOP issue 2571 by removing the renderer specific scalings and picking the decoder parts into use as streamlined versions.
parent 9db396b3
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@
#define FIX_FLOAT_1578_OMASA_REND_SPIKES                /* Nokia: Float issue 1578: Fix spikes and collapsed perception in OMASA/MASA rendering to FOA/HOA */
#define FIX_1521_SBA_LOUDNESS_STEREO                    /* FhG: issue 1521: Fix loudness for SBA to stereo rendering */
#define FIX_1559                                        /* Eri/FhG: fix for Issue 1559 in FD CNG with bitrate/bw switching */
#define FIX_BASOP_2571_MASA_EXT_RENDER_FIXES            /* Nokia: BASOP issue 2571: Fix MASA EXT DirAC renderer by unifying it with decoder */

/* ##################### End NON-BE switches ########################### */

+172 −0
Original line number Diff line number Diff line
@@ -4043,6 +4043,14 @@ static void ivas_masa_ext_dirac_render_sf_fx(
    Word32 dirEne_fx;
    Word32 surCohEner_fx;
    move16();
#ifdef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
    Word16 tmp1;
    Word16 size;
    Word16 shift;
    Word16 num_channels_dir;
    DIRAC_OUTPUT_SYNTHESIS_PARAMS *h_dirac_output_synthesis_params;
    DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state;
#endif

    FOR( Word16 ii = 0; ii < MAX_OUTPUT_CHANNELS; ii++ )
    {
@@ -4097,6 +4105,128 @@ static void ivas_masa_ext_dirac_render_sf_fx(
        move16();
    }

#ifdef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
    IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_MONO ) )
    {
        IF( hDirACRend->masa_stereo_type_detect )
        {
            hDirACRend->masa_stereo_type_detect->subtract_power_y_fx = 0;
            move32();
            hDirACRend->masa_stereo_type_detect->q_subtract_power_y = Q31;
            move16();
        }
    }

    size = imult1616( hDirACRend->num_outputs_dir, hSpatParamRendCom->num_freq_bands );

    test();
    IF( ( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) ) )
    {
        IF( hDirACRend->h_output_synthesis_psd_params.max_band_decorr != 0 )
        {
            DIRAC_OUTPUT_SYNTHESIS_STATE *state = &( hDirACRend->h_output_synthesis_psd_state );
            tmp1 = L_norm_arr( state->proto_power_diff_smooth_fx, state->proto_power_diff_smooth_len );

            scale_sig32( state->proto_power_diff_smooth_fx, state->proto_power_diff_smooth_len, tmp1 ); // Q(proto_power_diff_smooth_q + tmp1)
            state->proto_power_diff_smooth_q = add( state->proto_power_diff_smooth_q, tmp1 );
            move16();
        }
    }

    h_dirac_output_synthesis_params = &( hDirACRend->h_output_synthesis_psd_params );
    h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state );
    num_channels_dir = hDirACRend->num_outputs_dir;
    move16();
    if ( EQ_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) )
    {
        num_channels_dir = hDirACRend->hOutSetup.nchan_out_woLFE;
        move16();
    }

    test();
    IF( h_dirac_output_synthesis_params->use_onset_filters && NE_32( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
    {
        tmp1 = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, size );
        scale_sig32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, size, sub( tmp1, h_dirac_output_synthesis_state->q_cy_auto_diff_smooth ) ); // tmp1
        h_dirac_output_synthesis_state->q_cy_auto_diff_smooth = tmp1;
        move16();
    }

    scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26
    hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q = Q26;
    move16();

    IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_GAIN_SHD ) )
    {
        shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size );
        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_fx, size, shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth + shift)
        hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth, shift );
        move16();

        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size, sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev ) ); // Q26
        hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = Q26;
        move16();

        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth ) ); // Q26
        hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth = Q26;
        move16();

        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hDirACRend->num_outputs_diff, hDirACRend->h_output_synthesis_psd_params.max_band_decorr ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev ) ); // Q26
        hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = Q26;
        move16();
    }
    ELSE
    {
        scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26
        hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q = Q26;
        move16();

        shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size );
        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_dir_smooth_prev_fx, size, shift ); // Q( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev+ shift)
        hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_dir_smooth_prev, shift );
        move16();
        shift = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size );
        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_cross_dir_smooth_prev_fx, size, shift ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev + shift)
        hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_cross_dir_smooth_prev, shift );
        move16();
        tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ) );
        scale_sig32( hDirACRend->h_output_synthesis_psd_state.cy_auto_diff_smooth_prev_fx, imult1616( hSpatParamRendCom->num_freq_bands, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev+ tmp1)
        hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev = add( hDirACRend->h_output_synthesis_psd_state.q_cy_auto_diff_smooth_prev, tmp1 );
        move16();
        tmp1 = 31;
        move16();
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            tmp1 = s_min( tmp1, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) );
        }
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + i, s_min( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[0], tmp1 );
        move16();
        tmp1 = 31;
        move16();
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            tmp1 = s_min( tmp1, L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ) ) );
        }
        FOR( i = 0; i < i_mult( hSpatParamRendCom->num_freq_bands, hDirACRend->num_protos_dir ); i = add( i, hSpatParamRendCom->num_freq_bands ) )
        {
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_fx + CLDFB_NO_CHANNELS_HALF + i, s_max( 0, sub( hSpatParamRendCom->num_freq_bands, CLDFB_NO_CHANNELS_HALF ) ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q tmp1)
        }
        hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1] = add( hDirACRend->h_output_synthesis_psd_state.proto_power_smooth_prev_q[1], tmp1 );
        move16();
        IF( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx != 0 )
        {
            tmp1 = L_norm_arr( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) );
            scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_fx, imult1616( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ), tmp1 ); // Q(hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q+ tmp1)
            hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q = add( hDirACRend->h_output_synthesis_psd_state.proto_power_diff_smooth_prev_q, tmp1 );
            move16();
        }
    }

#endif
    /* Subframe loop */
    slot_idx_start = hSpatParamRendCom->slots_rendered;
    move16();
@@ -4108,8 +4238,10 @@ static void ivas_masa_ext_dirac_render_sf_fx(
    md_idx = hSpatParamRendCom->render_to_md_map[subframe_idx];
    move16();

#ifndef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
    DIRAC_OUTPUT_SYNTHESIS_STATE *h_dirac_output_synthesis_state;
    h_dirac_output_synthesis_state = &( hDirACRend->h_output_synthesis_psd_state );
#endif

    /* copy parameters into local buffers*/

@@ -4501,6 +4633,18 @@ static void ivas_masa_ext_dirac_render_sf_fx(
        test();
        IF( EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_LS ) || EQ_16( hDirACRend->synthesisConf, DIRAC_SYNTHESIS_PSD_SHD ) )
        {
            Word16 diffuse_start, exp;
            diffuse_start = i_mult( i_mult( slot_idx, 2 ), i_mult( hDirACRend->h_output_synthesis_psd_params.max_band_decorr, hDirACRend->hOutSetup.nchan_out_woLFE ) );

            exp = getScaleFactor32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len );
            scale_sig32( hDirACRend->proto_frame_dec_f_fx, hDirACRend->proto_frame_dec_f_len, exp ); // hDirACRend->proto_frame_dec_f_q + exp
            hDirACRend->proto_frame_dec_f_q = add( hDirACRend->proto_frame_dec_f_q, exp );
            move16();
            exp = getScaleFactor32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx, diffuse_start );
            scale_sig32( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_fx, diffuse_start, exp ); // h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q + exp
            h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q = add( h_dirac_output_synthesis_state->proto_diffuse_buffer_f_q, exp );
            move16();

            /* Compute diffuse prototypes */
            ivas_dirac_dec_compute_diffuse_proto_fx( hDirACRend, hSpatParamRendCom->num_freq_bands, slot_idx );
        }
@@ -4634,6 +4778,7 @@ static void ivas_masa_ext_dirac_render_sf_fx(
    }
    ELSE
    {
#ifndef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
        IF( hDirACRend->proto_signal_decorr_on )
        {
            Word16 new_proto_diffuse_buffer_f_q = getScaleFactor32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len );
@@ -4647,13 +4792,19 @@ static void ivas_masa_ext_dirac_render_sf_fx(
            move16();
        }

#endif
        Word16 reference_power_temp_q = getScaleFactor32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len );
        scale_sig32( DirAC_mem.reference_power_fx, DirAC_mem.reference_power_len, reference_power_temp_q ); /*DirAC_mem.reference_power_q + reference_power_temp_q*/
        DirAC_mem.reference_power_q[0] = add( DirAC_mem.reference_power_q[0], reference_power_temp_q );
        DirAC_mem.reference_power_q[1] = add( DirAC_mem.reference_power_q[1], reference_power_temp_q );
        move16();
#ifdef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
        DirAC_mem.reference_power_smooth_q[0] = DirAC_mem.reference_power_q[0];
        DirAC_mem.reference_power_smooth_q[1] = DirAC_mem.reference_power_q[1];
#else
        DirAC_mem.reference_power_smooth_q[0] = add( DirAC_mem.reference_power_q[0], reference_power_temp_q );
        DirAC_mem.reference_power_smooth_q[1] = add( DirAC_mem.reference_power_q[1], reference_power_temp_q );
#endif
        move16();

        Word16 q_cy_auto_diff_smooth = getScaleFactor32( h_dirac_output_synthesis_state->cy_auto_diff_smooth_fx, h_dirac_output_synthesis_state->cy_auto_diff_smooth_len );
@@ -4761,6 +4912,27 @@ static void ivas_masa_ext_dirac_render_sf_fx(
        DirAC_mem.reference_power_smooth_q[1] = s_min( hDirACRend->h_output_synthesis_psd_state.reference_power_smooth_prev_q[1], DirAC_mem.reference_power_q[1] );
        move16();

#ifdef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q, Q26 ) )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_fx,
                         hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_len,
                         sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_dir_prev_q ) ); // Q26
        }
        IF( NE_16( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q, Q26 ) )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_fx,
                         hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_len,
                         sub( Q26, hDirACRend->h_output_synthesis_psd_state.gains_diff_prev_q ) ); // Q26
        }
        IF( hDirACRend->proto_signal_decorr_on )
        {
            Scale_sig32( hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_fx, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_len, sub( hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q, hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q ) ); // proto_direct_buffer_f_q
            hDirACRend->h_output_synthesis_psd_state.proto_diffuse_buffer_f_q = hDirACRend->h_output_synthesis_psd_state.proto_direct_buffer_f_q;
            move16();
        }

#endif
        ivas_dirac_dec_output_synthesis_process_subframe_psd_ls_fx( Cldfb_RealBuffer_fx,
                                                                    Cldfb_ImagBuffer_fx,
                                                                    hSpatParamRendCom,
+16 −2
Original line number Diff line number Diff line
@@ -244,9 +244,10 @@ struct IVAS_REND
static ivas_error initMasaExtRenderer( input_masa *inputMasa, const AUDIO_CONFIG outConfig, const RENDER_CONFIG_DATA *hRendCfg, hrtf_handles *hHrtfs );

static void freeMasaExtRenderer( MASA_EXT_REND_HANDLE *hMasaExtRendOut );
#ifndef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES

static void intermidiate_ext_dirac_render( MASA_EXT_REND_HANDLE hMasaExtRend, Word16 to_fix );

#endif
static ivas_error renderSbaToMultiBinauralCldfb( input_sba *sbaInput, Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_Out_Imag[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], const Word16 low_res_pre_rend_rot, const Word16 num_subframes, const Word16 Q_in );
static ivas_error renderSbaToMultiBinaural( input_sba *sbaInput, const AUDIO_CONFIG outConfig, Word32 out[][L_FRAME48k], const Word16 *pq_fact );

@@ -9378,12 +9379,22 @@ static ivas_error renderInputMasa(
                case RENDERER_DIRAC:

                    copyMasaMetadataToDiracRenderer_fx( &masaInput->masaMetadata, masaInput->hMasaExtRend->hSpatParamRendCom, maxBin );
#ifndef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
                    intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 1 );
#endif
#ifdef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
                    FOR( ch = 0; ch < inAudio.config.numChannels; ch++ )
                    {
                        masaInput->hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = Q11;
                        move16();
                    }
#else
                    FOR( ch = 0; ch < masaInput->hMasaExtRend->hDirACRend->hOutSetup.nchan_out_woLFE + masaInput->hMasaExtRend->hDirACRend->hOutSetup.num_lfe; ch++ )
                    {
                        masaInput->hMasaExtRend->cldfbAnaRend[0]->Q_cldfb_state = Q11;
                        move16();
                    }
#endif
                    FOR( ch = 0; ch < inAudio.config.numChannels; ch++ )
                    {
                        Scale_sig32( tmpBuffer_buff_fx[ch], inAudio.config.numSamplesPerChannel, sub( Q11, *outAudio.pq_fact ) ); /* Q11 */
@@ -9403,7 +9414,9 @@ static ivas_error renderInputMasa(
                        move16();
                    }

#ifndef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
                    intermidiate_ext_dirac_render( masaInput->hMasaExtRend, 0 );
#endif
                    BREAK;
                case RENDERER_STEREO_PARAMETRIC:
                case RENDERER_BINAURAL_PARAMETRIC:
@@ -11329,6 +11342,7 @@ static void freeMasaExtRenderer(
    return;
}

#ifndef FIX_BASOP_2571_MASA_EXT_RENDER_FIXES
static void intermidiate_ext_dirac_render(
    MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure             */
    Word16 to_fix )
@@ -11565,7 +11579,7 @@ static void intermidiate_ext_dirac_render(

    return;
}

#endif

static ivas_error printConfigInfo_rend(
    IVAS_REND_HANDLE hIvasRend /* i  : IVAS renderer handle     */