ConvectionKernels_S3TC.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #ifndef __CVTT_S3TC_H__
  3. #define __CVTT_S3TC_H__
  4. #include "ConvectionKernels_ParallelMath.h"
  5. namespace cvtt
  6. {
  7. namespace Internal
  8. {
  9. template<int TVectorSize>
  10. class EndpointRefiner;
  11. }
  12. struct PixelBlockU8;
  13. }
  14. namespace cvtt
  15. {
  16. namespace Internal
  17. {
  18. class S3TCComputer
  19. {
  20. public:
  21. typedef ParallelMath::Float MFloat;
  22. typedef ParallelMath::SInt16 MSInt16;
  23. typedef ParallelMath::UInt15 MUInt15;
  24. typedef ParallelMath::UInt16 MUInt16;
  25. typedef ParallelMath::SInt32 MSInt32;
  26. static void Init(MFloat& error);
  27. static void QuantizeTo6Bits(MUInt15& v);
  28. static void QuantizeTo5Bits(MUInt15& v);
  29. static void QuantizeTo565(MUInt15 endPoint[3]);
  30. static MFloat ParanoidFactorForSpan(const MSInt16& span);
  31. static MFloat ParanoidDiff(const MUInt15& a, const MUInt15& b, const MFloat& d);
  32. static void TestSingleColor(uint32_t flags, const MUInt15 pixels[16][4], const MFloat floatPixels[16][4], int range, const float* channelWeights,
  33. MFloat &bestError, MUInt15 bestEndpoints[2][3], MUInt15 bestIndexes[16], MUInt15 &bestRange, const ParallelMath::RoundTowardNearestForScope *rtn);
  34. static void TestEndpoints(uint32_t flags, const MUInt15 pixels[16][4], const MFloat floatPixels[16][4], const MFloat preWeightedPixels[16][4], const MUInt15 unquantizedEndPoints[2][3], int range, const float* channelWeights,
  35. MFloat &bestError, MUInt15 bestEndpoints[2][3], MUInt15 bestIndexes[16], MUInt15 &bestRange, EndpointRefiner<3> *refiner, const ParallelMath::RoundTowardNearestForScope *rtn);
  36. static void TestCounts(uint32_t flags, const int *counts, int nCounts, const MUInt15 &numElements, const MUInt15 pixels[16][4], const MFloat floatPixels[16][4], const MFloat preWeightedPixels[16][4], bool alphaTest,
  37. const MFloat floatSortedInputs[16][4], const MFloat preWeightedFloatSortedInputs[16][4], const float *channelWeights, MFloat &bestError, MUInt15 bestEndpoints[2][3], MUInt15 bestIndexes[16], MUInt15 &bestRange,
  38. const ParallelMath::RoundTowardNearestForScope* rtn);
  39. static void PackExplicitAlpha(uint32_t flags, const PixelBlockU8* inputs, int inputChannel, uint8_t* packedBlocks, size_t packedBlockStride);
  40. static void PackInterpolatedAlpha(uint32_t flags, const PixelBlockU8* inputs, int inputChannel, uint8_t* packedBlocks, size_t packedBlockStride, bool isSigned, int maxTweakRounds, int numRefineRounds);
  41. static void PackRGB(uint32_t flags, const PixelBlockU8* inputs, uint8_t* packedBlocks, size_t packedBlockStride, const float channelWeights[4], bool alphaTest, float alphaThreshold, bool exhaustive, int maxTweakRounds, int numRefineRounds);
  42. };
  43. }
  44. }
  45. #endif