| 75 | |
| 76 | template<OCIO::BitDepth inBD, OCIO::BitDepth outBD> |
| 77 | void 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 | |
| 122 | template<OCIO::BitDepth inBD> |
| 123 | void testConvert_InBitDepth(OCIO::BitDepth outBD) |
nothing calls this directly
no test coverage detected