Commit 2d8f1f60 authored by vaclav's avatar vaclav
Browse files

port UNIFIED_DECODING_PATHS_LEFTOVERS

parent 49da59d2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -195,7 +195,11 @@ typedef enum
#define MAX_JBM_L_FRAME48k                      1920
#define MAX_JBM_L_FRAME_NS                      40000000L
#define MAX_SPAR_INTERNAL_CHANNELS              IVAS_SPAR_MAX_CH
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
#define MAX_CLDFB_DIGEST_CHANNELS               3                           /* == maximum of ParamISM TCs and ParamMC TCs */
#else
#define MAX_CLDFB_DIGEST_CHANNELS               (FOA_CHANNELS + MAX_NUM_OBJECTS)
#endif

typedef enum
{
+6 −5
Original line number Diff line number Diff line
@@ -641,6 +641,7 @@ void ivas_jbm_dec_get_adapted_subframes_fx(
    Word16 *nb_subframes                                        /* i/o: number of subframes in the frame        */
);

#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS
void ivas_jbm_dec_copy_tc_no_tsm_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                 Q0  */
    Word32 *tc_fx[],                                            /* i  : transport channels                  Q11 */
@@ -654,7 +655,7 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
    Word32 *transport_channels_f[],                             /* i  : synthesized core-coder transport channels/DirAC output  Q_tc*/
    Word16 *Q_tc                                                /* i/o : Q of input tc buffer                   */
);

#endif
/*! r: number of bits read */
Word16 read_GR0(
    const UWord16 *bit_stream,                                  /* i  : bitstream to be read                    */
@@ -4353,8 +4354,8 @@ void ivas_ism_dec_digest_tc_fx(
void ivas_param_ism_dec_digest_tc_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                         */
    const UWord16 nCldfbSlots,                                  /* i  : number of CLDFB slots in transport channels */
    Word32 *transport_channels[],                               /* i  : synthesized core-coder transport channels/DirAC output  */
    const Word16 q_tc_in 
    Word32 *p_data_fx[],                                        /* i  : synthesized core-coder transport channels/DirAC output  */
    const Word16 q_data_in 
);


@@ -5163,8 +5164,8 @@ void ivas_param_mc_dec_close_fx(
void ivas_param_mc_dec_digest_tc_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                             */
    const UWord8 nCldfbSlots,                                   /* i  : number of CLFBS slots in the transport channels */
    Word32 *p_data_fx[],                                        /* i/o: synthesized core-coder transport channels/DirAC output */
    const Word16 transport_f_e
    Word32 *p_data_f[],                                         /* i/o: synthesized core-coder transport channels/DirAC output */
    const Word16 q_data_in
);

#ifdef OBJ_EDITING_API
+1 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@
#define FIX_1388_MSAN_ivas_init_decoder                 /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */
#define FIX_1288_SPLIT_REND_XSAN                        /* Dlb: Fix asan, msan and usan issues in split rendering mode*/
#define LIB_DEC_REVISION                                /* VA: cleaning and simplification of lib_dec.c */
#define UNIFIED_DECODING_PATHS_LEFTOVERS                /* VA: issue 880: remove leftovers after NONBE_UNIFIED_DECODING_PATHS */

// object-editing feature porting
#define OBJ_EDITING_INTERFACE                           /* Interface for object editing */
+1 −1
Original line number Diff line number Diff line
@@ -2076,7 +2076,7 @@ void ivas_dirac_dec_render_fx(
    move16();
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    Word32 *output_f_local_fx[MAX_OUTPUT_CHANNELS];
    Word32 output_f_local_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 }; // VE2SB: TBV
    Word32 output_f_local_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 };

    hSpatParamRendCom = st_ivas->hSpatParamRendCom;

+100 −44
Original line number Diff line number Diff line
@@ -44,6 +44,15 @@
#include "debug.h"


#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
/*-----------------------------------------------------------------------*
 * Local function declarations
 *-----------------------------------------------------------------------*/

static void ivas_ism_param_dec_tc_gain_adjust_fx( Decoder_Struct *st_ivas, const UWord16 nSamples, const UWord16 nFadeLength, Word32 *p_data_fx[], Word16 *q_data );

