Commit aa6d58e5 authored by vaclav's avatar vaclav
Browse files

- Merge remote-tracking branch 'remotes/origin/main' into...

- Merge remote-tracking branch 'remotes/origin/main' into float-1562-crash-in-stereo-decoding-in-dtx-and-bitrate-switching
parents ba62b98d 16616fc6
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6116,7 +6116,7 @@ void mvc2c(
    const Word16 n                                              /* i  : vector size                             */
);

void stereo_switching_dec(
void stereo_switching_dec_fx(
    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
@@ -103,6 +103,7 @@
#define FIX_1547_ISMDTX_HANDLE                          /* VA: float issue 1547: fix use of 'hISMDTX' handle */
#define FIX_1540_EXPOSE_PT_IN_RTP_HEADER_API            /* Expose Payload Type setting in RTP Header */
#define FIX_BASOP_2491_MDCT_JBM_CLICK                   /* FhG: BASOP #2491: Fix Q_synth after TCX concealment (using ACELP concealment) */
#define FIX_1563_FIX_STEREO_SW                          /* VA: float issue 1563: fix clicks in stereo switching */
#define FIX_1562_DTX_CRASH_DECODER                      /* VA: float issue 1562: fix crash in stereo decoding in DTX and bitrate switching */

/* ##################### End NON-BE switches ########################### */
+1 −1
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ ivas_error ivas_cpe_dec_fx(
     * Resets/updates in case of stereo switching
     *----------------------------------------------------------------*/

    stereo_switching_dec( hCPE, ivas_total_brate );
    stereo_switching_dec_fx( hCPE, ivas_total_brate );

    /*----------------------------------------------------------------*
     * Configuration of stereo decoder
+17 −16
Original line number Diff line number Diff line
@@ -46,6 +46,15 @@

#define DFT2TD_CORR_THRESH_FX 1932735283

static Word32 side_gain_table[32 + 1] = {
    -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944,
    -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824,
    -966367616, -858993408, -751619200, -644245120, -536870912, -429496704,
    -322122496, -214748288, -107374208, 0, 107374336, 214748416,
    322122496, 429496832, 536870912, 644245248, 751619328, 858993408,
    966367744, 1073741824, 1181116160, 1288490240
};


/*-------------------------------------------------------------------*
 * Function allocate_CoreCoder_TCX()
@@ -1689,16 +1698,7 @@ void synchro_synthesis_fx(
 * Handling of memories in case of CPE modes switching
 *-------------------------------------------------------------------*/

static Word32 side_gain_table[32 + 1] = {
    -ONE_IN_Q31, -2040109440, -1932735232, -1825361152, -1717986944,
    -1610612736, -1503238528, -1395864320, -1288490240, -1181115904, -1073741824,
    -966367616, -858993408, -751619200, -644245120, -536870912, -429496704,
    -322122496, -214748288, -107374208, 0, 107374336, 214748416,
    322122496, 429496832, 536870912, 644245248, 751619328, 858993408,
    966367744, 1073741824, 1181116160, 1288490240
};

void stereo_switching_dec(
void stereo_switching_dec_fx(
    CPE_DEC_HANDLE hCPE,          /* i/o: CPE decoder structure         */
    const Word32 ivas_total_brate /* i  : IVAS total bitrate          Q0*/
)
@@ -1891,13 +1891,11 @@ void stereo_switching_dec(
            sts[0]->mem_deemph_fx = 0;
            move16();


            sts[0]->tilt_code_fx = 0;
            move16();
            sts[0]->gc_threshold_fx = 0;
            move16();


            set16_fx( sts[0]->mem_syn1_fx, 0, M );
            set16_fx( sts[0]->mem_syn2_fx, 0, M );
            set16_fx( sts[0]->mem_syn3_fx, 0, M );
@@ -1906,7 +1904,6 @@ void stereo_switching_dec(
            sts[1]->last_L_frame = sts[0]->last_L_frame; /* Q0 */
            move16();


            set16_fx( sts[0]->old_exc_fx, 0, L_EXC_MEM_DEC );
            set16_fx( sts[0]->lsf_old_fx, 0, M );
            set16_fx( sts[0]->lsp_old_fx, 0, M );
@@ -1917,14 +1914,12 @@ void stereo_switching_dec(
        sts[1]->prev_bfi = sts[0]->prev_bfi; /* Q0 */
        move16();


        // fix need to do correctly
        set32_fx( sts[1]->old_pitch_buf_fx, L_deposit_h( L_SUBFR ), 2 * NB_SUBFR16k );
        sts[1]->old_fpitchFB = L_deposit_h( 2 * L_SUBFR ); /* 15Q16 */
        move32();

        /* reset CLDFB memories */

        cldfb_reset_memory_fx( sts[1]->cldfbAna );
        cldfb_reset_memory_fx( sts[1]->cldfbBPF );
        cldfb_reset_memory_fx( sts[1]->cldfbSyn );
@@ -1937,7 +1932,6 @@ void stereo_switching_dec(
        sts[1]->gc_threshold_fx = 0;
        move16();


        set16_fx( sts[1]->mem_syn1_fx, 0, M );
        set16_fx( sts[1]->mem_syn2_fx, 0, M );
        set16_fx( sts[1]->mem_syn3_fx, 0, M );
@@ -2015,6 +2009,13 @@ void stereo_switching_dec(
            Copy( sts[0]->hTcxDec->old_syn_Overl, sts[1]->hTcxDec->old_syn_Overl, 256 );              /* Q_old_syn_Overl*/
            sts[1]->hTcxDec->Q_old_syn_Overl = sts[0]->hTcxDec->Q_old_syn_Overl;
        }
#ifdef FIX_1563_FIX_STEREO_SW
        ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
        {
            sts[1]->last_core = ACELP_CORE;
            move16();
        }
#endif
    }
    ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
    {
+14 −4
Original line number Diff line number Diff line
@@ -515,15 +515,19 @@ ivas_error stereo_memory_enc_fx(
                return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxEnc\n" ) );
            }

            // st->hTcxEnc->spectrum[0] = st->hTcxEnc->spectrum_long;
            // st->hTcxEnc->spectrum[1] = st->hTcxEnc->spectrum_long + N_TCX10_MAX;
            st->hTcxEnc->spectrum_fx[0] = st->hTcxEnc->spectrum_long_fx;               /* Q31-st->hTcxEnc->spectrum_e[0] */
            st->hTcxEnc->spectrum_fx[1] = st->hTcxEnc->spectrum_long_fx + N_TCX10_MAX; /* Q31-st->hTcxEnc->spectrum_e[1] */
            st->hTcxEnc->spectrum_e[0] = st->hTcxEnc->spectrum_e[1] = 0;
            move16();
            move16();
#ifdef FIX_1563_FIX_STEREO_SW
            set16_fx( st->hTcxEnc->old_out_fx, 0, L_FRAME32k );
            st->hTcxEnc->Q_old_out = 0;
            move16();
#else
            // set_f( st->hTcxEnc->old_out, 0, L_FRAME32k );
            // set_f( st->hTcxEnc->spectrum_long, 0, N_MAX );
#endif
            set32_fx( st->hTcxEnc->spectrum_long_fx, 0, N_MAX );
            st->hTcxEnc->spectrum_long_e = 0;
            st->hTcxEnc->tfm_mem_fx = 1610612736; /* 0.75 in Q31 */
@@ -557,7 +561,6 @@ ivas_error stereo_memory_enc_fx(
#ifdef DEBUGGING
            hCPE->hStereoMdct->mdct_stereo_mode_cmdl = SMDCT_MS_DECISION;
#endif

            initMdctStereoEncData_fx( hCPE->hStereoMdct, ivas_format, hCPE->element_mode, hCPE->element_brate, hCPE->hCoreCoder[0]->max_bwidth, 0, NULL, 1 );

            test();
@@ -630,6 +633,7 @@ ivas_error stereo_memory_enc_fx(
    return error;
}


/*-------------------------------------------------------------------*
 * Function stereo_switching_enc()
 *
@@ -673,7 +677,6 @@ void stereo_switching_enc_fx(
        Copy32( sts[1]->input32_fx + sub( extract_l( Mpy_32_32( sts[1]->input_Fs, 42949673 /* 1/50 in Q31*/ ) ), sts[1]->encoderLookahead_FB ), sts[1]->input32_fx - sts[1]->encoderLookahead_FB, sts[1]->encoderLookahead_FB ); /* sts[1]->q_inp32 */
    }


    /* TD/MDCT -> DFT stereo switching */
    test();
    IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) && NE_16( hCPE->last_element_mode, IVAS_CPE_DFT ) )
@@ -937,6 +940,13 @@ void stereo_switching_enc_fx(
            sts[1]->last_bwidth = sts[0]->last_bwidth; /* Q0 */
            move16();
        }
#ifdef FIX_1563_FIX_STEREO_SW
        ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) )
        {
            sts[1]->last_core = ACELP_CORE;
            move16();
        }
#endif
    }
    ELSE IF( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && EQ_16( hCPE->last_element_mode, IVAS_CPE_MDCT ) )
    {