[FFmpeg-devel] [PATCH 1/5] avfilter/vf_ciescope: Handle black as very dark neutral gray

Michael Niedermayer michael at niedermayer.cc
Sun Jun 6 16:47:53 EEST 2021


Fixes: floating point division by 0
Fixes: undefined behavior in handling NaN
Fixes: Ticket 8268

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavfilter/vf_ciescope.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavfilter/vf_ciescope.c b/libavfilter/vf_ciescope.c
index b3b906f517..f8fe554c06 100644
--- a/libavfilter/vf_ciescope.c
+++ b/libavfilter/vf_ciescope.c
@@ -844,6 +844,9 @@ rgb_to_xy(double rc,
 {
     double sum;
 
+    if (rc == 0 && gc == 0 && bc == 0)
+        rc = gc = bc = 0.1/65536;
+
     *x = m[0][0] * rc + m[0][1] * gc + m[0][2] * bc;
     *y = m[1][0] * rc + m[1][1] * gc + m[1][2] * bc;
     *z = m[2][0] * rc + m[2][1] * gc + m[2][2] * bc;
-- 
2.17.1



More information about the ffmpeg-devel mailing list