Commit d8232be0 authored by Manuel Jander's avatar Manuel Jander
Browse files

Merge remote-tracking branch 'origin' into basop-2493-usage-of-extract_l-with-values-out-of-range

parents 48a3b801 14f78288
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -825,7 +825,11 @@ Word16 getTcxLpcShapedAri(
 * Initialization of TCX
 *-----------------------------------------------------------------------*/

#ifdef HARMONIZE_2567_init_functions
void init_tcx_cfg_fx(
#else
void init_tcx_cfg_ivas_fx(
#endif
    TCX_CONFIG_HANDLE hTcxCfg,
    const Word32 total_brate,     /*Q0*/
    const Word32 sr_core,         /*Q0*/
@@ -841,7 +845,12 @@ void init_tcx_cfg_ivas_fx(
    const Word16 infoIGFStopFreq, /*Q0*/
    const Word16 element_mode,    /*Q0*/
    const Word16 ini_frame,       /*Q0*/
#ifdef HARMONIZE_2567_init_functions
    const Word16 MCT_flag, /*Q0*/
    const Word16 fscaleFB /*Q0*/ )
#else
    const Word16 MCT_flag /*Q0*/ )
#endif
{
    Word16 i;
    Word16 mdctWindowLength;
@@ -859,7 +868,11 @@ void init_tcx_cfg_ivas_fx(
    hTcxCfg->tcx_mdct_window_length_old = hTcxCfg->tcx_mdct_window_length; /*Q0*/
    move16();
    mdctWindowLength = getMdctWindowLength_fx( fscale ); /*Q0*/
#ifdef HARMONIZE_2567_init_functions
    mdctWindowLengthFB = getMdctWindowLength_fx( fscaleFB ); /*Q0*/ /* this replaces (int16_t) ( mdctWindowLength * input_Fs / sr_core ) as used in float */
#else
    mdctWindowLengthFB = (Word16) ( mdctWindowLength * input_Fs / sr_core );
#endif

    init_tcx_window_cfg_fx( hTcxCfg, sr_core, input_Fs, L_frame, L_frameTCX, mdctWindowLength, mdctWindowLengthFB, element_mode );
    /* SQ deadzone & memory quantization*/
@@ -1080,6 +1093,7 @@ void init_tcx_window_cfg_fx(
    return;
}

#ifndef HARMONIZE_2567_init_functions
void init_tcx_cfg_fx(
    TCX_CONFIG_HANDLE hTcxCfg,
    const Word32 total_brate,     /*Q0*/
@@ -1227,3 +1241,4 @@ void init_tcx_cfg_fx(

    return;
}
#endif
+7 −0
Original line number Diff line number Diff line
@@ -96,6 +96,13 @@
#define FIX_FLOAT_1539_G192_FORMAT_SWITCH               /* VA/Nokia: reintroduce format switching for g192 bitstreams */
#define HARMONIZE_2595_reconfig_decoder_LPD             /* FhG: Harmonize reconfig_decoder_LPD with its ivas derivate */
#define HARMONIZE_2596_SetModeIndex                     /* FhG: Harmonize SetModeIndex with its ivas derivate */
#define HARMONIZE_2597_ShapeSpectrum                    /* FhG: Harmonize ShapeSpectrum with its ivas derivate */
#define HARMONIZE_2567_init_functions                   /* FhG: harmonize derivates for evs/ivas regarding functions init_acelp*(),init_tcx_cfg*(), init_tcx*(), init_coder_ace_plus*(), init_core_sig_ana*() and init_modes*() */
#define HARMONIZE_2607_GetFilterParameters              /* FhG: Harmonize GetFilterParameters with its ivas derivate */
#define HAMRONIZE_2606_ENC_PRM                          /* FhG: Harmonize enc_prm_fx(), to match floating-point code */
#define HARMONIZE_2604_decoder_tcx_post                 /* FhG: Harmonize decoder_tcx_post with its ivas derivate */
#define HARMONIZE_2598_tcx_arith_decode_envelope        /* FhG: harmonize tcx_arith_decode_envelope between EVS and IVAS versions */
#define HARMONIZE_2598_tcx_arith_encode_envelope        /* FhG: harmonize tcx_arith_encode_envelope between EVS and IVAS versions */

/* #################### End BE switches ################################## */

+81 −26
Original line number Diff line number Diff line
@@ -3794,12 +3794,14 @@ void tcx_get_gain(
    Word16 *en_y_e  /* o: energy of y exponent (optional) */
);

#ifndef HARMONIZE_2567_init_functions
void init_TCX_config(
    TCX_CONFIG_HANDLE hTcxCfg,
    Word16 L_frame,
    Word16 fscale,
    Word16 L_frameTCX,
    Word16 fscaleFB );
#endif

void resetTecDec_Fx(
    TEC_DEC_HANDLE hTecDec );
@@ -5725,6 +5727,7 @@ void init_tcx_window_cfg_fx(
    const Word16 element_mode        /* i  : mode of CPE/SCE          */
);

#ifndef HARMONIZE_2567_init_functions
void init_tcx_cfg_fx(
    TCX_CONFIG_HANDLE hTcxCfg,
    const Word32 total_brate,
@@ -5743,6 +5746,7 @@ void init_tcx_cfg_fx(
    const Word16 ini_frame,
    const Word16 MCT_flag /* i  : hMCT handle allocated (1) or not (0)  */,
    const Word16 fscaleFB );
#endif

void syn_output_fx(
    const Word16 codec_mode,   /* i  : MODE1 or MODE2                       */
@@ -7996,13 +8000,16 @@ void decoder_tcx_ivas_fx(
    const Word16 frame_cnt,
    const Word16 sba_dirac_stereo_flag );

#ifndef HARMONIZE_2604_decoder_tcx_post
void decoder_tcx_post_fx(
    Decoder_State *st_fx,
    Word16 *synth,
    Word16 *synthFB,
    Word16 *A,
    Word16 bfi );
#endif

#ifndef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Word32 q_spectrum[],  /* o: quantised MDCT coefficients     Q31-e */
    Word16 *q_spectrum_e, /* o: MDCT exponent                   Q0 */
@@ -8020,6 +8027,7 @@ void tcx_arith_decode_envelope_fx(
    Word16 *nf_seed,        /* o: noise filling seed              Q0 */
    Word16 low_complexity   /* i: low-complexity flag           Q0 */
);
#endif

void tcx_decoder_memory_update(
    Word16 *xn_buf,    /* i/o: mdct output buffer used also as temporary buffer  : Q0 */
@@ -8425,14 +8433,23 @@ UWord32 mvl2s_r(
    const Word16 n /* i  : vector size   */
);

void decoder_tcx_post_ivas_fx(
    Decoder_State *st_fx,
    Word16 *synth,
    Word16 *synthFB,
#ifdef HARMONIZE_2604_decoder_tcx_post
void decoder_tcx_post_fx( Decoder_State *st_fx,
                          Word16 *synth,   // Q_syn
                          Word16 *synthFB, // Q_syn
                          Word16 Q_syn,
    Word16 *A,
                          Word16 *A, // Q: 14 - norm_s(A[0])
                          Word16 bfi,
                          Word16 MCT_flag );
#else
void decoder_tcx_post_ivas_fx( Decoder_State *st_fx,
                               Word16 *synth,   // Q_syn
                               Word16 *synthFB, // Q_syn
                               Word16 Q_syn,
                               Word16 *A, // Q: 14 - norm_s(A[0])
                               Word16 bfi,
                               Word16 MCT_flag );
#endif

void con_tcx_fx(
    Decoder_State *st,      /* i/o: coder memory state          */
@@ -9529,11 +9546,20 @@ void writeTCXparam_fx(
    const Word16 target_bitsTCX10[2],
    const Word16 pre_past_flag );

#ifdef HARMONIZE_2567_init_functions
void init_coder_ace_plus_fx(
    Encoder_State *st,             /* i  : Encoder state                          */
    const Word32 last_total_brate, /* i  : last total bitrate                     */
    const Word32 igf_brate,        /* i  : IGF configuration bitrate           */
    const Word16 shift,
    const Word16 MCT_flag /* i  : hMCT handle allocated (1) or not (0)   */
#else
void init_coder_ace_plus_ivas_fx(
    Encoder_State *st,             /* i  : Encoder state                          */
    const Word32 last_total_brate, /* i  : last total bitrate                     */
    const Word32 igf_brate,        /* i  : IGF configuration bitrate           */
    const Word16 MCT_flag          /* i  : hMCT handle allocated (1) or not (0)   */
#endif
);

void core_coder_reconfig_ivas_fx(
@@ -9562,23 +9588,32 @@ void SetModeIndex_ivas_fx(
#endif
);

#ifdef HARMONIZE_2567_init_functions
void init_tcx_cfg_fx(
#else
void init_tcx_cfg_ivas_fx(
#endif
    TCX_CONFIG_HANDLE hTcxCfg,
    const Word32 total_brate,
    const Word32 sr_core,
    const Word32 input_Fs,
    const Word16 L_frame,
    const Word16 bwidth,
    const Word16 L_frameTCX,
    const Word16 fscale,
    const Word16 preemph_fac,
    const Word16 tcxonly,
    const Word16 rf_mode,
    const Word16 igf,
    const Word16 infoIGFStopFreq,
    const Word16 element_mode,
    const Word16 ini_frame,
    const Word16 MCT_flag );
    const Word32 total_brate,     /*Q0*/
    const Word32 sr_core,         /*Q0*/
    const Word32 input_Fs,        /*Q0*/
    const Word16 L_frame,         /*Q0*/
    const Word16 bwidth,          /*Q0*/
    const Word16 L_frameTCX,      /*Q0*/
    const Word16 fscale,          /*Q0*/
    const Word16 preemph_fac,     /*Q15*/
    const Word16 tcxonly,         /*Q0*/
    const Word16 rf_mode,         /*Q0*/
    const Word16 igf,             /*Q0*/
    const Word16 infoIGFStopFreq, /*Q0*/
    const Word16 element_mode,    /*Q0*/
    const Word16 ini_frame,       /*Q0*/
#ifdef HARMONIZE_2567_init_functions
    const Word16 MCT_flag, /*Q0*/
    const Word16 fscaleFB /*Q0*/ );
#else
    const Word16 MCT_flag /*Q0*/ );
#endif

Word16 msvq_stage1_dct_search_fx(
    const Word32 *u_fx,                       /* i  : target                                        exp : u_e */
@@ -9972,9 +10007,28 @@ void tcx_arith_render_envelope_ivas_fx(
    Word32 env[]              /* o  : shaped signal envelope                     Q16*/
);

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Decoder_State *st,
    /* i/o: coder state                   */ /*EVS: move argument 5->1 */
    Word32 q_spectrum[],                     /* o  : quantised MDCT coefficients Q(31-q_spectrum_e)  */
    Word16 *q_spectrum_e,                    /* o  : MDCT exponent                 */
    const Word16 L_frame,                    /* i  : frame or MDCT length          */
    Word16 L_spec,                           /* i  : length w/o BW limitation      */
    const Word16 A_ind[],                    /* i  : quantised LPC coefficients    */
    const Word16 target_bits,                /* i  : number of available bits      */
    Word16 prm[],                            /* i  : bitstream parameters          */
    const Word16 use_hm,                     /* i  : use HM in current frame?      */
    Word16 prm_hm[],                         /* i  : HM parameter area             */
    Word16 tcxltp_pitch,                     /* i  : TCX LTP pitch in FD, -1 if n/a*/
    Word16 *arith_bits,                      /* o  : bits used for ari. coding     */
    Word16 *signaling_bits,                  /* o  : bits used for signaling       */
    Word16 *nf_seed,                         /* o  : noise filling seed         Q0 */
    const Word16 low_complexity              /* i  : low-complexity flag           */
#else
void tcx_arith_decode_envelope_ivas_fx(
    Decoder_State *st,          /* i/o: coder state                   */
    Word32 q_spectrum[],        /* o  : quantised MDCT coefficients   */
    Word32 q_spectrum[],        /* o  : quantised MDCT coefficients Q(31-q_spectrum_e)  */
    Word16 *q_spectrum_e,       /* o  : MDCT exponent                 */
    const Word16 L_frame,       /* i  : frame or MDCT length          */
    Word16 L_spec,              /* i  : length w/o BW limitation      */
@@ -9982,11 +10036,12 @@ void tcx_arith_decode_envelope_ivas_fx(
    const Word16 target_bits,   /* i  : number of available bits      */
    Word16 prm[],               /* i  : bitstream parameters          */
    const Word16 use_hm,        /* i  : use HM in current frame?      */
    const Word16 prm_hm[],      /* i  : HM parameter area             */
    Word16 prm_hm[],            /* i  : HM parameter area             */
    Word16 tcxltp_pitch,        /* i  : TCX LTP pitch in FD, -1 if n/a*/
    Word16 *arith_bits,         /* o  : bits used for ari. coding     */
    Word16 *signaling_bits,     /* o  : bits used for signaling       */
    const Word16 low_complexity /* i  : low-complexity flag           */
#endif
);

void UnmapIndex_fx(
+2 −0
Original line number Diff line number Diff line
@@ -2165,6 +2165,7 @@ void tcx_get_gain(
}


#ifndef HARMONIZE_2567_init_functions
void init_TCX_config(
    TCX_CONFIG_HANDLE hTcxCfg,
    Word16 L_frame,    /*Q0*/
@@ -2215,3 +2216,4 @@ void init_TCX_config(

    return;
}
#endif
+49 −7
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ static Word16 tcx_arith_decode_fx(
    return bp;
}

#ifndef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Word32 q_spectrum[],    /* o  : quantised MDCT coefficients     Q31-e */
    Word16 *q_spectrum_e,   /* o  : MDCT exponent                   Q0 */
@@ -209,6 +210,7 @@ void tcx_arith_decode_envelope_fx(

    set32_fx( q_spectrum + L_spec, 0, sub( L_frame, L_spec ) );
}
#endif

/*-------------------------------------------------------*
 * tcx_arith_decode()
@@ -293,6 +295,26 @@ static Word16 tcx_arith_decode_ivas_fx(
 *
 *-------------------------------------------------------*/

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
void tcx_arith_decode_envelope_fx(
    Decoder_State *st,
    /* i/o: coder state                   */ /*EVS: move argument 5->1 */
    Word32 q_spectrum[],                     /* o  : quantised MDCT coefficients Q(31-q_spectrum_e)  */
    Word16 *q_spectrum_e,                    /* o  : MDCT exponent                 */
    const Word16 L_frame,                    /* i  : frame or MDCT length          */
    Word16 L_spec,                           /* i  : length w/o BW limitation      */
    const Word16 A_ind[],                    /* i  : quantised LPC coefficients    */
    const Word16 target_bits,                /* i  : number of available bits      */
    Word16 prm[],                            /* i  : bitstream parameters          */
    const Word16 use_hm,                     /* i  : use HM in current frame?      */
    Word16 prm_hm[],                         /* i  : HM parameter area             */
    Word16 tcxltp_pitch,                     /* i  : TCX LTP pitch in FD, -1 if n/a*/
    Word16 *arith_bits,                      /* o  : bits used for ari. coding     */
    Word16 *signaling_bits,                  /* o  : bits used for signaling       */
    Word16 *nf_seed,
    /* o  : noise filling seed         Q0 */ /*IVAS: 0*/
    const Word16 low_complexity              /* i  : low-complexity flag           */
#else
void tcx_arith_decode_envelope_ivas_fx(
    Decoder_State *st,          /* i/o: coder state                   */
    Word32 q_spectrum[],        /* o  : quantised MDCT coefficients Q(31-q_spectrum_e)  */
@@ -308,6 +330,7 @@ void tcx_arith_decode_envelope_ivas_fx(
    Word16 *arith_bits,         /* o  : bits used for ari. coding     */
    Word16 *signaling_bits,     /* o  : bits used for signaling       */
    const Word16 low_complexity /* i  : low-complexity flag           */
#endif
)
{
    Word32 env[N_MAX_ARI]; /* unscaled envelope (Q16) */
@@ -315,7 +338,6 @@ void tcx_arith_decode_envelope_ivas_fx(
    Word16 envelope_e;
    Word16 L_spec_core;
    TCX_CONFIG_HANDLE hTcxCfg;
    TCX_DEC_HANDLE hTcxDec;
    Word16 gamma_w, gamma_uw;
    Word16 hm_bits;

@@ -326,7 +348,7 @@ void tcx_arith_decode_envelope_ivas_fx(
    test();
    test();
    test();
    IF( GT_16( L_spec, N_MAX_ARI ) || ( ( st->element_mode == EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
    IF( GT_16( L_spec, N_MAX_ARI ) || ( EQ_16( st->element_mode, EVS_MONO ) && GT_16( target_bits, ( ACELP_13k20 / FRAMES_PER_SEC ) ) ) ||
        ( EQ_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE / FRAMES_PER_SEC ) ) ) ) ||
        ( GT_16( st->element_mode, IVAS_SCE ) && ( GT_16( st->bits_frame_nominal, ( LPC_SHAPED_ARI_MAX_RATE_CPE / FRAMES_PER_SEC ) ) ) ) ||
        ( target_bits <= 0 ) )
@@ -346,17 +368,27 @@ void tcx_arith_decode_envelope_ivas_fx(
    }

    hTcxCfg = st->hTcxCfg;
    hTcxDec = st->hTcxDec;
    *signaling_bits = 0;
    move16();

    assert( hTcxDec->enableTcxLpc );
    assert( st->hTcxDec->enableTcxLpc );
    gamma_w = MAX16B;
    move16();
    gamma_uw = st->inv_gamma;
    move16();

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        tcx_arith_render_envelope( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
    }
    ELSE
    {
#endif
        tcx_arith_render_envelope_ivas_fx( A_ind, L_frame, L_spec, hTcxCfg->preemph_fac, gamma_w, gamma_uw, env );
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    }
#endif


    IF( use_hm != 0 )
    {
@@ -395,8 +427,18 @@ void tcx_arith_decode_envelope_ivas_fx(

    envelope = (Word16 *) env;
    tcx_arith_scale_envelope( L_spec, L_spec_core, env, target_bits, low_complexity, envelope, &envelope_e );

#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    IF( EQ_16( st->element_mode, EVS_MONO ) )
    {
        *arith_bits = tcx_arith_decode_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e, nf_seed );
    }
    ELSE
    {
#endif
        *arith_bits = tcx_arith_decode_ivas_fx( L_spec, envelope, envelope_e, target_bits, prm, q_spectrum, q_spectrum_e );
#ifdef HARMONIZE_2598_tcx_arith_decode_envelope
    }
#endif
    move16();

    /* safety check in case of bit errors */
Loading