diff options
author | Loren Merritt <lorenm@u.washington.edu> | 2008-07-13 14:56:01 +0000 |
---|---|---|
committer | Loren Merritt <lorenm@u.washington.edu> | 2008-07-13 14:56:01 +0000 |
commit | f27e1d645e609c01fbacfc2425818b56126df567 (patch) | |
tree | 37eb74cee17dfd256db399efd6047de8ca05670a /libavcodec/dsputil.c | |
parent | 6647ab80e36aa2484a145029141984843958b246 (diff) | |
download | ffmpeg-streaming-f27e1d645e609c01fbacfc2425818b56126df567.zip ffmpeg-streaming-f27e1d645e609c01fbacfc2425818b56126df567.tar.gz |
simplify vorbis windowing
Originally committed as revision 14205 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/dsputil.c')
-rw-r--r-- | libavcodec/dsputil.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c index 9ec077e..55929d0 100644 --- a/libavcodec/dsputil.c +++ b/libavcodec/dsputil.c @@ -3930,17 +3930,40 @@ void ff_vector_fmul_add_add_c(float *dst, const float *src0, const float *src1, dst[i*step] = src0[i] * src1[i] + src2[i] + src3; } +void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len){ + int i; + for(i=0; i<len; i++) + dst[i] = src0[i]*win[len-i-1] + src1[i]*win[i] + add_bias; +} + +static av_always_inline int float_to_int16_one(const float *src){ + int_fast32_t tmp = *(const int32_t*)src; + if(tmp & 0xf0000){ + tmp = (0x43c0ffff - tmp)>>31; + // is this faster on some gcc/cpu combinations? +// if(tmp > 0x43c0ffff) tmp = 0xFFFF; +// else tmp = 0; + } + return tmp - 0x8000; +} + void ff_float_to_int16_c(int16_t *dst, const float *src, long len){ int i; - for(i=0; i<len; i++) { - int_fast32_t tmp = ((const int32_t*)src)[i]; - if(tmp & 0xf0000){ - tmp = (0x43c0ffff - tmp)>>31; - // is this faster on some gcc/cpu combinations? -// if(tmp > 0x43c0ffff) tmp = 0xFFFF; -// else tmp = 0; + for(i=0; i<len; i++) + dst[i] = float_to_int16_one(src+i); +} + +void ff_float_to_int16_interleave_c(int16_t *dst, const float *src, long len, int channels){ + int i,j,c; + if(channels==2){ + for(i=0; i<len; i++){ + dst[2*i] = float_to_int16_one(src+i); + dst[2*i+1] = float_to_int16_one(src+i+len); } - dst[i] = tmp - 0x8000; + }else{ + for(c=0; c<channels; c++, src+=len) + for(i=0, j=c; i<len; i++, j+=channels) + dst[j] = float_to_int16_one(src+i); } } @@ -4450,7 +4473,9 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx) c->vector_fmul = vector_fmul_c; c->vector_fmul_reverse = vector_fmul_reverse_c; c->vector_fmul_add_add = ff_vector_fmul_add_add_c; + c->vector_fmul_window = ff_vector_fmul_window_c; c->float_to_int16 = ff_float_to_int16_c; + c->float_to_int16_interleave = ff_float_to_int16_interleave_c; c->add_int16 = add_int16_c; c->sub_int16 = sub_int16_c; c->scalarproduct_int16 = scalarproduct_int16_c; |