Commit 4ced5d77 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/hevc: Fix modulo operations

Fixes qp fields becoming out of range
Fixes: asan_static-oob_e393a3_6998_WPP_A_ericsson_MAIN10_2.bit
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent d66bab0a
...@@ -688,8 +688,8 @@ static int hls_slice_header(HEVCContext *s) ...@@ -688,8 +688,8 @@ static int hls_slice_header(HEVCContext *s)
s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag; s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
if (!s->pps->cu_qp_delta_enabled_flag) if (!s->pps->cu_qp_delta_enabled_flag)
s->HEVClc->qp_y = ((s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset) % s->HEVClc->qp_y = FFUMOD(s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset,
(52 + s->sps->qp_bd_offset)) - s->sps->qp_bd_offset; 52 + s->sps->qp_bd_offset) - s->sps->qp_bd_offset;
s->slice_initialized = 1; s->slice_initialized = 1;
......
...@@ -160,8 +160,8 @@ void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, ...@@ -160,8 +160,8 @@ void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC,
if (s->HEVClc->tu.cu_qp_delta != 0) { if (s->HEVClc->tu.cu_qp_delta != 0) {
int off = s->sps->qp_bd_offset; int off = s->sps->qp_bd_offset;
s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off,
(52 + off)) - off; 52 + off) - off;
} else } else
s->HEVClc->qp_y = qp_y; s->HEVClc->qp_y = qp_y;
} }
......
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