[FFmpeg-cvslog] ac3enc: remove a branch in asym_quant() by doing 2 shifts
Justin Ruggles
git at videolan.org
Thu Jun 23 05:11:56 CEST 2011
ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Tue Jun 21 16:14:19 2011 -0400| [f21fb76b1be18036c93c3e29fe1889a9fabf30b3] | committer: Justin Ruggles
ac3enc: remove a branch in asym_quant() by doing 2 shifts
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f21fb76b1be18036c93c3e29fe1889a9fabf30b3
---
libavcodec/ac3enc.c | 12 +++---------
1 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 1db6941..db45c83 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;
More information about the ffmpeg-cvslog
mailing list