}
/**
- * Calculate culmulative frequency for next symbol. Does NO update!
+ * Calculate cumulative frequency for next symbol. Does NO update!
* @param ctx decoder context
* @param tot_f is the total frequency or (code_value)1<<shift
- * @return the culmulative frequency
+ * @return the cumulative frequency
*/
static inline int range_decode_culfreq(APEContext *ctx, int tot_f)
{
/* Update the adaption coefficients */
absres = FFABS(res);
if (absres)
- *f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>
- (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
+ *f->adaptcoeffs = APESIGN(res) *
+ (8 << ((absres > f->avg * 3) + (absres > f->avg * 4 / 3)));
+ /* equivalent to the following code
+ if (absres <= f->avg * 4 / 3)
+ *f->adaptcoeffs = APESIGN(res) * 8;
+ else if (absres <= f->avg * 3)
+ *f->adaptcoeffs = APESIGN(res) * 16;
+ else
+ *f->adaptcoeffs = APESIGN(res) * 32;
+ */
else
*f->adaptcoeffs = 0;