[FFmpeg-cvslog] avcodec/hevc: Fix modulo operations

Michael Niedermayer git at videolan.org
Wed Jan 8 01:27:50 CET 2014


ffmpeg | branch: release/2.1 | Michael Niedermayer <michaelni at gmx.at> | Mon Jan  6 02:51:20 2014 +0100| [908b951b4e945eb0ba373548ff5921c547cec0fd] | committer: 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: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 4ced5d7780fea2ea49444d6686d26f26b3a2160f)

Conflicts:

	libavcodec/hevc_filter.c

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=908b951b4e945eb0ba373548ff5921c547cec0fd
---

 libavcodec/hevc.c        |    4 ++--
 libavcodec/hevc_filter.c |    3 ++-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 011b1ee..2f7c5b6 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -636,8 +636,8 @@ static int hls_slice_header(HEVCContext *s)
     s->HEVClc->first_qp_group = !s->sh.dependent_slice_segment_flag;
 
     if (!s->pps->cu_qp_delta_enabled_flag)
-        s->HEVClc->qp_y = ((s->sh.slice_qp + 52 + 2 * s->sps->qp_bd_offset) %
-                          (52 + s->sps->qp_bd_offset)) - 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;
 
     s->slice_initialized = 1;
 
diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index 0a6d7c9..d040406 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -155,7 +155,8 @@ void ff_hevc_set_qPy(HEVCContext *s, int xC, int yC, int xBase, int yBase, int l
 
     if (s->HEVClc->tu.cu_qp_delta != 0) {
         int off = s->sps->qp_bd_offset;
-        s->HEVClc->qp_y = ((qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off) % (52 + off)) - off;
+        s->HEVClc->qp_y = FFUMOD(qp_y + s->HEVClc->tu.cu_qp_delta + 52 + 2 * off,
+                                 52 + off) - off;
     } else
         s->HEVClc->qp_y = qp_y;
 }



More information about the ffmpeg-cvslog mailing list