1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

avcodec: Use av_clip_uintp2() where possible

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-02-21 15:46:38 +01:00
parent d301a13427
commit 114a2eb272
5 changed files with 7 additions and 7 deletions

View File

@ -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];

View File

@ -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;
}

View File

@ -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;

View File

@ -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++) {

View File

@ -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);