#endif

/*-----------------------------------------------------------------------*
 * Local function definitions
 *-----------------------------------------------------------------------*/
@@ -80,6 +89,7 @@ static void ivas_param_ism_dec_dequant_powrat_fx(
    PARAM_ISM_CONFIG_HANDLE hParamIsm;

    hParamIsm = hParamIsmDec->hParamIsm;

    /* Get the power ratio values */
    FOR( band_idx = 0; band_idx < hParamIsm->nbands; band_idx++ )
    {
@@ -91,6 +101,7 @@ static void ivas_param_ism_dec_dequant_powrat_fx(
            move16();
        }
    }

    return;
}

@@ -1102,9 +1113,16 @@ void ivas_ism_dec_digest_tc_fx(
void ivas_param_ism_dec_digest_tc_fx(
    Decoder_Struct *st_ivas,   /* i/o: IVAS decoder handle                                              */
    const UWord16 nCldfbSlots, /* i  : number of CLDFB slots in transport channels                      */
    Word32 *transport_channels[], /* i  : synthesized core-coder transport channels/DirAC output  q_tc_in   */
    const Word16 q_tc_in )
    Word32 *p_data_fx[],       /* i  : synthesized core-coder transport channels/DirAC output q_data_in */
    const Word16 q_data_in )
{
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    Word16 i, ch, slot_idx, output_frame;
    Word16 num_freq_bands, cldfb_ch, n_ch_cldfb;
    Word32 *cldfb_real_buffer, *cldfb_imag_buffer;
    Word16 q_data = q_data_in;
    move16();
#else
    move16();
    move16();
    move16();
@@ -1115,7 +1133,7 @@ void ivas_param_ism_dec_digest_tc_fx(
    Word16 exp_real_tmp = 0, exp_imag_tmp = 0;
#endif

    Word16 q_tc = q_tc_in;
    Word16 q_data = q_data_in;
    move16();
#ifndef OBJ_EDITING_API
    Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
@@ -1134,8 +1152,18 @@ void ivas_param_ism_dec_digest_tc_fx(
    PARAM_ISM_DEC_HANDLE hParamIsmDec;
    SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom;
    Word16 fade_len;
#endif

    /* Initialization */
#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands;
    move16();
    output_frame = imult1616( nCldfbSlots, num_freq_bands );
    n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full );

    cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx;
    cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx;
#else
#ifndef OBJ_EDITING_API
    set32_fx( &direct_response_fx[0][0], 0, MAX_NUM_OBJECTS * PARAM_ISM_MAX_CHAN );
#endif
@@ -1148,6 +1176,7 @@ void ivas_param_ism_dec_digest_tc_fx(

    nchan_transport = st_ivas->nchan_transport;
    move16();
#endif
#ifndef OBJ_EDITING_API
    ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
    move32();
@@ -1172,10 +1201,8 @@ void ivas_param_ism_dec_digest_tc_fx(
        move16();
    }
#endif

    push_wmops( "ivas_param_ism_dec" );

#ifndef OBJ_EDITING_API

    /* general setup */
    ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx );

@@ -1260,22 +1287,54 @@ void ivas_param_ism_dec_digest_tc_fx(
    }
#endif

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    ivas_ism_param_dec_tc_gain_adjust_fx( st_ivas, output_frame, shr( output_frame, 1 ), p_data_fx, &q_data );

    IF( NE_16( q_data, q_data_in ) )
    {
        FOR( i = 0; i < 2; i++ )
        {
            scale_sig32( p_data_fx[i], output_frame, sub( q_data_in, q_data ) ); // q_tc_in
        }
        q_data = q_data_in;
        move16();
    }
#else
    IF( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /*TODO : FhG to check*/
        ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, fade_len, transport_channels, &q_tc );

        IF( NE_16( q_tc, q_tc_in ) )
        ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas, output_frame, fade_len, p_data_fx, &q_data );
        IF( NE_16( q_data, q_data_in ) )
        {
            FOR( i = 0; i < 2; i++ )
            {
                scale_sig32( transport_channels[i], output_frame, sub( q_tc_in, q_tc ) ); // q_tc_in
                scale_sig32( p_data_fx[i], output_frame, sub( q_data_in, q_data ) ); // q_tc_in
            }
            q_tc = q_tc_in;
            q_data = q_data_in;
            move16();
        }
    }
