| 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 |
/* |
| 18 |
EtcIndividualTrys.cpp |
| 19 |
|
| 20 |
Gathers the results of the various encoding trys for both halves of a 4x4 block for Individual mode |
| 21 |
|
| 22 |
*/ |
| 23 |
|
| 24 |
#include "EtcConfig.h" |
| 25 |
#include "EtcIndividualTrys.h" |
| 26 |
|
| 27 |
#include <assert.h> |
| 28 |
|
| 29 |
namespace Etc |
| 30 |
{ |
| 31 |
|
| 32 |
// ---------------------------------------------------------------------------------------------------- |
| 33 |
// construct a list of trys (encoding attempts) |
| 34 |
// |
| 35 |
// a_frgbaColor1 is the basecolor for the first half |
| 36 |
// a_frgbaColor2 is the basecolor for the second half |
| 37 |
// a_pauiPixelMapping1 is the pixel order for the first half |
| 38 |
// a_pauiPixelMapping2 is the pixel order for the second half |
| 39 |
// a_uiRadius is the amount to vary the base colors |
| 40 |
// |
| 41 |
IndividualTrys::IndividualTrys(ColorFloatRGBA a_frgbaColor1, ColorFloatRGBA a_frgbaColor2, |
| 42 |
const unsigned int *a_pauiPixelMapping1, |
| 43 |
const unsigned int *a_pauiPixelMapping2, |
| 44 |
unsigned int a_uiRadius) |
| 45 |
{ |
| 46 |
assert(a_uiRadius <= MAX_RADIUS); |
| 47 |
|
| 48 |
ColorFloatRGBA frgbaQuantizedColor1 = a_frgbaColor1.QuantizeR4G4B4(); |
| 49 |
ColorFloatRGBA frgbaQuantizedColor2 = a_frgbaColor2.QuantizeR4G4B4(); |
| 50 |
|
| 51 |
// quantize base colors |
| 52 |
// ensure that trys with a_uiRadius don't overflow |
| 53 |
int iRed1 = MoveAwayFromEdge(frgbaQuantizedColor1.IntRed(15.0f), a_uiRadius); |
| 54 |
int iGreen1 = MoveAwayFromEdge(frgbaQuantizedColor1.IntGreen(15.0f), a_uiRadius); |
| 55 |
int iBlue1 = MoveAwayFromEdge(frgbaQuantizedColor1.IntBlue(15.0f), a_uiRadius); |
| 56 |
int iRed2 = MoveAwayFromEdge(frgbaQuantizedColor2.IntRed(15.0f), a_uiRadius); |
| 57 |
int iGreen2 = MoveAwayFromEdge(frgbaQuantizedColor2.IntGreen(15.0f), a_uiRadius); |
| 58 |
int iBlue2 = MoveAwayFromEdge(frgbaQuantizedColor2.IntBlue(15.0f), a_uiRadius); |
| 59 |
|
| 60 |
m_half1.Init(iRed1, iGreen1, iBlue1, a_pauiPixelMapping1, a_uiRadius); |
| 61 |
m_half2.Init(iRed2, iGreen2, iBlue2, a_pauiPixelMapping2, a_uiRadius); |
| 62 |
|
| 63 |
} |
| 64 |
|
| 65 |
// ---------------------------------------------------------------------------------------------------- |
| 66 |
// |
| 67 |
void IndividualTrys::Half::Init(int a_iRed, int a_iGreen, int a_iBlue, |
| 68 |
const unsigned int *a_pauiPixelMapping, unsigned int a_uiRadius) |
| 69 |
{ |
| 70 |
|
| 71 |
m_iRed = a_iRed; |
| 72 |
m_iGreen = a_iGreen; |
| 73 |
m_iBlue = a_iBlue; |
| 74 |
|
| 75 |
m_pauiPixelMapping = a_pauiPixelMapping; |
| 76 |
m_uiRadius = a_uiRadius; |
| 77 |
|
| 78 |
m_uiTrys = 0; |
| 79 |
|
| 80 |
} |
| 81 |
|
| 82 |
// ---------------------------------------------------------------------------------------------------- |
| 83 |
// |
| 84 |
|
| 85 |
} // namespace Etc |