Fix some MSVC warnings
are_images_equal.cc: Include <string> because this file uses
std::stoi().
avifincrtest_helpers.cc: The '<' comparison in the following for loop
has a signed/unsigned mismatch:
for (uint32_t plane = 0; plane < (info.monochrome ? 1 : AVIF_PLANE_COUNT_YUV);
Fix the warning by declaring 'plane' as 'int'.
avifrgbtoyuvtest.cc: The first two parameters of GetPsnr() are of the
'double' type but we are passing 'int64_t' arguments, and MSVC warns
about possible loss of data in the conversion from 'int64_t' to
'double'. Cast the 'int64_t' arguments to 'double'.
diff --git a/tests/gtest/are_images_equal.cc b/tests/gtest/are_images_equal.cc
index 7e01a79..70d02d1 100644
--- a/tests/gtest/are_images_equal.cc
+++ b/tests/gtest/are_images_equal.cc
@@ -3,6 +3,7 @@
// Compares two files and returns whether they are the same once decoded.
#include <iostream>
+#include <string>
#include "aviftest_helpers.h"
#include "avifutil.h"
diff --git a/tests/gtest/avifincrtest_helpers.cc b/tests/gtest/avifincrtest_helpers.cc
index a61d3d3..da26e09 100644
--- a/tests/gtest/avifincrtest_helpers.cc
+++ b/tests/gtest/avifincrtest_helpers.cc
@@ -40,7 +40,7 @@
const uint32_t pixel_byte_count =
(image1.depth > 8) ? sizeof(uint16_t) : sizeof(uint8_t);
- for (uint32_t plane = 0; plane < (info.monochrome ? 1 : AVIF_PLANE_COUNT_YUV);
+ for (int plane = 0; plane < (info.monochrome ? 1 : AVIF_PLANE_COUNT_YUV);
++plane) {
const uint32_t width = (plane == AVIF_CHAN_Y) ? image1.width : uv_width;
const uint32_t width_byte_count = width * pixel_byte_count;
diff --git a/tests/gtest/avifrgbtoyuvtest.cc b/tests/gtest/avifrgbtoyuvtest.cc
index e63e3fb..27f5607 100644
--- a/tests/gtest/avifrgbtoyuvtest.cc
+++ b/tests/gtest/avifrgbtoyuvtest.cc
@@ -229,7 +229,8 @@
static_cast<double>(diff_sum) / static_cast<double>(num_diffs);
const double average_abs_diff =
static_cast<double>(abs_diff_sum) / static_cast<double>(num_diffs);
- const double psnr = GetPsnr(sq_diff_sum, num_diffs, rgb_max);
+ const double psnr = GetPsnr(static_cast<double>(sq_diff_sum),
+ static_cast<double>(num_diffs), rgb_max);
EXPECT_LE(std::abs(average_diff), max_abs_average_diff);
EXPECT_GE(psnr, min_psnr);
@@ -307,7 +308,9 @@
// max_abs_average_diff is not tested here because it is not meaningful for
// only 3*3 conversions as it takes the maximum difference per conversion.
// PSNR is averaged on all pixels so it can be tested here.
- EXPECT_GE(GetPsnr(sq_diff_sum, num_diffs, rgb_max), min_psnr);
+ EXPECT_GE(GetPsnr(static_cast<double>(sq_diff_sum),
+ static_cast<double>(num_diffs), rgb_max),
+ min_psnr);
}
constexpr avifRGBFormat kAllRgbFormats[] = {