diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index ea6cc23e97..c3546f9058 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -581,7 +581,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, // init the encoder state for (i = 0; i < avctx->channels; i++) { // clip step so it fits 6 bits - c->status[i].step_index = av_clip(c->status[i].step_index, 0, 63); + c->status[i].step_index = av_clip_uintp2(c->status[i].step_index, 6); put_sbits(&pb, 16, samples[i]); put_bits(&pb, 6, c->status[i].step_index); c->status[i].prev_sample = samples[i]; diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index bf5f7bf54b..58918aa958 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -87,7 +87,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, energy /= frame->nb_samples; if (energy > 0) { double dbov = 10 * log10(energy / 1081109975); - qdbov = av_clip(-floor(dbov), 0, 127); + qdbov = av_clip_uintp2(-floor(dbov), 7); } else { qdbov = 127; } diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 3d3bb94640..02ac0e0b7d 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -418,7 +418,7 @@ static void categorize(COOKContext *q, COOKSubpacket *p, const int *quant_index_ num_bits = 0; index = 0; for (j = p->total_subbands; j > 0; j--) { - exp_idx = av_clip((i - quant_index_table[index] + bias) / 2, 0, 7); + exp_idx = av_clip_uintp2((i - quant_index_table[index] + bias) / 2, 3); index++; num_bits += expbits_tab[exp_idx]; } @@ -429,7 +429,7 @@ static void categorize(COOKContext *q, COOKSubpacket *p, const int *quant_index_ /* Calculate total number of bits. */ num_bits = 0; for (i = 0; i < p->total_subbands; i++) { - exp_idx = av_clip((bias - quant_index_table[i]) / 2, 0, 7); + exp_idx = av_clip_uintp2((bias - quant_index_table[i]) / 2, 3); num_bits += expbits_tab[exp_idx]; exp_index1[i] = exp_idx; exp_index2[i] = exp_idx; diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index e63088fae9..fdbaa28a97 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -148,10 +148,10 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb) luma_log2_weight_denom = get_ue_golomb_long(gb); if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom); - s->sh.luma_log2_weight_denom = av_clip(luma_log2_weight_denom, 0, 7); + s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3); if (s->sps->chroma_format_idc != 0) { int delta = get_se_golomb(gb); - s->sh.chroma_log2_weight_denom = av_clip(s->sh.luma_log2_weight_denom + delta, 0, 7); + s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3); } for (i = 0; i < s->sh.nb_refs[L0]; i++) { diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c index 379508123f..d27eff2c3e 100644 --- a/libavcodec/ivi_common.c +++ b/libavcodec/ivi_common.c @@ -646,7 +646,7 @@ static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, quant = band->glob_quant + mb->q_delta; if (avctx->codec_id == AV_CODEC_ID_INDEO4) - quant = av_clip(quant, 0, 31); + quant = av_clip_uintp2(quant, 5); else quant = av_clip(quant, 0, 23);