[FFmpeg-cvslog] avfilter/vf_lenscorrection: fix division by zero

Paul B Mahol git at videolan.org
Mon Apr 18 19:05:42 EEST 2022


ffmpeg | branch: release/3.2 | Paul B Mahol <onemda at gmail.com> | Sun Oct 13 23:28:16 2019 +0200| [94e502e96b0870177e0af4c1e8718ac71475e374] | committer: Michael Niedermayer

avfilter/vf_lenscorrection: fix division by zero

Fixes #8265

(cherry picked from commit 19587c9332f5be4f6bc6d7b2b8ef3fd21dfeaa01)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavfilter/vf_lenscorrection.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavfilter/vf_lenscorrection.c b/libavfilter/vf_lenscorrection.c
index 239fe195bd..43f3c1b7d0 100644
--- a/libavfilter/vf_lenscorrection.c
+++ b/libavfilter/vf_lenscorrection.c
@@ -155,10 +155,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     for (plane = 0; plane < rect->nb_planes; ++plane) {
         int hsub = plane == 1 || plane == 2 ? rect->hsub : 0;
         int vsub = plane == 1 || plane == 2 ? rect->vsub : 0;
-        int hdiv = 1 << hsub;
-        int vdiv = 1 << vsub;
-        int w = rect->width / hdiv;
-        int h = rect->height / vdiv;
+        int w = AV_CEIL_RSHIFT(rect->width, hsub);
+        int h = AV_CEIL_RSHIFT(rect->height, vsub);
         int xcenter = rect->cx * w;
         int ycenter = rect->cy * h;
         int k1 = rect->k1 * (1<<24);



More information about the ffmpeg-cvslog mailing list