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