Commit 3fe68251 authored by multrus's avatar multrus
Browse files

[cleanup] accept FIX_BASOP_2529_MASA_RATIO_SCALINGS

parent 3805ff49
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -114,7 +114,6 @@
#define FIX_2500_RENDCONF_REFACTOR                      /* Eri: Basop issue #2500: Renderer configuration range check before conversion to fixed point. Harmonize between BASOP/float */
#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION         /* Eri: Basop issue 2023: Distance attenuation scaling, adding clamping of distance att input and listener position */
#define FIX_BASOP_2023_TDREND_DISTATT_PRECISION_BUGFIX  /* Eri: Bug discovered in cleanup of basop issue 2023 */
#define FIX_BASOP_2529_MASA_RATIO_SCALINGS              /* Nokia: BASOP issue 2529: Fix MASA ratio scalings and verifications */
#define FIX_1576_LCLD_CRASH_DIFFERENT_CODEC_ISAR_FRAME_SIZE  /* Dolby: float issue 1576: fix for crash in LCLD mode when codec frame size is less than isar frame size */
#define FIX_BASOP_2531_MCT_CP_BITRATE                   /* FhG: BASOP issue 2531: Fix MCT cp_bitrate calculation; affects bitrate switching only */
#define FIX_BASOP_2541_OMASA_ENC_FIXES                  /* Nokia: BASOP issue 2541: Fix function ivas_encode_masaism_metadata_fx */
+0 −21
Original line number Diff line number Diff line
@@ -2303,17 +2303,9 @@ static void compensate_energy_ratios_fx(
            move32();
            FOR( dir = 0; dir < numDirs; dir++ )
            {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                ratioSum = L_add( ratioSum, L_shr( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], 1 ) ); // accumulate in Q29
#else
                ratioSum = L_add( ratioSum, hMeta->directional_meta[dir].energy_ratio_fx[sf][band] ); // Q30
#endif
            }
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            ratioSum = L_add( ratioSum, L_shr( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], 1 ) ); // accumulate in  Q29
#else
            ratioSum = L_add( ratioSum, hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] ); // Q30
#endif

            IF( ratioSum == 0 )
            {
@@ -2325,12 +2317,7 @@ static void compensate_energy_ratios_fx(
                hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30; // Q30
                move32();
            }
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            ELSE IF( GT_32( L_abs( L_sub( ratioSum, ONE_IN_Q29 ) ), 1 ) ) // else if ( ratioSum != 1.0f ) from float with minor rounding tolerance
#else
            // ELSE IF( NE_32( ratioSum, ONE_IN_Q30 ) )
            ELSE /* Removing the check against 1 works well!!! */
#endif
            {
                Word16 exp_diff;
                FOR( dir = 0; dir < numDirs; dir++ )
@@ -2338,21 +2325,13 @@ static void compensate_energy_ratios_fx(
                    hMeta->directional_meta[dir].energy_ratio_fx[sf][band] =
                        BASOP_Util_Divide3232_Scale_newton( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum, &exp_diff );
                    move32();
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                    hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q2 ) ); // back to Q30
#else
                    hMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( hMeta->directional_meta[dir].energy_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30
#endif
                    move32();
                }
                hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] =
                    BASOP_Util_Divide3232_Scale_newton( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum, &exp_diff );
                move32();
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q2 ) ); // back to Q30
#else
                hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( hMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], sub( exp_diff, Q1 ) ); // Q30
#endif
                move32();
            }
        }
+0 −36
Original line number Diff line number Diff line
@@ -9073,11 +9073,7 @@ static void renderMasaToMasa(
    IVAS_REND_AudioBuffer outAudio )
{
    Word16 sf, band, dir, numDirs;
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
    Word32 ratioSum_fx; /* Q29 for accumulation */
#else
    Word32 ratioSum_fx; /* Q30 */
#endif
    MASA_DECODER_EXT_OUT_META_HANDLE outMeta;
    MASA_METADATA_FRAME *inMeta;
    Word32 tmpBuffer_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k];
@@ -9205,17 +9201,9 @@ static void renderMasaToMasa(
            move32();
            FOR( dir = 0; dir < numDirs; dir++ )
            {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                ratioSum_fx = L_add( ratioSum_fx, L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], 1 ) ); // accumulate in Q29
#else
                ratioSum_fx = L_add( ratioSum_fx, inMeta->directional_meta[dir].energy_ratio_fx[sf][band] );
#endif
            }
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            ratioSum_fx = L_add( ratioSum_fx, L_shr( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], 1 ) ); // accumulate in Q29
#else
            ratioSum_fx = L_add( ratioSum_fx, inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] );
#endif

            IF( ratioSum_fx == 0 )
            {
@@ -9227,11 +9215,7 @@ static void renderMasaToMasa(
                inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = ONE_IN_Q30;
                move32();
            }
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            ELSE IF( GT_32( L_abs( L_sub( ratioSum_fx, ONE_IN_Q29 ) ), 1 ) ) // else if ( ratioSum != 1.0f ) from float with minor rounding tolerance
#else
            ELSE IF( NE_32( ratioSum_fx, ONE_IN_Q30 ) )
#endif
            {
                Word16 tmp_e = 0;
                move16();
@@ -9240,11 +9224,7 @@ static void renderMasaToMasa(
                FOR( dir = 0; dir < numDirs; dir++ )
                {
                    tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], ratioSum_fx, &tmp_e );
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                    inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 2 ) ); /* Back to Q30 */
#else
                    inMeta->directional_meta[dir].energy_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */
#endif
                    move32();
                }
                tmp_e = 0;
