Commit 139eee46 authored by fotopoulou's avatar fotopoulou
Browse files

Merge branch 'main' into 874-phase-inversion-in-the-left-channel-of-the-32kbps-stereo-synthesis

parents 3b101a3e 48a885f2
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -808,6 +808,7 @@ float getTcxBandwidth_flt(
    return tcxBandwidth;
}

#ifndef IVAS_FLOAT_FIXED
/*-------------------------------------------------------------------*
 * getIgfPresent()
 *
@@ -905,7 +906,7 @@ int16_t getIgfPresent(

    return igfPresent;
}

#else
Word16 getIgfPresent_fx(
    const Word16 element_mode, /* i  : IVAS element mode           */
    const Word32 total_brate,  /* i  : total bitrate               */
@@ -1009,6 +1010,8 @@ Word16 getIgfPresent_fx(

    return igfPresent;
}
#endif

/*-------------------------------------------------------------------*
 * getCnaPresent()
 *
+2 −2
Original line number Diff line number Diff line
@@ -29,9 +29,9 @@ Word32 floatToFixed( float f, Word16 Q )
float fixedToFloat( Word32 i, Word16 Q )
{
    if ( Q < 0 )
        return ( i * (float) ( ( (unsigned) 1 ) << ( -Q ) ) );
        return ( i * (float) ( ( 1LL ) << ( -Q ) ) );
    else
        return (float) ( i ) / (float) ( (unsigned int) 1 << Q );
        return (float) ( i ) / (float) ( 1LL << Q );
}
void floatToFixed_arrL( float *f, Word32 *i, Word16 Q, Word16 l )
{
+9 −2
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
#define PI_OVER_180_Q22                         ( 73204 )
#define _180_OVER_PI                            ( 180.0f / EVS_PI )
#ifdef IVAS_FLOAT_FIXED
#define _180_OVER_PI_Q25                         1922521886
#define _180_OVER_PI_Q25                         1922527338
#define PI_OVER_180_Q25                         ( 585635 )
#define _180_IN_Q22 (754974720)
#define _360_IN_Q22 (1509949440)
@@ -1263,7 +1263,7 @@ enum
#endif
#define BITS_MASA2TOTTAL_DCT0                   6
#define STEP_M2T                                0.1f
#define STEP_M2T_FX                             214748364
#define STEP_M2T_FX                             214748365
#define MASA_HEADER_BITS                        2
#define MASA_SUBFRAME_BITS                      1
#define MASA_LOWBITRATE_MODE_BITS               1
@@ -1648,6 +1648,13 @@ typedef enum
#define LFE_PLC_LENANA                          LFE_PLC_BUFLEN
#define LFE_PLC_FDEL                            300

/*----------------------------------------------------------------------------------*
 * HO Dirac Constants
 *----------------------------------------------------------------------------------*/
#define HODIRAC_BETA                            (214748368)                 /* 0.2f in Q30 */
#define HODIRAC_FAC1                            (951579008)                 /* 1.772454f in Q29 */
#define HODIRAC_FAC2                            (549393984)                 /* 1.023326f in Q29 */
#define HODIRAC_FAC3                            (317192992)                 /* 0.590818f in Q29 */

/*----------------------------------------------------------------------------------*
 * Amplitude Panning (EFAP, VBAP) constants
+371 −0

File changed.

Preview size limit exceeded, changes collapsed.

+81 −61
Original line number Diff line number Diff line
@@ -70,9 +70,11 @@ void stereo_dmx_evs_enc(
);

/*! r: number of channels to be analysed */
#ifndef IVAS_FLOAT_FIXED
int16_t getNumChanAnalysis(
    Encoder_Struct *st_ivas                                     /* i  : IVAS encoder structure                  */
);
#endif