#endif

#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
    /* CLDFB Analysis */
    FOR( ( ch = 0, cldfb_ch = 0 ); cldfb_ch < n_ch_cldfb; ( cldfb_ch++, ch++ ) )
    {
        FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ )
        {
            q_data = q_data_in;
            move16();
            cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][num_freq_bands * slot_idx] ),
                                         &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                                         &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands],
                                         num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &q_data );
            st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = sub( 31, q_data );
            move16();
            st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = sub( 31, q_data );
            move16();
        }
    }
#else
    FOR( ch = 0; ch < nchan_transport; ch++ )
    {
        /* CLDFB Analysis */
@@ -1285,9 +1344,9 @@ void ivas_param_ism_dec_digest_tc_fx(
            {
                Word32 RealBuffer_fx[CLDFB_NO_CHANNELS_MAX];
                Word32 ImagBuffer_fx[CLDFB_NO_CHANNELS_MAX];
                q_tc = q_tc_in;
                q_data = q_data_in;
                move16();
                cldfbAnalysis_ts_fx_fixed_q( &( transport_channels[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_tc );
                cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][hSpatParamRendCom->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hSpatParamRendCom->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_data );
                Copy32( RealBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
                Copy32( ImagBuffer_fx, &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[slot_idx * hSpatParamRendCom->num_freq_bands * nchan_transport + ch * hSpatParamRendCom->num_freq_bands], hSpatParamRendCom->num_freq_bands );
                hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = sub( 31, q_tc );
@@ -1334,11 +1393,10 @@ void ivas_param_ism_dec_digest_tc_fx(
    }

    /* Compute mixing matrix */
    ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag,
                                             hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx );
    ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx );

#endif
    pop_wmops();
#endif

    return;
}
@@ -1429,7 +1487,6 @@ void ivas_param_ism_dec_prepare_renderer_fx(
        nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE;
        move16();
    }
    push_wmops( "ivas_param_ism_dec_digest_tc" );

    /* general setup */
    ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx );
@@ -1557,34 +1614,34 @@ void ivas_param_ism_dec_prepare_renderer_fx(
    ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag,
                                             hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx );


    pop_wmops();

    return;
}

#endif

/*-------------------------------------------------------------------------*
 * ivas_ism_param_dec_tc_gain_ajust()
 * ivas_ism_param_dec_tc_gain_adjust()
 *
 *
 *-------------------------------------------------------------------------*/


#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS
static void ivas_ism_param_dec_tc_gain_adjust_fx(
#else
void ivas_ism_param_dec_tc_gain_ajust_fx(
#endif
    Decoder_Struct *st_ivas,   /* i/o: IVAS decoder handle                                          */
    const UWord16 nSamples,    /* i  : number of samples to be compensate                           */
    const UWord16 nFadeLength, /* i  : length of the crossfade in samples                           */
    Word32 *transport_channels_f[], /* i  : synthesized core-coder transport channels/DirAC output  Q_tc*/
    Word16 *Q_tc                    /* i/o : Q of input tc buffer                                       */
    Word32 *p_data_fx[],       /* i  : synthesized core-coder transport channels/DirAC output q_data*/
    Word16 *q_data             /* i/o: Q of input data buffer                                       */
)

{
    Word16 i, tmp_e1, tmp_e2, tmp, tmp2, invFade;
    Word32 L_tmp1, L_tmp2;

    Word16 gain_fx, last_gain_fx;
    Word32 ene_tc_fx, ene_sum_fx;

    Word16 ene_tc_e, ene_sum_e;

    ene_tc_fx = 0;
@@ -1596,7 +1653,6 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
    ene_sum_e = 0;
    move16();


    last_gain_fx = st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx;
    move16();

@@ -1613,14 +1669,13 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
        move16();
        ch1_e = 0;
        move16();
        ch0 = transport_channels_f[0][i];
        ch0 = p_data_fx[0][i];
        move16();
        ch1 = transport_channels_f[1][i];
        ch1 = p_data_fx[1][i];
        move16();
        ch0 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, 0, 0, &ch0_e );
        ch1 = BASOP_Util_Add_Mant32Exp( ch1, ch1_e, 0, 0, &ch1_e );


        L_tmp1 = Mpy_32_32( ch0, ch0 ); /*L*L*/
        tmp_e1 = add( ch0_e, ch0_e );
        L_tmp2 = Mpy_32_32( ch1, ch1 ); /*R*R*/
@@ -1629,7 +1684,6 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
        ene_tc_fx = BASOP_Util_Add_Mant32Exp( ene_tc_fx, ene_tc_e, L_tmp1, tmp_e1, &ene_tc_e );
        ene_tc_fx = BASOP_Util_Add_Mant32Exp( ene_tc_fx, ene_tc_e, L_tmp2, tmp_e2, &ene_tc_e );


        L_tmp1 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, ch1, ch1_e, &tmp_e1 ); /*L + R*/
        L_tmp1 = Mpy_32_32( L_tmp1, L_tmp1 );                                 // Q(31-(tmp_e1+tmp_e1           /*(L + R)*(L + R)*/
        tmp_e1 = add( tmp_e1, tmp_e1 );
