Debian Codegraph @

third_party/etc2comp/EtcLib/EtcCodec/EtcDifferentialTrys.h

raw
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 "EtcColorFloatRGBA.h"
20
21 namespace Etc
22 {
23
24 class DifferentialTrys
25 {
26 public:
27
28 static const unsigned int MAX_RADIUS = 2;
29
30 DifferentialTrys(ColorFloatRGBA a_frgbaColor1,
31 ColorFloatRGBA a_frgbaColor2,
32 const unsigned int *a_pauiPixelMapping1,
33 const unsigned int *a_pauiPixelMapping2,
34 unsigned int a_uiRadius,
35 int a_iGrayOffset1, int a_iGrayOffset2);
36
37 inline static int MoveAwayFromEdge(int a_i, int a_iDistance)
38 {
39 if (a_i < (0+ a_iDistance))
40 {
41 return (0 + a_iDistance);
42 }
43 else if (a_i > (31- a_iDistance))
44 {
45 return (31 - a_iDistance);
46 }
47
48 return a_i;
49 }
50
51 class Try
52 {
53 public :
54 static const unsigned int SELECTORS = 8; // per half
55
56 int m_iRed;
57 int m_iGreen;
58 int m_iBlue;
59 unsigned int m_uiCW;
60 unsigned int m_auiSelectors[SELECTORS];
61 float m_fError;
62 };
63
64 class Half
65 {
66 public:
67
68 static const unsigned int MAX_TRYS = 125;
69
70 void Init(int a_iRed, int a_iGreen, int a_iBlue,
71 const unsigned int *a_pauiPixelMapping,
72 unsigned int a_uiRadius);
73
74 // center of trys
75 int m_iRed;
76 int m_iGreen;
77 int m_iBlue;
78
79 const unsigned int *m_pauiPixelMapping;
80 unsigned int m_uiRadius;
81
82 unsigned int m_uiTrys;
83 Try m_atry[MAX_TRYS];
84
85 Try *m_ptryBest;
86 };
87
88 Half m_half1;
89 Half m_half2;
90
91 bool m_boolSeverelyBentColors;
92 };
93
94 // ----------------------------------------------------------------------------------------------------
95 //
96
97 } // namespace Etc