diff options
author | 2023-09-17 17:56:03 -0400 | |
---|---|---|
committer | 2023-09-17 17:56:03 -0400 | |
commit | 5077dcbe1cd3bd436c6f6d800df1dc00eaa02352 (patch) | |
tree | 2ab034984b91c601765c61554f82875701aca013 /src/lib/util/aviio.cpp | |
parent | 7aca06fb13d4e017ee3c16b4f70742cf4311cc86 (diff) |
aviio.cpp: Use std::clamp
Diffstat (limited to 'src/lib/util/aviio.cpp')
-rw-r--r-- | src/lib/util/aviio.cpp | 7 |
1 files 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 <algorithm> #include <array> #include <cassert> #include <cstdlib> @@ -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; } |