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