void copy_encoder_config(
    Encoder_Struct *st_ivas,                                    /* i  : IVAS encoder structure                  */
@@ -964,8 +966,8 @@ void smooth_dft2td_transition(

void smooth_dft2td_transition_fx(
    CPE_DEC_HANDLE hCPE,             /* i/o: CPE decoder structure			 */
  Word32 *output_fx[CPE_CHANNELS], /* i/o: synthesis @external Fs       */
  const Word16 output_frame   /* i  : output frame lenght          */
    Word32 *output_fx[CPE_CHANNELS], /* i/o: synthesis @external Fs       Q11*/
    const Word16 output_frame        /* i  : output frame lenght           Q0*/
);
/*! r: flag indicating a valid bitrate */
int16_t is_IVAS_bitrate(
@@ -2318,7 +2320,7 @@ int16_t stereo_dft_band_config(
    const int16_t NFFT,                                         /* i  : analysis/synthesis window length        */
    const int16_t enc_dec                                       /* i  : flag to indicate enc vs dec             */
);

#ifndef IVAS_FLOAT_FIXED
void stereo_td_itd(
    ITD_DATA *hITD,                                             /* i/o: ITD data structure                      */
    float input_mem_itd[CPE_CHANNELS][STEREO_DFT_OVL_MAX],      /* o  : ITD memory (only used in DFT Stereo)    */
@@ -2328,6 +2330,7 @@ void stereo_td_itd(
    const int16_t input_frame,                                  /* i  : input frame length                      */
    float *input_mem[CPE_CHANNELS]                              /* i/o: input buffer memory                     */
);
#endif

void stereo_dft_dmx_out_reset(
    STEREO_DFT_DMX_DATA_HANDLE hStereoDftDmx                    /* i/o: DFT stereo DMX decoder                  */
@@ -2538,8 +2541,8 @@ void stereo_tca_dec(

void stereo_tca_dec_fx(
  CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure					 */
  Word32 *synth[CPE_CHANNELS],                                 /* i/o: output synth                    */
  const Word16 output_frame                                  /* i  : length of a frame per channel   */
  Word32 *synth[CPE_CHANNELS],                                 /* i/o: output synth                    qsynth*/
  const Word16 output_frame                                  /* i  : length of a frame per channel		   Q0*/
);

void stereo_tca_scale_R_channel(
@@ -2550,8 +2553,8 @@ void stereo_tca_scale_R_channel(

void stereo_tca_scale_R_channel_fx(
    CPE_DEC_HANDLE hCPE,      /* i/o: CPE decoder structure				 */
  Word32 *output_fx,         /* i/o: output synthesis, R channel */
  const Word16 output_frame /* i  : frame length                */
    Word32 *output_fx,        /* i/o: output synthesis, R channel	q_out*/
    const Word16 output_frame /* i  : frame length					   Q0*/
);

void adjustTargetSignal(
@@ -2633,13 +2636,15 @@ int16_t select_stereo_mode(
    const IVAS_FORMAT ivas_format                               /* i  : IVAS format                                     */
);

#ifndef IVAS_FLOAT_FIXED
void stereo_classifier_init(
    STEREO_CLASSIF_HANDLE hStereoClassif                        /* i/o: stereo classifier structure                     */
);

#else
void stereo_classifier_init_fx(
  STEREO_CLASSIF_HANDLE hStereoClassif                        /* i/o: stereo classifier structure                     */
);
#endif

void stereo_classifier_features(
    STEREO_CLASSIF_HANDLE hStereoClassif,                       /* i/o: stereo classifier structure                     */
@@ -2754,7 +2759,7 @@ void stereo_td_init_dec(

void stereo_td_init_dec_fx(
  STEREO_TD_DEC_DATA_HANDLE hStereoTD,                        /* i/o: TD stereo decoder handle                */
  const Word16 last_element_mode                             /* i  : last element mode                       */
  const Word16 last_element_mode                             /* i  : last element mode                       Q0*/
);

void tdm_configure_dec(
@@ -2778,15 +2783,15 @@ void tdm_upmix_plain(
);

void tdm_upmix_plain_fx(
  Word32 Left_fx[],                 /* o  : left channel            */
  Word32 Right_fx[],                /* o  : right channel           */
  const Word32 PCh_2_L_fx[],        /* i  : primary channel         */
  const Word32 SCh_2_R_fx[],        /* i  : secondary channel       */
  const Word32 LR_ratio_fx,         /* i  : mixing ratio            */
  const Word32 inv_den_LR_ratio_fx, /* i  : inverse mixing ration   */
  const Word16 start_index,    /* i  : start index             */
  const Word16 end_index,      /* i  : end index               */
  const Word16 plus_minus_flag /* i  : plus/minus flag         */
    Word32 Left_fx[],                 /* o  : left channel            Qx*/
    Word32 Right_fx[],                /* o  : right channel           Qx*/
    const Word32 PCh_2_L_fx[],        /* i  : primary channel         Qx*/
    const Word32 SCh_2_R_fx[],        /* i  : secondary channel       Qx*/
    const Word32 LR_ratio_fx,         /* i  : mixing ratio            Q31*/
    const Word32 inv_den_LR_ratio_fx, /* i  : inverse mixing ration   Q31*/
    const Word16 start_index,         /* i  : start index             Q0*/
    const Word16 end_index,           /* i  : end index               Q0*/
    const Word16 plus_minus_flag      /* i  : plus/minus flag         Q0*/
);

void stereo_tdm_combine(
@@ -2800,11 +2805,11 @@ void stereo_tdm_combine(

void stereo_tdm_combine_fx(
    CPE_DEC_HANDLE hCPE,       /* i/o: CPE decoder structure                       */
  Word32 *PCh_2_L_fx,         /* i/o: Primary channel -> output as left channel   */
  Word32 *SCh_2_R_fx,         /* i/o: Secondary channel -> output as right channel*/
  const Word16 output_frame, /* i  : Number of samples                           */
  const Word16 flag_HB,      /* i  : flag to distinguish between core (0) and HB (1) synthesis */
  const Word16 tdm_ratio_idx /* i  : TDM ratio index                             */
    Word32 *PCh_2_L_fx,        /* i/o: Primary channel -> output as left channel					Qx*/
    Word32 *SCh_2_R_fx,        /* i/o: Secondary channel -> output as right channel					Qx*/
    const Word16 output_frame, /* i  : Number of samples											Q0*/
    const Word16 flag_HB,      /* i  : flag to distinguish between core (0) and HB (1) synthesis	Q0*/
    const Word16 tdm_ratio_idx /* i  : TDM ratio index												Q0*/
);
#ifdef IVAS_FLOAT_FIXED
Word16 tdm_lp_comparison_fx(
@@ -2888,6 +2893,7 @@ void tdm_bit_alloc(
    const int16_t tdm_inst_ratio_idx                            /* i  : instantaneous correlation ratio index   */
);

#ifndef IVAS_FLOAT_FIXED
void td_stereo_param_updt(
    const float lsp_old_PCh[],                                  /* i  : primary channel old LSPs                */
    const float lsf_old_PCh[],                                  /* i  : primary channel old LSFs                */
@@ -2898,6 +2904,7 @@ void td_stereo_param_updt(
    const int16_t flag_ACELP16k,                                /* i  : ACELP@16kHz flag                        */
    const int16_t tdm_use_IAWB_Ave_lpc                          /* i  : flag to indicate the usage of mean inactive LP coefficients */
);
#endif

void gsc_enc(
    Encoder_State *st,                                          /* i/o: State structure                         */
@@ -2998,19 +3005,7 @@ void tdm_SCh_lsf_reuse_fx(
    const Word16 lsf_wgts_fx[M],                                /* i  : LSF weights                             */
    Word16 *beta_index                                          /* i/o: quantization index                      */
);
#endif


void tdm_SCh_lsf_reuse_ivas_fx(
    const Word16 enc_dec,       /* i  : encoder/decoder flag                */
    const Word32 element_brate, /* i  : element bitrate                     */
    Word16 lsf_new[M],            /* i/o: LSFs at the end of the frame        */
    Word16 lsp_new[M],            /* i/o: LSPs at the end of the frame        */
    const Word16 tdm_lsfQ_PCh[M], /* i  : primary channel LSFs (log2(2.56))   */
    const Word16 lsf_wgts[M],     /* i  : LSF weights Q15?                    */
    Word16 *beta_index          /* i/o: quantization index                  */
);

#else
void tdm_SCh_lsf_reuse(
    const int16_t enc_dec,                                      /* i  : encoder/decoder flag                    */
    const int32_t element_brate,                                /* i  : element bitrate                         */
@@ -3020,6 +3015,7 @@ void tdm_SCh_lsf_reuse(
    const float lsf_wgts[M],                                    /* i  : LSF weights                             */
    int16_t *beta_index                                         /* i/o: quantization index                      */
);
#endif

void first_VQstages(
    const float *const *cb,
@@ -3667,8 +3663,8 @@ void applyDmxMdctStereo(

void applyDmxMdctStereo_fx(
  const CPE_DEC_HANDLE hCPE,                                  /* i  : CPE handle								   */
  Word32 *output_fx[CPE_CHANNELS],                                /* o  : output from core decoder                */
  const Word16 output_frame                                  /* i  : output frame length                     */
  Word32 *output_fx[CPE_CHANNELS],                            /* o  : output from core decoder                q_out*/
  const Word16 output_frame                                   /* i  : output frame length						 Q0*/
);


@@ -4108,7 +4104,7 @@ void stereo_switching_enc(
#endif
void stereo_switching_dec(
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure                   */
    const int32_t ivas_total_brate                              /* i  : IVAS total bitrate                      */
    const Word32 ivas_total_brate                               /* i  : IVAS total bitrate                    Q0*/
);

void stereo_td2dft_update(
@@ -4122,11 +4118,11 @@ void stereo_td2dft_update(

void stereo_td2dft_update_fx(
    CPE_DEC_HANDLE hCPE,      /* i/o: CPE decoder structure     */
  const Word16 n,           /* i  : channel number          */
  Word32 output_fx[],            /* i/o: synthesis @internal Fs  */
  Word32 synth_fx[],             /* i/o: synthesis @output Fs    */
  Word32 hb_synth_fx[],          /* i/o: hb synthesis            */
  const Word16 output_frame /* i  : frame length            */
    const Word16 n,           /* i  : channel number          Q0*/
    Word32 output_fx[],       /* i/o: synthesis @internal Fs  Q11*/
    Word32 synth_fx[],        /* i/o: synthesis @output Fs    Q11*/
    Word32 hb_synth_fx[],     /* i/o: hb synthesis            Q11*/
    const Word16 output_frame /* i  : frame length            Q0*/
);
void stereo_mdct2dft_update(
    CPE_DEC_HANDLE hCPE,                                        /* i/o: CPE decoder structure                   */
@@ -4136,8 +4132,8 @@ void stereo_mdct2dft_update(

void stereo_mdct2dft_update_fx(
    CPE_DEC_HANDLE hCPE, /* i/o: CPE decoder structure        */
  Word32 output0_fx[],     /* i/o: synthesis @internal Fs, ch0  */
  Word32 synth0_fx[]       /* i/o: synthesis @output Fs, ch0    */
    Word32 output0_fx[], /* i/o: synthesis @internal Fs, ch0  Q11*/
    Word32 synth0_fx[]   /* i/o: synthesis @output Fs, ch0    Q11*/
);
/*! r: number of bits written */
#ifdef IVAS_FLOAT_FIXED
@@ -5141,6 +5137,26 @@ void ivas_dirac_dec_get_response_fx(
    Word16 Q_out);
#endif


#ifdef IVAS_FLOAT_FIXED
void calculate_hodirac_sector_parameters_fx(
  DIRAC_ENC_HANDLE hDirAC,                                          /* i  : DirAC handle                                  */
  Word32 RealBuffer_fx[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector (L+1)^2 x N_bins, real part     */
  Word32 ImagBuffer_fx[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX], /* i  : signal vector, imaginary part                 */
  Word16 Qfac,                                                      /* i  : Q-factor of signal vector                     */
  const Word32 beta_fx,                                             /* i  : forgetting factor for average filtering, Q30  */
  const Word16 *band_grouping,                                      /* i  : indices of band groups                        */
  const Word16 N_bands,                                             /* i  : number of bands (groups)                      */
  const Word16 enc_param_start_band,                                /* i  : first band to process                         */
  Word32 *azi_fx,                                                   /* o  : array of sector azimuth angles, flat     Q23  */
  Word32 *ele_fx,                                                   /* o  : array of sector elevation angles, flat   Q23  */
  Word32 *diff_fx,                                                  /* o  : array of sector diffuseness values, flat      */
  Word16 *diff_exp,                                                 /* o  : array of sector diffuseness exponents, flat   */
  Word32 *ene_fx,                                                   /* o  : array of sector energy values, flat           */
  Word16 *ene_exp                                                   /* o  : array of sector energy exponents, flat        */
);
#endif

void calculate_hodirac_sector_parameters(
    DIRAC_ENC_HANDLE hDirAC,
    float RealBuffer[DIRAC_MAX_ANA_CHANS][DIRAC_NO_FB_BANDS_MAX],/* i : signal vector (L+1)^2 x N_bins, real part       */
@@ -5862,12 +5878,12 @@ void ivas_sba_mix_matrix_determiner(

/* AGC */
/*! r: AGC enable flag */
#ifndef IVAS_FLOAT_FIXED
int16_t ivas_agc_enc_get_flag(
    const int16_t nchan_transport                               /* i  : number of transport channels            */
);

#ifdef IVAS_FLOAT_FIXED
Word16 ivas_agc_enc_get_flag_fx(
#else
Word16 ivas_agc_enc_get_flag(
  const Word16 nchan_transport /* i  : number of transport channels            */
);
#endif
@@ -6145,7 +6161,7 @@ ivas_error ivas_sba_dec_render_fx(
    const UWord16 nSamplesAsked,    /* i  : number of CLDFB slots requested           */
    UWord16 *nSamplesRendered,      /* o  : number of CLDFB slots rendered            */
    UWord16 *nSamplesAvailableNext, /* o  : number of CLDFB slots still to render     */
    Word32 *output_fx[],               /* o  : rendered time signal                      */
    Word32 *output_fx[],               /* o  : rendered time signal                      Q11*/
    Word16 out_len/*Store the length of values in each channel*/
);
#endif // IVAS_FLOAT_FIXED
@@ -7144,9 +7160,11 @@ void ivas_masa_estimate_energy(
    const int16_t nchan_transport                               /* i  : number of MASA input/transport channels         */
);

#ifndef IVAS_FLOAT_FIXED
ivas_error ivas_masa_enc_config(
    Encoder_Struct* st_ivas                                     /* i/o: IVAS encoder structure                          */
);
#endif

void ivas_masa_set_elements(
    const int32_t ivas_total_brate,                             /* i  : codec total bitrate                             */
@@ -8057,9 +8075,11 @@ void ivas_omasa_enc_close(
    OMASA_ENC_HANDLE *hOMasa                                    /* i/o: encoder OMASA handle                    */
);

#ifndef IVAS_FLOAT_FIXED
ivas_error ivas_omasa_enc_config(
    Encoder_Struct *st_ivas                                     /* i/o: IVAS encoder structure                  */
);
#endif // !IVAS_FLOAT_FIXED

ivas_error ivas_omasa_dec_config(
    Decoder_Struct *st_ivas,                                    /* i/o: IVAS decoder structure                  */
@@ -8449,10 +8469,10 @@ void dequantize_sns_fx(
    Decoder_State **sts );

void inverseMS_fx(
    const Word16 L_frame,                                      /* i  : frame length                            */
    Word32 x0[],                                                 /* i/o: mid/left channel coefficients           */
    Word32 x1[],                                                 /* i/o: side/right channel coefficients         */
    const Word32 norm_fac                                        /* i  : normalization factor                    */
    const Word16 L_frame, /* i  : frame length						Q0*/
    Word32 x0[],          /* i/o: mid/left channel coefficients		Qx*/
    Word32 x1[],          /* i/o: side/right channel coefficients	Qx*/
    const Word32 norm_fac /* i  : normalization factor			   Q31*/
);

#endif
Loading