Mercurial > libavcodec.hg
changeset 9658:67a20f0eb42c libavcodec
Support for getting (i)MDCT output multiplied by a constant scaling factor.
Scaling (i)MDCT output has no runtime overhead and can be used to improve
performance of audio codecs. All the changes are only needed in
'ff_mdct_init' function and slow down initialization a bit.
author | serge |
---|---|
date | Sat, 16 May 2009 14:17:08 +0000 |
parents | 8a65ae8929fb |
children | b4350a6fb24a |
files | aac.c aacenc.c ac3dec.c atrac3.c cook.c dca.c dsputil.h fft-test.c mdct.c nellymoserdec.c nellymoserenc.c vorbis_dec.c vorbis_enc.c wmadec.c wmaenc.c |
diffstat | 15 files changed, 26 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/aac.c Sat May 16 06:39:08 2009 +0000 +++ b/aac.c Sat May 16 14:17:08 2009 +0000 @@ -500,8 +500,8 @@ ff_aac_scalefactor_code, sizeof(ff_aac_scalefactor_code[0]), sizeof(ff_aac_scalefactor_code[0]), 352); - ff_mdct_init(&ac->mdct, 11, 1); - ff_mdct_init(&ac->mdct_small, 8, 1); + ff_mdct_init(&ac->mdct, 11, 1, 1.0); + ff_mdct_init(&ac->mdct_small, 8, 1, 1.0); // window initialization ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
--- a/aacenc.c Sat May 16 06:39:08 2009 +0000 +++ b/aacenc.c Sat May 16 14:17:08 2009 +0000 @@ -214,8 +214,8 @@ s->samplerate_index = i; dsputil_init(&s->dsp, avctx); - ff_mdct_init(&s->mdct1024, 11, 0); - ff_mdct_init(&s->mdct128, 8, 0); + ff_mdct_init(&s->mdct1024, 11, 0, 1.0); + ff_mdct_init(&s->mdct128, 8, 0, 1.0); // window init ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024); ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
--- a/ac3dec.c Sat May 16 06:39:08 2009 +0000 +++ b/ac3dec.c Sat May 16 14:17:08 2009 +0000 @@ -194,8 +194,8 @@ ac3_common_init(); ac3_tables_init(); - ff_mdct_init(&s->imdct_256, 8, 1); - ff_mdct_init(&s->imdct_512, 9, 1); + ff_mdct_init(&s->imdct_256, 8, 1, 1.0); + ff_mdct_init(&s->imdct_512, 9, 1, 1.0); ff_kbd_window_init(s->window, 5.0, 256); dsputil_init(&s->dsp, avctx); av_lfg_init(&s->dith_state, 0);
--- a/atrac3.c Sat May 16 06:39:08 2009 +0000 +++ b/atrac3.c Sat May 16 14:17:08 2009 +0000 @@ -268,7 +268,7 @@ } /* Initialize the MDCT transform. */ - ff_mdct_init(&mdct_ctx, 9, 1); + ff_mdct_init(&mdct_ctx, 9, 1, 1.0); } /**
--- a/cook.c Sat May 16 06:39:08 2009 +0000 +++ b/cook.c Sat May 16 14:17:08 2009 +0000 @@ -259,7 +259,7 @@ q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel); /* Initialize the MDCT. */ - if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1)) { + if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1, 1.0)) { av_free(q->mlt_window); return -1; }
--- a/dca.c Sat May 16 06:39:08 2009 +0000 +++ b/dca.c Sat May 16 14:17:08 2009 +0000 @@ -1318,7 +1318,7 @@ dca_init_vlcs(); dsputil_init(&s->dsp, avctx); - ff_mdct_init(&s->imdct, 6, 1); + ff_mdct_init(&s->imdct, 6, 1, 1.0); for(i = 0; i < 6; i++) s->samples_chanptr[i] = s->samples + i * 256;
--- a/dsputil.h Sat May 16 06:39:08 2009 +0000 +++ b/dsputil.h Sat May 16 14:17:08 2009 +0000 @@ -771,7 +771,7 @@ extern float ff_sine_4096[4096]; extern float *ff_sine_windows[6]; -int ff_mdct_init(MDCTContext *s, int nbits, int inverse); +int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale); void ff_imdct_calc_c(MDCTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_half_c(MDCTContext *s, FFTSample *output, const FFTSample *input); void ff_imdct_calc_3dn(MDCTContext *s, FFTSample *output, const FFTSample *input);
--- a/fft-test.c Sat May 16 06:39:08 2009 +0000 +++ b/fft-test.c Sat May 16 14:17:08 2009 +0000 @@ -223,7 +223,7 @@ av_log(NULL, AV_LOG_INFO,"IMDCT"); else av_log(NULL, AV_LOG_INFO,"MDCT"); - ff_mdct_init(m, fft_nbits, do_inverse); + ff_mdct_init(m, fft_nbits, do_inverse, 1.0); } else { if (do_inverse) av_log(NULL, AV_LOG_INFO,"IFFT");
--- a/mdct.c Sat May 16 06:39:08 2009 +0000 +++ b/mdct.c Sat May 16 14:17:08 2009 +0000 @@ -68,10 +68,10 @@ /** * init MDCT or IMDCT computation. */ -av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse) +av_cold int ff_mdct_init(MDCTContext *s, int nbits, int inverse, double scale) { int n, n4, i; - double alpha; + double alpha, theta; memset(s, 0, sizeof(*s)); n = 1 << nbits; @@ -85,10 +85,12 @@ if (!s->tsin) goto fail; + theta = 1.0 / 8.0 + (scale < 0 ? n4 : 0); + scale = sqrt(fabs(scale)); for(i=0;i<n4;i++) { - alpha = 2 * M_PI * (i + 1.0 / 8.0) / n; - s->tcos[i] = -cos(alpha); - s->tsin[i] = -sin(alpha); + alpha = 2 * M_PI * (i + theta) / n; + s->tcos[i] = -cos(alpha) * scale; + s->tsin[i] = -sin(alpha) * scale; } if (ff_fft_init(&s->fft, s->nbits - 2, inverse) < 0) goto fail;
--- a/nellymoserdec.c Sat May 16 06:39:08 2009 +0000 +++ b/nellymoserdec.c Sat May 16 14:17:08 2009 +0000 @@ -130,7 +130,7 @@ s->avctx = avctx; av_lfg_init(&s->random_state, ff_random_get_seed()); - ff_mdct_init(&s->imdct_ctx, 8, 1); + ff_mdct_init(&s->imdct_ctx, 8, 1, 1.0); dsputil_init(&s->dsp, avctx);
--- a/nellymoserenc.c Sat May 16 06:39:08 2009 +0000 +++ b/nellymoserenc.c Sat May 16 14:17:08 2009 +0000 @@ -145,7 +145,7 @@ avctx->frame_size = NELLY_SAMPLES; s->avctx = avctx; - ff_mdct_init(&s->mdct_ctx, 8, 0); + ff_mdct_init(&s->mdct_ctx, 8, 0, 1.0); dsputil_init(&s->dsp, avctx); /* Generate overlap window */
--- a/vorbis_dec.c Sat May 16 06:39:08 2009 +0000 +++ b/vorbis_dec.c Sat May 16 14:17:08 2009 +0000 @@ -896,8 +896,8 @@ vc->saved = av_mallocz((vc->blocksize[1]/4)*vc->audio_channels * sizeof(float)); vc->previous_window=0; - ff_mdct_init(&vc->mdct[0], bl0, 1); - ff_mdct_init(&vc->mdct[1], bl1, 1); + ff_mdct_init(&vc->mdct[0], bl0, 1, 1.0); + ff_mdct_init(&vc->mdct[1], bl1, 1, 1.0); AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ", vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
--- a/vorbis_enc.c Sat May 16 06:39:08 2009 +0000 +++ b/vorbis_enc.c Sat May 16 14:17:08 2009 +0000 @@ -359,8 +359,8 @@ venc->win[0] = ff_vorbis_vwin[venc->log2_blocksize[0] - 6]; venc->win[1] = ff_vorbis_vwin[venc->log2_blocksize[1] - 6]; - ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0); - ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0); + ff_mdct_init(&venc->mdct[0], venc->log2_blocksize[0], 0, 1.0); + ff_mdct_init(&venc->mdct[1], venc->log2_blocksize[1], 0, 1.0); } static void put_float(PutBitContext * pb, float f) {
--- a/wmadec.c Sat May 16 06:39:08 2009 +0000 +++ b/wmadec.c Sat May 16 14:17:08 2009 +0000 @@ -110,7 +110,7 @@ /* init MDCT */ for(i = 0; i < s->nb_block_sizes; i++) - ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1); + ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 1, 1.0); if (s->use_noise_coding) { init_vlc(&s->hgain_vlc, HGAINVLCBITS, sizeof(ff_wma_hgain_huffbits),
--- a/wmaenc.c Sat May 16 06:39:08 2009 +0000 +++ b/wmaenc.c Sat May 16 14:17:08 2009 +0000 @@ -63,7 +63,7 @@ /* init MDCT */ for(i = 0; i < s->nb_block_sizes; i++) - ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0); + ff_mdct_init(&s->mdct_ctx[i], s->frame_len_bits - i + 1, 0, 1.0); avctx->block_align= s->block_align= avctx->bit_rate*(int64_t)s->frame_len / (avctx->sample_rate*8);