From 5077dcbe1cd3bd436c6f6d800df1dc00eaa02352 Mon Sep 17 00:00:00 2001 From: AJR Date: Sun, 17 Sep 2023 17:56:03 -0400 Subject: [PATCH] aviio.cpp: Use std::clamp --- src/lib/util/aviio.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/util/aviio.cpp b/src/lib/util/aviio.cpp index dad5637fe10..40ce6ebe689 100644 --- a/src/lib/util/aviio.cpp +++ b/src/lib/util/aviio.cpp @@ -16,6 +16,7 @@ #include "osdcomm.h" #include "osdfile.h" +#include #include #include #include @@ -1282,9 +1283,9 @@ avi_file::error avi_stream::uncompressed_yuv420p_to_argb32(const std::uint8_t *d int g = luma - (0.698001f * (v - 0x80)) - (0.337633f * (u - 0x80)); int b = luma + (1.732446f * (u - 0x80)); - r = (r < 0) ? 0 : ((r > 255) ? 255 : r); - g = (g < 0) ? 0 : ((g > 255) ? 255 : g); - b = (b < 0) ? 0 : ((b > 255) ? 255 : b); + r = std::clamp(r, 0, 255); + g = std::clamp(g, 0, 255); + b = std::clamp(b, 0, 255); *dest++ = 0xff << 24 | r << 16 | g << 8 | b; }