[FFmpeg-cvslog] ac3enc: make sym_quant() branch-free

Justin Ruggles git at videolan.org
Wed Mar 23 03:03:42 CET 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Tue Mar 22 14:36:18 2011 -0400| [85ab2904700c5bf8b55a33ad598191e36318e195] | committer: Justin Ruggles

ac3enc: make sym_quant() branch-free

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=85ab2904700c5bf8b55a33ad598191e36318e195
---

 libavcodec/ac3enc.c |   12 +-----------
 1 files changed, 1 insertions(+), 11 deletions(-)

diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index d9b06d9..202e611 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1096,17 +1096,7 @@ static int compute_bit_allocation(AC3EncodeContext *s)
  */
 static inline int sym_quant(int c, int e, int levels)
 {
-    int v;
-
-    if (c >= 0) {
-        v = (levels * (c << e)) >> 24;
-        v = (v + 1) >> 1;
-        v = (levels >> 1) + v;
-    } else {
-        v = (levels * ((-c) << e)) >> 24;
-        v = (v + 1) >> 1;
-        v = (levels >> 1) - v;
-    }
+    int v = ((((levels * c) >> (24 - e)) + 1) >> 1) + (levels >> 1);
     av_assert2(v >= 0 && v < levels);
     return v;
 }




More information about the ffmpeg-cvslog mailing list