}
/**
- * 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;
.init = ape_decode_init,
.close = ape_decode_close,
.decode = ape_decode_frame,
- .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY | CODEC_CAP_DR1,
+ .capabilities = AV_CODEC_CAP_SUBFRAMES | AV_CODEC_CAP_DELAY |
+ AV_CODEC_CAP_DR1,
.flush = ape_flush,
.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_U8P,
AV_SAMPLE_FMT_S16P,