Commit 1c1ac790 authored by vaclav's avatar vaclav
Browse files

Merge branch '1957-basop-PortFlpMr2106' into 'main'

Port MR2106 from float to BASOP

Closes #1957

See merge request !2152
parents 69a83006 216fae66
Loading
Loading
Loading
Loading
Loading
+140 −142
Original line number Diff line number Diff line
@@ -2162,7 +2162,8 @@ ivas_error only_reduce_bits_direction_fx(
    Word16 reduce_bits,
    const Word16 coding_subbands,
    const Word16 no_subframes,
    Word16 *ind_order );
    Word16 *ind_order 
);

void ivas_qmetadata_azimuth_elevation_to_direction_vector_fx(
    const Word32 az, /* i  : azimuth                            Q22     */
@@ -2276,7 +2277,6 @@ void stereo_dtf_cng_fx(
    Word16 q_dft                                                /* i  : Q factor of the DFT data                    */
);


void ivas_spar_update_md_hist_fx(
    ivas_spar_md_dec_state_t *hMdDec                            /* i/o: SPAR MD decoder handle                      */
);
@@ -2304,8 +2304,14 @@ void ivas_dirac_dec_render_sf_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                      */
    Word32 *output_fx[],                                        /* i/o: synthesized core-coder transport channels/DirAC output  */
    const Word16 nchan_transport,                               /* i  : number of transport channels                */
#ifdef FIX_1319_STACK_SBA_DECODER
    Word32 *pppQMfFrame_ts_re_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX],
    Word32 *pppQMfFrame_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX]
#else
    Word32 *pppQMfFrame_ts_re_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX],
    Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] );
    Word32 *pppQMfFrame_ts_im_fx[IVAS_MAX_FB_MIXER_IN_CH][CLDFB_NO_COL_MAX] 
#endif
);

void ivas_dirac_dec_render_fx(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder handle                         */
@@ -2437,7 +2443,8 @@ ivas_error PsychoacousticParameters_Init_fx(
    const Word8 nBands,                                         /* i  : Number of spectrum subbands                                     */
    const Word16 isTCX20,                                       /* i  : Flag indicating if the subband division is for TCX20 or TCX10   */
    const Word16 isWarped,                                      /* i  : Flag indicating if the scale is linear or warped                */
    PsychoacousticParameters *pPsychParams );
    PsychoacousticParameters *pPsychParams 
);

ivas_error ivas_FB_mixer_open_fx(
    IVAS_FB_MIXER_HANDLE *hFbMixer_out,                         /* i/o: FB mixer handle                             */
@@ -2464,7 +2471,8 @@ void ivas_fb_mixer_cross_fading_fx(
    Word32 *pMdft_out_new_fx,
    const Word16 ch,
    const Word16 frame_len,
    const Word16 cf_offset );
    const Word16 cf_offset 
);

// ivas_omasa_dec.c
ivas_error ivas_omasa_dirac_td_binaural_jbm_fx(
@@ -2494,13 +2502,15 @@ Word16 ivas_sba_spar_sid_bitlen_fx(
void ivas_sba_get_spar_hoa_ch_ind_fx(
    const Word16 num_md_chs,       /* i  : number of MD channels       */
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate           */
    Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] );
    Word16 HOA_md_ind[IVAS_SPAR_MAX_CH] 
);

void ivas_sba_get_spar_hoa_md_flag_fx(
    const Word16 sba_order,        /* i  : Ambisonic (SBA) order        */
    const Word32 ivas_total_brate, /* i  : IVAS total bitrate           */
    Word16 *spar_hoa_md_flag,
    Word16 *spar_hoa_dirac2spar_md_flag );
    Word16 *spar_hoa_dirac2spar_md_flag 
);

