aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-06-21 16:14:19 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-06-22 12:18:10 -0400
commitf21fb76b1be18036c93c3e29fe1889a9fabf30b3 (patch)
treeb04f6b0479e8ce3467f07d57bb5b75ecefa7bc9d
parent0e4dbe2996cad6d5e0b1c1d702306f3bd8499df9 (diff)
downloadffmpeg-f21fb76b1be18036c93c3e29fe1889a9fabf30b3.tar.gz
ac3enc: remove a branch in asym_quant() by doing 2 shifts
-rw-r--r--libavcodec/ac3enc.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 1db69414a5..db45c8360e 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1123,15 +1123,9 @@ static inline int sym_quant(int c, int e, int levels)
*/
static inline int asym_quant(int c, int e, int qbits)
{
- int lshift, m, v;
+ int m, v;
- lshift = e + qbits - 24;
- if (lshift >= 0)
- v = c << lshift;
- else
- v = c >> (-lshift);
- /* rounding */
- v = (v + 1) >> 1;
+ v = (((c << e) >> (24 - qbits)) + 1) >> 1;
m = (1 << (qbits-1));
if (v >= m)
v = m - 1;