/* set compression option overrides from AVCodecContext */
if(avctx->use_lpc >= 0) {
- s->options.use_lpc = clip(avctx->use_lpc, 0, 11);
+ s->options.use_lpc = av_clip(avctx->use_lpc, 0, 11);
}
if(s->options.use_lpc == 1)
av_log(avctx, AV_LOG_DEBUG, " use lpc: Levinson-Durbin recursion with Welch window\n");
error=0;
for(i=0; i<order; i++) {
error += lpc_in[i] * (1 << sh);
- lpc_out[i] = clip(lrintf(error), -qmax, qmax);
+ lpc_out[i] = av_clip(lrintf(error), -qmax, qmax);
error -= lpc_out[i];
}
*shift = sh;
for(i=2; i<n; i++) {
lt = left_ch[i] - 2*left_ch[i-1] + left_ch[i-2];
rt = right_ch[i] - 2*right_ch[i-1] + right_ch[i-2];
- sum[2] += ABS((lt + rt) >> 1);
- sum[3] += ABS(lt - rt);
- sum[0] += ABS(lt);
- sum[1] += ABS(rt);
+ sum[2] += FFABS((lt + rt) >> 1);
+ sum[3] += FFABS(lt - rt);
+ sum[0] += FFABS(lt);
+ sum[1] += FFABS(rt);
}
/* estimate bit counts */
for(i=0; i<4; i++) {
static void write_utf8(PutBitContext *pb, uint32_t val)
{
- int bytes, shift;
-
- if(val < 0x80){
- put_bits(pb, 8, val);
- return;
- }
-
- bytes= (av_log2(val)+4) / 5;
- shift = (bytes - 1) * 6;
- put_bits(pb, 8, (256 - (256>>bytes)) | (val >> shift));
- while(shift >= 6){
- shift -= 6;
- put_bits(pb, 8, 0x80 | ((val >> shift) & 0x3F));
- }
+ uint8_t tmp;
+ PUT_UTF8(val, tmp, put_bits(pb, 8, tmp);)
}
static void output_frame_header(FlacEncodeContext *s)