]> git.sesse.net Git - movit/blobdiff - ycbcr_conversion_effect_test.cpp
Convert a loop to range-based for.
[movit] / ycbcr_conversion_effect_test.cpp
index 27a10e32783c8d68588c7b888abd236b3027d341..6f7988c24470f76dc3146af4c56c9c6b89767c96 100644 (file)
@@ -40,7 +40,7 @@ TEST(YCbCrConversionEffectTest, BasicInOut) {
 
        unsigned char out_data[width * height * 4];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -96,7 +96,7 @@ TEST(YCbCrConversionEffectTest, ClampToValidRange) {
 
        unsigned char out_data[width * height * 4];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -152,7 +152,7 @@ TEST(YCbCrConversionEffectTest, LimitedRangeToFullRange) {
 
        unsigned char out_data[width * height * 4];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -209,7 +209,7 @@ TEST(YCbCrConversionEffectTest, PlanarOutput) {
 
        unsigned char out_y[width * height], out_cb[width * height], out_cr[width * height];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -234,7 +234,7 @@ TEST(YCbCrConversionEffectTest, PlanarOutput) {
        input->set_pixel_data(2, cr);
        tester.get_chain()->add_input(input);
 
-       tester.run(out_y, out_cb, out_cr, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
+       tester.run({out_y, out_cb, out_cr}, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
        expect_equal(y, out_y, width, height);
        expect_equal(cb, out_cb, width, height);
        expect_equal(cr, out_cr, width, height);
@@ -279,7 +279,7 @@ TEST(YCbCrConversionEffectTest, SplitLumaAndChroma) {
 
        unsigned char out_y[width * height * 4], out_cbcr[width * height * 4];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -304,7 +304,7 @@ TEST(YCbCrConversionEffectTest, SplitLumaAndChroma) {
        input->set_pixel_data(2, cr);
        tester.get_chain()->add_input(input);
 
-       tester.run(out_y, out_cbcr, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
+       tester.run(std::vector<unsigned char *>{out_y, out_cbcr}, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
        expect_equal(expected_y, out_y, width * 4, height);
        expect_equal(expected_cbcr, out_cbcr, width * 4, height);
 }
@@ -343,7 +343,7 @@ TEST(YCbCrConversionEffectTest, OutputChunkyAndRGBA) {
        unsigned char out_ycbcr[width * height * 4];
        unsigned char out_rgba[width * height * 4];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -373,7 +373,7 @@ TEST(YCbCrConversionEffectTest, OutputChunkyAndRGBA) {
        // just that the shader compiles and doesn't mess up badly.
        tester.get_chain()->set_dither_bits(8);
 
-       tester.run(out_ycbcr, out_rgba, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
+       tester.run(std::vector<unsigned char *>{out_ycbcr, out_rgba}, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
        expect_equal(expected_ycbcr, out_ycbcr, width * 4, height);
 
        // Y'CbCr isn't 100% accurate (the input values are rounded),
@@ -417,7 +417,7 @@ TEST(YCbCrConversionEffectTest, MultipleOutputsAndRGBA) {
        unsigned char out_cbcr[width * height * 4];
        unsigned char out_rgba[width * height * 4];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -448,7 +448,7 @@ TEST(YCbCrConversionEffectTest, MultipleOutputsAndRGBA) {
        // just that the shader compiles and doesn't mess up badly.
        tester.get_chain()->set_dither_bits(8);
 
-       tester.run(out_ycbcr, out_y, out_cbcr, out_rgba, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
+       tester.run({out_ycbcr, out_y, out_cbcr, out_rgba}, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
        expect_equal(expected_ycbcr, out_ycbcr, width * 4, height);
 
        // Check that the extra Y' and CbCr outputs also are fine.
@@ -483,7 +483,7 @@ TEST(YCbCrConversionEffectTest, ChangeOutputFormat) {
 
        unsigned char out_y[width * height], out_cb[width * height], out_cr[width * height];
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA8);
 
        ImageFormat format;
        format.color_space = COLORSPACE_sRGB;
@@ -509,11 +509,11 @@ TEST(YCbCrConversionEffectTest, ChangeOutputFormat) {
        input->set_pixel_data(2, cr);
        tester.get_chain()->add_input(input);
 
-       tester.run(out_y, out_cb, out_cr, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
+       tester.run({out_y, out_cb, out_cr}, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
 
        // Now change the output format to match what we gave the input, and re-run.
        tester.get_chain()->change_ycbcr_output_format(ycbcr_format);
-       tester.run(out_y, out_cb, out_cr, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
+       tester.run({out_y, out_cb, out_cr}, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB);
 
        expect_equal(y, out_y, width, height);
        expect_equal(cb, out_cb, width, height);
@@ -545,7 +545,7 @@ TEST(YCbCrConversionEffectTest, TenBitOutput) {
                127, 960, 471, 3,
        };
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGB10_A2);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGB10_A2);
        tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB);
 
        ImageFormat format;
@@ -598,7 +598,7 @@ TEST(YCbCrConversionEffectTest, TenBitOutputInSixteen) {
                127, 960, 471, 65535,
        };
 
-       EffectChainTester tester(NULL, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA16);
+       EffectChainTester tester(nullptr, width, height, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA16);
        tester.add_input(data, FORMAT_RGBA_POSTMULTIPLIED_ALPHA, COLORSPACE_sRGB, GAMMA_sRGB);
 
        ImageFormat format;
@@ -619,7 +619,9 @@ TEST(YCbCrConversionEffectTest, TenBitOutputInSixteen) {
        tester.add_ycbcr_output(format, OUTPUT_ALPHA_FORMAT_POSTMULTIPLIED, ycbcr_format, YCBCR_OUTPUT_INTERLEAVED, GL_UNSIGNED_SHORT);
        tester.run(out_data, GL_RGBA, COLORSPACE_sRGB, GAMMA_sRGB);
 
-       expect_equal(expected_data, out_data, 4 * width, height);
+       // Add some slight leeway for the benefit of cards that don't
+       // round correctly (would be fixed by DitherEffect if we had dither).
+       expect_equal(expected_data, out_data, 4 * width, height, 2);
 }
 
 }  // namespace movit