Debian Codegraph @

third_party/etc2comp/EtcLib/EtcCodec/EtcSortedBlockList.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 namespace Etc
20 {
21 class Block4x4;
22
23 class SortedBlockList
24 {
25 public:
26
27 class Link
28 {
29 public:
30
31 inline void Init(Block4x4 *a_pblock)
32 {
33 m_pblock = a_pblock;
34 m_plinkNext = nullptr;
35 }
36
37 inline Block4x4 * GetBlock(void)
38 {
39 return m_pblock;
40 }
41
42 inline void SetNext(Link *a_plinkNext)
43 {
44 m_plinkNext = a_plinkNext;
45 }
46
47 inline Link * GetNext(void)
48 {
49 return m_plinkNext;
50 }
51
52 inline Link * Advance(unsigned int a_uiSteps = 1)
53 {
54 Link *plink = this;
55
56 for (unsigned int uiStep = 0; uiStep < a_uiSteps; uiStep++)
57 {
58 if (plink == nullptr)
59 {
60 break;
61 }
62
63 plink = plink->m_plinkNext;
64 }
65
66 return plink;
67 }
68
69 private:
70
71 Block4x4 *m_pblock;
72 Link *m_plinkNext;
73 };
74
75 SortedBlockList(unsigned int a_uiImageBlocks, unsigned int a_uiBuckets);
76 ~SortedBlockList(void);
77
78 void AddBlock(Block4x4 *a_pblock);
79
80 void Sort(void);
81
82 inline Link * GetLinkToFirstBlock(void)
83 {
84 return m_plinkFirst;
85 }
86
87 inline unsigned int GetNumberOfAddedBlocks(void)
88 {
89 return m_uiAddedBlocks;
90 }
91
92 inline unsigned int GetNumberOfSortedBlocks(void)
93 {
94 return m_uiSortedBlocks;
95 }
96
97 void Print(void);
98
99 private:
100
101 void InitBuckets(void);
102
103 class Bucket
104 {
105 public:
106 Link *plinkFirst;
107 Link *plinkLast;
108 };
109
110 unsigned int m_uiImageBlocks;
111 int m_iBuckets;
112
113 unsigned int m_uiAddedBlocks;
114 unsigned int m_uiSortedBlocks;
115 Link *m_palinkPool;
116 Bucket *m_pabucket;
117 float m_fMaxError;
118
119 Link *m_plinkFirst;
120 Link *m_plinkLast;
121
122 };
123
124 } // namespace Etc