ac3enc: make sym_quant() branch-free

oldabi
Justin Ruggles 14 years ago
parent 45ed822550
commit 85ab290470
  1. 12
      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;
}

Loading…
Cancel
Save