Commit eea769df authored by Peter Meerwald's avatar Peter Meerwald Committed by Anton Khirnov

hevc: Use generic av_clip function, not C implementation

hevc seems to be the only place where the C implementation
of the av_clip function is explicitly selected, precluding
platform-specific optimizations
Signed-off-by: 's avatarPeter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent faa8ffda
......@@ -251,10 +251,10 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
uint8_t luma_weight_l1_flag[16];
uint8_t chroma_weight_l1_flag[16];
s->sh.luma_log2_weight_denom = av_clip_c(get_ue_golomb_long(gb), 0, 7);
s->sh.luma_log2_weight_denom = av_clip(get_ue_golomb_long(gb), 0, 7);
if (s->sps->chroma_format_idc != 0) {
int delta = get_se_golomb(gb);
s->sh.chroma_log2_weight_denom = av_clip_c(s->sh.luma_log2_weight_denom + delta, 0, 7);
s->sh.chroma_log2_weight_denom = av_clip(s->sh.luma_log2_weight_denom + delta, 0, 7);
}
for (i = 0; i < s->sh.nb_refs[L0]; i++) {
......@@ -282,7 +282,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
int delta_chroma_weight_l0 = get_se_golomb(gb);
int delta_chroma_offset_l0 = get_se_golomb(gb);
s->sh.chroma_weight_l0[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l0;
s->sh.chroma_offset_l0[i][j] = av_clip_c((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
s->sh.chroma_offset_l0[i][j] = av_clip((delta_chroma_offset_l0 - ((128 * s->sh.chroma_weight_l0[i][j])
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
}
} else {
......@@ -318,7 +318,7 @@ static void pred_weight_table(HEVCContext *s, GetBitContext *gb)
int delta_chroma_weight_l1 = get_se_golomb(gb);
int delta_chroma_offset_l1 = get_se_golomb(gb);
s->sh.chroma_weight_l1[i][j] = (1 << s->sh.chroma_log2_weight_denom) + delta_chroma_weight_l1;
s->sh.chroma_offset_l1[i][j] = av_clip_c((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
s->sh.chroma_offset_l1[i][j] = av_clip((delta_chroma_offset_l1 - ((128 * s->sh.chroma_weight_l1[i][j])
>> s->sh.chroma_log2_weight_denom) + 128), -128, 127);
}
} else {
......@@ -964,7 +964,7 @@ static void hls_residual_coding(HEVCContext *s, int x0, int y0,
else
offset = s->pps->cr_qp_offset + s->sh.slice_cr_qp_offset;
qp_i = av_clip_c(qp_y + offset, -s->sps->qp_bd_offset, 57);
qp_i = av_clip(qp_y + offset, -s->sps->qp_bd_offset, 57);
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
......
......@@ -365,7 +365,7 @@ static void cabac_init_state(HEVCContext *s)
int init_value = init_values[init_type][i];
int m = (init_value >> 4) * 5 - 45;
int n = ((init_value & 15) << 3) - 16;
int pre = 2 * (((m * av_clip_c(s->sh.slice_qp, 0, 51)) >> 4) + n) - 127;
int pre = 2 * (((m * av_clip(s->sh.slice_qp, 0, 51)) >> 4) + n) - 127;
pre ^= pre >> 31;
if (pre > 124)
......
......@@ -58,7 +58,7 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
else
offset = s->pps->cr_qp_offset;
qp_i = av_clip_c(qp_y + offset, 0, 57);
qp_i = av_clip(qp_y + offset, 0, 57);
if (qp_i < 30)
qp = qp_i;
else if (qp_i > 43)
......@@ -66,7 +66,7 @@ static int chroma_tc(HEVCContext *s, int qp_y, int c_idx, int tc_offset)
else
qp = qp_c[qp_i - 30];
idxt = av_clip_c(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53);
idxt = av_clip(qp + DEFAULT_INTRA_TC_OFFSET + tc_offset, 0, 53);
return tctable[idxt];
}
......
......@@ -141,13 +141,13 @@ static av_always_inline void mv_scale(Mv *dst, Mv *src, int td, int tb)
{
int tx, scale_factor;
td = av_clip_int8_c(td);
tb = av_clip_int8_c(tb);
td = av_clip_int8(td);
tb = av_clip_int8(tb);
tx = (0x4000 + abs(td / 2)) / td;
scale_factor = av_clip_c((tb * tx + 32) >> 6, -4096, 4095);
dst->x = av_clip_int16_c((scale_factor * src->x + 127 +
scale_factor = av_clip((tb * tx + 32) >> 6, -4096, 4095);
dst->x = av_clip_int16((scale_factor * src->x + 127 +
(scale_factor * src->x < 0)) >> 8);
dst->y = av_clip_int16_c((scale_factor * src->y + 127 +
dst->y = av_clip_int16((scale_factor * src->y + 127 +
(scale_factor * src->y < 0)) >> 8);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment