Commit e79feade authored by Michael Sturm's avatar Michael Sturm
Browse files

Unifies IGFDecApplyMono function.

parent bf19243e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -8116,9 +8116,14 @@ void IGFDecApplyMono(
    Word32 *spectrum,                        /**< in/out: | MDCT spectrum                                        */
    Word16 *spectrum_e,                      /**< in/out: | exponent of spectrum                                 */
    const Word16 igfGridIdx,                 /**< in:     | in case of CELP->TCX switching, use 1.25 framelength */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    Word16 bfi,                              /**< in:     | frame loss == 1, frame good == 0                     */
    Word16 element_mode                      /**< in:     | IVAS element mode                                    */
#else
    Word16 bfi                               /**< in:     | frame loss == 1, frame good == 0                     */
#endif
);

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
void IGFDecApplyMono_ivas(
    const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in:     | instance handle of IGF Decoder                       */
    Word32 *spectrum,                        /**< in/out: | MDCT spectrum                                        */
@@ -8127,6 +8132,7 @@ void IGFDecApplyMono_ivas(
    Word16 bfi,                              /**< in:     | frame loss == 1, frame good == 0                     */
    Word16 element_mode                      /**< in:     | IVAS element mode                                    */
);
#endif

void IGFDecApplyStereo(
    const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i  : instance handle of IGF Decoder                       */
+20 −0
Original line number Diff line number Diff line
@@ -1040,7 +1040,11 @@ void decoder_tcx_fx(

        *st->hIGFDec->igfData.igfInfo.nfSeed = extract_l( L_mac0( 13849L, nf_seed, 31821 ) );
        move16();
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGFDecApplyMono( st->hIGFDec, x, &x_e, igfGridIdx, bfi, st->element_mode );
#else
        IGFDecApplyMono( st->hIGFDec, x, &x_e, igfGridIdx, bfi );
#endif
    }
    test();
    test();
@@ -1048,7 +1052,11 @@ void decoder_tcx_fx(
    {
        *st->hIGFDec->igfData.igfInfo.nfSeed = extract_l( L_mac0( 13849L, nf_seed, 31821 ) );
        move16();
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGFDecApplyMono( st->hIGFDec, x, &x_e, IGF_GRID_LB_SHORT, bfi, st->element_mode );
#else
        IGFDecApplyMono( st->hIGFDec, x, &x_e, IGF_GRID_LB_SHORT, bfi );
#endif
    }

    index = hTcxCfg->tcx_last_overlap_mode; /* backup last TCX overlap mode */
@@ -3847,7 +3855,11 @@ void decoder_tcx_IGF_mono_fx(
            }
        }

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGFDecApplyMono( st->hIGFDec, x_fx, x_e, igfGridIdx, bfi, st->element_mode );
#else
        IGFDecApplyMono_ivas( st->hIGFDec, x_fx, x_e, igfGridIdx, bfi, st->element_mode );
#endif

        *x_len = st->hIGFDec->igfData.igfInfo.grid[igfGridIdx].stopLine;
        move16();
@@ -5316,7 +5328,11 @@ void decoder_tcx_noiseshaping_igf_fx(
                move16();
            }

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
            IGFDecApplyMono( st->hIGFDec, x_fx, x_e, igfGridIdx, bfi, st->element_mode );
#else
            IGFDecApplyMono_ivas( st->hIGFDec, x_fx, x_e, igfGridIdx, bfi, st->element_mode );
#endif

            *x_len = s_max( *x_len, st->hIGFDec->igfData.igfInfo.grid[igfGridIdx].stopLine );
            move16();
@@ -5328,7 +5344,11 @@ void decoder_tcx_noiseshaping_igf_fx(
    {
        IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) )
        {
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
            IGFDecApplyMono( st->hIGFDec, x_fx, x_e, IGF_GRID_LB_SHORT, bfi, st->element_mode );
#else
            IGFDecApplyMono_ivas( st->hIGFDec, x_fx, x_e, IGF_GRID_LB_SHORT, bfi, st->element_mode );
#endif

            *x_len = s_max( *x_len, st->hIGFDec->igfData.igfInfo.grid[IGF_GRID_LB_SHORT].stopLine );
            move16();
+133 −15
Original line number Diff line number Diff line
@@ -3686,6 +3686,7 @@ void IGFDecReadLevel( /**< ou
/**********************************************************************/ /*
apply the IGF decoder
**************************************************************************/
#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance,           /**< in:     | instance handle of IGF Decoder                       */
                      Word32 *spectrum,                                  /**< in/out: | MDCT spectrum                                        */
                      Word16 *spectrum_e,                                /**< in/out: | exponent of spectrum                                 */
@@ -3866,6 +3867,15 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
                           Word16 bfi,                                   /**< in:     | frame loss == 1, frame good == 0                     */
                           Word16 element_mode                           /**< in:     | IVAS element mode                                    */
)
#else
void IGFDecApplyMono( const IGF_DEC_INSTANCE_HANDLE hInstance,      /**< in:     | instance handle of IGF Decoder                       */
                      Word32 *spectrum,                             /**< in/out: | MDCT spectrum                                        */
                      Word16 *spectrum_e,                           /**< in/out: | exponent of spectrum                                 */
                      const Word16 igfGridIdx,                      /**< in:     | in case of CELP->TCX switching, use 1.25 framelength */
                      Word16 bfi,                                   /**< in:     | frame loss == 1, frame good == 0                     */
                      Word16 element_mode                           /**< in:     | IVAS element mode                                    */
)
#endif
{
    IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData;
    H_IGF_GRID hGrid;
@@ -3875,7 +3885,9 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
    Word16 specMed_e;                     /*      | exponent of the medium whitened spectrum      */
    Word32 igf_spec[IGF_MAX_GRANULE_LEN]; /* Q31  | prepared IGF spectrum                         */
    Word16 igf_spec_e[IGF_MAX_TILES];     /*      | exponents of igf_spec, one exponent per tile  */
#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    Word16 len;
#endif

    hPrivateData = &hInstance->igfData;
    hGrid = &hPrivateData->igfInfo.grid[igfGridIdx];
@@ -3884,6 +3896,24 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in

    IF( GT_16( element_mode, EVS_MONO ) )
    {
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        Word16 len;
        IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) )
        {
            len = ( N_MAX_TCX - IGF_START_MN ) / 2;
            move16();
        }
        ELSE
        {
            len = ( N_MAX_TCX - IGF_START_MN );
            move16();
        }

        set16_fx( hInstance->flag_sparse, 0, len );
        set32_fx( hInstance->virtualSpec_fx, 0, len );
        hInstance->virtualSpec_e = 0;
        move16();
#endif
        whiteningLevel = IGF_MID_WHITENING_LEVEL2;
        move16();
    }
@@ -3892,7 +3922,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
        whiteningLevel = IGF_MID_WHITENING_LEVEL;
        move16();
    }

#ifndef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) )
    {
        len = ( N_MAX_TCX - IGF_START_MN ) / 2;
@@ -3908,6 +3938,7 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
    set32_fx( hInstance->virtualSpec_fx, 0, len );
    hInstance->virtualSpec_e = 0;
    move16();
#endif

    specMed_e = 0;
    move16();
@@ -3949,6 +3980,53 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
            IF( EQ_16( hPrivateData->currWhiteningLevel[i], IGF_WHITENING_MID ) )
            {
                test();
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                IF( EQ_16( element_mode, EVS_MONO ) )
                {
                    s_l = getScaleFactor32( hPrivateData->pSpecFlat + hGrid->minSrcSubband - whiteningLevel,
                                            add( sub( hGrid->startLine, hGrid->minSrcSubband ), whiteningLevel ) );

                    IGF_getWhiteSpectralData( hPrivateData->pSpecFlat,
                                              s_l,
                                              igf_spec,
                                              hGrid->minSrcSubband,
                                              hGrid->startLine,
                                              whiteningLevel );

                    specMed_e = hPrivateData->pSpecFlat_exp;
                    move16();

                    /*14 seems to be precise enough*/
                    hPrivateData->headroom_TCX_noise_white = IGF_getScaleFactor32Cond( hInstance->infoTCXNoise_evs + hGrid->minSrcSubband,
                                                                                       igf_spec + hGrid->minSrcSubband,
                                                                                       sub( hGrid->startLine, hGrid->minSrcSubband ) );
                }
                ELSE IF( !bfi )
                {
                    s_l = getScaleFactor32( hPrivateData->pSpecFlat + hGrid->minSrcSubband - whiteningLevel,
                                            add( sub( hGrid->startLine, hGrid->minSrcSubband ), whiteningLevel ) );

                    IGF_getWhiteSpectralData_ivas( hPrivateData->pSpecFlat,
                                                   hPrivateData->pSpecFlat_exp,
                                                   s_l,
                                                   igf_spec,
                                                   &igf_spec_e[i],
                                                   hGrid->minSrcSubband,
                                                   hGrid->startLine,
                                                   whiteningLevel );

                    specMed_e = igf_spec_e[i];
                    move16();
                }
                ELSE
                {
                    Copy32( hPrivateData->pSpecFlat, igf_spec, hGrid->startLine );
                    igf_spec_e[i] = hPrivateData->pSpecFlat_exp,
                    move16();
                    specMed_e = igf_spec_e[i];
                    move16();
                }
#else
                IF( EQ_16( element_mode, EVS_MONO ) || !bfi )
                {
                    s_l = getScaleFactor32( hPrivateData->pSpecFlat + hGrid->minSrcSubband - whiteningLevel,
@@ -3971,11 +4049,12 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
                }
                specMed_e = igf_spec_e[i];
                move16();
#endif

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                hPrivateData->n_noise_bands = IGF_replaceTCXNoise_1( igf_spec,
                                                                     igf_spec_e[i],
                                                                     0,
                                                                     hPrivateData->headroom_TCX_noise_white,
                                                                     hInstance->infoTCXNoise_ptr,
                                                                     hGrid->minSrcSubband,
                                                                     hGrid->startLine,
@@ -4004,9 +4083,15 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
            {

#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
                IF( EQ_16( element_mode, EVS_MONO ) ) {
                    hPrivateData->headroom_TCX_noise = IGF_getScaleFactor32Cond( hInstance->infoTCXNoise_evs + hGrid->minSrcSubband,
                                                                                 hPrivateData->pSpecFlat + hGrid->minSrcSubband,
                                                                                 sub( hGrid->startLine, hGrid->minSrcSubband ) );
                    move16;
                }
                hPrivateData->n_noise_bands_off = IGF_replaceTCXNoise_1( hPrivateData->pSpecFlat,
                                                                         hPrivateData->pSpecFlat_exp,
                                                                         0,
                                                                         hPrivateData->headroom_TCX_noise,
                                                                         hInstance->infoTCXNoise_ptr,
                                                                         hGrid->minSrcSubband,
                                                                         hGrid->startLine,
@@ -4030,13 +4115,46 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGF_prep( hPrivateData,
                  igfGridIdx,
                  hInstance->infoTCXNoise_ptr,
                  EQ_16(element_mode, EVS_MONO) ? hInstance->infoTCXNoise_evs : hInstance->infoTCXNoise_ptr,
                  igf_spec,
                  igf_spec_e,
                  hPrivateData->pSpecFlat,
                  hPrivateData->pSpecFlat_exp,
                  specMed_e,
                  element_mode );

        IGF_calc( hPrivateData,
                  igfGridIdx,
                  spectrum,
                  *spectrum_e,
                  igf_spec,
                  igf_spec_e,
                  element_mode );

        IF( EQ_16( element_mode, EVS_MONO ) ) {
            IGF_appl( hPrivateData,
                      igfGridIdx,
                      spectrum,
                      spectrum_e,
                      igf_spec,
                      igf_spec_e,
                      hInstance->virtualSpec,
                      &hInstance->virtualSpec_e,
                      hInstance->flag_sparseBuf );
        }
        ELSE
        {
            IGF_appl_ivas( hPrivateData,
                           igfGridIdx,
                           spectrum,
                           spectrum_e,
                           igf_spec,
                           igf_spec_e,
                           hInstance->virtualSpec,
                           &hInstance->virtualSpec_e,
                           hInstance->flag_sparseBuf,
                           1 );
        }
#else
        IGF_prep_ivas( hPrivateData,
                       igfGridIdx,
@@ -4047,23 +4165,14 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
                       hPrivateData->pSpecFlat_exp,
                       specMed_e,
                       element_mode );
#endif
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
        IGF_calc( hPrivateData,
                  igfGridIdx,
                  spectrum,
                  *spectrum_e,
                  igf_spec,
                  igf_spec_e,
                  element_mode );
#else

        IGF_calc_ivas( hPrivateData,
                       igfGridIdx,
                       spectrum,
                       *spectrum_e,
                       igf_spec,
                       igf_spec_e );
#endif

        IGF_appl_ivas( hPrivateData,
                       igfGridIdx,
                       spectrum,
@@ -4074,10 +4183,19 @@ void IGFDecApplyMono_ivas( const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in
                       &hInstance->virtualSpec_e,
                       hInstance->flag_sparseBuf,
                       1 );
#endif
    }

    /* reset TCX noise indicator vector */
#ifdef FIX_2346_DUPLICATED_IGF_FUNCTIONS
    IF( EQ_16( element_mode, EVS_MONO ) )
    {
        set16_fx( hInstance->infoTCXNoise_evs, 0, IGF_START_MX );
    }
    ELSE IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) )
#else
    IF( EQ_16( igfGridIdx, IGF_GRID_LB_SHORT ) )
#endif
    {
        set16_fx( hInstance->infoTCXNoise_ptr, 0, IGF_START_MX / 2 );
    }