Commit 7a0a9d7d authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

Merge branch 'usan_fixes_2' into 'main'

USAN fixes for encoder and decoder

See merge request !1189
parents 6a68c167 d29e5c5e
Loading
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -974,7 +974,11 @@ void computeDiffuseness_fixed(
        Word16 shift_qtotal;
        if ( shift_q < 0 )
        {
#ifdef FIX_USAN_ISSUES
            shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q );
#else
            shiftEquiv = L_lshl( 0x80000000, shift_q );
#endif
        }
        if ( shift_q >= 0 )
        {
@@ -1020,7 +1024,11 @@ void computeDiffuseness_fixed(
#ifdef FIX_1072_SPEEDUP_COMPUTEDIFUSENESS
        if ( shift_q < 0 )
        {
#ifdef FIX_USAN_ISSUES
            shiftEquiv = L_lshl( (Word32) 0x80000000, shift_q );
#else
            shiftEquiv = L_lshl( 0x80000000, shift_q );
#endif
        }
        if ( shift_q >= 0 )
        {
+1 −0
Original line number Diff line number Diff line
@@ -156,6 +156,7 @@
#define FIX_ISSUE_1291                          /* Ittiam: Wrong use of imult1616() in ACELP rescaling */
#define FIX_920_IGF_INIT_ERROR                  /* FhG: issue 920: fix bitrate mismatch in initial IGF config to avoid error message in same cases */
#define FIX_MINOR_SVD_WMOPS_MR1010X             /* FhG: Minor WMOPS tuning, bit-exact to previous version, saves about 8.2 WMOPS for MR1010 */
#define FIX_USAN_ISSUES                         /* Ittiam: Fix issues reported by USAN */
#define SVD_WMOPS_OPT                           /* Ittiam : SVD related optimizations */
#define NONBE_FIX_1087_OOB_SBA_DTX_RS           /* VA: issue 1087: Extend the length of the buffer for MCT decoding to avoid out-of-bound writing in SBA SID bitrate switching decoding */
#define FIX_ISSUE_1279                          /* VA: correction of wrong scaling update */
+13 −0
Original line number Diff line number Diff line
@@ -139,8 +139,21 @@ void tdm_low_rate_dec_fx(

    edct_16fx( exc_wo_nf_fx, exc_wo_nf_fx, L_FRAME, find_guarded_bits_fx( L_FRAME ), IVAS_CPE_TD );

#ifdef FIX_USAN_ISSUES
    IF( bwe_exc != NULL )
    {
        Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx,
                     L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type );
    }
    ELSE
    {
        Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], NULL, st->hGSCDec->last_exc_dct_in_fx,
                     L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type );
    }
#else
    Rescale_exc( st->hMusicPF->dct_post_old_exc_fx, &exc[0], &bwe_exc[0], st->hGSCDec->last_exc_dct_in_fx,
                 L_FRAME, L_FRAME * HIBND_ACB_L_FAC, L_shl( st->lp_gainc_fx, 13 /* Q3 -> Q16*/ ), &( st->Q_exc ), st->Q_subfr, NULL, 0, st->coder_type );
#endif
    /*----------------------------------------------------------------------*
     * Remove potential pre-echo in case an onset has been detected
     *----------------------------------------------------------------------*/
+13 −0
Original line number Diff line number Diff line
@@ -337,8 +337,21 @@ void ivas_mct_core_enc_fx(

        IF( switch_bw )
        {
#ifdef FIX_USAN_ISSUES
            IF( sts[ch_core]->hIGFEnc == NULL )
            {
                initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth,
                                          sts[ch_core]->igf, NULL, 0 );
            }
            ELSE
            {
                initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth,
                                          sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 );
            }
#else
            initMdctStereoEncData_fx( hMCT->hBlockData[ch]->hStereoMdct, ivas_format, sts[ch_core]->element_mode, sts[ch_core]->element_brate, sts[ch_core]->bwidth,
                                      sts[ch_core]->igf, sts[ch_core]->hIGFEnc->igfData.igfInfo.grid, 0 );
#endif
        }

        IF( sts[ch_core]->igf )
+17 −0
Original line number Diff line number Diff line
@@ -2503,7 +2503,11 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
            }
            ELSE
            {
#ifdef FIX_USAN_ISSUES
                avg_elevation_index = (UWord16) L_add( avg_elevation_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_elevation_offset ) );
#else
                avg_elevation_index = u_extract_l( UL_addNsD( avg_elevation_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_elevation_offset ) ) );
#endif
            }
            // avg_elevation_index = (uint16_t) ( ( avg_elevation_index + avg_elevation_alphabet ) % avg_elevation_alphabet );
            avg_elevation_index = u_extract_l( UL_addNsD( avg_elevation_index, avg_elevation_alphabet ) % avg_elevation_alphabet );
@@ -2638,8 +2642,13 @@ static Word16 ivas_qmetadata_entropy_encode_dir_fx(
    FOR( avg_azimuth_offset = 0; avg_azimuth_offset < q_direction->cfg.search_effort; avg_azimuth_offset++ )
    {
        set_zero_fx( avg_direction_vector, 3 );
#ifdef FIX_USAN_ISSUES
        avg_azimuth_index = (UWord16) L_add( avg_azimuth_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_azimuth_offset ) );
        avg_azimuth_index = (UWord16) ( L_add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet );
#else
        avg_azimuth_index = (UWord16) add( avg_azimuth_index_initial, ivas_qmetadata_dereorder_generic_fx( avg_azimuth_offset ) );
        avg_azimuth_index = (UWord16) ( add( avg_azimuth_index, avg_azimuth_alphabet ) % avg_azimuth_alphabet );
#endif
        all_zero_dist_azimuth_indexes = 1;
        move16();
        azimuth_bits_ec = ivas_qmetadata_encode_quasi_uniform_length_fx( ivas_qmetadata_reorder_generic_fx( sub( avg_azimuth_index, shr( avg_azimuth_alphabet, 1 ) ) ), avg_azimuth_alphabet );
@@ -5445,7 +5454,11 @@ static Word16 encode_surround_coherence_hr_fx(
                    }
                    ELSE
                    {
#ifdef FIX_USAN_ISSUES
                        no_idx16 = add( shr( nbits_fr, 4 ), 1 );
#else
                        no_idx16 = shr_r( nbits_fr, 4 );
#endif
                    }

                    /* write combined index */
@@ -5467,7 +5480,11 @@ static Word16 encode_surround_coherence_hr_fx(
                        }
                        ELSE
                        {
#ifdef FIX_USAN_ISSUES
                            no_idx16 = add( shr( nbits_fr1, 4 ), 1 );
#else
                            no_idx16 = shr_r( nbits_fr1, 4 );
#endif
                        }

                        assert( no_idx16 <= 4 );
Loading