@@ -1675,10 +1729,11 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
        last_gain_fx = shr( last_gain_fx, sub( tmp_e1, tmp_e2 ) ); // Q(15-tmp_e1)
    }

    IF( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame > 1 )
    IF( GT_16( st_ivas->hSCE[0]->hCoreCoder[0]->ini_frame, 1 ) )
    {
        /* Smoothing */
        gain_fx = add( mult_r( 24574, gain_fx ), mult_r( 8192, last_gain_fx ) ); // 24574 =.75f in Q15 , 8192=.25f in Q15

        /* 10ms ramp */
        /* slope between two consecutive gains, 480 samples length */
        invFade = div_s( 1, nFadeLength ); // Q15
@@ -1689,18 +1744,18 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
            /* tmp2 = ( last_gain_fx + i * grad_fx )*/
            tmp2 = add( mult_r( sub( 32767, tmp ), last_gain_fx ), mult_r( tmp, gain_fx ) ); // 32767= 1.0f in Q15,

            transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], tmp2 ); // Q(Q_tc-tmp_e1)
            p_data_fx[0][i] = Mpy_32_16_1( p_data_fx[0][i], tmp2 ); // Q(Q_tc-tmp_e1)
            move32();
            transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], tmp2 ); // Q(Q_tc-tmp_e1)
            p_data_fx[1][i] = Mpy_32_16_1( p_data_fx[1][i], tmp2 ); // Q(Q_tc-tmp_e1)
            move32();

            tmp = add( tmp, invFade );
        }
        FOR( ; i < nSamples; i++ )
        {
            transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], gain_fx ); // Q(Q_tc-tmp_e1)
            p_data_fx[0][i] = Mpy_32_16_1( p_data_fx[0][i], gain_fx ); // Q(Q_tc-tmp_e1)
            move32();
            transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], gain_fx ); // Q(Q_tc-tmp_e1)
            p_data_fx[1][i] = Mpy_32_16_1( p_data_fx[1][i], gain_fx ); // Q(Q_tc-tmp_e1)
            move32();
        }
    }
@@ -1708,9 +1763,9 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
    {
        FOR( i = 0; i < nSamples; i++ )
        {
            transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], gain_fx ); // Q(Q_tc-tmp_e1)
            p_data_fx[0][i] = Mpy_32_16_1( p_data_fx[0][i], gain_fx ); // Q(Q_tc-tmp_e1)
            move32();
            transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], gain_fx ); // Q(Q_tc-tmp_e1)
            p_data_fx[1][i] = Mpy_32_16_1( p_data_fx[1][i], gain_fx ); // Q(Q_tc-tmp_e1)
            move32();
        }
    }
@@ -1720,8 +1775,9 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
    st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e = tmp_e1;
    move16();

    *Q_tc = sub( *Q_tc, tmp_e1 );
    *q_data = sub( *q_data, tmp_e1 );
    move16();

    return;
}

Loading