Explicitly cast unorms to float during YUV conversion, fixing clang warning
diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bf57f..b5d1450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -8,6 +8,9 @@ ### Added - Enable still picture mode with rav1e >= 0.3.0 (cryptomilk) +### Changed +- Explicitly cast unorms to float during YUV conversion, fixing clang warning + ## [0.5.4] - 2020-01-21 ### Changed - Fix monochrome inputs on avifImageCopy. Monochrome still isn't really a first-class citizen in libavif, but this should at least honor the incoming data better.
diff --git a/src/reformat.c b/src/reformat.c index 0278fdf..457abe2 100644 --- a/src/reformat.c +++ b/src/reformat.c
@@ -220,9 +220,9 @@ } // Convert unorm to float - const float Y = unormY / maxChannel; - const float Cb = (unormU / maxChannel) - 0.5f; - const float Cr = (unormV / maxChannel) - 0.5f; + const float Y = (float)unormY / maxChannel; + const float Cb = ((float)unormU / maxChannel) - 0.5f; + const float Cr = ((float)unormV / maxChannel) - 0.5f; float R = Y + (2 * (1 - kr)) * Cr; float B = Y + (2 * (1 - kb)) * Cb; @@ -264,7 +264,7 @@ } // Convert unorm to float - const float Y = unormY / maxChannel; + const float Y = (float)unormY / maxChannel; const float Cb = -0.5f; const float Cr = -0.5f; @@ -318,9 +318,9 @@ } // Convert unorm to float - const float Y = unormY / maxChannel; - const float Cb = (unormU / maxChannel) - 0.5f; - const float Cr = (unormV / maxChannel) - 0.5f; + const float Y = (float)unormY / maxChannel; + const float Cb = ((float)unormU / maxChannel) - 0.5f; + const float Cr = ((float)unormV / maxChannel) - 0.5f; float R = Y + (2 * (1 - kr)) * Cr; float B = Y + (2 * (1 - kb)) * Cb; @@ -362,7 +362,7 @@ } // Convert unorm to float - const float Y = unormY / maxChannel; + const float Y = (float)unormY / maxChannel; const float Cb = -0.5f; const float Cr = -0.5f;