@@ -9252,11 +9232,7 @@ static void renderMasaToMasa(
                tmp = 0;
                move32();
                tmp = BASOP_Util_Divide3232_Scale_newton( inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band], ratioSum_fx, &tmp_e );
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 2 ) ); /* Back to Q30 */
#else
                inMeta->common_meta.diffuse_to_total_ratio_fx[sf][band] = L_shl( tmp, sub( tmp_e, 1 ) ); /* Q30 */
#endif
                move32();
            }
        }
@@ -9271,17 +9247,9 @@ static void renderMasaToMasa(
            FOR( dir = 0; dir < numDirs; dir++ )
            {
                outMeta->directionIndex[dir][sf][band] = index_theta_phi_16_fx( &inMeta->directional_meta[dir].elevation_fx[sf][band], &inMeta->directional_meta[dir].azimuth_fx[sf][band], masaInput->hMasaPrerend->sph_grid16 );
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                outMeta->directToTotalRatio[dir][sf][band] = (UWord8) W_extract_h( W_mult_32_16( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], UINT8_MAX << 1 ) );
#else
                outMeta->directToTotalRatio[dir][sf][band] = (UWord8) L_shr( inMeta->directional_meta[dir].energy_ratio_fx[sf][band], Q22 );
#endif
                outMeta->diffuseToTotalRatio[sf][band] = (UWord8) sub( outMeta->diffuseToTotalRatio[sf][band], outMeta->directToTotalRatio[dir][sf][band] );
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                outMeta->spreadCoherence[dir][sf][band] = (UWord8) W_extract_h( W_mult_32_16( L_deposit_h( inMeta->directional_meta[dir].spread_coherence_fx[sf][band] ), UINT8_MAX << 1 ) );
#else
                outMeta->spreadCoherence[dir][sf][band] = (UWord8) shr( inMeta->directional_meta[dir].spread_coherence_fx[sf][band], Q7 );
#endif

                move16();
                move16();
@@ -9289,11 +9257,7 @@ static void renderMasaToMasa(
                move16();
            }

#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            outMeta->surroundCoherence[sf][band] = (UWord8) W_extract_h( W_mult_32_16( L_deposit_h( inMeta->common_meta.surround_coherence_fx[sf][band] ), UINT8_MAX << 1 ) );
#else
            outMeta->surroundCoherence[sf][band] = (UWord8) shr( inMeta->common_meta.surround_coherence_fx[sf][band], Q7 );
#endif
            move16();
        }
    }
+0 −22
Original line number Diff line number Diff line
@@ -194,11 +194,7 @@ ivas_error MasaFileReader_readNextFrame(

            for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ )
            {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
                hMeta->directional_meta[i].energy_ratio_fx[j][b] = (Word32) ( ( (int64_t) readOther[b] * ONE_IN_Q30 + 254 ) / 255 ); // Q30
#else
                hMeta->directional_meta[i].energy_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30
#endif
            }

            /* Spread coherence */
@@ -209,15 +205,11 @@ ivas_error MasaFileReader_readNextFrame(

            for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ )
            {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
#ifdef FIX_BASOP_2545_FIX_LTV_REGRESSION_2529
                int32_t tmp_coh = ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255;
                hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( tmp_coh > MAX_16 ? MAX_16 : tmp_coh ); // Q15, need to clamp
#else
                hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255 ); // Q15
#endif
#else
                hMeta->directional_meta[i].spread_coherence_fx[j][b] = (Word16) ( readOther[b] * ONE_IN_Q7 ); // Q15
#endif
            }
        }
@@ -231,11 +223,7 @@ ivas_error MasaFileReader_readNextFrame(

        for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ )
        {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            hMeta->common_meta.diffuse_to_total_ratio_fx[j][b] = (Word32) ( ( (int64_t) readOther[b] * ONE_IN_Q30 + 254 ) / 255 ); // Q30
#else
            hMeta->common_meta.diffuse_to_total_ratio_fx[j][b] = (Word32) ( readOther[b] * ONE_IN_Q22 ); // Q30
#endif
        }

        /* Surround coherence */
@@ -246,16 +234,11 @@ ivas_error MasaFileReader_readNextFrame(

        for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ )
        {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
#ifdef FIX_BASOP_2545_FIX_LTV_REGRESSION_2529
            int32_t tmp_coh = ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255;
            hMeta->common_meta.surround_coherence_fx[j][b] = (Word16) ( tmp_coh > MAX_16 ? MAX_16 : tmp_coh ); // Q15, need to clamp
#else
            hMeta->common_meta.surround_coherence_fx[j][b] = (Word16) ( ( (int32_t) readOther[b] * ONE_IN_Q15 + 254 ) / 255 ); // Q15
#endif
#else
            hMeta->common_meta.surround_coherence_fx[j][b] = shl( (Word16) readOther[b], 7 ); // Q8->Q15
            move16();
#endif
        }

@@ -267,12 +250,7 @@ ivas_error MasaFileReader_readNextFrame(

        for ( b = 0; b < MASA_FREQUENCY_BANDS; b++ )
        {
#ifdef FIX_BASOP_2529_MASA_RATIO_SCALINGS
            hMeta->common_meta.remainder_to_total_ratio_fx[j][b] = (Word32) ( ( (int64_t) readOther[b] * ONE_IN_Q30 + 254 ) / 255 ); // Q30
#else
            hMeta->common_meta.remainder_to_total_ratio_fx[j][b] = L_shl( (Word32) readOther[b], Q22 ); // Q8 -> Q30
            move32();
#endif
        }
    }