| 1 |
/* |
| 2 |
* Copyright 2015 The Etc2Comp Authors. |
| 3 |
* |
| 4 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
* you may not use this file except in compliance with the License. |
| 6 |
* You may obtain a copy of the License at |
| 7 |
* |
| 8 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
* |
| 10 |
* Unless required by applicable law or agreed to in writing, software |
| 11 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
* See the License for the specific language governing permissions and |
| 14 |
* limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
#pragma once |
| 18 |
|
| 19 |
#include "EtcBlock4x4Encoding_ETC1.h" |
| 20 |
|
| 21 |
namespace Etc |
| 22 |
{ |
| 23 |
|
| 24 |
class Block4x4Encoding_RGB8 : public Block4x4Encoding_ETC1 |
| 25 |
{ |
| 26 |
public: |
| 27 |
|
| 28 |
Block4x4Encoding_RGB8(void); |
| 29 |
virtual ~Block4x4Encoding_RGB8(void); |
| 30 |
|
| 31 |
virtual void InitFromEncodingBits(Block4x4 *a_pblockParent, |
| 32 |
unsigned char *a_paucEncodingBits, |
| 33 |
ColorFloatRGBA *a_pafrgbaSource, |
| 34 |
|
| 35 |
ErrorMetric a_errormetric); |
| 36 |
|
| 37 |
virtual void PerformIteration(float a_fEffort); |
| 38 |
|
| 39 |
virtual void SetEncodingBits(void); |
| 40 |
|
| 41 |
inline ColorFloatRGBA GetColor3(void) const |
| 42 |
{ |
| 43 |
return m_frgbaColor3; |
| 44 |
} |
| 45 |
|
| 46 |
protected: |
| 47 |
|
| 48 |
static const unsigned int PLANAR_CORNER_COLORS = 3; |
| 49 |
static const unsigned int MAX_PLANAR_REGRESSION_SIZE = 4; |
| 50 |
static const unsigned int TH_DISTANCES = 8; |
| 51 |
|
| 52 |
static float s_afTHDistanceTable[TH_DISTANCES]; |
| 53 |
|
| 54 |
void TryPlanar(unsigned int a_uiRadius); |
| 55 |
void TryTAndH(unsigned int a_uiRadius); |
| 56 |
|
| 57 |
void InitFromEncodingBits_Planar(void); |
| 58 |
|
| 59 |
ColorFloatRGBA m_frgbaColor3; // used for planar |
| 60 |
|
| 61 |
void SetEncodingBits_T(void); |
| 62 |
void SetEncodingBits_H(void); |
| 63 |
void SetEncodingBits_Planar(void); |
| 64 |
|
| 65 |
// state shared between iterations |
| 66 |
ColorFloatRGBA m_frgbaOriginalColor1_TAndH; |
| 67 |
ColorFloatRGBA m_frgbaOriginalColor2_TAndH; |
| 68 |
|
| 69 |
void CalculateBaseColorsForTAndH(void); |
| 70 |
void TryT(unsigned int a_uiRadius); |
| 71 |
void TryT_BestSelectorCombination(void); |
| 72 |
void TryH(unsigned int a_uiRadius); |
| 73 |
void TryH_BestSelectorCombination(void); |
| 74 |
|
| 75 |
private: |
| 76 |
|
| 77 |
void InitFromEncodingBits_T(void); |
| 78 |
void InitFromEncodingBits_H(void); |
| 79 |
|
| 80 |
void CalculatePlanarCornerColors(void); |
| 81 |
|
| 82 |
void ColorRegression(ColorFloatRGBA *a_pafrgbaPixels, unsigned int a_uiPixels, |
| 83 |
ColorFloatRGBA *a_pfrgbaSlope, ColorFloatRGBA *a_pfrgbaOffset); |
| 84 |
|
| 85 |
bool TwiddlePlanar(void); |
| 86 |
bool TwiddlePlanarR(); |
| 87 |
bool TwiddlePlanarG(); |
| 88 |
bool TwiddlePlanarB(); |
| 89 |
|
| 90 |
void DecodePixels_T(void); |
| 91 |
void DecodePixels_H(void); |
| 92 |
void DecodePixels_Planar(void); |
| 93 |
|
| 94 |
}; |
| 95 |
|
| 96 |
} // namespace Etc |