示例#1
0
/*-- convert to mono, add curr result to y,
    window and add next time to current left */
int hybrid_sum(float xin[], float xin_left[], float y[18][32],
               int btype, int nlong, int ntot)
{
    int i, j;
    float *x, *x0;
    float xa, xb;
    int n;
    int nout;



    if (btype == 2)
        btype = 0;
    x = xin;
    x0 = xin_left;

    /*-- do long blocks (if any) --*/
    n = (nlong + 17) / 18;	/* number of dct's to do */
    for (i = 0; i < n; i++)
    {
        imdct18(x);
        for (j = 0; j < 9; j++)
        {
            y[j][i] += win[btype][j] * x[9 + j];
            y[9 + j][i] += win[btype][9 + j] * x[17 - j];
        }
        /* window x for next time x0 */
        for (j = 0; j < 4; j++)
        {
            xa = x[j];
            xb = x[8 - j];
            x0[j] += win[btype][18 + j] * xb;
            x0[8 - j] += win[btype][(18 + 8) - j] * xa;
            x0[9 + j] += win[btype][(18 + 9) + j] * xa;
            x0[17 - j] += win[btype][(18 + 17) - j] * xb;
        }
        xa = x[j];
        x0[j] += win[btype][18 + j] * xa;
        x0[9 + j] += win[btype][(18 + 9) + j] * xa;

        x += 18;
        x0 += 18;
    }

    /*-- do short blocks (if any) --*/
    n = (ntot + 17) / 18;	/* number of 6 pt dct's triples to do */
    for (; i < n; i++)
    {
        imdct6_3(x);
        for (j = 0; j < 3; j++)
        {
            y[6 + j][i] += win[2][j] * x[3 + j];
            y[9 + j][i] += win[2][3 + j] * x[5 - j];

            y[12 + j][i] += win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j];
            y[15 + j][i] += win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j];
        }
        /* window x for next time */
        for (j = 0; j < 3; j++)
        {
            x0[j] += win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j];
            x0[3 + j] += win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j];
        }
        for (j = 0; j < 3; j++)
        {
            x0[6 + j] += win[2][6 + j] * x[(12 + 2) - j];
            x0[9 + j] += win[2][9 + j] * x[12 + j];
        }
        x += 18;
        x0 += 18;
    }

    nout = 18 * i;

    return nout;
}
示例#2
0
/*====================================================================*/
int hybrid(float xin[], float xprev[], float y[18][32],
           int btype, int nlong, int ntot, int nprev)
{
    int i, j;
    float *x, *x0;
    float xa, xb;
    int n;
    int nout;



    if (btype == 2)
        btype = 0;
    x = xin;
    x0 = xprev;

    /*-- do long blocks (if any) --*/
    n = (nlong + 17) / 18;	/* number of dct's to do */
    for (i = 0; i < n; i++)
    {
        imdct18(x);
        for (j = 0; j < 9; j++)
        {
            y[j][i] = x0[j] + win[btype][j] * x[9 + j];
            y[9 + j][i] = x0[9 + j] + win[btype][9 + j] * x[17 - j];
        }
        /* window x for next time x0 */
        for (j = 0; j < 4; j++)
        {
            xa = x[j];
            xb = x[8 - j];
            x[j] = win[btype][18 + j] * xb;
            x[8 - j] = win[btype][(18 + 8) - j] * xa;
            x[9 + j] = win[btype][(18 + 9) + j] * xa;
            x[17 - j] = win[btype][(18 + 17) - j] * xb;
        }
        xa = x[j];
        x[j] = win[btype][18 + j] * xa;
        x[9 + j] = win[btype][(18 + 9) + j] * xa;

        x += 18;
        x0 += 18;
    }

    /*-- do short blocks (if any) --*/
    n = (ntot + 17) / 18;	/* number of 6 pt dct's triples to do */
    for (; i < n; i++)
    {
        imdct6_3(x);
        for (j = 0; j < 3; j++)
        {
            y[j][i] = x0[j];
            y[3 + j][i] = x0[3 + j];

            y[6 + j][i] = x0[6 + j] + win[2][j] * x[3 + j];
            y[9 + j][i] = x0[9 + j] + win[2][3 + j] * x[5 - j];

            y[12 + j][i] = x0[12 + j] + win[2][6 + j] * x[2 - j] + win[2][j] * x[(6 + 3) + j];
            y[15 + j][i] = x0[15 + j] + win[2][9 + j] * x[j] + win[2][3 + j] * x[(6 + 5) - j];
        }
        /* window x for next time x0 */
        for (j = 0; j < 3; j++)
        {
            x[j] = win[2][6 + j] * x[(6 + 2) - j] + win[2][j] * x[(12 + 3) + j];
            x[3 + j] = win[2][9 + j] * x[6 + j] + win[2][3 + j] * x[(12 + 5) - j];
        }
        for (j = 0; j < 3; j++)
        {
            x[6 + j] = win[2][6 + j] * x[(12 + 2) - j];
            x[9 + j] = win[2][9 + j] * x[12 + j];
        }
        for (j = 0; j < 3; j++)
        {
            x[12 + j] = 0.0f;
            x[15 + j] = 0.0f;
        }
        x += 18;
        x0 += 18;
    }

    /*--- overlap prev if prev longer that current --*/
    n = (nprev + 17) / 18;
    for (; i < n; i++)
    {
        for (j = 0; j < 18; j++)
            y[j][i] = x0[j];
        x0 += 18;
    }
    nout = 18 * i;

    /*--- clear remaining only to band limit --*/
    for (; i < pMP3Stream->band_limit_nsb; i++)
    {
        for (j = 0; j < 18; j++)
            y[j][i] = 0.0f;
    }

    return nout;
}
示例#3
0
void inv_mdct(float *in0,
			  float out2[18][32],
				float *prevblock,
				int block_type) {
	int i,m,p;

#ifdef MDCT_BLOCKTYPE_PROFILE
	static int prof_bt[4]={0,0,0,0};
	static int prof_bt_total=0;

	prof_bt[block_type]++;
	prof_bt_total++;

	if (!(prof_bt_total&262143)) {
		static char buf[256];

		wsprintf(buf, "%d MDCTs, %d%% type 0, %d%% type 1, %d%% type 2, %d%% type 3\n"
			,prof_bt_total
			,(prof_bt[0]*100)/prof_bt_total
			,(prof_bt[1]*100)/prof_bt_total
			,(prof_bt[2]*100)/prof_bt_total
			,(prof_bt[3]*100)/prof_bt_total);
		OutputDebugString(buf);
	}
#endif

	double  sum;
	double in[18], out[36];

	/*
	for(p=0;p<36;p++) {
		sum = 0.0;
		for(m=0;m<18;m++)
			sum += in[m] * cos( (PI/72) * (2*p+1+18)*(2*m+1));

		out[p] = sum;
	}
	*/

	if (block_type == 2) {
		int j;

		imdct6_3(in, in0);

		for(i=0;i<36;i++)
			out[i]=0.0;

		for(i=0;i<3;i++){
			for(p=0;p<3;p++) {
				out[6*i+6+p] += in[i*6+p+3] * win[2][p];
				out[6*i+11-p] += -in[i*6+p+3] * win[2][5-p];
				out[6*i+14-p] += -in[i*6+p] * win[2][3+p];
				out[6*i+15+p] += -in[i*6+p] * win[2][2-p];
			}
		}

		for(i=0; i<18; i++) {
			out2[i][0] = out[i] + prevblock[i];
			prevblock[i] = out[i+18];
		}

	} else {

		imdct18(in, in0);

		switch(block_type) {
		case 0:
//			for(i=0; i<18; i++) {
//				out[i   ] *= win[0][i];
//				out[35-i] *= win[0][i];
//			}

//			for(i=0; i<9; i++) {
//				out[i] = in[i+9];
//				out[17-i] = -in[i+9];
//				out[26-i] = -in[i];
//				out[27+i] = -in[i];
//			}

			for(i=0; i<9; i++) {
				out2[i  ][0] = prevblock[i  ] - in[ 9+i]*win[0][i  ];
				out2[i+9][0] = prevblock[i+9] + in[17-i]*win[0][i+9];
			}

			for(i=0; i<4; i++) {
				double in1 = in[8-i];
				double in2 = in[i];

				prevblock[   i] = in1 * win[0][17-i];
				prevblock[ 9+i] = in2 * win[0][ 8-i];
				prevblock[ 8-i] = in2 * win[0][ 9+i];
				prevblock[17-i] = in1 * win[0][   i];
			}

			prevblock[4  ] = in[4] * win[0][13];
			prevblock[4+9] = in[4] * win[0][ 4];

			break;
		case 1:
			for(i=0; i<9; i++) {
				out[i] = -in[i+9];
				out[17-i] = in[i+9];
				out[26-i] = in[i];
				out[27+i] = in[i];
			}

			for(i=0; i<18; i++)
				out[i] *= win[1][i];

			for(i=18; i<24; i++)
				out[i] = -out[i];

			for(i=24; i<30; i++)
				out[i] *= win[1][i];

			for(i=30; i<36; i++)
				out[i] = 0.0;

			for(i=0; i<18; i++) {
				out2[i][0] = out[i] + prevblock[i];
				prevblock[i] = out[i+18];
			}
			break;
		case 3:
			for(i=0; i<9; i++) {
				out[i] = -in[i+9];
				out[17-i] = in[i+9];
				out[26-i] = in[i];
				out[27+i] = in[i];
			}

			for(i=0; i<6; i++)
				out[i] = 0.0;

			for(i=6; i<12; i++)
				out[i] *= win[3][i];

			for(i=12; i<18; i++)
				out[i] = -out[i];

			for(i=18; i<36; i++)
				out[i] *= win[3][i];

			for(i=0; i<18; i++) {
				out2[i][0] = out[i] + prevblock[i];
				prevblock[i] = out[i+18];
			}
			break;
		}
	}
}