diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2009-10-28 10:51:51 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2009-10-28 10:51:51 +0000 |
commit | 4f99c31c3935a8a56b78af26ee0650c8d86d8a5b (patch) | |
tree | db87c203517fdbb3bd6f01fccb0f1dd047a79b24 | |
parent | 638783bf8155d1d4a901646ce836aeed14227824 (diff) | |
download | ffmpeg-4f99c31c3935a8a56b78af26ee0650c8d86d8a5b.tar.gz |
Split synth filter out of dca.c.
Originally committed as revision 20396 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavcodec/Makefile | 2 | ||||
-rw-r--r-- | libavcodec/dca.c | 36 | ||||
-rw-r--r-- | libavcodec/synth_filter.c | 56 | ||||
-rw-r--r-- | libavcodec/synth_filter.h | 27 |
4 files changed, 89 insertions, 32 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile index e5fecbc809..30cdd11d6d 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -73,7 +73,7 @@ OBJS-$(CONFIG_CLJR_ENCODER) += cljr.o OBJS-$(CONFIG_COOK_DECODER) += cook.o OBJS-$(CONFIG_CSCD_DECODER) += cscd.o OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o -OBJS-$(CONFIG_DCA_DECODER) += dca.o +OBJS-$(CONFIG_DCA_DECODER) += dca.o synth_filter.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o \ mpegvideo_enc.o motion_est.o \ diff --git a/libavcodec/dca.c b/libavcodec/dca.c index f1a5ab4344..bd8990f41a 100644 --- a/libavcodec/dca.c +++ b/libavcodec/dca.c @@ -37,6 +37,7 @@ #include "dcadata.h" #include "dcahuff.h" #include "dca.h" +#include "synth_filter.h" //#define TRACE @@ -753,9 +754,6 @@ static void qmf_32_subbands(DCAContext * s, int chans, const float *prCoeff; int i, j; - int hist_index= s->hist_index[chans]; - float *subband_fir_hist2 = s->subband_fir_noidea[chans]; - int subindex; scale *= sqrt(1/8.0); @@ -768,7 +766,6 @@ static void qmf_32_subbands(DCAContext * s, int chans, /* Reconstructed channel sample index */ for (subindex = 0; subindex < 8; subindex++) { - float *subband_fir_hist = s->subband_fir_hist[chans] + hist_index; /* Load in one sample from each subband and clear inactive subbands */ for (i = 0; i < s->subband_activity[chans]; i++){ if((i-1)&2) s->raXin[i] = -samples_in[i][subindex]; @@ -777,36 +774,13 @@ static void qmf_32_subbands(DCAContext * s, int chans, for (; i < 32; i++) s->raXin[i] = 0.0; - ff_imdct_half(&s->imdct, subband_fir_hist, s->raXin); - - /* Multiply by filter coefficients */ - for (i = 0; i < 16; i++){ - float a= subband_fir_hist2[i ]; - float b= subband_fir_hist2[i+16]; - float c= 0; - float d= 0; - for (j = 0; j < 512-hist_index; j += 64){ - a += prCoeff[i+j ]*(-subband_fir_hist[15-i+j]); - b += prCoeff[i+j+16]*( subband_fir_hist[ i+j]); - c += prCoeff[i+j+32]*( subband_fir_hist[16+i+j]); - d += prCoeff[i+j+48]*( subband_fir_hist[31-i+j]); - } - for ( ; j < 512; j += 64){ - a += prCoeff[i+j ]*(-subband_fir_hist[15-i+j-512]); - b += prCoeff[i+j+16]*( subband_fir_hist[ i+j-512]); - c += prCoeff[i+j+32]*( subband_fir_hist[16+i+j-512]); - d += prCoeff[i+j+48]*( subband_fir_hist[31-i+j-512]); - } - samples_out[i ] = a * scale + bias; - samples_out[i+16] = b * scale + bias; - subband_fir_hist2[i ] = c; - subband_fir_hist2[i+16] = d; - } + ff_synth_filter_float(&s->imdct, + s->subband_fir_hist[chans], &s->hist_index[chans], + s->subband_fir_noidea[chans], prCoeff, + samples_out, s->raXin, scale, bias); samples_out+= 32; - hist_index = (hist_index-32)&511; } - s->hist_index[chans]= hist_index; } static void lfe_interpolation_fir(int decimation_select, diff --git a/libavcodec/synth_filter.c b/libavcodec/synth_filter.c new file mode 100644 index 0000000000..3df1a2a8a2 --- /dev/null +++ b/libavcodec/synth_filter.c @@ -0,0 +1,56 @@ +/* + * copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "synth_filter.h" + +void ff_synth_filter_float(FFTContext *imdct, + float *synth_buf_ptr, int *synth_buf_offset, + float synth_buf2[32], const float window[512], + float out[32], const float in[32], float scale, float bias) +{ + float *synth_buf= synth_buf_ptr + *synth_buf_offset; + int i, j; + + ff_imdct_half(imdct, synth_buf, in); + + for (i = 0; i < 16; i++){ + float a= synth_buf2[i ]; + float b= synth_buf2[i+16]; + float c= 0; + float d= 0; + for (j = 0; j < 512 - *synth_buf_offset; j += 64){ + a += window[i+j ]*(-synth_buf[15-i+j]); + b += window[i+j+16]*( synth_buf[ i+j]); + c += window[i+j+32]*( synth_buf[16+i+j]); + d += window[i+j+48]*( synth_buf[31-i+j]); + } + for ( ; j < 512; j += 64){ + a += window[i+j ]*(-synth_buf[15-i+j-512]); + b += window[i+j+16]*( synth_buf[ i+j-512]); + c += window[i+j+32]*( synth_buf[16+i+j-512]); + d += window[i+j+48]*( synth_buf[31-i+j-512]); + } + out[i ] = a * scale + bias; + out[i+16] = b * scale + bias; + synth_buf2[i ] = c; + synth_buf2[i+16] = d; + } + *synth_buf_offset= (*synth_buf_offset-32)&511; +} diff --git a/libavcodec/synth_filter.h b/libavcodec/synth_filter.h new file mode 100644 index 0000000000..0472048fbc --- /dev/null +++ b/libavcodec/synth_filter.h @@ -0,0 +1,27 @@ +/* + * copyright (c) 2008 Michael Niedermayer <michaelni@gmx.at> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dsputil.h" + +void ff_synth_filter_float(FFTContext *imdct, + float *synth_buf_ptr, int *synth_buf_offset, + float synth_buf2[32], const float window[512], + float out[32], const float in[32], float scale, float bias); + |