void ivas_omasa_dirac_rend_jbm_fx(
    Decoder_Struct *st_ivas,      /* i/o: IVAS decoder handle                      */
@@ -2637,28 +2647,15 @@ Word16 getNumChanAnalysis_fx(
    Encoder_Struct *st_ivas /* i  : IVAS encoder structure              */
);


/*----------------------------------------------------------------------------------*
 * Limiter prototypes
 *----------------------------------------------------------------------------------*/


ivas_error ivas_limiter_open(
    IVAS_LIMITER_HANDLE *hLimiter_out, /* o  : limiter struct handle                   */
    const int16_t num_channels,        /* i  : number of I/O channels                  */
    const int32_t sampling_rate        /* i  : sampling rate for processing            */
);

void ivas_limiter_close(
    IVAS_LIMITER_HANDLE *phLimiter /* i/o: pointer to limiter handle, can be NULL  */
);

void ivas_limiter_dec(
    IVAS_LIMITER_HANDLE hLimiter,       /* i/o: limiter struct handle                                           */
    float *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer                                             */
    const int16_t num_channels,         /* i  : number of channels to be processed                              */
    const int16_t output_frame,         /* i  : number of samples per channel in the buffer                     */
    const int16_t BER_detect            /* i  : BER detect flag                                                 */
);
void ivas_limiter_dec_fx(
    IVAS_LIMITER_HANDLE hLimiter,        /* i/o: limiter struct handle                                           */
    Word32 *output[MAX_OUTPUT_CHANNELS], /* i/o: input/output buffer                                             */
@@ -2667,13 +2664,7 @@ void ivas_limiter_dec_fx(
    const Word16 BER_detect,             /* i  : BER detect flag                                                 */
    Word16 q_factor                      /* i  : Q factor of the output samples                                  */
);
void limiter_process(
    IVAS_LIMITER_HANDLE hLimiter,  /* i/o: limiter struct handle                                           */
    const int16_t output_frame,    /* i  : number of samples to be processed per channel in the I/O buffer */
    const float threshold,         /* i  : signal amplitude above which limiting starts to be applied      */
    const int16_t BER_detect,      /* i  : BER detect flag                                                 */
    int16_t *strong_saturation_cnt /* i/o: counter of strong saturations (can be NULL)                     */
);

void limiter_process_fx(
    IVAS_LIMITER_HANDLE hLimiter,  /* i/o: limiter struct handle                                              */
    const Word16 output_frame,     /* i  : number of samples to be processed per channel in the I/O buffer    */
@@ -2722,13 +2713,15 @@ void ivas_lfe_lpf_enc_apply_fx(
// ivas_arith.c
void ivas_ari_done_encoding_14bits_fx(
    BSTR_ENC_HANDLE hBstr,
    Tastat *s );
    Tastat *s 
);

void ivas_ari_encode_14bits_ext_fx(
    BSTR_ENC_HANDLE hBstr,
    Tastat *s,
    Word32 symbol,
    const UWord16 *cum_freq );
    const UWord16 *cum_freq 
);

void ms_inv_mask_processing_fx(
    STEREO_MDCT_ENC_DATA_HANDLE hStereoMdct, /* i/o: MDCT encoder structure                  */
@@ -2839,6 +2832,7 @@ void ivas_spar_bitrate_dist_fx(
    const Word16 sba_order,        /* i  : Ambisonic (SBA) order                   */
    const Word16 bwidth            /* i  : audio bandwidth                         */
);

ivas_error ivas_corecoder_enc_reconfig_fx(
    Encoder_Struct *st_ivas,          /* i/o: IVAS encoder structure                */
    const Word16 nSCE_old,            /* i  : number of SCEs in previous frame      */
@@ -2855,6 +2849,7 @@ void ivas_sba_zero_vert_comp_fx(
    const Word16 sba_planar, /* i  : SBA planar flag             */
    const Word16 input_frame /* i  : frame length                */
);

void tdm_configure_dec_fx(
    const Word16 ivas_format,     /* i  : IVAS format                     */
    const Word16 ism_mode,        /* i  : ISM mode in combined format     */
@@ -2877,6 +2872,7 @@ Word16 mdct_classifier_ivas_fx(
    const Word32 brate         /* i  : current brate, IVAS: nominal bitrate, EVS: st->total_brate */
);


/*----------------------------------------------------------------------------------*
 * Range Coder prototypes
 *----------------------------------------------------------------------------------*/
@@ -6380,7 +6376,6 @@ void tdm_bit_alloc(
    const Word16 tdm_inst_ratio_idx                            /* i  : instantaneous correlation ratio index   */
);


/*! r: value of the indice */
uint16_t get_indice_st(
    Decoder_State *st,                                          /* i/o: decoder state structure                 */
@@ -6389,6 +6384,7 @@ uint16_t get_indice_st(
    const Word16 nb_bits                                        /* i  : number of bits to quantize the indice   */
);


/*----------------------------------------------------------------------------------*
 * MDCT Stereo prototypes
 *----------------------------------------------------------------------------------*/
@@ -6409,9 +6405,11 @@ Word16 write_stereo_to_bitstream_fx
    BSTR_ENC_HANDLE hBstr                                       /* i/o: bitstream handle                        */
);


/*----------------------------------------------------------------------------------*
 * Stereo CNG prototypes
 *----------------------------------------------------------------------------------*/

void stereo_cng_dec_update(
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure                   */
    const Word32 ivas_total_brate                               /* i  : IVAS total bitrate                    Q0*/
+1 −0
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@
#define NONBE_1244_FIX_SWB_BWE_MEMORY                   /* VA: issue 1244: fix to SWB BWE memory in case of switching from FB coding - pending a review by Huawei */
#define FIX_1129_EXT_REND_OUTPUT_HIGH                   /* Philips: issue 1129: External renderer BINAURAL_ROOM_REVERB format output level too high compared to internal rendering output */
#define NONBE_1328_FIX_NON_LINEARITY                    /* VA: Fix possible issue when computing bwe_exc_extended and previous frame were almost 0, float issue 1328  */
#define FIX_1319_STACK_SBA_DECODER                      /* VA: issue 1319: Optimize the definition of buffer lengths in the SBA decoder */

/* #################### End BASOP porting switches ############################ */

+172 −32

File changed.

Preview size limit exceeded, changes collapsed.

+29 −7
Original line number Diff line number Diff line
@@ -808,6 +808,7 @@ void ivas_spar_get_cldfb_gains_fx(
        tgt_fx[sample] = L_shl( Mpy_32_32( tgt_fx[sample], L_add( T_fx[sample][0], L_add( T_fx[sample][1], T_fx[sample][2] ) ) ), 10 ); /*Q31*/
        move32();
    }

    /* compute matrices */
    FOR( slot_row = 0; slot_row < num_cf_slots; slot_row++ )
    {
@@ -842,6 +843,7 @@ void ivas_spar_get_cldfb_gains_fx(
    Word16 output_q = 27;
    move16();
    matrix_inverse_fx( Tt_T_fx, Tt_T_inv_fx, num_cf_slots, &output_q );

    /* compute the optimal coefficients */
    FOR( slot_row = 0; slot_row < num_cf_slots; slot_row++ )
    {
@@ -862,6 +864,8 @@ void ivas_spar_get_cldfb_gains_fx(

    return;
}


Word16 ivas_is_res_channel(
    const Word16 ch,             /* i  : ch index in WYZX ordering          Q0*/
    const Word16 nchan_transport /* i  : number of transport channels (1-4) Q0*/
@@ -1190,8 +1194,6 @@ void ivas_spar_get_parameters_fx(
            }
            ELSE
            {


                FOR( spar_band = 0; spar_band < num_spar_bands; spar_band++ )
                {
                    FOR( in_ch = 0; in_ch < num_ch_in; in_ch++ )
@@ -1220,6 +1222,7 @@ void ivas_spar_get_parameters_fx(
            }
        }
    }

    return;
}

@@ -1316,8 +1319,10 @@ static void ivas_spar_calc_smooth_facs_fx(
    Word32 smooth_short_avg_fx[IVAS_MAX_NUM_BANDS];
    Word32 L_temp;
    Word16 exp_tmp, q_tmp;

    bin = 0;
    move16();

    FOR( b = 0; b < nbands_spar; b++ )
    {
        test();
@@ -1640,7 +1645,6 @@ void ivas_spar_dec_digest_tc_fx(

            IF( hSpar->hTdDecorr )
            {

                ivas_td_decorr_process_fx( hSpar->hTdDecorr, p_tc, pPcm_tmp, nSamplesToDecorr );
                st_ivas->hTcBuffer->q_tc_fx = s_min( st_ivas->hTcBuffer->q_tc_fx, q_format );
                move16();
@@ -1691,15 +1695,25 @@ void ivas_spar_dec_upmixer_sf_fx(
)
{
    Word16 cldfb_band, num_cldfb_bands, numch_in, numch_out;
#ifdef FIX_1319_STACK_SBA_DECODER
    Word32 *cldfb_in_ts_re_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX];
    Word32 *cldfb_in_ts_im_fx[HOA3_CHANNELS][CLDFB_NO_COL_MAX];
#else
    Word32 *cldfb_in_ts_re_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX];
    Word32 *cldfb_in_ts_im_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX];
#endif
    Word16 i, b, ts, out_ch, in_ch;
    Word16 num_spar_bands, spar_band, nchan_transport;
    Word16 num_in_ingest, split_band;
    Word16 slot_size, slot_idx_start;
    Word16 md_idx;
#ifdef FIX_1319_STACK_SBA_DECODER
    Word32 *p_tc_fx[HOA3_CHANNELS];
    Word32 Pcm_tmp_fx[HOA3_CHANNELS][2 /* Re, Im*/ * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES];
#else
    Word32 *p_tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
    Word32 Pcm_tmp_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k];
#endif
    Word16 numch_out_dirac;
    Word32 mixer_mat_fx[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS];
    Word16 b_skip_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH];
@@ -1709,6 +1723,7 @@ void ivas_spar_dec_upmixer_sf_fx(
    Word16 q1 = 30;
    Word16 prod;
    move16();

    push_wmops( "ivas_spar_dec_upmixer_sf_fx" );
    hSpar = st_ivas->hSpar;
    hDecoderConfig = st_ivas->hDecoderConfig;
@@ -1760,7 +1775,6 @@ void ivas_spar_dec_upmixer_sf_fx(
        }
    }


    /*---------------------------------------------------------------------*
     * TD Decorr and pcm ingest
     *---------------------------------------------------------------------*/
@@ -1783,17 +1797,25 @@ void ivas_spar_dec_upmixer_sf_fx(
    hSpar->hFbMixer->fb_cfg->num_in_chans = num_in_ingest; /*Q0*/
    move16();


    /*---------------------------------------------------------------------*
     * Prepare CLDFB buffers
     *---------------------------------------------------------------------*/

#ifdef FIX_1319_STACK_SBA_DECODER
    set_zero_fx( &Pcm_tmp_fx[0][0], HOA3_CHANNELS * 2 * L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES );
#else
    set_zero_fx( &Pcm_tmp_fx[0][0], ( MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ) * L_FRAME48k );
#endif

    /* set-up pointers */
    IF( NE_32( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_FOA ) )
    {
        /* at this point, output channels are used as intermediate procesing buffers */
#ifdef FIX_1319_STACK_SBA_DECODER
        FOR( in_ch = 0; in_ch < HOA3_CHANNELS; in_ch++ )
#else
        FOR( in_ch = 0; in_ch < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; in_ch++ )
#endif
        {
            FOR( ts = 0; ts < MAX_PARAM_SPATIAL_SUBFRAMES; ts++ )
            {
@@ -1828,7 +1850,6 @@ void ivas_spar_dec_upmixer_sf_fx(
    numch_out_dirac = hDecoderConfig->nchan_out;
    move16();


    /* CLDFB analysis of incoming frame */
    FOR( in_ch = 0; in_ch < numch_in; in_ch++ )
    {
@@ -1894,6 +1915,7 @@ void ivas_spar_dec_upmixer_sf_fx(
                }
            }
        }

        /* Note: This version splits the cldfb band loop into 2 loops, removing some inner-loop IF_statements */
        Word16 min_cldf_band = s_min( CLDFB_PAR_WEIGHT_START_BAND, num_cldfb_bands );
        Word32 out_re_fx[IVAS_SPAR_MAX_CH];
@@ -1935,7 +1957,6 @@ void ivas_spar_dec_upmixer_sf_fx(
            }
        }


        /* Second loop from min_cldf_band (CLDFB_PAR_WEIGHT_START_BAND) till num_cldfb_bands */
        FOR( ; cldfb_band < num_cldfb_bands; cldfb_band++ )
        {
@@ -1975,6 +1996,7 @@ void ivas_spar_dec_upmixer_sf_fx(
                move32();
            }
        }

        test();
        IF( ( EQ_16( ( add( add( slot_idx_start, ts ), 1 ) ), hSpar->num_slots ) ) || ( NE_16( ( shr( md_idx, 2 ) /* md_idx / JBM_CLDFB_SLOTS_IN_SUBFRAME */ ), ( hSpar->render_to_md_map[( ( slot_idx_start + ts ) + 1 )] / JBM_CLDFB_SLOTS_IN_SUBFRAME /*It's value is 4*/ ) ) ) )
        {