diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-03-11 16:45:01 -0500 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-03-14 08:45:31 -0400 |
commit | f1efbca5e914b28cd37cb1ea82d371acf3b96f61 (patch) | |
tree | a1464d5951e558f17e941c9f13d3548b733e6c03 /libavcodec/ac3dsp.c | |
parent | 323e6fead07c75f418e4b60704a4f437bb3483b2 (diff) | |
download | ffmpeg-f1efbca5e914b28cd37cb1ea82d371acf3b96f61.tar.gz |
ac3enc: add SIMD-optimized shifting functions for use with the fixed-point AC3 encoder.
Diffstat (limited to 'libavcodec/ac3dsp.c')
-rw-r--r-- | libavcodec/ac3dsp.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c index da3a123e9b..4d9db9be50 100644 --- a/libavcodec/ac3dsp.c +++ b/libavcodec/ac3dsp.c @@ -50,10 +50,47 @@ static int ac3_max_msb_abs_int16_c(const int16_t *src, int len) return v; } +static void ac3_lshift_int16_c(int16_t *src, unsigned int len, + unsigned int shift) +{ + uint32_t *src32 = (uint32_t *)src; + const uint32_t mask = ~(((1 << shift) - 1) << 16); + int i; + len >>= 1; + for (i = 0; i < len; i += 8) { + src32[i ] = (src32[i ] << shift) & mask; + src32[i+1] = (src32[i+1] << shift) & mask; + src32[i+2] = (src32[i+2] << shift) & mask; + src32[i+3] = (src32[i+3] << shift) & mask; + src32[i+4] = (src32[i+4] << shift) & mask; + src32[i+5] = (src32[i+5] << shift) & mask; + src32[i+6] = (src32[i+6] << shift) & mask; + src32[i+7] = (src32[i+7] << shift) & mask; + } +} + +static void ac3_rshift_int32_c(int32_t *src, unsigned int len, + unsigned int shift) +{ + do { + *src++ >>= shift; + *src++ >>= shift; + *src++ >>= shift; + *src++ >>= shift; + *src++ >>= shift; + *src++ >>= shift; + *src++ >>= shift; + *src++ >>= shift; + len -= 8; + } while (len > 0); +} + av_cold void ff_ac3dsp_init(AC3DSPContext *c) { c->ac3_exponent_min = ac3_exponent_min_c; c->ac3_max_msb_abs_int16 = ac3_max_msb_abs_int16_c; + c->ac3_lshift_int16 = ac3_lshift_int16_c; + c->ac3_rshift_int32 = ac3_rshift_int32_c; if (HAVE_MMX) ff_ac3dsp_init_x86(c); |