MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / testConvert_OutBitDepth

Function testConvert_OutBitDepth

tests/cpu/SSE2_tests.cpp:77–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75
76template<OCIO::BitDepth inBD, OCIO::BitDepth outBD>
77void testConvert_OutBitDepth()
78{
79 typedef typename OCIO::BitDepthInfo<inBD>::Type InType;
80 typedef typename OCIO::BitDepthInfo<outBD>::Type OutType;
81
82 size_t maxValue = OCIO::BitDepthInfo<inBD>::maxValue + 1;
83
84 if (OCIO::BitDepthInfo<inBD>::isFloat)
85 maxValue = 65536;
86
87 std::vector<InType> inImage(maxValue);
88 std::vector<OutType> outImage(maxValue);
89
90 for (unsigned i = 0; i < maxValue; i++)
91 {
92 inImage[i] = scale_unsigned<inBD>(i);
93 }
94
95 float scale = (float)OCIO::BitDepthInfo<outBD>::maxValue / (float)OCIO::BitDepthInfo<inBD>::maxValue;
96 __m128 s = _mm_set1_ps(scale);
97
98 for (unsigned i = 0; i < inImage.size(); i += 16)
99 {
100 __m128 r, g, b, a;
101 OCIO::SSE2RGBAPack<inBD>::Load(&inImage[i], r, g, b, a);
102 r = _mm_mul_ps(r, s);
103 g = _mm_mul_ps(g, s);
104 b = _mm_mul_ps(b, s);
105 a = _mm_mul_ps(a, s);
106 OCIO::SSE2RGBAPack<outBD>::Store(&outImage[i], r, g, b, a);
107 }
108 for (unsigned i = 0; i < outImage.size(); i++)
109 {
110 float v = (float)inImage[i] * scale;
111
112 if (OCIO::BitDepthInfo<outBD>::isFloat)
113 v = (OutType)v; // casts to half if format is half
114 else
115 v = rintf(v);
116
117 OCIO_CHECK_ASSERT_MESSAGE(!OCIO::FloatsDiffer(v, (float)outImage[i], 0, false),
118 GetErrorMessage(v, (float)outImage[i], inBD, outBD));
119 }
120}
121
122template<OCIO::BitDepth inBD>
123void testConvert_InBitDepth(OCIO::BitDepth outBD)

Callers

nothing calls this directly

Calls 3

FloatsDifferFunction · 0.85
GetErrorMessageFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected