Commit fa8f9ea6 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

fix porting issues in ivas_param_mc_dec_prepare_renderer

parent 21ac6fe5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -5190,7 +5190,7 @@ void ivas_param_mc_dec_digest_tc_fx(
#ifdef OBJ_EDITING_API
void ivas_param_mc_dec_prepare_renderer(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                                 */
    const UWord16 nCldfbSlots                                   /* i  : number of CLFBS slots in the transport channels     */
    const UWord8 nCldfbSlots                                   /* i  : number of CLFBS slots in the transport channels     */
);
#endif

+291 −159
Original line number Diff line number Diff line
@@ -1645,8 +1645,10 @@ void ivas_param_mc_dec_digest_tc_fx(
#endif

        /* slot loop for gathering the input data */
        FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ){
            IF( st_ivas->hDecoderConfig->Opt_tsm ){
        FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
        {
            IF( st_ivas->hDecoderConfig->Opt_tsm )
            {
#ifndef OBJ_EDITING_API
                IF( param_band_idx == 0 ) /* only run cldfbAna once */
                {
@@ -1671,6 +1673,7 @@ void ivas_param_mc_dec_digest_tc_fx(
                }
#endif
            }

#ifndef OBJ_EDITING_API
            IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) )
            {
@@ -1714,11 +1717,145 @@ IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) )
#endif
        }

#ifndef OBJ_EDITING_API
        Word16 tmp_cx_e, tmp_cx_imag_e;
        /* map from complex input covariance to real values */
        FOR( is_next_band = 0; is_next_band < 2; is_next_band++ )
        {
            test();
            IF( is_next_band && skip_next_band )
            {
                CONTINUE;
            }
            /* Cx for transport channels */
            IF( is_next_band )
            {
                pCx = &cx_next_band_fx[0];
                pCx_imag = &cx_imag_next_band_fx[0];
                tmp_cx_e = cx_next_band_e;
                tmp_cx_imag_e = cx_imag_next_band_e;
            }
            ELSE
            {
                pCx = &cx_fx[0];
                pCx_imag = &cx_imag_fx[0];
                tmp_cx_e = cx_e;
                tmp_cx_imag_e = cx_imag_e;
            }

            FOR( i = 0; i < nchan_transport * nchan_transport; i++ )
            {
                real_part_fx = pCx[i]; // Q(31 - cx_buff_e)
                imag_part_fx = pCx_imag[i];
                move32();
                move32();
                cx_buff_e[is_next_band][i] = tmp_cx_e;
                move16();
                /* (a-ib)(c+id) = ac + bd + i(ad-bc) */
                IF( LT_16( param_band_idx, hParamMC->max_param_band_abs_cov ) )
                {
                    L_tmp1 = Mpy_32_32( real_part_fx, real_part_fx );
                    L_tmp2 = Mpy_32_32( imag_part_fx, imag_part_fx );
                    L_tmp1 = BASOP_Util_Add_Mant32Exp( L_tmp1, add( tmp_cx_e, tmp_cx_e ), L_tmp2, add( tmp_cx_imag_e, tmp_cx_imag_e ), &tmp_e );
                    pCx[i] = Sqrt32( L_tmp1, &tmp_e );
                    move32();
                    cx_buff_e[is_next_band][i] = tmp_e;
                    move16();
                }
                ELSE
                {
                    pCx[i] = real_part_fx;
                    move32();
                    cx_buff_e[is_next_band][i] = tmp_cx_e;
                    move16();
                }
            }
        }

        max_e = cx_buff_e[0][0];
        move16();

        /* Cx for transport channels */
        FOR( is_next_band = 0; is_next_band < 2; is_next_band++ )
        {
            FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ )
            {

                IF( LT_16( max_e, cx_buff_e[is_next_band][i] ) )
                {
                    max_e = cx_buff_e[is_next_band][i];
                }
            }
        }
        /* Cx for transport channels */
        FOR( is_next_band = 0; is_next_band < 2; is_next_band++ )
        {
            FOR( i = 0; i < imult1616( nchan_transport, nchan_transport ); i++ )
            {
                if ( is_next_band == 0 )
                {
                    cx_fx[i] = L_shr( cx_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) );
                }
                else
                {
                    cx_next_band_fx[i] = L_shr( cx_next_band_fx[i], sub( max_e, cx_buff_e[is_next_band][i] ) );
                }
                move32();
            }
        }
        cx_e = max_e;
        move16();


        /* we have to do it similar to the encoder in case of attacks (i.e. accumulate two bands) to ensure correct DMX of the target covariance*/

        test();
        test();
        IF( hParamMC->hMetadataPMC->bAttackPresent && ( EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_LS_CONV_COV ) || EQ_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) )
        {
            Word16 len = imult1616( nchan_transport, nchan_transport );
            Word16 sc = s_min( getScaleFactor32( cx_fx, len ), getScaleFactor32( cx_next_band_fx, len ) );
            IF( EQ_16( sc, 0 ) )
            {
                Scale_sig32( cx_fx, len, -Q1 );           // add one bit head room
                Scale_sig32( cx_next_band_fx, len, -Q1 ); // add one bit head room
                cx_e = add( cx_e, Q1 );
                cx_next_band_e = add( cx_e, Q1 );
            }
            v_add_fx( cx_fx, cx_next_band_fx, cx_fx, len );
            Copy32( cx_fx, cx_next_band_fx, len );
        }

        FOR( is_next_band = 0; is_next_band < 2; is_next_band++ )
        {
            test();
            IF( is_next_band && skip_next_band )
            {
                CONTINUE;
            }

            IF( NE_32( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) )
            {
                IF( is_next_band )
                {

                    ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_next_band_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
                }
                ELSE
                {

                    ivas_param_mc_get_mixing_matrices_fx( hParamMC, hSynthesisOutputSetup, cx_fx, cx_e, add( param_band_idx, is_next_band ), hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_out_transport, hParamMC->synthesis_conf, nchan_transport, nchan_out_cov );
                }
            }
        }
    }
