Commit 06c10cc8 authored by Dominik Weckbecker's avatar Dominik Weckbecker 💬
Browse files

Merge branch '1600_basop_mc_encoder_crashes_with_br_and_bw_switching' into 'main-pc'

Port float MR 1373 to BASOP

See merge request !1611
parents 4eb66a95 d2c0111b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@

#define NONBE_FIX_974_OSBA_JBM_MONO_RS_USAN             /* FhG : issue #974: usan in mono and stereo output in OSBA JBM RS */
#define NONBE_FIX_982_OMASA_DELAY_COMP_5MS              /* FhG : issue #982 : 5ms and 20ms output different for OMASA */
#define FIX_ACCESS_WITHIN_NULL_STRUCT_MC_BW_SWITCHING   /* FhG: fix usan error in MCT with bw swicthing */
#define NONBE_FIX_986_MC_BW_SWITCHING                   /* FhG: fix crash in bw and br switching with MC */
#define NONBE_FIX_975_JBM_USAN                          /* FhG: Fix issue #975, USAN in JBM decoding ad 13.2kbps */

/* #################### End BASOP porting switches ############################ */
+23 −0
Original line number Diff line number Diff line
@@ -1140,6 +1140,28 @@ Word16 set_bw_mct_fx(

    bw_changed = 0;
    move16();
#ifdef NONBE_FIX_986_MC_BW_SWITCHING
    IF( NE_16( mct_bwidth, last_mct_bwidth ) )
    {
        bw_changed = 1;
        move16();
    }

    /*
     * always set bw for all CPEs even if it is the same value as before,
     * in case of bw + br switching when changing to MCT, this overwrites
     * potentially incorrect initial values
     */
    FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
    {
        FOR( ch = 0; ch < CPE_CHANNELS; ch++ )
        {
            st = hCPE[cpe_id]->hCoreCoder[ch];
            st->bwidth = mct_bwidth;
            move16();
        }
    }
#else
    IF( NE_16( mct_bwidth, last_mct_bwidth ) )
    {
        bw_changed = 1;
@@ -1155,5 +1177,6 @@ Word16 set_bw_mct_fx(
            }
        }
    }
#endif
    return bw_changed;
}
+12 −0
Original line number Diff line number Diff line
@@ -1019,7 +1019,19 @@ ivas_error ivas_cpe_enc_fx(
        IF( ( NE_32( hCPE->last_element_brate, hCPE->element_brate ) || NE_16( hCPE->element_mode, hCPE->last_element_mode ) || ( EQ_16( hCPE->element_mode, IVAS_CPE_TD ) && NE_16( sts[0]->bits_frame_nominal, last_bits_frame_nominal ) ) || NE_16( sts[n]->last_bwidth, sts[n]->bwidth ) ) && ( n == 0 || EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) ) )
        {
            Word16 igf;
#ifdef NONBE_FIX_986_MC_BW_SWITCHING
            Word16 bw;

            /* float uses ternary operator for this: bw = ( hCPE->element_mode == IVAS_CPE_MDCT ) ? sts[n]->bwidth : sts[n]->max_bwidth; */
            bw = sts[n]->max_bwidth;
            IF( EQ_16( hCPE->element_mode, IVAS_CPE_MDCT ) )
            {
                bw = sts[n]->bwidth;
            }
            igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), bw, sts[n]->rf_mode ); /* Q0 */
#else
            igf = getIgfPresent_fx( sts[n]->element_mode, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->rf_mode ); /* Q0 */
#endif
            IF( ( error = IGF_Reconfig_fx( &sts[n]->hIGFEnc, igf, 0, L_mult0( sts[n]->bits_frame_nominal, FRAMES_PER_SEC ), sts[n]->max_bwidth, sts[n]->element_mode, sts[n]->rf_mode ) ) != IVAS_ERR_OK )
            {
                return error;
+21 −0
Original line number Diff line number Diff line
@@ -183,7 +183,9 @@ ivas_error ivas_mct_enc_fx(
    Word32 orig_spectrum_long_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][L_FRAME48k];
    Word16 switch_bw;
    IVAS_FORMAT ivas_format;
#ifndef NONBE_FIX_986_MC_BW_SWITCHING
    Word16 max_bwidth;
#endif
    Word32 ivas_total_brate;
    ivas_error error;
    Word32 *pdata_fx[MAX_INPUT_CHANNELS];
@@ -198,7 +200,9 @@ ivas_error ivas_mct_enc_fx(
    hMCT->hBstr = st_ivas->hCPE[0]->hCoreCoder[0]->hBstr; /* pointer to write MCT side bits */

    ivas_format = st_ivas->hEncoderConfig->ivas_format;
#ifndef NONBE_FIX_986_MC_BW_SWITCHING
    max_bwidth = st_ivas->hEncoderConfig->max_bwidth;
#endif
    ivas_total_brate = st_ivas->hEncoderConfig->ivas_total_brate;
    move32();
    move16();
@@ -248,6 +252,22 @@ ivas_error ivas_mct_enc_fx(
            cp_bitrate = L_shl( L_deposit_l( div_l( ivas_total_brate, st_ivas->nchan_transport ) ), 2 ); // a/b => div_l(a, b/2) or (2 * div_l(a, b))
        }

#ifdef NONBE_FIX_986_MC_BW_SWITCHING
        IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf )
        {
            FOR( n = 0; n < shr( hMCT->nchan_out_woLFE, 1 ); n++ )
            {
                initMdctStereoEncData_fx( hMCT->hBlockData[n]->hStereoMdct, ivas_format, IVAS_CPE_MDCT, cp_bitrate, st_ivas->hCPE[0]->hCoreCoder[0]->bwidth, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFEnc->igfData.igfInfo.grid, 0 );
            }
        }
        ELSE
        {
            FOR( n = 0; n < shr( hMCT->nchan_out_woLFE, 1 ); n++ )
            {
                initMdctStereoEncData_fx( hMCT->hBlockData[n]->hStereoMdct, ivas_format, IVAS_CPE_MDCT, cp_bitrate, st_ivas->hCPE[0]->hCoreCoder[0]->bwidth, st_ivas->hCPE[0]->hCoreCoder[0]->igf, NULL, 0 );
            }
        }
#else
        IF( st_ivas->hCPE[0]->hCoreCoder[0]->igf )
        {
            FOR( n = 0; n < shr( hMCT->nchan_out_woLFE, 1 ); n++ )
@@ -262,6 +282,7 @@ ivas_error ivas_mct_enc_fx(
                initMdctStereoEncData_fx( hMCT->hBlockData[n]->hStereoMdct, ivas_format, IVAS_CPE_MDCT, cp_bitrate, max_bwidth, st_ivas->hCPE[0]->hCoreCoder[0]->igf, NULL, 0 );
            }
        }
#endif
    }

    /* set coded audio band-width */