| 83 | |
| 84 | template<OCIO::BitDepth inBD, OCIO::BitDepth outBD> |
| 85 | void testConvert_OutBitDepth() |
| 86 | { |
| 87 | typedef typename OCIO::BitDepthInfo<inBD>::Type InType; |
| 88 | typedef typename OCIO::BitDepthInfo<outBD>::Type OutType; |
| 89 | |
| 90 | size_t maxValue = OCIO::BitDepthInfo<inBD>::maxValue + 1; |
| 91 | |
| 92 | if (OCIO::BitDepthInfo<inBD>::isFloat) |
| 93 | maxValue = 65536; |
| 94 | |
| 95 | std::vector<InType> inImage(maxValue); |
| 96 | std::vector<OutType> outImage(maxValue); |
| 97 | |
| 98 | for (unsigned i = 0; i < maxValue; i++) |
| 99 | { |
| 100 | inImage[i] = scale_unsigned<inBD>(i); |
| 101 | } |
| 102 | |
| 103 | float scale = (float)OCIO::BitDepthInfo<outBD>::maxValue / (float)OCIO::BitDepthInfo<inBD>::maxValue; |
| 104 | __m256 s = _mm256_set1_ps(scale); |
| 105 | |
| 106 | for (unsigned i = 0; i < inImage.size(); i += 32) |
| 107 | { |
| 108 | __m256 r, g, b, a; |
| 109 | OCIO::AVXRGBAPack<inBD>::Load(&inImage[i], r, g, b, a); |
| 110 | r = _mm256_mul_ps(r, s); |
| 111 | g = _mm256_mul_ps(g, s); |
| 112 | b = _mm256_mul_ps(b, s); |
| 113 | a = _mm256_mul_ps(a, s); |
| 114 | OCIO::AVXRGBAPack<outBD>::Store(&outImage[i], r, g, b, a); |
| 115 | } |
| 116 | for (unsigned i = 0; i < outImage.size(); i++) |
| 117 | { |
| 118 | float v = (float)inImage[i] * scale; |
| 119 | |
| 120 | if (OCIO::BitDepthInfo<outBD>::isFloat) |
| 121 | v = (OutType)v; // casts to half if format is half |
| 122 | else |
| 123 | v = rintf(v); |
| 124 | |
| 125 | OCIO_CHECK_ASSERT_MESSAGE(!OCIO::FloatsDiffer(v, (float)outImage[i], 0, false), |
| 126 | GetErrorMessage(v, (float)outImage[i], inBD, outBD)); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | template<OCIO::BitDepth inBD> |
| 131 | void testConvert_InBitDepth(OCIO::BitDepth outBD) |
nothing calls this directly
no test coverage detected