Пример #1
0
void
mdct_sub48(lame_internal_flags * gfc, const sample_t * w0, const sample_t * w1)
{
    SessionConfig_t const *const cfg = &gfc->cfg;
    EncStateVar_t *const esv = &gfc->sv_enc;
    int     gr, k, ch;
    const sample_t *wk;

    wk = w0 + 286;
    /* thinking cache performance, ch->gr loop is better than gr->ch loop */
    for (ch = 0; ch < cfg->channels_out; ch++) {
        for (gr = 0; gr < cfg->mode_gr; gr++) {
            int     band;
            gr_info *const gi = &(gfc->l3_side.tt[gr][ch]);
            FLOAT  *mdct_enc = gi->xr;
            FLOAT  *samp = esv->sb_sample[ch][1 - gr][0];

            for (k = 0; k < 18 / 2; k++) {
                window_subband(wk, samp);
                window_subband(wk + 32, samp + 32);
                samp += 64;
                wk += 64;
                /*
                 * Compensate for inversion in the analysis filter
                 */
                for (band = 1; band < 32; band += 2) {
                    samp[band - 32] *= -1;
                }
            }

            /*
             * Perform imdct of 18 previous subband samples
             * + 18 current subband samples
             */
            for (band = 0; band < 32; band++, mdct_enc += 18) {
                int     type = gi->block_type;
                FLOAT const *const band0 = esv->sb_sample[ch][gr][0] + order[band];
                FLOAT  *const band1 = esv->sb_sample[ch][1 - gr][0] + order[band];
                if (gi->mixed_block_flag && band < 2)
                    type = 0;
                if (esv->amp_filter[band] < 1e-12) {
                    memset(mdct_enc, 0, 18 * sizeof(FLOAT));
                }
                else {
                    if (esv->amp_filter[band] < 1.0) {
                        for (k = 0; k < 18; k++)
                            band1[k * 32] *= esv->amp_filter[band];
                    }
                    if (type == SHORT_TYPE) {
                        for (k = -NS / 4; k < 0; k++) {
                            FLOAT const w = win[SHORT_TYPE][k + 3];
                            mdct_enc[k * 3 + 9] = band0[(9 + k) * 32] * w - band0[(8 - k) * 32];
                            mdct_enc[k * 3 + 18] = band0[(14 - k) * 32] * w + band0[(15 + k) * 32];
                            mdct_enc[k * 3 + 10] = band0[(15 + k) * 32] * w - band0[(14 - k) * 32];
                            mdct_enc[k * 3 + 19] = band1[(2 - k) * 32] * w + band1[(3 + k) * 32];
                            mdct_enc[k * 3 + 11] = band1[(3 + k) * 32] * w - band1[(2 - k) * 32];
                            mdct_enc[k * 3 + 20] = band1[(8 - k) * 32] * w + band1[(9 + k) * 32];
                        }
                        mdct_short(mdct_enc);
                    }
                    else {
                        FLOAT   work[18];
                        for (k = -NL / 4; k < 0; k++) {
                            FLOAT   a, b;
                            a = win[type][k + 27] * band1[(k + 9) * 32]
                                + win[type][k + 36] * band1[(8 - k) * 32];
                            b = win[type][k + 9] * band0[(k + 9) * 32]
                                - win[type][k + 18] * band0[(8 - k) * 32];
                            work[k + 9] = a - b * tantab_l[k + 9];
                            work[k + 18] = a * tantab_l[k + 9] + b;
                        }

                        mdct_long(mdct_enc, work);
                    }
                }
                /*
                 * Perform aliasing reduction butterfly
                 */
                if (type != SHORT_TYPE && band != 0) {
                    for (k = 7; k >= 0; --k) {
                        FLOAT   bu, bd;
                        bu = mdct_enc[k] * ca[k] + mdct_enc[-1 - k] * cs[k];
                        bd = mdct_enc[k] * cs[k] - mdct_enc[-1 - k] * ca[k];

                        mdct_enc[-1 - k] = bu;
                        mdct_enc[k] = bd;
                    }
                }
            }
        }
        wk = w1 + 286;
        if (cfg->mode_gr == 1) {
            memcpy(esv->sb_sample[ch][0], esv->sb_sample[ch][1], 576 * sizeof(FLOAT));
        }
    }
}
Пример #2
0
void mdct_sub48( lame_internal_flags *gfc, const sample_t *w0, const sample_t *w1, 
                 FLOAT8 mdct_freq[2][2][576] )
{
    int gr, k, ch;
    const sample_t *wk;

    wk = w0 + 286;
    /* thinking cache performance, ch->gr loop is better than gr->ch loop */
    for (ch = 0; ch < gfc->channels_out; ch++) {
	for (gr = 0; gr < gfc->mode_gr; gr++) {
	    int	band;
	    FLOAT8 *mdct_enc = &mdct_freq[gr][ch][0];
	    gr_info *gi = &(gfc->l3_side.gr[gr].ch[ch].tt);
	    FLOAT8 *samp = gfc->sb_sample[ch][1 - gr][0];

	    for (k = 0; k < 18 / 2; k++) {
		window_subband(wk, samp);
		window_subband(wk + 32, samp + 32);
		samp += 64;
		wk += 64;
		/*
		 * Compensate for inversion in the analysis filter
		 */
		for (band = 1; band < 32; band+=2) {
		    samp[band-32] *= -1;
		}
	    }


	    /* apply filters on the polyphase filterbank outputs */
	    /* bands <= gfc->highpass_band will be zeroed out below */
	    /* bands >= gfc->lowpass_band  will be zeroed out below */
	    if (gfc->filter_type==0) {
              for (band=gfc->highpass_start_band;  band <= gfc->highpass_end_band; band++) { 
		  for (k=0; k<18; k++) 
		    gfc->sb_sample[ch][1-gr][k][order[band]]*=gfc->amp_highpass[band];
	      }
              for (band=gfc->lowpass_start_band;  band <= gfc->lowpass_end_band; band++) { 
		  for (k=0; k<18; k++) 
		    gfc->sb_sample[ch][1-gr][k][order[band]]*=gfc->amp_lowpass[band];
	      }
	    }
	    


	    /*
	     * Perform imdct of 18 previous subband samples
	     * + 18 current subband samples
	     */
	    for (band = 0; band < 32; band++, mdct_enc += 18) {
		int type = gi->block_type;
		FLOAT8 *band0, *band1;
		band0 = gfc->sb_sample[ch][  gr][0] + order[band];
		band1 = gfc->sb_sample[ch][1-gr][0] + order[band];
		if (gi->mixed_block_flag && band < 2)
		    type = 0;
		if (band >= gfc->lowpass_band || band <= gfc->highpass_band) {
		    memset((char *)mdct_enc,0,18*sizeof(FLOAT8));
		} else {
		  if (type == SHORT_TYPE) {
		    for (k = -NS/4; k < 0; k++) {
			FLOAT8 w = win[SHORT_TYPE][k+3];
			mdct_enc[k*3+ 9] = band0[( 9+k)*32] * w - band0[( 8-k)*32];
			mdct_enc[k*3+18] = band0[(14-k)*32] * w + band0[(15+k)*32];
			mdct_enc[k*3+10] = band0[(15+k)*32] * w - band0[(14-k)*32];
			mdct_enc[k*3+19] = band1[( 2-k)*32] * w + band1[( 3+k)*32];
			mdct_enc[k*3+11] = band1[( 3+k)*32] * w - band1[( 2-k)*32];
			mdct_enc[k*3+20] = band1[( 8-k)*32] * w + band1[( 9+k)*32];
		    }
		    mdct_short(mdct_enc);
		  } else {
		    FLOAT8 work[18];
		    for (k = -NL/4; k < 0; k++) {
			FLOAT8 a, b;
			a = win[type][k+27] * band1[(k+9)*32]
			  + win[type][k+36] * band1[(8-k)*32];
			b = win[type][k+ 9] * band0[(k+9)*32]
			  - win[type][k+18] * band0[(8-k)*32];
			work[k+ 9] = a - b*tantab_l[k+9];
			work[k+18] = a*tantab_l[k+9] + b;
		    }

		    mdct_long(mdct_enc, work);
		  }
		}
		/*
		 * Perform aliasing reduction butterfly
		 */
		if (type != SHORT_TYPE) {
		  if (band == 0)
		    continue;
		  for (k = 7; k >= 0; --k) {
		    FLOAT8 bu,bd;
		    bu = mdct_enc[k] * ca[k] + mdct_enc[-1-k] * cs[k];
		    bd = mdct_enc[k] * cs[k] - mdct_enc[-1-k] * ca[k];
		    
		    mdct_enc[-1-k] = bu;
		    mdct_enc[k]    = bd;
		  }
		}
	      }
	}
	wk = w1 + 286;
	if (gfc->mode_gr == 1) {
	    memcpy(gfc->sb_sample[ch][0], gfc->sb_sample[ch][1], 576 * sizeof(FLOAT8));
	}
    }
}