ffmpeg | branch: master | Thilo Borgmann <thilo.borgm...@mail.de> | Sat Jun  4 
13:45:30 2022 +0200| [b7cea557304b8733074f512629043f37130c5181] | committer: 
Thilo Borgmann

lavfi/blockdetect: Fix possible div by 0

Found-by Covererity, CID 1504568, 1504569

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

 libavfilter/vf_blockdetect.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libavfilter/vf_blockdetect.c b/libavfilter/vf_blockdetect.c
index 8503b8d815..85fca68945 100644
--- a/libavfilter/vf_blockdetect.c
+++ b/libavfilter/vf_blockdetect.c
@@ -132,8 +132,10 @@ static float calculate_blockiness(BLKContext *s, int w, 
int h,
                 nonblock_count++;
             }
         }
+        if (block_count && nonblock_count) {
         temp = (block / block_count) / (nonblock / nonblock_count);
         ret = FFMAX(ret, temp);
+        }
     }
 
     // vertical blockiness (fixed height)
@@ -175,8 +177,10 @@ static float calculate_blockiness(BLKContext *s, int w, 
int h,
                 nonblock_count++;
             }
         }
+        if (block_count && nonblock_count) {
         temp = (block / block_count) / (nonblock / nonblock_count);
         ret = FFMAX(ret, temp);
+        }
     }
 
     // return highest value of horz||vert

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to