#endif
    pop_wmops();

    return;
}


#ifdef OBJ_EDITING_API
/*-------------------------------------------------------------------------
 * ivas_param_mc_dec_prepare_renderer()
@@ -1728,16 +1865,16 @@ return;

void ivas_param_mc_dec_prepare_renderer(
    Decoder_Struct *st_ivas,  /* i/o: IVAS decoder handle                                       */
    const UWord16 nCldfbSlots /* i  : number of CLFBS slots in the transport channels           */
    const UWord8 nCldfbSlots /* i  : number of CLFBS slots in the transport channels           */
)
{
    PARAM_MC_DEC_HANDLE hParamMC;
    Word16 i;
    Word16 is_next_band, skip_next_band;
    Word16 slot_idx, param_band_idx;
    Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb;
    Word16 nchan_out_cov;
    /*CLDFB*/
    PARAM_MC_DEC_HANDLE hParamMC;

    Word32 *pCx, *pCx_imag;
    Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];                // Q(31 - cx_e)
    Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS];           // Q(31 - cx_imag_e)
@@ -1759,7 +1896,7 @@ void ivas_param_mc_dec_prepare_renderer(
    hParamMC = st_ivas->hParamMC;
    assert( hParamMC );

    push_wmops( "param_mc_dec_digest_tc" );
    set16_fx( channel_active, 0, MAX_CICP_CHANNELS );

    nchan_transport = st_ivas->nchan_transport;
    move16();
@@ -1841,9 +1978,9 @@ void ivas_param_mc_dec_prepare_renderer(
        cx_imag_next_band_e = 0;
        move16();
     
        /* slot loop for gathering the input data */
        FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
        {
            /* slot loop for gathering the input data */
           IF( GE_16( slot_idx, shl( hParamMC->hMetadataPMC->attackIndex, 1 ) ) )
            {
                FOR( is_next_band = 0; is_next_band < 2; is_next_band++ )
@@ -1883,7 +2020,7 @@ void ivas_param_mc_dec_prepare_renderer(
                    }
                }
            }

	}
        Word16 tmp_cx_e, tmp_cx_imag_e;
        /* map from complex input covariance to real values */
        FOR( is_next_band = 0; is_next_band < 2; is_next_band++ )
@@ -2016,11 +2153,6 @@ void ivas_param_mc_dec_prepare_renderer(
        }
    }
}

    pop_wmops();

    return;
}
#endif

/*-------------------------------------------------------------------------