1 | /* The copyright in this software is being made available under the BSD |
---|
2 | * License, included below. This software may be subject to other third party |
---|
3 | * and contributor rights, including patent rights, and no such rights are |
---|
4 | * granted under this license. |
---|
5 | * |
---|
6 | * Copyright (c) 2010-2014, ITU/ISO/IEC |
---|
7 | * All rights reserved. |
---|
8 | * |
---|
9 | * Redistribution and use in source and binary forms, with or without |
---|
10 | * modification, are permitted provided that the following conditions are met: |
---|
11 | * |
---|
12 | * * Redistributions of source code must retain the above copyright notice, |
---|
13 | * this list of conditions and the following disclaimer. |
---|
14 | * * Redistributions in binary form must reproduce the above copyright notice, |
---|
15 | * this list of conditions and the following disclaimer in the documentation |
---|
16 | * and/or other materials provided with the distribution. |
---|
17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
18 | * be used to endorse or promote products derived from this software without |
---|
19 | * specific prior written permission. |
---|
20 | * |
---|
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
---|
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
24 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS |
---|
25 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
26 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
27 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
30 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
---|
31 | * THE POSSIBILITY OF SUCH DAMAGE. |
---|
32 | */ |
---|
33 | |
---|
34 | /** \file TComRom.cpp |
---|
35 | \brief global variables & functions |
---|
36 | */ |
---|
37 | |
---|
38 | #include "TComRom.h" |
---|
39 | #include <memory.h> |
---|
40 | #include <stdlib.h> |
---|
41 | #include <stdio.h> |
---|
42 | // ==================================================================================================================== |
---|
43 | // Initialize / destroy functions |
---|
44 | // ==================================================================================================================== |
---|
45 | |
---|
46 | //! \ingroup TLibCommon |
---|
47 | //! \{ |
---|
48 | |
---|
49 | // initialize ROM variables |
---|
50 | Void initROM() |
---|
51 | { |
---|
52 | Int i, c; |
---|
53 | |
---|
54 | // g_aucConvertToBit[ x ]: log2(x/4), if x=4 -> 0, x=8 -> 1, x=16 -> 2, ... |
---|
55 | ::memset( g_aucConvertToBit, -1, sizeof( g_aucConvertToBit ) ); |
---|
56 | c=0; |
---|
57 | for ( i=4; i<=MAX_CU_SIZE; i*=2 ) |
---|
58 | { |
---|
59 | g_aucConvertToBit[ i ] = c; |
---|
60 | c++; |
---|
61 | } |
---|
62 | |
---|
63 | c=2; |
---|
64 | for ( i=0; i<MAX_CU_DEPTH; i++ ) |
---|
65 | { |
---|
66 | g_auiSigLastScan[0][i] = new UInt[ c*c ]; |
---|
67 | g_auiSigLastScan[1][i] = new UInt[ c*c ]; |
---|
68 | g_auiSigLastScan[2][i] = new UInt[ c*c ]; |
---|
69 | initSigLastScan( g_auiSigLastScan[0][i], g_auiSigLastScan[1][i], g_auiSigLastScan[2][i], c, c); |
---|
70 | |
---|
71 | c <<= 1; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | Void destroyROM() |
---|
76 | { |
---|
77 | for (Int i=0; i<MAX_CU_DEPTH; i++ ) |
---|
78 | { |
---|
79 | delete[] g_auiSigLastScan[0][i]; |
---|
80 | delete[] g_auiSigLastScan[1][i]; |
---|
81 | delete[] g_auiSigLastScan[2][i]; |
---|
82 | } |
---|
83 | |
---|
84 | #if H_3D_DIM_DMM |
---|
85 | if( !g_dmmWedgeLists.empty() ) |
---|
86 | { |
---|
87 | for( UInt ui = 0; ui < g_dmmWedgeLists.size(); ui++ ) { g_dmmWedgeLists[ui].clear(); } |
---|
88 | g_dmmWedgeLists.clear(); |
---|
89 | } |
---|
90 | if( !g_dmmWedgeRefLists.empty() ) |
---|
91 | { |
---|
92 | for( UInt ui = 0; ui < g_dmmWedgeRefLists.size(); ui++ ) { g_dmmWedgeRefLists[ui].clear(); } |
---|
93 | g_dmmWedgeRefLists.clear(); |
---|
94 | } |
---|
95 | |
---|
96 | if( !g_dmmWedgeNodeLists.empty() ) |
---|
97 | { |
---|
98 | for( UInt ui = 0; ui < g_dmmWedgeNodeLists.size(); ui++ ) { g_dmmWedgeNodeLists[ui].clear(); } |
---|
99 | g_dmmWedgeNodeLists.clear(); |
---|
100 | } |
---|
101 | #endif |
---|
102 | } |
---|
103 | |
---|
104 | // ==================================================================================================================== |
---|
105 | // Data structure related table & variable |
---|
106 | // ==================================================================================================================== |
---|
107 | |
---|
108 | UInt g_uiMaxCUWidth = MAX_CU_SIZE; |
---|
109 | UInt g_uiMaxCUHeight = MAX_CU_SIZE; |
---|
110 | UInt g_uiMaxCUDepth = MAX_CU_DEPTH; |
---|
111 | UInt g_uiAddCUDepth = 0; |
---|
112 | UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
113 | UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
114 | UInt g_auiRasterToPelX [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
115 | UInt g_auiRasterToPelY [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, }; |
---|
116 | |
---|
117 | UInt g_auiPUOffset[8] = { 0, 8, 4, 4, 2, 10, 1, 5}; |
---|
118 | |
---|
119 | Void initZscanToRaster ( Int iMaxDepth, Int iDepth, UInt uiStartVal, UInt*& rpuiCurrIdx ) |
---|
120 | { |
---|
121 | Int iStride = 1 << ( iMaxDepth - 1 ); |
---|
122 | |
---|
123 | if ( iDepth == iMaxDepth ) |
---|
124 | { |
---|
125 | rpuiCurrIdx[0] = uiStartVal; |
---|
126 | rpuiCurrIdx++; |
---|
127 | } |
---|
128 | else |
---|
129 | { |
---|
130 | Int iStep = iStride >> iDepth; |
---|
131 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal, rpuiCurrIdx ); |
---|
132 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep, rpuiCurrIdx ); |
---|
133 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride, rpuiCurrIdx ); |
---|
134 | initZscanToRaster( iMaxDepth, iDepth+1, uiStartVal+iStep*iStride+iStep, rpuiCurrIdx ); |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | Void initRasterToZscan ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
139 | { |
---|
140 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
141 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
142 | |
---|
143 | UInt uiNumPartInWidth = (UInt)uiMaxCUWidth / uiMinCUWidth; |
---|
144 | UInt uiNumPartInHeight = (UInt)uiMaxCUHeight / uiMinCUHeight; |
---|
145 | |
---|
146 | for ( UInt i = 0; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
147 | { |
---|
148 | g_auiRasterToZscan[ g_auiZscanToRaster[i] ] = i; |
---|
149 | } |
---|
150 | } |
---|
151 | |
---|
152 | Void initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth ) |
---|
153 | { |
---|
154 | UInt i; |
---|
155 | |
---|
156 | UInt* uiTempX = &g_auiRasterToPelX[0]; |
---|
157 | UInt* uiTempY = &g_auiRasterToPelY[0]; |
---|
158 | |
---|
159 | UInt uiMinCUWidth = uiMaxCUWidth >> ( uiMaxDepth - 1 ); |
---|
160 | UInt uiMinCUHeight = uiMaxCUHeight >> ( uiMaxDepth - 1 ); |
---|
161 | |
---|
162 | UInt uiNumPartInWidth = uiMaxCUWidth / uiMinCUWidth; |
---|
163 | UInt uiNumPartInHeight = uiMaxCUHeight / uiMinCUHeight; |
---|
164 | |
---|
165 | uiTempX[0] = 0; uiTempX++; |
---|
166 | for ( i = 1; i < uiNumPartInWidth; i++ ) |
---|
167 | { |
---|
168 | uiTempX[0] = uiTempX[-1] + uiMinCUWidth; uiTempX++; |
---|
169 | } |
---|
170 | for ( i = 1; i < uiNumPartInHeight; i++ ) |
---|
171 | { |
---|
172 | memcpy(uiTempX, uiTempX-uiNumPartInWidth, sizeof(UInt)*uiNumPartInWidth); |
---|
173 | uiTempX += uiNumPartInWidth; |
---|
174 | } |
---|
175 | |
---|
176 | for ( i = 1; i < uiNumPartInWidth*uiNumPartInHeight; i++ ) |
---|
177 | { |
---|
178 | uiTempY[i] = ( i / uiNumPartInWidth ) * uiMinCUWidth; |
---|
179 | } |
---|
180 | }; |
---|
181 | |
---|
182 | |
---|
183 | Int g_quantScales[6] = |
---|
184 | { |
---|
185 | 26214,23302,20560,18396,16384,14564 |
---|
186 | }; |
---|
187 | |
---|
188 | Int g_invQuantScales[6] = |
---|
189 | { |
---|
190 | 40,45,51,57,64,72 |
---|
191 | }; |
---|
192 | |
---|
193 | const Short g_aiT4[4][4] = |
---|
194 | { |
---|
195 | { 64, 64, 64, 64}, |
---|
196 | { 83, 36,-36,-83}, |
---|
197 | { 64,-64,-64, 64}, |
---|
198 | { 36,-83, 83,-36} |
---|
199 | }; |
---|
200 | |
---|
201 | const Short g_aiT8[8][8] = |
---|
202 | { |
---|
203 | { 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
204 | { 89, 75, 50, 18,-18,-50,-75,-89}, |
---|
205 | { 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
206 | { 75,-18,-89,-50, 50, 89, 18,-75}, |
---|
207 | { 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
208 | { 50,-89, 18, 75,-75,-18, 89,-50}, |
---|
209 | { 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
210 | { 18,-50, 75,-89, 89,-75, 50,-18} |
---|
211 | }; |
---|
212 | |
---|
213 | const Short g_aiT16[16][16] = |
---|
214 | { |
---|
215 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
216 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90}, |
---|
217 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
218 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87}, |
---|
219 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
220 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80}, |
---|
221 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
222 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70}, |
---|
223 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
224 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57}, |
---|
225 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
226 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43}, |
---|
227 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
228 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25}, |
---|
229 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
230 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9} |
---|
231 | }; |
---|
232 | |
---|
233 | const Short g_aiT32[32][32] = |
---|
234 | { |
---|
235 | { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64}, |
---|
236 | { 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13, 4, -4,-13,-22,-31,-38,-46,-54,-61,-67,-73,-78,-82,-85,-88,-90,-90}, |
---|
237 | { 90, 87, 80, 70, 57, 43, 25, 9, -9,-25,-43,-57,-70,-80,-87,-90,-90,-87,-80,-70,-57,-43,-25, -9, 9, 25, 43, 57, 70, 80, 87, 90}, |
---|
238 | { 90, 82, 67, 46, 22, -4,-31,-54,-73,-85,-90,-88,-78,-61,-38,-13, 13, 38, 61, 78, 88, 90, 85, 73, 54, 31, 4,-22,-46,-67,-82,-90}, |
---|
239 | { 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89, 89, 75, 50, 18,-18,-50,-75,-89,-89,-75,-50,-18, 18, 50, 75, 89}, |
---|
240 | { 88, 67, 31,-13,-54,-82,-90,-78,-46, -4, 38, 73, 90, 85, 61, 22,-22,-61,-85,-90,-73,-38, 4, 46, 78, 90, 82, 54, 13,-31,-67,-88}, |
---|
241 | { 87, 57, 9,-43,-80,-90,-70,-25, 25, 70, 90, 80, 43, -9,-57,-87,-87,-57, -9, 43, 80, 90, 70, 25,-25,-70,-90,-80,-43, 9, 57, 87}, |
---|
242 | { 85, 46,-13,-67,-90,-73,-22, 38, 82, 88, 54, -4,-61,-90,-78,-31, 31, 78, 90, 61, 4,-54,-88,-82,-38, 22, 73, 90, 67, 13,-46,-85}, |
---|
243 | { 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83, 83, 36,-36,-83,-83,-36, 36, 83}, |
---|
244 | { 82, 22,-54,-90,-61, 13, 78, 85, 31,-46,-90,-67, 4, 73, 88, 38,-38,-88,-73, -4, 67, 90, 46,-31,-85,-78,-13, 61, 90, 54,-22,-82}, |
---|
245 | { 80, 9,-70,-87,-25, 57, 90, 43,-43,-90,-57, 25, 87, 70, -9,-80,-80, -9, 70, 87, 25,-57,-90,-43, 43, 90, 57,-25,-87,-70, 9, 80}, |
---|
246 | { 78, -4,-82,-73, 13, 85, 67,-22,-88,-61, 31, 90, 54,-38,-90,-46, 46, 90, 38,-54,-90,-31, 61, 88, 22,-67,-85,-13, 73, 82, 4,-78}, |
---|
247 | { 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75, 75,-18,-89,-50, 50, 89, 18,-75,-75, 18, 89, 50,-50,-89,-18, 75}, |
---|
248 | { 73,-31,-90,-22, 78, 67,-38,-90,-13, 82, 61,-46,-88, -4, 85, 54,-54,-85, 4, 88, 46,-61,-82, 13, 90, 38,-67,-78, 22, 90, 31,-73}, |
---|
249 | { 70,-43,-87, 9, 90, 25,-80,-57, 57, 80,-25,-90, -9, 87, 43,-70,-70, 43, 87, -9,-90,-25, 80, 57,-57,-80, 25, 90, 9,-87,-43, 70}, |
---|
250 | { 67,-54,-78, 38, 85,-22,-90, 4, 90, 13,-88,-31, 82, 46,-73,-61, 61, 73,-46,-82, 31, 88,-13,-90, -4, 90, 22,-85,-38, 78, 54,-67}, |
---|
251 | { 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64, 64,-64,-64, 64}, |
---|
252 | { 61,-73,-46, 82, 31,-88,-13, 90, -4,-90, 22, 85,-38,-78, 54, 67,-67,-54, 78, 38,-85,-22, 90, 4,-90, 13, 88,-31,-82, 46, 73,-61}, |
---|
253 | { 57,-80,-25, 90, -9,-87, 43, 70,-70,-43, 87, 9,-90, 25, 80,-57,-57, 80, 25,-90, 9, 87,-43,-70, 70, 43,-87, -9, 90,-25,-80, 57}, |
---|
254 | { 54,-85, -4, 88,-46,-61, 82, 13,-90, 38, 67,-78,-22, 90,-31,-73, 73, 31,-90, 22, 78,-67,-38, 90,-13,-82, 61, 46,-88, 4, 85,-54}, |
---|
255 | { 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50, 50,-89, 18, 75,-75,-18, 89,-50,-50, 89,-18,-75, 75, 18,-89, 50}, |
---|
256 | { 46,-90, 38, 54,-90, 31, 61,-88, 22, 67,-85, 13, 73,-82, 4, 78,-78, -4, 82,-73,-13, 85,-67,-22, 88,-61,-31, 90,-54,-38, 90,-46}, |
---|
257 | { 43,-90, 57, 25,-87, 70, 9,-80, 80, -9,-70, 87,-25,-57, 90,-43,-43, 90,-57,-25, 87,-70, -9, 80,-80, 9, 70,-87, 25, 57,-90, 43}, |
---|
258 | { 38,-88, 73, -4,-67, 90,-46,-31, 85,-78, 13, 61,-90, 54, 22,-82, 82,-22,-54, 90,-61,-13, 78,-85, 31, 46,-90, 67, 4,-73, 88,-38}, |
---|
259 | { 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36, 36,-83, 83,-36,-36, 83,-83, 36}, |
---|
260 | { 31,-78, 90,-61, 4, 54,-88, 82,-38,-22, 73,-90, 67,-13,-46, 85,-85, 46, 13,-67, 90,-73, 22, 38,-82, 88,-54, -4, 61,-90, 78,-31}, |
---|
261 | { 25,-70, 90,-80, 43, 9,-57, 87,-87, 57, -9,-43, 80,-90, 70,-25,-25, 70,-90, 80,-43, -9, 57,-87, 87,-57, 9, 43,-80, 90,-70, 25}, |
---|
262 | { 22,-61, 85,-90, 73,-38, -4, 46,-78, 90,-82, 54,-13,-31, 67,-88, 88,-67, 31, 13,-54, 82,-90, 78,-46, 4, 38,-73, 90,-85, 61,-22}, |
---|
263 | { 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18, 18,-50, 75,-89, 89,-75, 50,-18,-18, 50,-75, 89,-89, 75,-50, 18}, |
---|
264 | { 13,-38, 61,-78, 88,-90, 85,-73, 54,-31, 4, 22,-46, 67,-82, 90,-90, 82,-67, 46,-22, -4, 31,-54, 73,-85, 90,-88, 78,-61, 38,-13}, |
---|
265 | { 9,-25, 43,-57, 70,-80, 87,-90, 90,-87, 80,-70, 57,-43, 25, -9, -9, 25,-43, 57,-70, 80,-87, 90,-90, 87,-80, 70,-57, 43,-25, 9}, |
---|
266 | { 4,-13, 22,-31, 38,-46, 54,-61, 67,-73, 78,-82, 85,-88, 90,-90, 90,-90, 88,-85, 82,-78, 73,-67, 61,-54, 46,-38, 31,-22, 13, -4} |
---|
267 | }; |
---|
268 | |
---|
269 | const UChar g_aucChromaScale[58]= |
---|
270 | { |
---|
271 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16, |
---|
272 | 17,18,19,20,21,22,23,24,25,26,27,28,29,29,30,31,32, |
---|
273 | 33,33,34,34,35,35,36,36,37,37,38,39,40,41,42,43,44, |
---|
274 | 45,46,47,48,49,50,51 |
---|
275 | }; |
---|
276 | |
---|
277 | |
---|
278 | // Mode-Dependent DCT/DST |
---|
279 | const Short g_as_DST_MAT_4 [4][4]= |
---|
280 | { |
---|
281 | {29, 55, 74, 84}, |
---|
282 | {74, 74, 0 , -74}, |
---|
283 | {84, -29, -74, 55}, |
---|
284 | {55, -84, 74, -29}, |
---|
285 | }; |
---|
286 | |
---|
287 | |
---|
288 | // ==================================================================================================================== |
---|
289 | // ADI |
---|
290 | // ==================================================================================================================== |
---|
291 | |
---|
292 | #if FAST_UDI_USE_MPM |
---|
293 | const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = |
---|
294 | { |
---|
295 | 3, // 2x2 |
---|
296 | 8, // 4x4 |
---|
297 | 8, // 8x8 |
---|
298 | 3, // 16x16 |
---|
299 | 3, // 32x32 |
---|
300 | 3 // 64x64 |
---|
301 | }; |
---|
302 | #else // FAST_UDI_USE_MPM |
---|
303 | const UChar g_aucIntraModeNumFast[MAX_CU_DEPTH] = |
---|
304 | { |
---|
305 | 3, // 2x2 |
---|
306 | 9, // 4x4 |
---|
307 | 9, // 8x8 |
---|
308 | 4, // 16x16 33 |
---|
309 | 4, // 32x32 33 |
---|
310 | 5 // 64x64 33 |
---|
311 | }; |
---|
312 | #endif // FAST_UDI_USE_MPM |
---|
313 | |
---|
314 | // chroma |
---|
315 | |
---|
316 | const UChar g_aucConvertTxtTypeToIdx[4] = { 0, 1, 1, 2 }; |
---|
317 | |
---|
318 | |
---|
319 | // ==================================================================================================================== |
---|
320 | // Bit-depth |
---|
321 | // ==================================================================================================================== |
---|
322 | |
---|
323 | Int g_bitDepthY = 8; |
---|
324 | Int g_bitDepthC = 8; |
---|
325 | |
---|
326 | UInt g_uiPCMBitDepthLuma = 8; // PCM bit-depth |
---|
327 | UInt g_uiPCMBitDepthChroma = 8; // PCM bit-depth |
---|
328 | |
---|
329 | #if H_3D_DIM_DMM |
---|
330 | // ==================================================================================================================== |
---|
331 | // Depth coding modes |
---|
332 | // ==================================================================================================================== |
---|
333 | const WedgeResolution g_dmmWedgeResolution[6] = |
---|
334 | { |
---|
335 | HALF_PEL, // 4x4 |
---|
336 | HALF_PEL, // 8x8 |
---|
337 | FULL_PEL, // 16x16 |
---|
338 | #if SHARP_DMM1_I0110 |
---|
339 | FULL_PEL, // 32x32 |
---|
340 | FULL_PEL, // 64x64 |
---|
341 | FULL_PEL // 128x128 |
---|
342 | #else |
---|
343 | DOUBLE_PEL, // 32x32 |
---|
344 | DOUBLE_PEL, // 64x64 |
---|
345 | DOUBLE_PEL // 128x128 |
---|
346 | #endif |
---|
347 | }; |
---|
348 | |
---|
349 | const UChar g_dmm1TabIdxBits[6] = |
---|
350 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
351 | 0, 7, 10, 11, 11, 13 }; |
---|
352 | |
---|
353 | const UChar g_dmm3IntraTabIdxBits[6] = |
---|
354 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
355 | 0, 4, 7, 8, 8, 0 }; |
---|
356 | |
---|
357 | #if SHARP_DMM1_I0110 |
---|
358 | Bool g_wedgePattern[32*32]; |
---|
359 | #endif |
---|
360 | |
---|
361 | extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
362 | extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
363 | extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
364 | #endif |
---|
365 | |
---|
366 | // ==================================================================================================================== |
---|
367 | // Misc. |
---|
368 | // ==================================================================================================================== |
---|
369 | |
---|
370 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
371 | |
---|
372 | #if H_3D_IC |
---|
373 | UInt g_aICEnableCANDIDATE[10] = { 0, }; |
---|
374 | UInt g_aICEnableNUM[ 10 ] = { 0, }; |
---|
375 | Int g_lastlayer=0; |
---|
376 | #endif |
---|
377 | #if ENC_DEC_TRACE |
---|
378 | FILE* g_hTrace = NULL; |
---|
379 | const Bool g_bEncDecTraceEnable = true; |
---|
380 | const Bool g_bEncDecTraceDisable = false; |
---|
381 | Bool g_HLSTraceEnable = true; |
---|
382 | Bool g_bJustDoIt = false; |
---|
383 | UInt64 g_nSymbolCounter = 0; |
---|
384 | #if H_MV_ENC_DEC_TRAC |
---|
385 | Bool g_traceCU = true; |
---|
386 | Bool g_tracePU = true; |
---|
387 | Bool g_traceTU = true; |
---|
388 | Bool g_disableHLSTrace = false; |
---|
389 | UInt64 g_stopAtCounter = 0; |
---|
390 | Bool g_traceCopyBack = false; |
---|
391 | Bool g_decTraceDispDer = false; |
---|
392 | Bool g_decTraceMvFromMerge = false; |
---|
393 | Bool g_decTracePicOutput = false; |
---|
394 | Bool g_stopAtPos = false; |
---|
395 | Bool g_outputPos = false; |
---|
396 | #endif |
---|
397 | #endif |
---|
398 | // ==================================================================================================================== |
---|
399 | // Scanning order & context model mapping |
---|
400 | // ==================================================================================================================== |
---|
401 | |
---|
402 | // scanning order table |
---|
403 | UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; |
---|
404 | |
---|
405 | const UInt g_sigLastScan8x8[ 3 ][ 4 ] = |
---|
406 | { |
---|
407 | {0, 2, 1, 3}, |
---|
408 | {0, 1, 2, 3}, |
---|
409 | {0, 2, 1, 3} |
---|
410 | }; |
---|
411 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
412 | |
---|
413 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
414 | const UInt g_uiGroupIdx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9}; |
---|
415 | |
---|
416 | Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight) |
---|
417 | { |
---|
418 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
419 | UInt uiNextScanPos = 0; |
---|
420 | |
---|
421 | if( iWidth < 16 ) |
---|
422 | { |
---|
423 | UInt* pBuffTemp = pBuffD; |
---|
424 | if( iWidth == 8 ) |
---|
425 | { |
---|
426 | pBuffTemp = g_sigLastScanCG32x32; |
---|
427 | } |
---|
428 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
429 | { |
---|
430 | Int iPrimDim = Int( uiScanLine ); |
---|
431 | Int iScndDim = 0; |
---|
432 | while( iPrimDim >= iWidth ) |
---|
433 | { |
---|
434 | iScndDim++; |
---|
435 | iPrimDim--; |
---|
436 | } |
---|
437 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
438 | { |
---|
439 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
440 | uiNextScanPos++; |
---|
441 | iScndDim++; |
---|
442 | iPrimDim--; |
---|
443 | } |
---|
444 | } |
---|
445 | } |
---|
446 | if( iWidth > 4 ) |
---|
447 | { |
---|
448 | UInt uiNumBlkSide = iWidth >> 2; |
---|
449 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
450 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
451 | |
---|
452 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
453 | { |
---|
454 | uiNextScanPos = 0; |
---|
455 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
456 | if( iWidth == 32 ) |
---|
457 | { |
---|
458 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
459 | } |
---|
460 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
461 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
462 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
463 | UInt offsetScan = 16 * uiBlk; |
---|
464 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
465 | { |
---|
466 | Int iPrimDim = Int( uiScanLine ); |
---|
467 | Int iScndDim = 0; |
---|
468 | while( iPrimDim >= 4 ) |
---|
469 | { |
---|
470 | iScndDim++; |
---|
471 | iPrimDim--; |
---|
472 | } |
---|
473 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
474 | { |
---|
475 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
476 | uiNextScanPos++; |
---|
477 | iScndDim++; |
---|
478 | iPrimDim--; |
---|
479 | } |
---|
480 | } |
---|
481 | } |
---|
482 | } |
---|
483 | |
---|
484 | UInt uiCnt = 0; |
---|
485 | if( iWidth > 2 ) |
---|
486 | { |
---|
487 | UInt numBlkSide = iWidth >> 2; |
---|
488 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
489 | { |
---|
490 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
491 | { |
---|
492 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
493 | for(Int y=0; y < 4; y++) |
---|
494 | { |
---|
495 | for(Int x=0; x < 4; x++) |
---|
496 | { |
---|
497 | pBuffH[uiCnt] = y*iWidth + x + offset; |
---|
498 | uiCnt ++; |
---|
499 | } |
---|
500 | } |
---|
501 | } |
---|
502 | } |
---|
503 | |
---|
504 | uiCnt = 0; |
---|
505 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
506 | { |
---|
507 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
508 | { |
---|
509 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
510 | for(Int x=0; x < 4; x++) |
---|
511 | { |
---|
512 | for(Int y=0; y < 4; y++) |
---|
513 | { |
---|
514 | pBuffV[uiCnt] = y*iWidth + x + offset; |
---|
515 | uiCnt ++; |
---|
516 | } |
---|
517 | } |
---|
518 | } |
---|
519 | } |
---|
520 | } |
---|
521 | else |
---|
522 | { |
---|
523 | for(Int iY=0; iY < iHeight; iY++) |
---|
524 | { |
---|
525 | for(Int iX=0; iX < iWidth; iX++) |
---|
526 | { |
---|
527 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
528 | uiCnt ++; |
---|
529 | } |
---|
530 | } |
---|
531 | |
---|
532 | uiCnt = 0; |
---|
533 | for(Int iX=0; iX < iWidth; iX++) |
---|
534 | { |
---|
535 | for(Int iY=0; iY < iHeight; iY++) |
---|
536 | { |
---|
537 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
538 | uiCnt ++; |
---|
539 | } |
---|
540 | } |
---|
541 | } |
---|
542 | } |
---|
543 | |
---|
544 | Int g_quantTSDefault4x4[16] = |
---|
545 | { |
---|
546 | 16,16,16,16, |
---|
547 | 16,16,16,16, |
---|
548 | 16,16,16,16, |
---|
549 | 16,16,16,16 |
---|
550 | }; |
---|
551 | |
---|
552 | Int g_quantIntraDefault8x8[64] = |
---|
553 | { |
---|
554 | 16,16,16,16,17,18,21,24, |
---|
555 | 16,16,16,16,17,19,22,25, |
---|
556 | 16,16,17,18,20,22,25,29, |
---|
557 | 16,16,18,21,24,27,31,36, |
---|
558 | 17,17,20,24,30,35,41,47, |
---|
559 | 18,19,22,27,35,44,54,65, |
---|
560 | 21,22,25,31,41,54,70,88, |
---|
561 | 24,25,29,36,47,65,88,115 |
---|
562 | }; |
---|
563 | |
---|
564 | Int g_quantInterDefault8x8[64] = |
---|
565 | { |
---|
566 | 16,16,16,16,17,18,20,24, |
---|
567 | 16,16,16,17,18,20,24,25, |
---|
568 | 16,16,17,18,20,24,25,28, |
---|
569 | 16,17,18,20,24,25,28,33, |
---|
570 | 17,18,20,24,25,28,33,41, |
---|
571 | 18,20,24,25,28,33,41,54, |
---|
572 | 20,24,25,28,33,41,54,71, |
---|
573 | 24,25,28,33,41,54,71,91 |
---|
574 | }; |
---|
575 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
576 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
577 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
578 | Int g_eTTable[4] = {0,3,1,2}; |
---|
579 | |
---|
580 | #if H_MV_ENC_DEC_TRAC |
---|
581 | #if ENC_DEC_TRACE |
---|
582 | Void stopAtPos( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight ) |
---|
583 | { |
---|
584 | |
---|
585 | if ( g_outputPos ) |
---|
586 | { |
---|
587 | std::cout << "POC\t" << poc |
---|
588 | << "\tLayerId\t" << layerId |
---|
589 | << "\tCuPelX\t" << cuPelX |
---|
590 | << "\tCuPelY\t" << cuPelY |
---|
591 | << "\tCuWidth\t" << cuWidth |
---|
592 | << "\tCuHeight\t" << cuHeight |
---|
593 | << std::endl; |
---|
594 | } |
---|
595 | |
---|
596 | Bool stopFlag = false; |
---|
597 | if ( g_stopAtPos && poc == 0 && layerId == 1 ) |
---|
598 | { |
---|
599 | Bool stopAtCU = true; |
---|
600 | if ( stopAtCU ) // Stop at CU with specific size |
---|
601 | { |
---|
602 | stopFlag = ( cuPelX == 888 ) && ( cuPelY == 248 ) && ( cuWidth == 8 ) && ( cuHeight == 8); |
---|
603 | } |
---|
604 | else |
---|
605 | { // Stop at specific position |
---|
606 | Int xPos = 888; |
---|
607 | Int yPos = 248; |
---|
608 | |
---|
609 | Int cuPelXEnd = cuPelX + cuWidth - 1; |
---|
610 | Int cuPelYEnd = cuPelY + cuHeight - 1; |
---|
611 | |
---|
612 | stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos ); |
---|
613 | } |
---|
614 | } |
---|
615 | |
---|
616 | if ( stopFlag ) |
---|
617 | { // Set breakpoint here. |
---|
618 | std::cout << "Stop position. Break point here." << std::endl; |
---|
619 | } |
---|
620 | } |
---|
621 | |
---|
622 | Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt ) |
---|
623 | { |
---|
624 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
625 | { |
---|
626 | if ( g_stopAtCounter == g_nSymbolCounter ) |
---|
627 | { |
---|
628 | std::cout << "Break point here." << std::endl; |
---|
629 | } |
---|
630 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
631 | fprintf( g_hTrace, "%-50s : %d\n", symbolName, val ); |
---|
632 | fflush ( g_hTrace ); |
---|
633 | g_nSymbolCounter++; |
---|
634 | } |
---|
635 | } |
---|
636 | |
---|
637 | Void writeToTraceFile( const Char* symbolName, Bool doIt ) |
---|
638 | { |
---|
639 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
640 | { |
---|
641 | fprintf( g_hTrace, "%s", symbolName ); |
---|
642 | fflush ( g_hTrace ); |
---|
643 | g_nSymbolCounter++; |
---|
644 | } |
---|
645 | } |
---|
646 | |
---|
647 | #endif |
---|
648 | #endif |
---|
649 | #if H_3D_DIM_DMM |
---|
650 | std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
651 | std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
652 | std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
653 | |
---|
654 | Void initWedgeLists( Bool initNodeList ) |
---|
655 | { |
---|
656 | if( !g_dmmWedgeLists.empty() ) return; |
---|
657 | |
---|
658 | #if SHARP_DMM1_I0110 |
---|
659 | for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]); ui++ ) |
---|
660 | #else |
---|
661 | for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]+1); ui++ ) |
---|
662 | #endif |
---|
663 | { |
---|
664 | UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui; |
---|
665 | std::vector<TComWedgelet> acWedgeList; |
---|
666 | std::vector<TComWedgeRef> acWedgeRefList; |
---|
667 | createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] ); |
---|
668 | g_dmmWedgeLists.push_back( acWedgeList ); |
---|
669 | g_dmmWedgeRefLists.push_back( acWedgeRefList ); |
---|
670 | |
---|
671 | if( initNodeList ) |
---|
672 | { |
---|
673 | // create WedgeNodeList |
---|
674 | std::vector<TComWedgeNode> acWedgeNodeList; |
---|
675 | for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ ) |
---|
676 | { |
---|
677 | if( acWedgeList[uiPos].getIsCoarse() ) |
---|
678 | { |
---|
679 | TComWedgeNode cWedgeNode; |
---|
680 | cWedgeNode.setPatternIdx( uiPos ); |
---|
681 | |
---|
682 | UInt uiRefPos = 0; |
---|
683 | for( Int iOffS = -1; iOffS <= 1; iOffS++ ) |
---|
684 | { |
---|
685 | for( Int iOffE = -1; iOffE <= 1; iOffE++ ) |
---|
686 | { |
---|
687 | if( iOffS == 0 && iOffE == 0 ) { continue; } |
---|
688 | |
---|
689 | Int iSx = (Int)acWedgeList[uiPos].getStartX(); |
---|
690 | Int iSy = (Int)acWedgeList[uiPos].getStartY(); |
---|
691 | Int iEx = (Int)acWedgeList[uiPos].getEndX(); |
---|
692 | Int iEy = (Int)acWedgeList[uiPos].getEndY(); |
---|
693 | |
---|
694 | switch( acWedgeList[uiPos].getOri() ) |
---|
695 | { |
---|
696 | case( 0 ): { iSx += iOffS; iEy += iOffE; } break; |
---|
697 | case( 1 ): { iSy += iOffS; iEx -= iOffE; } break; |
---|
698 | case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break; |
---|
699 | case( 3 ): { iSy -= iOffS; iEx += iOffE; } break; |
---|
700 | case( 4 ): { iSx += iOffS; iEx += iOffE; } break; |
---|
701 | case( 5 ): { iSy += iOffS; iEy += iOffE; } break; |
---|
702 | default: assert( 0 ); |
---|
703 | } |
---|
704 | |
---|
705 | for( UInt k = 0; k < acWedgeRefList.size(); k++ ) |
---|
706 | { |
---|
707 | if( iSx == (Int)acWedgeRefList[k].getStartX() && |
---|
708 | iSy == (Int)acWedgeRefList[k].getStartY() && |
---|
709 | iEx == (Int)acWedgeRefList[k].getEndX() && |
---|
710 | iEy == (Int)acWedgeRefList[k].getEndY() ) |
---|
711 | { |
---|
712 | if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() ) |
---|
713 | { |
---|
714 | Bool bNew = true; |
---|
715 | for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } |
---|
716 | |
---|
717 | if( bNew ) |
---|
718 | { |
---|
719 | cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos ); |
---|
720 | uiRefPos++; |
---|
721 | break; |
---|
722 | } |
---|
723 | } |
---|
724 | } |
---|
725 | } |
---|
726 | } |
---|
727 | } |
---|
728 | acWedgeNodeList.push_back( cWedgeNode ); |
---|
729 | } |
---|
730 | } |
---|
731 | g_dmmWedgeNodeLists.push_back( acWedgeNodeList ); |
---|
732 | } |
---|
733 | } |
---|
734 | } |
---|
735 | |
---|
736 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) |
---|
737 | { |
---|
738 | assert( uiWidth == uiHeight ); |
---|
739 | |
---|
740 | UChar uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0; |
---|
741 | Int iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0; |
---|
742 | |
---|
743 | UInt uiBlockSize = 0; |
---|
744 | switch( eWedgeRes ) |
---|
745 | { |
---|
746 | #if !SHARP_DMM1_I0110 |
---|
747 | case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; } |
---|
748 | #endif |
---|
749 | case( FULL_PEL ): { uiBlockSize = uiWidth; break; } |
---|
750 | case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } |
---|
751 | } |
---|
752 | |
---|
753 | TComWedgelet cTempWedgelet( uiWidth, uiHeight ); |
---|
754 | for( UInt uiOri = 0; uiOri < 6; uiOri++ ) |
---|
755 | { |
---|
756 | // init the edge line parameters for each of the 6 wedgelet types |
---|
757 | switch( uiOri ) |
---|
758 | { |
---|
759 | case( 0 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = +1; iStepStartY = 0; iStepEndX = 0; iStepEndY = +1; break; } |
---|
760 | case( 1 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = (uiBlockSize-1); uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = -1; iStepEndY = 0; break; } |
---|
761 | case( 2 ): { uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY = 0; iStepEndX = 0; iStepEndY = -1; break; } |
---|
762 | case( 3 ): { uhStartX = 0; uhStartY = (uiBlockSize-1); uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = 0; iStepStartY = -1; iStepEndX = +1; iStepEndY = 0; break; } |
---|
763 | case( 4 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY = 0; iStepEndX = +1; iStepEndY = 0; break; } |
---|
764 | case( 5 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = 0; iStepEndY = +1; break; } |
---|
765 | } |
---|
766 | |
---|
767 | for( Int iK = 0; iK < uiBlockSize; iK++ ) |
---|
768 | { |
---|
769 | for( Int iL = 0; iL < uiBlockSize; iL++ ) |
---|
770 | { |
---|
771 | cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) ); |
---|
772 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
773 | } |
---|
774 | } |
---|
775 | } |
---|
776 | |
---|
777 | |
---|
778 | } |
---|
779 | |
---|
780 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) |
---|
781 | { |
---|
782 | Bool bValid = cWedgelet.checkNotPlain(); |
---|
783 | if( bValid ) |
---|
784 | { |
---|
785 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
786 | { |
---|
787 | if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
788 | { |
---|
789 | TComWedgeRef cWedgeRef; |
---|
790 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
791 | racWedgeRefList.push_back( cWedgeRef ); |
---|
792 | bValid = false; |
---|
793 | return; |
---|
794 | } |
---|
795 | } |
---|
796 | } |
---|
797 | if( bValid ) |
---|
798 | { |
---|
799 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
800 | { |
---|
801 | if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
802 | { |
---|
803 | TComWedgeRef cWedgeRef; |
---|
804 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
805 | racWedgeRefList.push_back( cWedgeRef ); |
---|
806 | bValid = false; |
---|
807 | return; |
---|
808 | } |
---|
809 | } |
---|
810 | } |
---|
811 | if( bValid ) |
---|
812 | { |
---|
813 | cWedgelet.findClosestAngle(); |
---|
814 | racWedgeList.push_back( cWedgelet ); |
---|
815 | TComWedgeRef cWedgeRef; |
---|
816 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); |
---|
817 | racWedgeRefList.push_back( cWedgeRef ); |
---|
818 | } |
---|
819 | } |
---|
820 | #endif //H_3D_DIM_DMM |
---|
821 | |
---|
822 | //! \} |
---|