Commit 48896bdd authored by vaclav's avatar vaclav
Browse files

port UNIFIED_DECODING_PATHS_LEFTOVERS

parent e51b4fce
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 −13
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                    */
@@ -4249,14 +4250,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    const Word16 nSamplesForRendering,                          /* i  : number of TC samples available for rendering                */
    Word16 *nSamplesResidual,                                   /* o  : number of samples not fitting into the renderer grid and buffer for the next call*/
    Word32 *data                                                /* i/o: transport channels/output synthesis signal                  */
);

void ivas_jbm_dec_feed_tc_to_renderer_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                                      */
    const Word16 nSamplesForRendering,                          /* i  : number of TC samples available for rendering                */
    Word16 *nSamplesResidual,                                   /* o  : number of samples not fitting into the renderer grid and buffer for the next call*/
    Word32 *data                                                /* i/o: transport channels/output synthesis signal                  */
    Word32 *data_fx                                             /* i/o: transport channels/output synthesis signal                  */
);

#ifdef OBJ_EDITING_API
@@ -4353,11 +4347,10 @@ 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                                      /* i  : Q-factor of input signal for single channel */
);


#ifdef OBJ_EDITING_API
void ivas_param_ism_dec_dequant_md_fx(
    Decoder_Struct *st_ivas                                     /* i/o: IVAS decoder handle                         */
@@ -5164,7 +5157,7 @@ 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
    const Word16 q_data                                         /* i  : Q-factor of input signal for single channel     */
);

#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;

+96 −38
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 Word16 nSamples, const Word16 nFadeLength, Word32 *p_data_fx[], Word16 *q_data );

#endif

/*-----------------------------------------------------------------------*
 * Local function definitions
 *-----------------------------------------------------------------------*/
@@ -580,6 +589,7 @@ static void ivas_param_ism_update_mixing_matrix_fx(
 *
 * Open Param ISM handle
 *-------------------------------------------------------------------------*/

ivas_error ivas_param_ism_dec_open_fx(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
)
@@ -917,6 +927,7 @@ void ivas_param_ism_dec_close_fx(
 *
 *
 *-------------------------------------------------------------------------*/

void ivas_ism_dec_digest_tc_fx(
    Decoder_Struct *st_ivas /* i/o: IVAS decoder structure      */
)
@@ -1102,9 +1113,17 @@ 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     /* i  : Q-factor of input signal for single channel                      */
)
{
#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 +1134,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_tc = q_data_in;
    move16();
#ifndef OBJ_EDITING_API
    Word16 ch, nchan_transport, nchan_out, nchan_out_woLFE, i;
@@ -1134,8 +1153,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, hSpatParamRendCom->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
@@ -1172,9 +1201,7 @@ void ivas_param_ism_dec_digest_tc_fx(
        move16();
    }
#endif

    push_wmops( "ivas_param_ism_dec" );

#endif
#ifndef OBJ_EDITING_API
    /* general setup */
    ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx );
@@ -1259,7 +1286,19 @@ 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_data_in
        }
        q_data = q_data_in;
        move16();
    }
#else
    IF( st_ivas->hDecoderConfig->Opt_tsm )
    {
        /*TODO : FhG to check*/
@@ -1275,7 +1314,29 @@ void ivas_param_ism_dec_digest_tc_fx(
            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 */
@@ -1336,9 +1397,8 @@ 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 );

#endif
    pop_wmops();
#endif

    return;
}
@@ -1429,7 +1489,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 +1616,33 @@ 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                                       */
    const Word16 nSamples,    /* i  : number of samples to be compensate                            */
    const Word16 nFadeLength, /* i  : length of the crossfade in samples                            */
    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 +1654,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 +1670,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 +1685,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 );
@@ -1679,6 +1734,7 @@ void ivas_ism_param_dec_tc_gain_ajust_fx(
    {
        /* 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 +1745,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 +1764,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,16 +1776,19 @@ 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;
}


/*-------------------------------------------------------------------------*
 * ivas_ism_param_dec_render_sf()
 *
 *
 *-------------------------------------------------------------------------*/

static void ivas_ism_param_dec_render_sf_fx(
    Decoder_Struct *st_ivas,
    IVAS_OUTPUT_SETUP hSetup,
@@ -1752,12 +1811,14 @@ static void ivas_ism_param_dec_render_sf_fx(
    Word16 idx_lfe;
    Word16 subframe_idx;
    Word16 samplesProcessed, no_col_cldfb, size_cldfb;

    hParamIsmDec = st_ivas->hParamIsmDec;
    hSpatParamRendCom = st_ivas->hSpatParamRendCom;
    slot_idx_start = hSpatParamRendCom->slots_rendered;
    move16();
    subframe_idx = hSpatParamRendCom->subframes_rendered;
    move16();

    /* Set some memories to zero */
    FOR( ch = 0; ch < nchan_out_woLFE; ch++ )
    {
@@ -1768,7 +1829,6 @@ static void ivas_ism_param_dec_render_sf_fx(
        }
    }


    Word16 real_exp[JBM_CLDFB_SLOTS_IN_SUBFRAME];
    Word16 imag_exp[JBM_CLDFB_SLOTS_IN_SUBFRAME];
    FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ )
@@ -1815,7 +1875,6 @@ static void ivas_ism_param_dec_render_sf_fx(
        }
        ELSE
        {

            Word32 *RealBuffer_fx[16];
            Word32 *ImagBuffer_fx[16];

@@ -2059,7 +2118,6 @@ void ivas_param_ism_params_to_masa_param_mapping_fx(
    }
#endif


    IF( st_ivas->hISMDTX.dtx_flag )
    {
        Word32 energy_ratio_fx;                                                                                                                                                /* Q30 */
Loading