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 | #if SHARP_DMM1_I0110 |
---|
358 | FULL_PEL, // 32x32 |
---|
359 | FULL_PEL, // 64x64 |
---|
360 | FULL_PEL // 128x128 |
---|
361 | #else |
---|
362 | DOUBLE_PEL, // 32x32 |
---|
363 | DOUBLE_PEL, // 64x64 |
---|
364 | DOUBLE_PEL // 128x128 |
---|
365 | #endif |
---|
366 | }; |
---|
367 | |
---|
368 | const UChar g_dmm1TabIdxBits[6] = |
---|
369 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
370 | 0, 7, 10, 11, 11, 13 }; |
---|
371 | |
---|
372 | const UChar g_dmm3IntraTabIdxBits[6] = |
---|
373 | { //2x2 4x4 8x8 16x16 32x32 64x64 |
---|
374 | 0, 4, 7, 8, 8, 0 }; |
---|
375 | |
---|
376 | #if SHARP_DMM1_I0110 |
---|
377 | Bool g_wedgePattern[32*32]; |
---|
378 | #endif |
---|
379 | |
---|
380 | extern std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
381 | extern std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
382 | extern std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
383 | #endif |
---|
384 | |
---|
385 | // ==================================================================================================================== |
---|
386 | // Misc. |
---|
387 | // ==================================================================================================================== |
---|
388 | |
---|
389 | Char g_aucConvertToBit [ MAX_CU_SIZE+1 ]; |
---|
390 | #if !MTK_LOW_LATENCY_IC_ENCODING_H0086_FIX |
---|
391 | #if H_3D_IC |
---|
392 | UInt g_aICEnableCANDIDATE[10] = { 0, }; |
---|
393 | UInt g_aICEnableNUM[ 10 ] = { 0, }; |
---|
394 | Int g_lastlayer=0; |
---|
395 | #endif |
---|
396 | #endif |
---|
397 | #if ENC_DEC_TRACE |
---|
398 | FILE* g_hTrace = NULL; |
---|
399 | const Bool g_bEncDecTraceEnable = true; |
---|
400 | const Bool g_bEncDecTraceDisable = false; |
---|
401 | Bool g_HLSTraceEnable = true; |
---|
402 | Bool g_bJustDoIt = false; |
---|
403 | UInt64 g_nSymbolCounter = 0; |
---|
404 | #if H_MV_ENC_DEC_TRAC |
---|
405 | Bool g_traceCU = false; |
---|
406 | Bool g_tracePU = false; |
---|
407 | Bool g_traceTU = false; |
---|
408 | Bool g_disableHLSTrace = false; |
---|
409 | UInt64 g_stopAtCounter = 0; |
---|
410 | Bool g_traceCopyBack = false; |
---|
411 | Bool g_decTraceDispDer = false; |
---|
412 | Bool g_decTraceMvFromMerge = false; |
---|
413 | Bool g_decTracePicOutput = false; |
---|
414 | Bool g_stopAtPos = false; |
---|
415 | Bool g_outputPos = false; |
---|
416 | #endif |
---|
417 | #endif |
---|
418 | // ==================================================================================================================== |
---|
419 | // Scanning order & context model mapping |
---|
420 | // ==================================================================================================================== |
---|
421 | |
---|
422 | // scanning order table |
---|
423 | UInt* g_auiSigLastScan[ 3 ][ MAX_CU_DEPTH ]; |
---|
424 | |
---|
425 | const UInt g_sigLastScan8x8[ 3 ][ 4 ] = |
---|
426 | { |
---|
427 | {0, 2, 1, 3}, |
---|
428 | {0, 1, 2, 3}, |
---|
429 | {0, 2, 1, 3} |
---|
430 | }; |
---|
431 | UInt g_sigLastScanCG32x32[ 64 ]; |
---|
432 | |
---|
433 | const UInt g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24}; |
---|
434 | 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}; |
---|
435 | |
---|
436 | Void initSigLastScan(UInt* pBuffD, UInt* pBuffH, UInt* pBuffV, Int iWidth, Int iHeight) |
---|
437 | { |
---|
438 | const UInt uiNumScanPos = UInt( iWidth * iWidth ); |
---|
439 | UInt uiNextScanPos = 0; |
---|
440 | |
---|
441 | if( iWidth < 16 ) |
---|
442 | { |
---|
443 | UInt* pBuffTemp = pBuffD; |
---|
444 | if( iWidth == 8 ) |
---|
445 | { |
---|
446 | pBuffTemp = g_sigLastScanCG32x32; |
---|
447 | } |
---|
448 | for( UInt uiScanLine = 0; uiNextScanPos < uiNumScanPos; uiScanLine++ ) |
---|
449 | { |
---|
450 | Int iPrimDim = Int( uiScanLine ); |
---|
451 | Int iScndDim = 0; |
---|
452 | while( iPrimDim >= iWidth ) |
---|
453 | { |
---|
454 | iScndDim++; |
---|
455 | iPrimDim--; |
---|
456 | } |
---|
457 | while( iPrimDim >= 0 && iScndDim < iWidth ) |
---|
458 | { |
---|
459 | pBuffTemp[ uiNextScanPos ] = iPrimDim * iWidth + iScndDim ; |
---|
460 | uiNextScanPos++; |
---|
461 | iScndDim++; |
---|
462 | iPrimDim--; |
---|
463 | } |
---|
464 | } |
---|
465 | } |
---|
466 | if( iWidth > 4 ) |
---|
467 | { |
---|
468 | UInt uiNumBlkSide = iWidth >> 2; |
---|
469 | UInt uiNumBlks = uiNumBlkSide * uiNumBlkSide; |
---|
470 | UInt log2Blk = g_aucConvertToBit[ uiNumBlkSide ] + 1; |
---|
471 | |
---|
472 | for( UInt uiBlk = 0; uiBlk < uiNumBlks; uiBlk++ ) |
---|
473 | { |
---|
474 | uiNextScanPos = 0; |
---|
475 | UInt initBlkPos = g_auiSigLastScan[ SCAN_DIAG ][ log2Blk ][ uiBlk ]; |
---|
476 | if( iWidth == 32 ) |
---|
477 | { |
---|
478 | initBlkPos = g_sigLastScanCG32x32[ uiBlk ]; |
---|
479 | } |
---|
480 | UInt offsetY = initBlkPos / uiNumBlkSide; |
---|
481 | UInt offsetX = initBlkPos - offsetY * uiNumBlkSide; |
---|
482 | UInt offsetD = 4 * ( offsetX + offsetY * iWidth ); |
---|
483 | UInt offsetScan = 16 * uiBlk; |
---|
484 | for( UInt uiScanLine = 0; uiNextScanPos < 16; uiScanLine++ ) |
---|
485 | { |
---|
486 | Int iPrimDim = Int( uiScanLine ); |
---|
487 | Int iScndDim = 0; |
---|
488 | while( iPrimDim >= 4 ) |
---|
489 | { |
---|
490 | iScndDim++; |
---|
491 | iPrimDim--; |
---|
492 | } |
---|
493 | while( iPrimDim >= 0 && iScndDim < 4 ) |
---|
494 | { |
---|
495 | pBuffD[ uiNextScanPos + offsetScan ] = iPrimDim * iWidth + iScndDim + offsetD; |
---|
496 | uiNextScanPos++; |
---|
497 | iScndDim++; |
---|
498 | iPrimDim--; |
---|
499 | } |
---|
500 | } |
---|
501 | } |
---|
502 | } |
---|
503 | |
---|
504 | UInt uiCnt = 0; |
---|
505 | if( iWidth > 2 ) |
---|
506 | { |
---|
507 | UInt numBlkSide = iWidth >> 2; |
---|
508 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
509 | { |
---|
510 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
511 | { |
---|
512 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
513 | for(Int y=0; y < 4; y++) |
---|
514 | { |
---|
515 | for(Int x=0; x < 4; x++) |
---|
516 | { |
---|
517 | pBuffH[uiCnt] = y*iWidth + x + offset; |
---|
518 | uiCnt ++; |
---|
519 | } |
---|
520 | } |
---|
521 | } |
---|
522 | } |
---|
523 | |
---|
524 | uiCnt = 0; |
---|
525 | for(Int blkX=0; blkX < numBlkSide; blkX++) |
---|
526 | { |
---|
527 | for(Int blkY=0; blkY < numBlkSide; blkY++) |
---|
528 | { |
---|
529 | UInt offset = blkY * 4 * iWidth + blkX * 4; |
---|
530 | for(Int x=0; x < 4; x++) |
---|
531 | { |
---|
532 | for(Int y=0; y < 4; y++) |
---|
533 | { |
---|
534 | pBuffV[uiCnt] = y*iWidth + x + offset; |
---|
535 | uiCnt ++; |
---|
536 | } |
---|
537 | } |
---|
538 | } |
---|
539 | } |
---|
540 | } |
---|
541 | else |
---|
542 | { |
---|
543 | for(Int iY=0; iY < iHeight; iY++) |
---|
544 | { |
---|
545 | for(Int iX=0; iX < iWidth; iX++) |
---|
546 | { |
---|
547 | pBuffH[uiCnt] = iY*iWidth + iX; |
---|
548 | uiCnt ++; |
---|
549 | } |
---|
550 | } |
---|
551 | |
---|
552 | uiCnt = 0; |
---|
553 | for(Int iX=0; iX < iWidth; iX++) |
---|
554 | { |
---|
555 | for(Int iY=0; iY < iHeight; iY++) |
---|
556 | { |
---|
557 | pBuffV[uiCnt] = iY*iWidth + iX; |
---|
558 | uiCnt ++; |
---|
559 | } |
---|
560 | } |
---|
561 | } |
---|
562 | } |
---|
563 | |
---|
564 | Int g_quantTSDefault4x4[16] = |
---|
565 | { |
---|
566 | 16,16,16,16, |
---|
567 | 16,16,16,16, |
---|
568 | 16,16,16,16, |
---|
569 | 16,16,16,16 |
---|
570 | }; |
---|
571 | |
---|
572 | Int g_quantIntraDefault8x8[64] = |
---|
573 | { |
---|
574 | 16,16,16,16,17,18,21,24, |
---|
575 | 16,16,16,16,17,19,22,25, |
---|
576 | 16,16,17,18,20,22,25,29, |
---|
577 | 16,16,18,21,24,27,31,36, |
---|
578 | 17,17,20,24,30,35,41,47, |
---|
579 | 18,19,22,27,35,44,54,65, |
---|
580 | 21,22,25,31,41,54,70,88, |
---|
581 | 24,25,29,36,47,65,88,115 |
---|
582 | }; |
---|
583 | |
---|
584 | Int g_quantInterDefault8x8[64] = |
---|
585 | { |
---|
586 | 16,16,16,16,17,18,20,24, |
---|
587 | 16,16,16,17,18,20,24,25, |
---|
588 | 16,16,17,18,20,24,25,28, |
---|
589 | 16,17,18,20,24,25,28,33, |
---|
590 | 17,18,20,24,25,28,33,41, |
---|
591 | 18,20,24,25,28,33,41,54, |
---|
592 | 20,24,25,28,33,41,54,71, |
---|
593 | 24,25,28,33,41,54,71,91 |
---|
594 | }; |
---|
595 | UInt g_scalingListSize [4] = {16,64,256,1024}; |
---|
596 | UInt g_scalingListSizeX [4] = { 4, 8, 16, 32}; |
---|
597 | UInt g_scalingListNum[SCALING_LIST_SIZE_NUM]={6,6,6,2}; |
---|
598 | Int g_eTTable[4] = {0,3,1,2}; |
---|
599 | |
---|
600 | #if H_MV_ENC_DEC_TRAC |
---|
601 | #if ENC_DEC_TRACE |
---|
602 | Void stopAtPos( Int poc, Int layerId, Int cuPelX, Int cuPelY, Int cuWidth, Int cuHeight ) |
---|
603 | { |
---|
604 | |
---|
605 | if ( g_outputPos ) |
---|
606 | { |
---|
607 | std::cout << "POC\t" << poc |
---|
608 | << "\tLayerId\t" << layerId |
---|
609 | << "\tCuPelX\t" << cuPelX |
---|
610 | << "\tCuPelY\t" << cuPelY |
---|
611 | << "\tCuWidth\t" << cuWidth |
---|
612 | << "\tCuHeight\t" << cuHeight |
---|
613 | << std::endl; |
---|
614 | } |
---|
615 | |
---|
616 | Bool stopFlag = false; |
---|
617 | if ( g_stopAtPos && poc == 0 && layerId == 1 ) |
---|
618 | { |
---|
619 | Bool stopAtCU = true; |
---|
620 | if ( stopAtCU ) // Stop at CU with specific size |
---|
621 | { |
---|
622 | stopFlag = ( cuPelX == 888 ) && ( cuPelY == 248 ) && ( cuWidth == 8 ) && ( cuHeight == 8); |
---|
623 | } |
---|
624 | else |
---|
625 | { // Stop at specific position |
---|
626 | Int xPos = 888; |
---|
627 | Int yPos = 248; |
---|
628 | |
---|
629 | Int cuPelXEnd = cuPelX + cuWidth - 1; |
---|
630 | Int cuPelYEnd = cuPelY + cuHeight - 1; |
---|
631 | |
---|
632 | stopFlag = (cuPelX <= xPos ) && (cuPelXEnd >= xPos ) && (cuPelY <= yPos ) && (cuPelYEnd >= yPos ); |
---|
633 | } |
---|
634 | } |
---|
635 | |
---|
636 | if ( stopFlag ) |
---|
637 | { // Set breakpoint here. |
---|
638 | std::cout << "Stop position. Break point here." << std::endl; |
---|
639 | } |
---|
640 | } |
---|
641 | |
---|
642 | Void writeToTraceFile( const Char* symbolName, Int val, Bool doIt ) |
---|
643 | { |
---|
644 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
645 | { |
---|
646 | if ( g_stopAtCounter == g_nSymbolCounter ) |
---|
647 | { |
---|
648 | std::cout << "Break point here." << std::endl; |
---|
649 | } |
---|
650 | fprintf( g_hTrace, "%8lld ", g_nSymbolCounter++ ); |
---|
651 | fprintf( g_hTrace, "%-50s : %d\n", symbolName, val ); |
---|
652 | fflush ( g_hTrace ); |
---|
653 | g_nSymbolCounter++; |
---|
654 | } |
---|
655 | } |
---|
656 | |
---|
657 | Void writeToTraceFile( const Char* symbolName, Bool doIt ) |
---|
658 | { |
---|
659 | if ( ( ( g_nSymbolCounter >= COUNTER_START && g_nSymbolCounter <= COUNTER_END )|| g_bJustDoIt ) && doIt ) |
---|
660 | { |
---|
661 | fprintf( g_hTrace, "%s", symbolName ); |
---|
662 | fflush ( g_hTrace ); |
---|
663 | g_nSymbolCounter++; |
---|
664 | } |
---|
665 | } |
---|
666 | |
---|
667 | #endif |
---|
668 | #endif |
---|
669 | #if H_3D_DIM_DMM |
---|
670 | std::vector< std::vector<TComWedgelet> > g_dmmWedgeLists; |
---|
671 | std::vector< std::vector<TComWedgeRef> > g_dmmWedgeRefLists; |
---|
672 | std::vector< std::vector<TComWedgeNode> > g_dmmWedgeNodeLists; |
---|
673 | |
---|
674 | Void initWedgeLists( Bool initNodeList ) |
---|
675 | { |
---|
676 | if( !g_dmmWedgeLists.empty() ) return; |
---|
677 | |
---|
678 | #if SHARP_DMM1_I0110 |
---|
679 | for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]); ui++ ) |
---|
680 | #else |
---|
681 | for( UInt ui = g_aucConvertToBit[DIM_MIN_SIZE]; ui < (g_aucConvertToBit[DIM_MAX_SIZE]+1); ui++ ) |
---|
682 | #endif |
---|
683 | { |
---|
684 | UInt uiWedgeBlockSize = ((UInt)DIM_MIN_SIZE)<<ui; |
---|
685 | std::vector<TComWedgelet> acWedgeList; |
---|
686 | std::vector<TComWedgeRef> acWedgeRefList; |
---|
687 | createWedgeList( uiWedgeBlockSize, uiWedgeBlockSize, acWedgeList, acWedgeRefList, g_dmmWedgeResolution[ui] ); |
---|
688 | g_dmmWedgeLists.push_back( acWedgeList ); |
---|
689 | g_dmmWedgeRefLists.push_back( acWedgeRefList ); |
---|
690 | |
---|
691 | if( initNodeList ) |
---|
692 | { |
---|
693 | // create WedgeNodeList |
---|
694 | std::vector<TComWedgeNode> acWedgeNodeList; |
---|
695 | for( UInt uiPos = 0; uiPos < acWedgeList.size(); uiPos++ ) |
---|
696 | { |
---|
697 | if( acWedgeList[uiPos].getIsCoarse() ) |
---|
698 | { |
---|
699 | TComWedgeNode cWedgeNode; |
---|
700 | cWedgeNode.setPatternIdx( uiPos ); |
---|
701 | |
---|
702 | UInt uiRefPos = 0; |
---|
703 | for( Int iOffS = -1; iOffS <= 1; iOffS++ ) |
---|
704 | { |
---|
705 | for( Int iOffE = -1; iOffE <= 1; iOffE++ ) |
---|
706 | { |
---|
707 | if( iOffS == 0 && iOffE == 0 ) { continue; } |
---|
708 | |
---|
709 | Int iSx = (Int)acWedgeList[uiPos].getStartX(); |
---|
710 | Int iSy = (Int)acWedgeList[uiPos].getStartY(); |
---|
711 | Int iEx = (Int)acWedgeList[uiPos].getEndX(); |
---|
712 | Int iEy = (Int)acWedgeList[uiPos].getEndY(); |
---|
713 | |
---|
714 | switch( acWedgeList[uiPos].getOri() ) |
---|
715 | { |
---|
716 | case( 0 ): { iSx += iOffS; iEy += iOffE; } break; |
---|
717 | case( 1 ): { iSy += iOffS; iEx -= iOffE; } break; |
---|
718 | case( 2 ): { iSx -= iOffS; iEy -= iOffE; } break; |
---|
719 | case( 3 ): { iSy -= iOffS; iEx += iOffE; } break; |
---|
720 | case( 4 ): { iSx += iOffS; iEx += iOffE; } break; |
---|
721 | case( 5 ): { iSy += iOffS; iEy += iOffE; } break; |
---|
722 | default: assert( 0 ); |
---|
723 | } |
---|
724 | |
---|
725 | for( UInt k = 0; k < acWedgeRefList.size(); k++ ) |
---|
726 | { |
---|
727 | if( iSx == (Int)acWedgeRefList[k].getStartX() && |
---|
728 | iSy == (Int)acWedgeRefList[k].getStartY() && |
---|
729 | iEx == (Int)acWedgeRefList[k].getEndX() && |
---|
730 | iEy == (Int)acWedgeRefList[k].getEndY() ) |
---|
731 | { |
---|
732 | if( acWedgeRefList[k].getRefIdx() != cWedgeNode.getPatternIdx() ) |
---|
733 | { |
---|
734 | Bool bNew = true; |
---|
735 | for( UInt m = 0; m < uiRefPos; m++ ) { if( acWedgeRefList[k].getRefIdx() == cWedgeNode.getRefineIdx( m ) ) { bNew = false; break; } } |
---|
736 | |
---|
737 | if( bNew ) |
---|
738 | { |
---|
739 | cWedgeNode.setRefineIdx( acWedgeRefList[k].getRefIdx(), uiRefPos ); |
---|
740 | uiRefPos++; |
---|
741 | break; |
---|
742 | } |
---|
743 | } |
---|
744 | } |
---|
745 | } |
---|
746 | } |
---|
747 | } |
---|
748 | acWedgeNodeList.push_back( cWedgeNode ); |
---|
749 | } |
---|
750 | } |
---|
751 | g_dmmWedgeNodeLists.push_back( acWedgeNodeList ); |
---|
752 | } |
---|
753 | } |
---|
754 | } |
---|
755 | |
---|
756 | Void createWedgeList( UInt uiWidth, UInt uiHeight, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList, WedgeResolution eWedgeRes ) |
---|
757 | { |
---|
758 | assert( uiWidth == uiHeight ); |
---|
759 | |
---|
760 | UChar uhStartX = 0, uhStartY = 0, uhEndX = 0, uhEndY = 0; |
---|
761 | Int iStepStartX = 0, iStepStartY = 0, iStepEndX = 0, iStepEndY = 0; |
---|
762 | |
---|
763 | UInt uiBlockSize = 0; |
---|
764 | switch( eWedgeRes ) |
---|
765 | { |
---|
766 | #if !SHARP_DMM1_I0110 |
---|
767 | case( DOUBLE_PEL ): { uiBlockSize = (uiWidth>>1); break; } |
---|
768 | #endif |
---|
769 | case( FULL_PEL ): { uiBlockSize = uiWidth; break; } |
---|
770 | case( HALF_PEL ): { uiBlockSize = (uiWidth<<1); break; } |
---|
771 | } |
---|
772 | |
---|
773 | TComWedgelet cTempWedgelet( uiWidth, uiHeight ); |
---|
774 | for( UInt uiOri = 0; uiOri < 6; uiOri++ ) |
---|
775 | { |
---|
776 | // init the edge line parameters for each of the 6 wedgelet types |
---|
777 | switch( uiOri ) |
---|
778 | { |
---|
779 | case( 0 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = +1; iStepStartY = 0; iStepEndX = 0; iStepEndY = +1; break; } |
---|
780 | case( 1 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = (uiBlockSize-1); uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = -1; iStepEndY = 0; break; } |
---|
781 | case( 2 ): { uhStartX = (uiBlockSize-1); uhStartY = (uiBlockSize-1); uhEndX = (uiBlockSize-1); uhEndY = (uiBlockSize-1); iStepStartX = -1; iStepStartY = 0; iStepEndX = 0; iStepEndY = -1; break; } |
---|
782 | case( 3 ): { uhStartX = 0; uhStartY = (uiBlockSize-1); uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = 0; iStepStartY = -1; iStepEndX = +1; iStepEndY = 0; break; } |
---|
783 | case( 4 ): { uhStartX = 0; uhStartY = 0; uhEndX = 0; uhEndY = (uiBlockSize-1); iStepStartX = +1; iStepStartY = 0; iStepEndX = +1; iStepEndY = 0; break; } |
---|
784 | case( 5 ): { uhStartX = (uiBlockSize-1); uhStartY = 0; uhEndX = 0; uhEndY = 0; iStepStartX = 0; iStepStartY = +1; iStepEndX = 0; iStepEndY = +1; break; } |
---|
785 | } |
---|
786 | |
---|
787 | for( Int iK = 0; iK < uiBlockSize; iK++ ) |
---|
788 | { |
---|
789 | for( Int iL = 0; iL < uiBlockSize; iL++ ) |
---|
790 | { |
---|
791 | cTempWedgelet.setWedgelet( uhStartX + (iK*iStepStartX) , uhStartY + (iK*iStepStartY), uhEndX + (iL*iStepEndX), uhEndY + (iL*iStepEndY), (UChar)uiOri, eWedgeRes, ((iL%2)==0 && (iK%2)==0) ); |
---|
792 | addWedgeletToList( cTempWedgelet, racWedgeList, racWedgeRefList ); |
---|
793 | } |
---|
794 | } |
---|
795 | } |
---|
796 | |
---|
797 | |
---|
798 | } |
---|
799 | |
---|
800 | Void addWedgeletToList( TComWedgelet cWedgelet, std::vector<TComWedgelet> &racWedgeList, std::vector<TComWedgeRef> &racWedgeRefList ) |
---|
801 | { |
---|
802 | Bool bValid = cWedgelet.checkNotPlain(); |
---|
803 | if( bValid ) |
---|
804 | { |
---|
805 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
806 | { |
---|
807 | if( cWedgelet.checkIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
808 | { |
---|
809 | TComWedgeRef cWedgeRef; |
---|
810 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
811 | racWedgeRefList.push_back( cWedgeRef ); |
---|
812 | bValid = false; |
---|
813 | return; |
---|
814 | } |
---|
815 | } |
---|
816 | } |
---|
817 | if( bValid ) |
---|
818 | { |
---|
819 | for( UInt uiPos = 0; uiPos < racWedgeList.size(); uiPos++ ) |
---|
820 | { |
---|
821 | if( cWedgelet.checkInvIdentical( racWedgeList[uiPos].getPattern() ) ) |
---|
822 | { |
---|
823 | TComWedgeRef cWedgeRef; |
---|
824 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), uiPos ); |
---|
825 | racWedgeRefList.push_back( cWedgeRef ); |
---|
826 | bValid = false; |
---|
827 | return; |
---|
828 | } |
---|
829 | } |
---|
830 | } |
---|
831 | if( bValid ) |
---|
832 | { |
---|
833 | cWedgelet.findClosestAngle(); |
---|
834 | racWedgeList.push_back( cWedgelet ); |
---|
835 | TComWedgeRef cWedgeRef; |
---|
836 | cWedgeRef.setWedgeRef( cWedgelet.getStartX(), cWedgelet.getStartY(), cWedgelet.getEndX(), cWedgelet.getEndY(), (UInt)(racWedgeList.size()-1) ); |
---|
837 | racWedgeRefList.push_back( cWedgeRef ); |
---|
838 | } |
---|
839 | } |
---|
840 | #endif //H_3D_DIM_DMM |
---|
841 | |
---|
842 | //! \} |
---|