Commit 6ef04f72 authored by Sandesh Venkatesh's avatar Sandesh Venkatesh
Browse files

IGF Stereo TCX Functions

[x] IGF stereo tcx functions converted to fixed point and
caller functions updated to use these functions.
parent 077e7b2c
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@
#include "prot.h"
#include "rom_com.h"
#include "wmc_auto.h"
#ifdef IVAS_FLOAT_FIXED
#include "prot_fx2.h"
#endif

/*---------------------------------------------------------------------*
 * IGF_ApplyTransFac_flt()
@@ -504,6 +507,12 @@ static void IGF_gridSetUp_flt(
        hGrid->sfbWrap[t] = 0;
    }

#ifdef IVAS_FLOAT_FIXED
    hGrid->fFactor = float_to_fix16(hGrid->fFactor_flt, Q14);
    hGrid->lFactor = float_to_fix16(hGrid->lFactor_flt, Q14);
    hGrid->gFactor = float_to_fix16(hGrid->gFactor_flt, Q14);
#endif

    return;
}

+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@
#define SQRT2                                   1.414213562373095f
#define SQRT2_FIXED                             1518500250 // Q30
#define SQRT2_OVER_2                            (SQRT2 / 2.0f)
#define SQRT2_OVER_2_FIXED                      1518500250 // Q31

#define INV_SQRT2                               7.071067811865475e-1f /* 1/sqrt(2) */
#define INV_SQRT3                               0.577350269189626f    /* 1/sqrt(3) */
+22 −0
Original line number Diff line number Diff line
@@ -378,6 +378,28 @@ void init_tcx_info_fx(
    Word16 *L_spec                /* o  : spectrum length                                                  */
);

void decoder_tcx_IGF_mono_fx(
    Decoder_State *st,                                         /* i/o: coder memory state                      */
    Word32 x_fx[],                                             /* o  : de-quatized coefficients                */
    Word16 *x_e,                                               /* o  : de-quatized coefficients exponent       */
    const Word16 L_frame,                                      /* i  : frame length                            */
    const Word16 left_rect,                                    /* i  : left part is rectangular                */
    const Word16 bfi,                                          /* i  : bad frame indicator                     */
    const Word16 frame_cnt                                     /* i  : frame counter in the super_frame        */
);

void decoder_tcx_IGF_stereo_fx(
    Decoder_State **sts,                     /* i/o: coder memory states                    */
    STEREO_MDCT_DEC_DATA_HANDLE hStereoMdct, /* i/o: MDCT stereo structure                  */
    Word16 ms_mask[NB_DIV][MAX_SFB],        /* i  : bandwise MS mask                       */
    float *x[CPE_CHANNELS][NB_DIV],          /* o  : de-quatized coefficients               */
    const Word16 L_frame,                   /* i  : frame length                           */
    const Word16 left_rect,                 /* i  : left part is rectangular               */
    const Word16 k,                         /* i  : Subframe index                         */
    const Word16 bfi,                       /* i  : bad frame indicator                    */
    const Word16 MCT_flag                   /* i  : hMCT handle allocated (1) or not (0)   */
);

void IGFDecReplicateTCX10State_fx(
    IGF_DEC_INSTANCE_HANDLE hIGFDec /* i/o: instance handle of IGF Decoder          */
);
+15 −1
Original line number Diff line number Diff line
@@ -8026,6 +8026,20 @@ void IGFDecApplyMono_ivas(
    Word16                                          element_mode        /**< in:     | IVAS element mode                                    */
);

void IGFDecApplyStereo(
    const IGF_DEC_INSTANCE_HANDLE hIGFDecL, /* i  : instance handle of IGF Decoder                       */
    const IGF_DEC_INSTANCE_HANDLE hIGFDecR, /* i  : instance handle of IGF Decoder                       */
    Word32 *spectrumL_fx,                   /* i/o: L MDCT spectrum                                      */
    Word16 *spectrumL_e,                    /* i/o: L MDCT spectrum exp                                  */
    Word32 *spectrumR_fx,                   /* i/o: R MDCT spectrum                                      */
    Word16 *spectrumR_e,                    /* i/o: R MDCT spectrum exp                                  */
    const Word16 igfGridIdx,                /* i  : in case of CELP->TCX switching, use 1.25 framelength */
    const Word16 *coreMsMask,
    const Word16 restrict_hopsize,
    const Word16 bfi, /* i  : frame loss == 1, frame good == 0                     */
    const Word16 bfi_apply_damping
);

void IGFDecSetMode(
  const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* o  : instance handle of IGF Decoder      */
  const Word32 total_brate,             /* i  : bitrate                             */
@@ -8051,7 +8065,7 @@ void IGFDecUpdateInfo(const IGF_DEC_INSTANCE_HANDLE hInstance,
  const Word16                                   igfGridIdx          /**< in:     | IGF grid index                 */
);

void IGFDecUpdateInfo_fx(
void IGFDecUpdateInfo_ivas_fx(
    const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i/o: instance handle of IGF Decoder      */
    const Word16 subFrameIdx,              /* i  : subframe index                      */
    const Word16 igfGridIdx                /* i  : IGF grid index                      */
+0 −31
Original line number Diff line number Diff line
@@ -2524,38 +2524,7 @@ void decoder_tcx_IGF_mono(
            igfGridIdx = ( st->last_core == ACELP_CORE || ( left_rect && bfi ) ) ? IGF_GRID_LB_TRAN : IGF_GRID_LB_NORM;
        }

#ifdef IVAS_FLOAT_FIXED
        Word16 len;
        Word32 x_fx[N_MAX];
        Word16 x_e;
        len = ((igfGridIdx == IGF_GRID_LB_SHORT) ? (N_MAX_TCX - IGF_START_MN) / 2 : (N_MAX_TCX - IGF_START_MN));
        IGF_GRID *hGrid = &st->hIGFDec->igfData.igfInfo.grid[igfGridIdx];
        Word16 stop = hGrid->stopLine;

        // Float to fixed
        f2me_buf(x, x_fx, &x_e, stop);
        hGrid->fFactor = float_to_fix16(hGrid->fFactor_flt, Q14);
        hGrid->lFactor = float_to_fix16(hGrid->lFactor_flt, Q14);
        hGrid->gFactor = float_to_fix16(hGrid->gFactor_flt, Q14);
        // u8bit to 16bit
        FOR(int l = 0; l < IGF_START_MX; l++)
        {
            st->hIGFDec->infoTCXNoise_evs[l] = (Word16)st->hIGFDec->infoTCXNoise[l];
        }

        IGFDecApplyMono_ivas( st->hIGFDec, x_fx, &x_e, igfGridIdx, bfi, st->element_mode );

        // Fixed to float
        me2f_buf(x_fx, x_e, x, stop);
        me2f_buf(st->hIGFDec->virtualSpec, st->hIGFDec->virtualSpec_e, st->hIGFDec->virtualSpec_float, len);
        // 16bit to u8bit
        FOR(Word16 l = 0; l < IGF_START_MX; l++)
        {
            st->hIGFDec->infoTCXNoise[l] = (uint8_t)st->hIGFDec->infoTCXNoise_evs[l];
        }
#else
        IGFDecApplyMono_flt( st->hIGFDec, x, igfGridIdx, bfi, st->element_mode );
#endif
    }

    return;
Loading