コード例 #1
0
static void calc_prediction_coef(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
                                 complex_t *alpha_0, complex_t *alpha_1, uint8_t k)
{
    real_t tmp, mul;
    acorr_coef ac;

    auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);

    if (ac.det == 0)
    {
        RE(alpha_1[k]) = 0;
        IM(alpha_1[k]) = 0;
    } else {
        mul = DIV_R(REAL_CONST(1.0), ac.det);
        tmp = (MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(IM(ac.r01), IM(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11)));
        RE(alpha_1[k]) = MUL_R(tmp, mul);
        tmp = (MUL_R(IM(ac.r01), RE(ac.r12)) + MUL_R(RE(ac.r01), IM(ac.r12)) - MUL_R(IM(ac.r02), RE(ac.r11)));
        IM(alpha_1[k]) = MUL_R(tmp, mul);
    }

    if (RE(ac.r11) == 0)
    {
        RE(alpha_0[k]) = 0;
        IM(alpha_0[k]) = 0;
    } else {
        mul = DIV_R(REAL_CONST(1.0), RE(ac.r11));
        tmp = -(RE(ac.r01) + MUL_R(RE(alpha_1[k]), RE(ac.r12)) + MUL_R(IM(alpha_1[k]), IM(ac.r12)));
        RE(alpha_0[k]) = MUL_R(tmp, mul);
        tmp = -(IM(ac.r01) + MUL_R(IM(alpha_1[k]), RE(ac.r12)) - MUL_R(RE(alpha_1[k]), IM(ac.r12)));
        IM(alpha_0[k]) = MUL_R(tmp, mul);
    }

    if ((MUL_R(RE(alpha_0[k]),RE(alpha_0[k])) + MUL_R(IM(alpha_0[k]),IM(alpha_0[k])) >= REAL_CONST(16)) ||
        (MUL_R(RE(alpha_1[k]),RE(alpha_1[k])) + MUL_R(IM(alpha_1[k]),IM(alpha_1[k])) >= REAL_CONST(16)))
    {
        RE(alpha_0[k]) = 0;
        IM(alpha_0[k]) = 0;
        RE(alpha_1[k]) = 0;
        IM(alpha_1[k]) = 0;
    }
}
コード例 #2
0
static void calc_prediction_coef_lp(sbr_info *sbr, qmf_t Xlow[MAX_NTSRHFG][64],
                                    complex_t *alpha_0, complex_t *alpha_1, real_t *rxx)
{
    uint8_t k;
    real_t tmp, mul;
    acorr_coef ac;

    for (k = 1; k < sbr->f_master[0]; k++)
    {
        auto_correlation(sbr, &ac, Xlow, k, sbr->numTimeSlotsRate + 6);

        if (ac.det == 0)
        {
            RE(alpha_0[k]) = 0;
            RE(alpha_1[k]) = 0;
        } else {
            mul = DIV_R(REAL_CONST(1.0), ac.det);
            tmp = MUL_R(RE(ac.r01), RE(ac.r22)) - MUL_R(RE(ac.r12), RE(ac.r02));
            RE(alpha_0[k]) = -MUL_R(tmp, mul);
            tmp = MUL_R(RE(ac.r01), RE(ac.r12)) - MUL_R(RE(ac.r02), RE(ac.r11));
            RE(alpha_1[k]) = MUL_R(tmp, mul);
        }

        if ((RE(alpha_0[k]) >= REAL_CONST(4)) || (RE(alpha_1[k]) >= REAL_CONST(4)))
        {
            RE(alpha_0[k]) = REAL_CONST(0);
            RE(alpha_1[k]) = REAL_CONST(0);
        }

        /* reflection coefficient */
        if (RE(ac.r11) == 0)
        {
            rxx[k] = COEF_CONST(0.0);
        } else {
            rxx[k] = DIV_C(RE(ac.r01), RE(ac.r11));
            rxx[k] = -rxx[k];
            if (rxx[k] > COEF_CONST( 1.0)) rxx[k] = COEF_CONST(1.0);
            if (rxx[k] < COEF_CONST(-1.0)) rxx[k] = COEF_CONST(-1.0);
        }
    }
}
コード例 #3
0
ファイル: aacquant.c プロジェクト: epheatt/wis-streamer
/* 
 * Parameter:
 *  coderInfo(I)
 *  xr(I)
 *  xmin(O)
 *  quality(I)
 */
static void CalcAllowedDist(CoderInfo *coderInfo, 
                            pow_t *xr2, real_32_t *xmin, real_32_t quality)
{
    register int32_t sfb, start, end, l;
    int32_t last = coderInfo->lastx;
    int32_t lastsb = 0;
    int32_t *cb_offset = coderInfo->sfb_offset;
    int32_t num_cb = coderInfo->nr_of_sfb;
    eng_t avgenrg = coderInfo->avgenrg;
    static real_32_t realconst1 = REAL_CONST(0.075);
    static real_32_t realconst2 = REAL_CONST(1.4);
    static real_32_t realconst3 = REAL_CONST(0.4);
    static real_32_t realconst4 = REAL_CONST(147.84); /* 132 * 1.12 */

    for (sfb = 0; sfb < num_cb; sfb++)  {
        if (last > cb_offset[sfb])
            lastsb = sfb;
    }

    for (sfb = 0; sfb < num_cb; sfb++)  {
        real_t thr;
        real_32_t tmp;
        eng_t enrg = 0;

        start = cb_offset[sfb];
        end = cb_offset[sfb + 1];

        if (sfb > lastsb)  {
            xmin[sfb] = 0;
            continue;
        }

        if (coderInfo->block_type != ONLY_SHORT_WINDOW) {
            eng_t enmax = -1;
            int32_t lmax;

            lmax = start;
            for (l = start; l < end; l++) {
                if (enmax < xr2[l]) {
                    enmax = xr2[l];
                    lmax = l;
                }
            }

            start = lmax - 2;
            end = lmax + 3;

            if (start < 0)
                start = 0;
        
            if (end > last)
                end = last;
        }

        for (l = start; l < end; l++) {
            enrg += xr2[l];
        }

        if ( (avgenrg == 0) || (enrg==0) )
            thr = 0;
        else {
            thr = (avgenrg<<REAL_BITS)*(end-start)/enrg;
            thr = faac_pow(thr, REAL_ICONST(sfb)/(lastsb*10)-realconst3);
        }

        tmp = DIV_R(REAL_ICONST(last-start),REAL_ICONST(last));
        tmp = MUL_R(MUL_R(tmp,tmp),tmp) + realconst1;

        thr = MUL_R(realconst2,thr) + tmp;

        xmin[sfb] = DIV_R(DIV_R(realconst4,thr),quality);
#ifdef DUMP_XMIN
        printf("xmin[%d] = %.8f\n",sfb,REAL2FLOAT(xmin[sfb]));
#endif
    }
#ifdef DUMP_XMIN
//    exit(1);
#endif
}