History

Pretty printed the C++ code with astyle

Ethan Hugg committed 12 years ago

Commit ff6b6691 parent 063709c225 files · +48457 −51954Browse files

Showing the changes to codec/decoder/core/src/deblocking.cpp (1 of 225 files). Show all

Unified · Split

codec/decoder/core/src/deblocking.cpp+795−881
@@ -34,7 +34,7 @@ · 33 unmodified lines
34 * \brief Interfaces introduced in frame deblocking filtering34 * \brief Interfaces introduced in frame deblocking filtering
35 *35 *
36 * \date 08/02/201036 * \date 08/02/2010
37 * 37 *
38 *************************************************************************************38 *************************************************************************************
39 */39 */
40 40
@@ -86,51 +86,54 @@ namespace WelsDec { · 45 unmodified lines
86 iBeta = g_kiBetaTable((iQp + iBetaOffset));\86 iBeta = g_kiBetaTable((iQp + iBetaOffset));\
87}87}
88 88
89static const uint8_t g_kuiAlphaTable[52+24] = { //this table refers to Table 8-16 in H.264/AVC standard89static const uint8_t g_kuiAlphaTable[52 + 24] = { //this table refers to Table 8-16 in H.264/AVC standard
90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,90 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,91 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
92 0, 0, 0, 0, 0, 0, 4, 4, 5, 6,92 0, 0, 0, 0, 0, 0, 4, 4, 5, 6,
93 7, 8, 9, 10, 12, 13, 15, 17, 20, 22,93 7, 8, 9, 10, 12, 13, 15, 17, 20, 22,
94 25, 28, 32, 36, 40, 45, 50, 56, 63, 71,94 25, 28, 32, 36, 40, 45, 50, 56, 63, 71,
95 80, 90,101,113,127,144,162,182,203,226,95 80, 90, 101, 113, 127, 144, 162, 182, 203, 226,
96 255, 25596 255, 255
97 ,255, 255,255, 255,255, 255,255, 255,255, 255,255, 25597 , 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255
98};98};
99 99
100static const int8_t g_kiBetaTable[52+24] = { //this table refers to Table 8-16 in H.264/AVC standard100static const int8_t g_kiBetaTable[52 + 24] = { //this table refers to Table 8-16 in H.264/AVC standard
101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,101 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,102 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
103 0, 0, 0, 0, 0, 0, 2, 2, 2, 3,103 0, 0, 0, 0, 0, 0, 2, 2, 2, 3,
104 3, 3, 3, 4, 4, 4, 6, 6, 7, 7,104 3, 3, 3, 4, 4, 4, 6, 6, 7, 7,
105 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,105 8, 8, 9, 9, 10, 10, 11, 11, 12, 12,
106 13, 13, 14, 14, 15, 15, 16, 16, 17, 17,106 13, 13, 14, 14, 15, 15, 16, 16, 17, 17,
107 18, 18107 18, 18
108 ,18, 18,18, 18,18, 18,18, 18,18, 18,18, 18108 , 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18
109};109};
110 110
111static const int8_t g_kiTc0Table[52+24][4] = { //this table refers Table 8-17 in H.264/AVC standard111static const int8_t g_kiTc0Table[52 + 24][4] = { //this table refers Table 8-17 in H.264/AVC standard
112 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },112 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },
113 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },113 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },
114 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },114 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },
115 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },115 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 },
116 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 1 },116 { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 1 },
117 { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 1, 1 }, { -1, 0, 1, 1 }, { -1, 1, 1, 1 },117 { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 1, 1 }, { -1, 0, 1, 1 }, { -1, 1, 1, 1 },
118 { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 },118 { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 },
119 { -1, 1, 1, 2 }, { -1, 1, 2, 3 }, { -1, 1, 2, 3 }, { -1, 2, 2, 3 }, { -1, 2, 2, 4 }, { -1, 2, 3, 4 },119 { -1, 1, 1, 2 }, { -1, 1, 2, 3 }, { -1, 1, 2, 3 }, { -1, 2, 2, 3 }, { -1, 2, 2, 4 }, { -1, 2, 3, 4 },
120 { -1, 2, 3, 4 }, { -1, 3, 3, 5 }, { -1, 3, 4, 6 }, { -1, 3, 4, 6 }, { -1, 4, 5, 7 }, { -1, 4, 5, 8 },120 { -1, 2, 3, 4 }, { -1, 3, 3, 5 }, { -1, 3, 4, 6 }, { -1, 3, 4, 6 }, { -1, 4, 5, 7 }, { -1, 4, 5, 8 },
121 { -1, 4, 6, 9 }, { -1, 5, 7,10 }, { -1, 6, 8,11 }, { -1, 6, 8,13 }, { -1, 7,10,14 }, { -1, 8,11,16 },121 { -1, 4, 6, 9 }, { -1, 5, 7, 10 }, { -1, 6, 8, 11 }, { -1, 6, 8, 13 }, { -1, 7, 10, 14 }, { -1, 8, 11, 16 },
122 { -1, 9,12,18 }, { -1, 10,13,20 }, {-1,11,15,23 }, { -1,13,17,25 }122 { -1, 9, 12, 18 }, { -1, 10, 13, 20 }, { -1, 11, 15, 23 }, { -1, 13, 17, 25 }
123 ,{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 }123 , { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }
124 ,{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 }124 , { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }
125};125};
126 126
127static const uint8_t g_kuiTableBIdx[2][8] = 127static const uint8_t g_kuiTableBIdx[2][8] = {
128{ 128 {
129 {0, 4, 8, 12, 129 0, 4, 8, 12,
130 3, 7, 11, 15}, 130 3, 7, 11, 15
131 },
131 132
132 {0, 1, 2, 3 , 133 {
133 12, 13, 14, 15}, 134 0, 1, 2, 3 ,
135 12, 13, 14, 15
136 },
134};137};
135 138
136#define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \139#define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \
@@ -141,761 +144,681 @@ static const uint8_t g_kuiTableBIdx[2][8] = · 4 unmodified lines
141 tc[3] = g_kiTc0Table(iIndexA)[pBS[3]] + bChroma;\144 tc[3] = g_kiTc0Table(iIndexA)[pBS[3]] + bChroma;\
142}145}
143 146
144void_t inline DeblockingBSInsideMBAvsbase( int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor )147void_t inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) {
145{148 uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
146 uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;149 FORCE_STACK_ALIGN_1D (uint8_t, uiBsx3, 4, 4);
147 FORCE_STACK_ALIGN_1D( uint8_t, uiBsx3, 4, 4 );150
148 151 uiNnz32b0 = * (uint32_t*) (pNnzTab + 0);
149 uiNnz32b0 = *(uint32_t *)(pNnzTab+0);152 uiNnz32b1 = * (uint32_t*) (pNnzTab + 4);
150 uiNnz32b1 = *(uint32_t *)(pNnzTab+4);153 uiNnz32b2 = * (uint32_t*) (pNnzTab + 8);
151 uiNnz32b2 = *(uint32_t *)(pNnzTab+8);154 uiNnz32b3 = * (uint32_t*) (pNnzTab + 12);
152 uiNnz32b3 = *(uint32_t *)(pNnzTab+12);155
153 156 * (uint32_t*)uiBsx3 = (uiNnz32b0 | (uiNnz32b0 >> 8)) << iLShiftFactor;
154 *(uint32_t *)uiBsx3 = (uiNnz32b0|(uiNnz32b0>>8))<<iLShiftFactor;157 nBS[0][1][0] = uiBsx3[0];
155 nBS[0][1][0] = uiBsx3[0];158 nBS[0][2][0] = uiBsx3[1];
156 nBS[0][2][0] = uiBsx3[1];159 nBS[0][3][0] = uiBsx3[2];
157 nBS[0][3][0] = uiBsx3[2];160
158 161 * (uint32_t*)uiBsx3 = (uiNnz32b1 | (uiNnz32b1 >> 8)) << iLShiftFactor;
159 *(uint32_t *)uiBsx3 = (uiNnz32b1|(uiNnz32b1>>8))<<iLShiftFactor;162 nBS[0][1][1] = uiBsx3[0];
160 nBS[0][1][1] = uiBsx3[0];163 nBS[0][2][1] = uiBsx3[1];
161 nBS[0][2][1] = uiBsx3[1];164 nBS[0][3][1] = uiBsx3[2];
162 nBS[0][3][1] = uiBsx3[2];165 * (uint32_t*)nBS[1][1] = (uiNnz32b0 | uiNnz32b1) << iLShiftFactor;
163 *(uint32_t *)nBS[1][1] = (uiNnz32b0|uiNnz32b1)<<iLShiftFactor;166
164 167 * (uint32_t*)uiBsx3 = (uiNnz32b2 | (uiNnz32b2 >> 8)) << iLShiftFactor;
165 *(uint32_t *)uiBsx3 = (uiNnz32b2|(uiNnz32b2>>8))<<iLShiftFactor;168 nBS[0][1][2] = uiBsx3[0];
166 nBS[0][1][2] = uiBsx3[0];169 nBS[0][2][2] = uiBsx3[1];
167 nBS[0][2][2] = uiBsx3[1];170 nBS[0][3][2] = uiBsx3[2];
168 nBS[0][3][2] = uiBsx3[2];171 * (uint32_t*)nBS[1][2] = (uiNnz32b1 | uiNnz32b2) << iLShiftFactor;
169 *(uint32_t *)nBS[1][2] = (uiNnz32b1|uiNnz32b2)<<iLShiftFactor;172
170 173 * (uint32_t*)uiBsx3 = (uiNnz32b3 | (uiNnz32b3 >> 8)) << iLShiftFactor;
171 *(uint32_t *)uiBsx3 = (uiNnz32b3|(uiNnz32b3>>8))<<iLShiftFactor;174 nBS[0][1][3] = uiBsx3[0];
172 nBS[0][1][3] = uiBsx3[0];175 nBS[0][2][3] = uiBsx3[1];
173 nBS[0][2][3] = uiBsx3[1];176 nBS[0][3][3] = uiBsx3[2];
174 nBS[0][3][3] = uiBsx3[2]; 177 * (uint32_t*)nBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor;
175 *(uint32_t *)nBS[1][3] = (uiNnz32b2|uiNnz32b3)<<iLShiftFactor;178
176 179}
177}180
178 181void_t static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab,
179void_t static inline DeblockingBSInsideMBNormal( PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, int32_t iMbXy )182 int32_t iMbXy) {
180{183 uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;
181 uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3;184 int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy];
182 int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy];185 FORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4);
183 FORCE_STACK_ALIGN_1D( uint8_t, uiBsx4, 4, 4 );186
184 187 uiNnz32b0 = * (uint32_t*) (pNnzTab + 0);
185 uiNnz32b0 = *(uint32_t *)(pNnzTab+0);188 uiNnz32b1 = * (uint32_t*) (pNnzTab + 4);
186 uiNnz32b1 = *(uint32_t *)(pNnzTab+4);189 uiNnz32b2 = * (uint32_t*) (pNnzTab + 8);
187 uiNnz32b2 = *(uint32_t *)(pNnzTab+8);190 uiNnz32b3 = * (uint32_t*) (pNnzTab + 12);
188 uiNnz32b3 = *(uint32_t *)(pNnzTab+12);191
189 192 * (uint32_t*)uiBsx4 = (uiNnz32b0 | (uiNnz32b0 >> 8));
190 *(uint32_t *)uiBsx4 = (uiNnz32b0|(uiNnz32b0>>8));193 nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0);
191 nBS[0][1][0] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0);194 nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1);
192 nBS[0][2][0] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1);195 nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2);
193 nBS[0][3][0] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2);196
194 197 * (uint32_t*)uiBsx4 = (uiNnz32b1 | (uiNnz32b1 >> 8));
195 *(uint32_t *)uiBsx4 = (uiNnz32b1|(uiNnz32b1>>8));198 nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4);
196 nBS[0][1][1] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4);199 nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5);
197 nBS[0][2][1] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5);200 nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6);
198 nBS[0][3][1] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6);201
199 202 * (uint32_t*)uiBsx4 = (uiNnz32b2 | (uiNnz32b2 >> 8));
200 *(uint32_t *)uiBsx4 = (uiNnz32b2|(uiNnz32b2>>8));203 nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8);
201 nBS[0][1][2] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8);204 nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9);
202 nBS[0][2][2] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10,9);205 nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10);
203 nBS[0][3][2] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11,10);206
204 207 * (uint32_t*)uiBsx4 = (uiNnz32b3 | (uiNnz32b3 >> 8));
205 *(uint32_t *)uiBsx4 = (uiNnz32b3|(uiNnz32b3>>8));208 nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12);
206 nBS[0][1][3] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13,12);209 nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13);
207 nBS[0][2][3] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14,13);210 nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14);
208 nBS[0][3][3] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15,14);211
209 212 // horizontal
210 // horizontal213 * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1);
211 *(uint32_t *)uiBsx4 = (uiNnz32b0|uiNnz32b1);214 nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0);
212 nBS[1][1][0] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0);215 nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1);
213 nBS[1][1][1] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1);216 nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2);
214 nBS[1][1][2] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2);217 nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3);
215 nBS[1][1][3] = BS_EDGE(uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3);218
216 219 * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2);
217 *(uint32_t *)uiBsx4 = (uiNnz32b1|uiNnz32b2);220 nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4);
218 nBS[1][2][0] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4);221 nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5);
219 nBS[1][2][1] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5);222 nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6);
220 nBS[1][2][2] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6);223 nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7);
221 nBS[1][2][3] = BS_EDGE(uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7);224
222 225 * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3);
223 *(uint32_t *)uiBsx4 = (uiNnz32b2|uiNnz32b3);226 nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8);
224 nBS[1][3][0] = BS_EDGE(uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8);227 nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9);
225 nBS[1][3][1] = BS_EDGE(uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9);228 nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10);
226 nBS[1][3][2] = BS_EDGE(uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10);229 nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11);
227 nBS[1][3][3] = BS_EDGE(uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11);230}
228}231
229 232uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) {
230uint32_t DeblockingBsMarginalMBAvcbase( PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy)233 int32_t i;
231{234 uint32_t uiBSx4;
232 int32_t i;235 //uint8_t* bS = static_cast<uint8_t*>(&uiBSx4);
233 uint32_t uiBSx4; 236 uint8_t* pBS = (uint8_t*) (&uiBSx4);
234 //uint8_t* bS = static_cast<uint8_t*>(&uiBSx4);237 uint32_t uiBIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][0]);
235 uint8_t* pBS = (uint8_t*)(&uiBSx4);238 uint32_t uiBnIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][4]);
236 uint32_t uiBIdx = *(uint32_t *)(&g_kuiTableBIdx[iEdge][0]); 239
237 uint32_t uiBnIdx = *(uint32_t *)(&g_kuiTableBIdx[iEdge][4]);240 for (i = 0; i < 4; i++) {
238 241 if (pCurDqLayer->pNzc[iMbXy][uiBIdx & 0xff] | pCurDqLayer->pNzc[iNeighMb][uiBnIdx & 0xff]) {
239 for( i = 0; i < 4; i++ )242 pBS[i] = 2;
240 {243 } else {
241 if( pCurDqLayer->pNzc[iMbXy][uiBIdx&0xff] | pCurDqLayer->pNzc[iNeighMb][uiBnIdx&0xff] )244 pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, (uiBIdx & 0xff),
242 {245 (uiBnIdx & 0xff));
243 pBS[i] = 2;246 }
244 } 247 uiBIdx = uiBIdx >> 8;
245 else 248 uiBnIdx = uiBnIdx >> 8;
246 {249 }
247 pBS[i] = MB_BS_MV(pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, (uiBIdx&0xff), (uiBnIdx&0xff));250 return uiBSx4;
248 }251}
249 uiBIdx = uiBIdx >> 8;252int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) {
250 uiBnIdx = uiBnIdx >> 8;253 int32_t iMbY = pCurDqLayer->iMbY;
251 }254 int32_t iMbX = pCurDqLayer->iMbX;
252 return uiBSx4;255 int32_t iMbXy = pCurDqLayer->iMbXyIndex;
253}256 BOOL_T bLeftFlag = FALSE;
254int32_t DeblockingAvailableNoInterlayer( PDqLayer pCurDqLayer, int32_t iFilterIdc )257 BOOL_T bTopFlag = FALSE;
255{258
256 int32_t iMbY = pCurDqLayer->iMbY;259 if (2 == iFilterIdc) {
257 int32_t iMbX = pCurDqLayer->iMbX;260 bLeftFlag = (iMbX > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - 1]);
258 int32_t iMbXy = pCurDqLayer->iMbXyIndex;261 bTopFlag = (iMbY > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - pCurDqLayer->iMbWidth]);
259 BOOL_T bLeftFlag = FALSE;262 } else { //if ( 0 == iFilterIdc )
260 BOOL_T bTopFlag = FALSE;263 bLeftFlag = (iMbX > 0);
261 264 bTopFlag = (iMbY > 0);
262 if ( 2 == iFilterIdc )265 }
263 {266 return (bLeftFlag << LEFT_FLAG_BIT) | (bTopFlag << TOP_FLAG_BIT);
264 bLeftFlag = ( iMbX > 0 ) && ( pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy-1] );267}
265 bTopFlag = ( iMbY > 0 ) && ( pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy-pCurDqLayer->iMbWidth] );268
266 }269void_t FilteringEdgeLumaH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
267 else //if ( 0 == iFilterIdc )270 int32_t iIndexA;
268 {271 int32_t iAlpha;
269 bLeftFlag = ( iMbX > 0 );272 int32_t iBeta;
270 bTopFlag = ( iMbY > 0 );273 FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
271 }274
272 return (bLeftFlag<<LEFT_FLAG_BIT)|(bTopFlag<<TOP_FLAG_BIT);275 GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
273}276 iBeta);
274 277
275void_t FilteringEdgeLumaH(SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )278 if (iAlpha | iBeta) {
276{279 TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0);
277 int32_t iIndexA; 280 pFilter->pLoopf->pfLumaDeblockingLT4Ver (pPix, iStride, iAlpha, iBeta, tc);
278 int32_t iAlpha; 281 }
279 int32_t iBeta; 282 return;
280 FORCE_STACK_ALIGN_1D( int8_t, tc, 4, 16 );283}
281 284
282 GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);285
283 286void_t FilteringEdgeLumaV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
284 if( iAlpha | iBeta )287 int32_t iIndexA;
285 {288 int32_t iAlpha;
286 TC0_TBL_LOOKUP(tc, iIndexA, pBS, 0);289 int32_t iBeta;
287 pFilter->pLoopf->pfLumaDeblockingLT4Ver(pPix, iStride, iAlpha, iBeta, tc);290 FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
288 }291
289 return;292 GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
290}293 iBeta);
291 294
292 295 if (iAlpha | iBeta) {
293void_t FilteringEdgeLumaV(SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )296 TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0);
294{297 pFilter->pLoopf->pfLumaDeblockingLT4Hor (pPix, iStride, iAlpha, iBeta, tc);
295 int32_t iIndexA;298 }
296 int32_t iAlpha;299 return;
297 int32_t iBeta; 300}
298 FORCE_STACK_ALIGN_1D( int8_t, tc, 4, 16 );301
299 302
300 GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);303void_t FilteringEdgeLumaIntraH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
301 304 int32_t iIndexA;
302 if( iAlpha | iBeta )305 int32_t iAlpha;
303 {306 int32_t iBeta;
304 TC0_TBL_LOOKUP(tc, iIndexA, pBS, 0);307
305 pFilter->pLoopf->pfLumaDeblockingLT4Hor(pPix, iStride, iAlpha, iBeta, tc);308 GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
306 }309 iBeta);
307 return;310
308}311 if (iAlpha | iBeta) {
309 312 pFilter->pLoopf->pfLumaDeblockingEQ4Ver (pPix, iStride, iAlpha, iBeta);
310 313 }
311void_t FilteringEdgeLumaIntraH( SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )314 return;
312{315}
313 int32_t iIndexA; 316
314 int32_t iAlpha; 317void_t FilteringEdgeLumaIntraV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) {
315 int32_t iBeta; 318 int32_t iIndexA;
316 319 int32_t iAlpha;
317 GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);320 int32_t iBeta;
318 321
319 if( iAlpha | iBeta )322 GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
320 {323 iBeta);
321 pFilter->pLoopf->pfLumaDeblockingEQ4Ver(pPix, iStride, iAlpha, iBeta);324
322 }325 if (iAlpha | iBeta) {
323 return;326 pFilter->pLoopf->pfLumaDeblockingEQ4Hor (pPix, iStride, iAlpha, iBeta);
324}327 }
325 328 return;
326void_t FilteringEdgeLumaIntraV( SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS )329}
327{330void_t FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
328 int32_t iIndexA; 331 uint8_t* pBS) {
329 int32_t iAlpha; 332 int32_t iIndexA;
330 int32_t iBeta; 333 int32_t iAlpha;
331 334 int32_t iBeta;
332 GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);335 FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
333 336
334 if( iAlpha | iBeta )337 GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
335 { 338 iBeta);
336 pFilter->pLoopf->pfLumaDeblockingEQ4Hor(pPix, iStride, iAlpha, iBeta);339
337 }340 if (iAlpha | iBeta) {
338 return;341 TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
339}342 pFilter->pLoopf->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
340void_t FilteringEdgeChromaH( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )343 }
341{ 344 return;
342 int32_t iIndexA; 345}
343 int32_t iAlpha; 346void_t FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
344 int32_t iBeta; 347 uint8_t* pBS) {
345 FORCE_STACK_ALIGN_1D( int8_t, tc, 4, 16 );348 int32_t iIndexA;
346 349 int32_t iAlpha;
347 GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);350 int32_t iBeta;
348 351 FORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16);
349 if( iAlpha | iBeta )352
350 {353 GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
351 TC0_TBL_LOOKUP(tc, iIndexA, pBS, 1);354 iBeta);
352 pFilter->pLoopf->pfChromaDeblockingLT4Ver(pPixCb, pPixCr, iStride,iAlpha, iBeta, tc);355
353 }356 if (iAlpha | iBeta) {
354 return;357 TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1);
355} 358 pFilter->pLoopf->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);
356void_t FilteringEdgeChromaV( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )359 }
357{ 360 return;
358 int32_t iIndexA; 361}
359 int32_t iAlpha; 362
360 int32_t iBeta; 363void_t FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
361 FORCE_STACK_ALIGN_1D( int8_t, tc, 4, 16 );364 uint8_t* pBS) {
362 365 int32_t iIndexA;
363 GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);366 int32_t iAlpha;
364 367 int32_t iBeta;
365 if( iAlpha | iBeta )368
366 {369 GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
367 TC0_TBL_LOOKUP(tc, iIndexA, pBS, 1);370 iBeta);
368 pFilter->pLoopf->pfChromaDeblockingLT4Hor(pPixCb, pPixCr, iStride, iAlpha, iBeta, tc);371
369 }372 if (iAlpha | iBeta) {
370 return;373 pFilter->pLoopf->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta);
371}374 }
372 375 return;
373void_t FilteringEdgeChromaIntraH( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )376}
374{377
375 int32_t iIndexA; 378void_t FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride,
376 int32_t iAlpha; 379 uint8_t* pBS) {
377 int32_t iBeta; 380 int32_t iIndexA;
378 381 int32_t iAlpha;
379 GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);382 int32_t iBeta;
380 383
381 if( iAlpha | iBeta )384 GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
382 {385 iBeta);
383 pFilter->pLoopf->pfChromaDeblockingEQ4Ver(pPixCb, pPixCr, iStride, iAlpha, iBeta);386
384 }387 if (iAlpha | iBeta) {
385 return;388 pFilter->pLoopf->pfChromaDeblockinEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta);
386}389 }
387 390 return;
388void_t FilteringEdgeChromaIntraV( SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS )391}
389{392
390 int32_t iIndexA; 393
391 int32_t iAlpha; 394void_t DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4],
392 int32_t iBeta; 395 int32_t iBoundryFlag) {
393 396 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
394 GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);397 int32_t iMbX = pCurDqLayer->iMbX;
395 398 int32_t iMbY = pCurDqLayer->iMbY;
396 if( iAlpha | iBeta )399
397 {400 int32_t iCurLumaQp = pCurDqLayer->pLumaQp[iMbXyIndex];
398 pFilter->pLoopf->pfChromaDeblockinEQ4Hor(pPixCb, pPixCr, iStride, iAlpha, iBeta);401 int32_t iCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex];
399 }402 int32_t iLineSize = pFilter->iCsStride[0];
400 return;403 int32_t iLineSizeUV = pFilter->iCsStride[1];
401}404
402 405 uint8_t* pDestY, * pDestCb, * pDestCr;
403 406 pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4);
404void_t DeblockingInterMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], int32_t iBoundryFlag )407 pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSizeUV + iMbX) << 3);
405{408 pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSizeUV + iMbX) << 3);
406 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;409
407 int32_t iMbX = pCurDqLayer->iMbX;410 if (iBoundryFlag & LEFT_FLAG_MASK) {
408 int32_t iMbY = pCurDqLayer->iMbY;411 int32_t iLeftXyIndex = iMbXyIndex - 1;
409 412 pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iLeftXyIndex] + 1) >> 1;
410 int32_t iCurLumaQp = pCurDqLayer->pLumaQp[iMbXyIndex];413 pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iLeftXyIndex] + 1) >> 1;
411 int32_t iCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex];414
412 int32_t iLineSize = pFilter->iCsStride[0];415 if (nBS[0][0][0] == 0x04) {
413 int32_t iLineSizeUV = pFilter->iCsStride[1];416 FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL);
414 417 FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
415 uint8_t * pDestY, * pDestCb, * pDestCr;418 } else {
416 pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4);419 if (* (uint32_t*)nBS[0][0] != 0) {
417 pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSizeUV + iMbX) << 3); 420 FilteringEdgeLumaV (pFilter, pDestY, iLineSize, nBS[0][0]);
418 pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSizeUV + iMbX) << 3);421 FilteringEdgeChromaV (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[0][0]);
419 422 }
420 if( iBoundryFlag & LEFT_FLAG_MASK)423 }
421 {424 }
422 int32_t iLeftXyIndex = iMbXyIndex - 1;425
423 pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iLeftXyIndex] + 1) >> 1;426 pFilter->iLumaQP = iCurLumaQp;
424 pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iLeftXyIndex]+ 1) >> 1;427 pFilter->iChromaQP = iCurChromaQp;
425 428
426 if( nBS[0][0][0] == 0x04 )429 if (* (uint32_t*)nBS[0][1] != 0) {
427 {430 FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]);
428 FilteringEdgeLumaIntraV( pFilter, pDestY, iLineSize, NULL );431 }
429 FilteringEdgeChromaIntraV( pFilter, pDestCb, pDestCr, iLineSizeUV, NULL );432
430 } 433 if (* (uint32_t*)nBS[0][2] != 0) {
431 else434 FilteringEdgeLumaV (pFilter, &pDestY[2 << 2], iLineSize, nBS[0][2]);
432 {435 FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]);
433 if(*(uint32_t *)nBS[0][0] != 0)436 }
434 {437
435 FilteringEdgeLumaV( pFilter, pDestY, iLineSize, nBS[0][0] );438 if (* (uint32_t*)nBS[0][3] != 0) {
436 FilteringEdgeChromaV( pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[0][0] );439 FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]);
437 }440 }
438 }441
439 }442 if (iBoundryFlag & TOP_FLAG_MASK) {
440 443 int32_t iTopXyIndex = iMbXyIndex - pCurDqLayer->iMbWidth;
441 pFilter->iLumaQP = iCurLumaQp;444 pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iTopXyIndex] + 1) >> 1;
442 pFilter->iChromaQP = iCurChromaQp;445 pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iTopXyIndex] + 1) >> 1;
443 446
444 if(*(uint32_t *)nBS[0][1] != 0)447 if (nBS[1][0][0] == 0x04) {
445 {448 FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL);
446 FilteringEdgeLumaV( pFilter, &pDestY[1<<2], iLineSize, nBS[0][1]);449 FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL);
447 }450 } else {
448 451 if (* (uint32_t*)nBS[1][0] != 0) {
449 if(*(uint32_t *)nBS[0][2] != 0)452 FilteringEdgeLumaH (pFilter, pDestY, iLineSize, nBS[1][0]);
450 {453 FilteringEdgeChromaH (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[1][0]);
451 FilteringEdgeLumaV( pFilter, &pDestY[2<<2], iLineSize, nBS[0][2]);454 }
452 FilteringEdgeChromaV( pFilter, &pDestCb[2<<1], &pDestCr[2<<1], iLineSizeUV, nBS[0][2] );455 }
453 }456 }
454 457
455 if(*(uint32_t *)nBS[0][3] != 0)458 pFilter->iLumaQP = iCurLumaQp;
456 {459 pFilter->iChromaQP = iCurChromaQp;
457 FilteringEdgeLumaV( pFilter, &pDestY[3<<2], iLineSize, nBS[0][3] );460
458 }461 if (* (uint32_t*)nBS[1][1] != 0) {
459 462 FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]);
460 if( iBoundryFlag & TOP_FLAG_MASK)463 }
461 { 464
462 int32_t iTopXyIndex = iMbXyIndex - pCurDqLayer->iMbWidth;465 if (* (uint32_t*)nBS[1][2] != 0) {
463 pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iTopXyIndex] + 1) >> 1;466 FilteringEdgeLumaH (pFilter, &pDestY[ (2 << 2)*iLineSize], iLineSize, nBS[1][2]);
464 pFilter->iChromaQP = (iCurChromaQp + pCurDqLayer->pChromaQp[iTopXyIndex] + 1) >> 1;467 FilteringEdgeChromaH (pFilter, &pDestCb[ (2 << 1)*iLineSizeUV], &pDestCr[ (2 << 1)*iLineSizeUV], iLineSizeUV,
465 468 nBS[1][2]);
466 if( nBS[1][0][0] == 0x04)469 }
467 {470
468 FilteringEdgeLumaIntraH( pFilter, pDestY, iLineSize, NULL );471 if (* (uint32_t*)nBS[1][3] != 0) {
469 FilteringEdgeChromaIntraH( pFilter, pDestCb, pDestCr, iLineSizeUV, NULL );472 FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]);
470 } 473 }
471 else 474}
472 {475
473 if(*(uint32_t *)nBS[1][0] != 0)476void_t /*__FASTCALL*/ FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
474 {477 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
475 FilteringEdgeLumaH( pFilter, pDestY, iLineSize, nBS[1][0] );478 int32_t iMbX = pCurDqLayer->iMbX;
476 FilteringEdgeChromaH( pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[1][0] );479 int32_t iMbY = pCurDqLayer->iMbY;
477 }480 int32_t iMbWidth = pCurDqLayer->iMbWidth;
478 } 481 int32_t iLineSize = pFilter->iCsStride[0];
479 }482
480 483 uint8_t* pDestY;
481 pFilter->iLumaQP = iCurLumaQp;484 int32_t iCurQp;
482 pFilter->iChromaQP = iCurChromaQp;485 int32_t iIndexA, iAlpha, iBeta;
483 486
484 if(*(uint32_t *)nBS[1][1] != 0)487 FORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
485 {488 FORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4);
486 FilteringEdgeLumaH( pFilter, &pDestY[(1<<2)*iLineSize], iLineSize, nBS[1][1] );489
487 }490 pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4);
488 491 iCurQp = pCurDqLayer->pLumaQp[iMbXyIndex];
489 if(*(uint32_t *)nBS[1][2] != 0)492
490 {493 * (uint32_t*)uiBSx4 = 0x03030303;
491 FilteringEdgeLumaH( pFilter, &pDestY[(2<<2)*iLineSize], iLineSize, nBS[1][2] );494
492 FilteringEdgeChromaH( pFilter, &pDestCb[(2<<1)*iLineSizeUV], &pDestCr[(2<<1)*iLineSizeUV], iLineSizeUV, nBS[1][2] );495 // luma v
493 }496 if (iBoundryFlag & LEFT_FLAG_MASK) {
494 497 pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - 1] + 1) >> 1;
495 if(*(uint32_t *)nBS[1][3] != 0)498 FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL);
496 {499 }
497 FilteringEdgeLumaH( pFilter, &pDestY[(3<<2)*iLineSize], iLineSize, nBS[1][3] );500
498 }501 pFilter->iLumaQP = iCurQp;
499}502 GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
500 503 iBeta);
501void_t /*__FASTCALL*/ FilteringEdgeLumaHV( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )504 if (iAlpha | iBeta) {
502{505 TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 0);
503 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;506 pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc);
504 int32_t iMbX = pCurDqLayer->iMbX;507 pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc);
505 int32_t iMbY = pCurDqLayer->iMbY;508 pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc);
506 int32_t iMbWidth = pCurDqLayer->iMbWidth;509 }
507 int32_t iLineSize = pFilter->iCsStride[0];510
508 511 // luma h
509 uint8_t *pDestY; 512 if (iBoundryFlag & TOP_FLAG_MASK) {
510 int32_t iCurQp;513 pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - iMbWidth] + 1) >> 1;
511 int32_t iIndexA, iAlpha, iBeta;514 FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL);
512 515 }
513 FORCE_STACK_ALIGN_1D(int8_t, iTc, 4, 16 );516
514 FORCE_STACK_ALIGN_1D(uint8_t, uiBSx4, 4, 4 );517 pFilter->iLumaQP = iCurQp;
515 518 if (iAlpha | iBeta) {
516 pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4);519 pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
517 iCurQp = pCurDqLayer->pLumaQp[iMbXyIndex];520 pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
518 521 pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
519 *(uint32_t*)uiBSx4 = 0x03030303;522 }
520 523}
521 // luma v524void_t /*__FASTCALL*/ FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
522 if( iBoundryFlag & LEFT_FLAG_MASK)525 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
523 {526 int32_t iMbX = pCurDqLayer->iMbX;
524 pFilter->iLumaQP = ( iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex-1] + 1 ) >> 1; 527 int32_t iMbY = pCurDqLayer->iMbY;
525 FilteringEdgeLumaIntraV( pFilter, pDestY, iLineSize, NULL );528 int32_t iMbWidth = pCurDqLayer->iMbWidth;
526 }529 int32_t iLineSize = pFilter->iCsStride[1];
527 530
528 pFilter->iLumaQP = iCurQp; 531 uint8_t* pDestCb, *pDestCr;
529 GET_ALPHA_BETA_FROM_QP(pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);532 int32_t iCurQp;
530 if( iAlpha | iBeta )533 int32_t iIndexA, iAlpha, iBeta;
531 {534
532 TC0_TBL_LOOKUP(iTc, iIndexA, uiBSx4, 0);535 FORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16);
533 pFilter->pLoopf->pfLumaDeblockingLT4Hor( &pDestY[1 << 2],iLineSize,iAlpha,iBeta,iTc );536 FORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4);
534 pFilter->pLoopf->pfLumaDeblockingLT4Hor( &pDestY[2 << 2],iLineSize,iAlpha,iBeta,iTc );537
535 pFilter->pLoopf->pfLumaDeblockingLT4Hor( &pDestY[3 << 2],iLineSize,iAlpha,iBeta,iTc );538 pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSize + iMbX) << 3);
536 }539 pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSize + iMbX) << 3);
537 540 iCurQp = pCurDqLayer->pChromaQp[iMbXyIndex];
538 // luma h541 * (uint32_t*)uiBSx4 = 0x03030303;
539 if( iBoundryFlag & TOP_FLAG_MASK)542
540 {543 // chroma v
541 pFilter->iLumaQP = ( iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex-iMbWidth] + 1 ) >> 1; 544 if (iBoundryFlag & LEFT_FLAG_MASK) {
542 FilteringEdgeLumaIntraH( pFilter, pDestY, iLineSize, NULL );545 pFilter->iChromaQP = (iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex - 1] + 1) >> 1;
543 } 546 FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSize, NULL);
544 547 }
545 pFilter->iLumaQP = iCurQp; 548
546 if( iAlpha | iBeta )549 pFilter->iChromaQP = iCurQp;
547 {550 GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha,
548 pFilter->pLoopf->pfLumaDeblockingLT4Ver( &pDestY[(1<<2)*iLineSize],iLineSize,iAlpha,iBeta,iTc );551 iBeta);
549 pFilter->pLoopf->pfLumaDeblockingLT4Ver( &pDestY[(2<<2)*iLineSize],iLineSize,iAlpha,iBeta,iTc );552 if (iAlpha | iBeta) {
550 pFilter->pLoopf->pfLumaDeblockingLT4Ver( &pDestY[(3<<2)*iLineSize],iLineSize,iAlpha,iBeta,iTc );553 TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1);
551 }554 pFilter->pLoopf->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc);
552}555 }
553void_t /*__FASTCALL*/ FilteringEdgeChromaHV( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )556
554{557 // chroma h
555 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;558 if (iBoundryFlag & TOP_FLAG_MASK) {
556 int32_t iMbX = pCurDqLayer->iMbX;559 pFilter->iChromaQP = (iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex - iMbWidth] + 1) >> 1;
557 int32_t iMbY = pCurDqLayer->iMbY;560 FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSize, NULL);
558 int32_t iMbWidth = pCurDqLayer->iMbWidth;561 }
559 int32_t iLineSize = pFilter->iCsStride[1];562
560 563 pFilter->iChromaQP = iCurQp;
561 uint8_t *pDestCb, *pDestCr; 564 if (iAlpha | iBeta) {
562 int32_t iCurQp;565 pFilter->pLoopf->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize,
563 int32_t iIndexA, iAlpha, iBeta;566 iAlpha, iBeta, iTc);
564 567 }
565 FORCE_STACK_ALIGN_1D( int8_t, iTc, 4, 16 );
566 FORCE_STACK_ALIGN_1D( uint8_t, uiBSx4, 4, 4 );
567
568 pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSize + iMbX) << 3);
569 pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSize + iMbX) << 3);
570 iCurQp = pCurDqLayer->pChromaQp[iMbXyIndex];
571 *(uint32_t*)uiBSx4 = 0x03030303;
572
573 // chroma v
574 if( iBoundryFlag & LEFT_FLAG_MASK)
575 {
576 pFilter->iChromaQP = ( iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex-1] + 1 ) >> 1;
577 FilteringEdgeChromaIntraV( pFilter, pDestCb, pDestCr, iLineSize, NULL);
578 }
579
580 pFilter->iChromaQP = iCurQp;
581 GET_ALPHA_BETA_FROM_QP(pFilter->iChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, iBeta);
582 if( iAlpha | iBeta )
583 {
584 TC0_TBL_LOOKUP(iTc, iIndexA, uiBSx4, 1);
585 pFilter->pLoopf->pfChromaDeblockingLT4Hor( &pDestCb[2 << 1],&pDestCr[2 << 1],iLineSize,iAlpha,iBeta,iTc );
586 }
587
588 // chroma h
589 if( iBoundryFlag & TOP_FLAG_MASK)
590 {
591 pFilter->iChromaQP = ( iCurQp + pCurDqLayer->pChromaQp[iMbXyIndex-iMbWidth] + 1 ) >> 1;
592 FilteringEdgeChromaIntraH( pFilter, pDestCb, pDestCr, iLineSize, NULL);
593 }
594
595 pFilter->iChromaQP = iCurQp;
596 if( iAlpha | iBeta )
597 {
598 pFilter->pLoopf->pfChromaDeblockingLT4Ver( &pDestCb[(2<<1)*iLineSize],&pDestCr[(2<<1)*iLineSize],iLineSize,iAlpha,iBeta,iTc );
599 }
600}568}
601 569
602// merge h&v lookup table operation to save performance570// merge h&v lookup table operation to save performance
603void_t DeblockingIntraMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )571void_t DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
604{572 FilteringEdgeLumaHV (pCurDqLayer, pFilter, iBoundryFlag);
605 FilteringEdgeLumaHV(pCurDqLayer, pFilter, iBoundryFlag);573 FilteringEdgeChromaHV (pCurDqLayer, pFilter, iBoundryFlag);
606 FilteringEdgeChromaHV(pCurDqLayer, pFilter, iBoundryFlag);574}
607}575
608 576void_t WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
609void_t WelsDeblockingMb( PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag )577 uint8_t nBS[2][4][4] = { 0 };
610{578
611 uint8_t nBS[2][4][4] = { 0 };579 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;
612 580 int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex];
613 int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex;581 int32_t iMbNb;
614 int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex];582
615 int32_t iMbNb;583 switch (iCurMbType) {
616 584 case MB_TYPE_INTRA4x4:
617 switch( iCurMbType )585 case MB_TYPE_INTRA16x16:
618 {586 case MB_TYPE_INTRA_PCM:
619 case MB_TYPE_INTRA4x4:587 DeblockingIntraMb (pCurDqLayer, pFilter, iBoundryFlag);
620 case MB_TYPE_INTRA16x16:588 break;
621 case MB_TYPE_INTRA_PCM:589 default:
622 DeblockingIntraMb( pCurDqLayer, pFilter, iBoundryFlag );590
623 break;591 if (iBoundryFlag & LEFT_FLAG_MASK) {
624 default:592 iMbNb = iMbXyIndex - 1;
625 593 * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
626 if(iBoundryFlag & LEFT_FLAG_MASK)594 pCurDqLayer, 0, iMbNb, iMbXyIndex);
627 {595 } else {
628 iMbNb = iMbXyIndex - 1;596 * (uint32_t*)nBS[0][0] = 0;
629 *(uint32_t*)nBS[0][0] = IS_INTRA(pCurDqLayer->pMbType[iMbNb])?0x04040404:DeblockingBsMarginalMBAvcbase( pCurDqLayer, 0, iMbNb, iMbXyIndex);597 }
598 if (iBoundryFlag & TOP_FLAG_MASK) {
599 iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth;
600 * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase (
601 pCurDqLayer, 1, iMbNb, iMbXyIndex);
602 } else {
603 * (uint32_t*)nBS[1][0] = 0;
604 }
605 //SKIP MB_16x16 or others
606 if (iCurMbType != MB_TYPE_SKIP) {
607 if (iCurMbType == MB_TYPE_16x16) {
608 DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1);
609 } else {
610 DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex);
611 }
612 } else {
613 * (uint32_t*)nBS[0][1] = * (uint32_t*)nBS[0][2] = * (uint32_t*)nBS[0][3] =
614 * (uint32_t*)nBS[1][1] = * (uint32_t*)nBS[1][2] = * (uint32_t*)nBS[1][3] = 0;
615 }
616 DeblockingInterMb (pCurDqLayer, pFilter, nBS, iBoundryFlag);
617 break;
618 }
619}
620
621// C code only
622void_t DeblockLumaLt4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta,
623 int8_t* pTc) {
624 for (int32_t i = 0; i < 16; i++) {
625 int32_t iTc0 = pTc[i >> 2];
626 if (iTc0 >= 0) {
627 int32_t p0 = pPix[-iStrideX];
628 int32_t p1 = pPix[-2 * iStrideX];
629 int32_t p2 = pPix[-3 * iStrideX];
630 int32_t q0 = pPix[0];
631 int32_t q1 = pPix[iStrideX];
632 int32_t q2 = pPix[2 * iStrideX];
633 bool_t bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
634 bool_t bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
635 bool_t bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
636 int32_t iTc = iTc0;
637 if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
638 bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta;
639 bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta;
640 if (bDetaP2P0) {
641 pPix[-2 * iStrideX] = p1 + WELS_CLIP3 ((p2 + ((p0 + q0 + 1) >> 1) - (p1 << 1)) >> 1, -iTc0, iTc0);
642 iTc++;
643 }
644 if (bDetaQ2Q0) {
645 pPix[iStrideX] = q1 + WELS_CLIP3 ((q2 + ((p0 + q0 + 1) >> 1) - (q1 << 1)) >> 1, -iTc0, iTc0);
646 iTc++;
630 }647 }
631 else648 int32_t iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc, iTc);
632 {649 pPix[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
633 *(uint32_t*)nBS[0][0] = 0;650 pPix[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
634 }651 }
635 if(iBoundryFlag & TOP_FLAG_MASK)652 }
636 {653 pPix += iStrideY;
637 iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth;654 }
638 *(uint32_t*)nBS[1][0] = IS_INTRA(pCurDqLayer->pMbType[iMbNb])?0x04040404:DeblockingBsMarginalMBAvcbase( pCurDqLayer, 1, iMbNb, iMbXyIndex);655}
656void_t DeblockLumaEq4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta) {
657 int32_t p0, p1, p2, q0, q1, q2;
658 int32_t iDetaP0Q0;
659 bool_t bDetaP1P0, bDetaQ1Q0;
660 for (int32_t i = 0; i < 16; i++) {
661 p0 = pPix[-iStrideX];
662 p1 = pPix[-2 * iStrideX];
663 p2 = pPix[-3 * iStrideX];
664 q0 = pPix[0];
665 q1 = pPix[iStrideX];
666 q2 = pPix[2 * iStrideX];
667 iDetaP0Q0 = WELS_ABS (p0 - q0);
668 bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
669 bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
670 if ((iDetaP0Q0 < iAlpha) && bDetaP1P0 && bDetaQ1Q0) {
671 if (iDetaP0Q0 < ((iAlpha >> 2) + 2)) {
672 bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta;
673 bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta;
674 if (bDetaP2P0) {
675 const int32_t p3 = pPix[-4 * iStrideX];
676 pPix[-iStrideX] = (p2 + (p1 << 1) + (p0 << 1) + (q0 << 1) + q1 + 4) >> 3; //p0
677 pPix[-2 * iStrideX] = (p2 + p1 + p0 + q0 + 2) >> 2; //p1
678 pPix[-3 * iStrideX] = ((p3 << 1) + p2 + (p2 << 1) + p1 + p0 + q0 + 4) >> 3;//p2
679 } else {
680 pPix[-1 * iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0
639 }681 }
640 else682 if (bDetaQ2Q0) {
641 {683 const int32_t q3 = pPix[3 * iStrideX];
642 *(uint32_t*)nBS[1][0] = 0;684 pPix[0] = (p1 + (p0 << 1) + (q0 << 1) + (q1 << 1) + q2 + 4) >> 3; //q0
643 }685 pPix[iStrideX] = (p0 + q0 + q1 + q2 + 2) >> 2; //q1
644 //SKIP MB_16x16 or others686 pPix[2 * iStrideX] = ((q3 << 1) + q2 + (q2 << 1) + q1 + q0 + p0 + 4) >> 3;//q2
645 if( iCurMbType != MB_TYPE_SKIP )687 } else {
646 {688 pPix[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0
647 if( iCurMbType == MB_TYPE_16x16 )689 }
648 {690 } else {
649 DeblockingBSInsideMBAvsbase( pCurDqLayer->pNzc[iMbXyIndex], nBS, 1 );691 pPix[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0
650 } 692 pPix[ 0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0
651 else 693 }
652 {694 }
653 DeblockingBSInsideMBNormal(pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex);695 pPix += iStrideY;
654 }696 }
655 }697}
656 else698void_t DeblockLumaLt4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* tc) {
657 {699 DeblockLumaLt4_c (pPix, iStride, 1, iAlpha, iBeta, tc);
658 *(uint32_t*)nBS[0][1] = *(uint32_t*)nBS[0][2] = *(uint32_t*)nBS[0][3] = 700}
659 *(uint32_t*)nBS[1][1] = *(uint32_t*)nBS[1][2] = *(uint32_t*)nBS[1][3] = 0;701void_t DeblockLumaLt4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* tc) {
660 }702 DeblockLumaLt4_c (pPix, 1, iStride, iAlpha, iBeta, tc);
661 DeblockingInterMb( pCurDqLayer, pFilter, nBS, iBoundryFlag );703}
662 break;704void_t DeblockLumaEq4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
663 }705 DeblockLumaEq4_c (pPix, iStride, 1, iAlpha, iBeta);
706}
707void_t DeblockLumaEq4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
708 DeblockLumaEq4_c (pPix, 1, iStride, iAlpha, iBeta);
709}
710void_t DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
711 int32_t iBeta, int8_t* pTc) {
712 int32_t p0, p1, q0, q1, iDeta;
713 bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
714
715 for (int32_t i = 0; i < 8; i++) {
716 int32_t iTc0 = pTc[i >> 1];
717 if (iTc0 > 0) {
718 p0 = pPixCb[-iStrideX];
719 p1 = pPixCb[-2 * iStrideX];
720 q0 = pPixCb[0];
721 q1 = pPixCb[iStrideX];
722
723 bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
724 bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
725 bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
726 if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
727 iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
728 pPixCb[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
729 pPixCb[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
730 }
731
732
733 p0 = pPixCr[-iStrideX];
734 p1 = pPixCr[-2 * iStrideX];
735 q0 = pPixCr[0];
736 q1 = pPixCr[iStrideX];
737
738 bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
739 bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
740 bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
741
742 if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
743 iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0);
744 pPixCr[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */
745 pPixCr[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */
746 }
747 }
748 pPixCb += iStrideY;
749 pPixCr += iStrideY;
750 }
751}
752void_t DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha,
753 int32_t iBeta) {
754 int32_t i = 0, d = 0;
755 int32_t p0, p1, q0, q1;
756 bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0;
757 for (int32_t i = 0; i < 8; i++) {
758 //cb
759 p0 = pPixCb[-iStrideX];
760 p1 = pPixCb[-2 * iStrideX];
761 q0 = pPixCb[0];
762 q1 = pPixCb[iStrideX];
763 bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
764 bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
765 bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
766 if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
767 pPixCb[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
768 pPixCb[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
769 }
770
771 //cr
772 p0 = pPixCr[-iStrideX];
773 p1 = pPixCr[-2 * iStrideX];
774 q0 = pPixCr[0];
775 q1 = pPixCr[iStrideX];
776 bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha;
777 bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta;
778 bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta;
779 if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) {
780 pPixCr[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */
781 pPixCr[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */
782 }
783 pPixCr += iStrideY;
784 pPixCb += iStrideY;
785 }
786}
787void_t DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
788 int8_t* tc) {
789 DeblockChromaLt4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, tc);
790}
791void_t DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta,
792 int8_t* tc) {
793 DeblockChromaLt4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, tc);
794}
795void_t DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
796 DeblockChromaEq4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta);
797}
798void_t DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
799 DeblockChromaEq4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta);
800}
801
802#ifdef X86_ASM
803extern "C" {
804 void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc) {
805 FORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16);
806
807 DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]);
808 DeblockLumaLt4V_sse2 (&uiBuf[4 * 16], 16, iAlpha, iBeta, pTc);
809 DeblockLumaTransposeV2H_sse2 (pPixY - 4, iStride, &uiBuf[0]);
810 }
811
812 void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta) {
813 FORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16);
814
815 DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]);
816 DeblockLumaEq4V_sse2 (&uiBuf[4 * 16], 16, iAlpha, iBeta);
817 DeblockLumaTransposeV2H_sse2 (pPixY - 4, iStride, &uiBuf[0]);
818 }
819
664}820}
665 821
666// C code only
667void_t DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc )
668{
669 for( int32_t i = 0;i<16;i++)
670 {
671 int32_t iTc0 = pTc[i>>2];
672 if(iTc0>=0)
673 {
674 int32_t p0 = pPix[-iStrideX];
675 int32_t p1 = pPix[-2*iStrideX];
676 int32_t p2 = pPix[-3*iStrideX];
677 int32_t q0 = pPix[0];
678 int32_t q1 = pPix[iStrideX];
679 int32_t q2 = pPix[2*iStrideX];
680 bool_t bDetaP0Q0= WELS_ABS( p0 - q0 )<iAlpha;
681 bool_t bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta;
682 bool_t bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta;
683 int32_t iTc = iTc0;
684 if ( bDetaP0Q0&& bDetaP1P0 && bDetaQ1Q0 )
685 {
686 bool_t bDetaP2P0 = WELS_ABS( p2 - p0 ) < iBeta;
687 bool_t bDetaQ2Q0 = WELS_ABS( q2 - q0 ) < iBeta;
688 if ( bDetaP2P0)
689 {
690 pPix[-2*iStrideX] = p1 + WELS_CLIP3( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -iTc0, iTc0 );
691 iTc++;
692 }
693 if (bDetaQ2Q0)
694 {
695 pPix[iStrideX] = q1 + WELS_CLIP3( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -iTc0, iTc0 );
696 iTc++;
697 }
698 int32_t iDeta = WELS_CLIP3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -iTc, iTc );
699 pPix[-iStrideX] = WELS_CLIP1( p0 + iDeta ); /* p0' */
700 pPix[0] = WELS_CLIP1( q0 - iDeta ); /* q0' */
701 }
702 }
703 pPix +=iStrideY;
704 }
705}
706void_t DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta )
707{
708 int32_t p0,p1,p2,q0,q1,q2;
709 int32_t iDetaP0Q0;
710 bool_t bDetaP1P0,bDetaQ1Q0;
711 for (int32_t i = 0;i<16;i++)
712 {
713 p0 = pPix[-iStrideX];
714 p1 = pPix[-2*iStrideX];
715 p2 = pPix[-3*iStrideX];
716 q0 = pPix[0];
717 q1 = pPix[iStrideX];
718 q2 = pPix[2*iStrideX];
719 iDetaP0Q0 = WELS_ABS( p0 - q0 );
720 bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta;
721 bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta;
722 if ((iDetaP0Q0<iAlpha) && bDetaP1P0 &&bDetaQ1Q0)
723 {
724 if (iDetaP0Q0< (( iAlpha >> 2 ) + 2 ) )
725 {
726 bool_t bDetaP2P0 = WELS_ABS( p2 - p0 ) < iBeta;
727 bool_t bDetaQ2Q0 = WELS_ABS( q2 - q0 ) < iBeta;
728 if(bDetaP2P0)
729 {
730 const int32_t p3 = pPix[-4*iStrideX];
731 pPix[-iStrideX] = ( p2 + (p1 << 1) + (p0 << 1) + (q0 << 1) + q1 + 4 ) >> 3; //p0
732 pPix[-2*iStrideX] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; //p1
733 pPix[-3*iStrideX] = ( (p3 << 1) + p2 + (p2 << 1) + p1 + p0 + q0 + 4 ) >> 3;//p2
734 }
735 else
736 {
737 pPix[-1*iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; //p0
738 }
739 if (bDetaQ2Q0)
740 {
741 const int32_t q3 = pPix[3*iStrideX];
742 pPix[0] = ( p1 + (p0 << 1) + (q0 << 1) + (q1 << 1) + q2 + 4 ) >> 3; //q0
743 pPix[iStrideX] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; //q1
744 pPix[2*iStrideX] = ( (q3 << 1) + q2 + (q2 << 1) + q1 + q0 + p0 + 4 ) >> 3;//q2
745 }
746 else
747 {
748 pPix[0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; //q0
749 }
750 }
751 else
752 {
753 pPix[-iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; //p0
754 pPix[ 0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; //q0
755 }
756 }
757 pPix += iStrideY;
758 }
759}
760void_t DeblockLumaLt4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
761{
762 DeblockLumaLt4_c( pPix, iStride, 1, iAlpha, iBeta, tc );
763}
764void_t DeblockLumaLt4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
765{
766 DeblockLumaLt4_c( pPix, 1, iStride, iAlpha, iBeta, tc );
767}
768void_t DeblockLumaEq4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta )
769{
770 DeblockLumaEq4_c( pPix, iStride, 1, iAlpha, iBeta);
771}
772void_t DeblockLumaEq4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta )
773{
774 DeblockLumaEq4_c( pPix, 1, iStride, iAlpha, iBeta );
775}
776void_t DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc )
777{
778 int32_t p0, p1, q0, q1,iDeta;
779 bool_t bDetaP0Q0,bDetaP1P0,bDetaQ1Q0;
780
781 for(int32_t i = 0;i<8;i++)
782 {
783 int32_t iTc0 = pTc[i>>1];
784 if(iTc0 >0)
785 {
786 p0 = pPixCb[-iStrideX];
787 p1 = pPixCb[-2*iStrideX];
788 q0 = pPixCb[0];
789 q1 = pPixCb[iStrideX];
790
791 bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha;
792 bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta;
793 bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta;
794 if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0)
795 {
796 iDeta = WELS_CLIP3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0 );
797 pPixCb[-iStrideX] = WELS_CLIP1( p0 + iDeta ); /* p0' */
798 pPixCb[0] = WELS_CLIP1( q0 - iDeta ); /* q0' */
799 }
800
801
802 p0 = pPixCr[-iStrideX];
803 p1 = pPixCr[-2*iStrideX];
804 q0 = pPixCr[0];
805 q1 = pPixCr[iStrideX];
806
807 bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha;
808 bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta;
809 bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta;
810
811 if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0)
812 {
813 iDeta = WELS_CLIP3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0 );
814 pPixCr[-iStrideX] = WELS_CLIP1( p0 + iDeta ); /* p0' */
815 pPixCr[0] = WELS_CLIP1( q0 - iDeta ); /* q0' */
816 }
817 }
818 pPixCb += iStrideY;
819 pPixCr += iStrideY;
820 }
821}
822void_t DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta )
823{
824 int32_t i = 0, d = 0;
825 int32_t p0, p1, q0, q1;
826 bool_t bDetaP0Q0,bDetaP1P0,bDetaQ1Q0;
827 for(int32_t i =0;i<8;i++)
828 {
829 //cb
830 p0 = pPixCb[-iStrideX];
831 p1 = pPixCb[-2*iStrideX];
832 q0 = pPixCb[0];
833 q1 = pPixCb[iStrideX];
834 bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha;
835 bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta;
836 bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta;
837 if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0)
838 {
839 pPixCb[-iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; /* p0' */
840 pPixCb[0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; /* q0' */
841 }
842
843 //cr
844 p0 = pPixCr[-iStrideX];
845 p1 = pPixCr[-2*iStrideX];
846 q0 = pPixCr[0];
847 q1 = pPixCr[iStrideX];
848 bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha;
849 bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta;
850 bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta;
851 if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0)
852 {
853 pPixCr[-iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; /* p0' */
854 pPixCr[0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; /* q0' */
855 }
856 pPixCr += iStrideY;
857 pPixCb += iStrideY;
858 }
859}
860void_t DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
861{
862 DeblockChromaLt4_c( pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, tc );
863}
864void_t DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *tc )
865{
866 DeblockChromaLt4_c( pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, tc );
867}
868void_t DeblockChromaEq4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta )
869{
870 DeblockChromaEq4_c( pPixCb, pPixCr, iStride, 1, iAlpha, iBeta );
871}
872void_t DeblockChromaEq4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta )
873{
874 DeblockChromaEq4_c( pPixCb, pPixCr, 1, iStride, iAlpha, iBeta );
875}
876
877#ifdef X86_ASM
878extern "C" {
879void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc)
880{
881 FORCE_STACK_ALIGN_1D(uint8_t, uiBuf, 16*8, 16);
882
883 DeblockLumaTransposeH2V_sse2(pPixY - 4, iStride, &uiBuf[0]);
884 DeblockLumaLt4V_sse2(&uiBuf[4*16], 16, iAlpha, iBeta, pTc);
885 DeblockLumaTransposeV2H_sse2(pPixY - 4, iStride, &uiBuf[0]);
886}
887
888void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta)
889{
890 FORCE_STACK_ALIGN_1D(uint8_t, uiBuf, 16*8, 16);
891
892 DeblockLumaTransposeH2V_sse2(pPixY - 4, iStride, &uiBuf[0]);
893 DeblockLumaEq4V_sse2(&uiBuf[4*16], 16, iAlpha, iBeta);
894 DeblockLumaTransposeV2H_sse2(pPixY - 4, iStride, &uiBuf[0]);
895}
896
897}
898
899#endif822#endif
900/*!823/*!
901 * \brief AVC slice deblocking filtering target layer824 * \brief AVC slice deblocking filtering target layer
@@ -904,108 +827,99 @@ void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32 · 2 unmodified lines
904 *827 *
905 * \return NONE828 * \return NONE
906 */829 */
907void_t WelsDeblockingFilterSlice( PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb )830void_t WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb) {
908{831 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
909 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;832 PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;
910 PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt;833 int32_t iMbWidth = pCurDqLayer->iMbWidth;
911 int32_t iMbWidth = pCurDqLayer->iMbWidth;834 int32_t iTotalMbCount = pSliceHeaderExt->sSliceHeader.pSps->uiTotalMbCount;
912 int32_t iTotalMbCount = pSliceHeaderExt->sSliceHeader.pSps->uiTotalMbCount;835
913 836 SDeblockingFilter pFilter = {0};
914 SDeblockingFilter pFilter = {0};837
915 838 PFmo pFmo = pCtx->pFmo;
916 PFmo pFmo = pCtx->pFmo;839 int32_t iNextMbXyIndex = 0;
917 int32_t iNextMbXyIndex = 0;840 int32_t iTotalNumMb = pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice;
918 int32_t iTotalNumMb = pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice;841 int32_t iCountNumMb = 0;
919 int32_t iCountNumMb = 0;842 int32_t iBoundryFlag;
920 int32_t iBoundryFlag;843 int32_t iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc;
921 int32_t iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc;844
922 845 /* Step1: parameters set */
923 /* Step1: parameters set */ 846 pFilter.pCsData[0] = pCtx->pDec->pData[0];
924 pFilter.pCsData[0] = pCtx->pDec->pData[0];847 pFilter.pCsData[1] = pCtx->pDec->pData[1];
925 pFilter.pCsData[1] = pCtx->pDec->pData[1];848 pFilter.pCsData[2] = pCtx->pDec->pData[2];
926 pFilter.pCsData[2] = pCtx->pDec->pData[2];849
927 850 pFilter.iCsStride[0] = pCtx->pDec->iLinesize[0];
928 pFilter.iCsStride[0] = pCtx->pDec->iLinesize[0];851 pFilter.iCsStride[1] = pCtx->pDec->iLinesize[1];
929 pFilter.iCsStride[1] = pCtx->pDec->iLinesize[1];852
930 853 pFilter.eSliceType = (ESliceType) pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType;
931 pFilter.eSliceType = (ESliceType) pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType;854
932 855 pFilter.iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset;
933 pFilter.iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset;856 pFilter.iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset;
934 pFilter.iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset;857
935 858 pFilter.pLoopf = &pCtx->sDeblockingFunc;
936 pFilter.pLoopf = &pCtx->sDeblockingFunc;859
937 860 /* Step2: macroblock deblocking */
938 /* Step2: macroblock deblocking */861 if (0 == iFilterIdc || 2 == iFilterIdc) {
939 if( 0 == iFilterIdc || 2 == iFilterIdc )862 iNextMbXyIndex = pSliceHeaderExt->sSliceHeader.iFirstMbInSlice;
940 {863 pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth;
941 iNextMbXyIndex = pSliceHeaderExt->sSliceHeader.iFirstMbInSlice;864 pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth;
942 pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth;865 pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
943 pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth; 866
944 pCurDqLayer->iMbXyIndex = iNextMbXyIndex;867 do {
945 868 iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, iFilterIdc);
946 do 869
947 {870 pDeblockMb (pCurDqLayer, &pFilter, iBoundryFlag);
948 iBoundryFlag = DeblockingAvailableNoInterlayer(pCurDqLayer, iFilterIdc);871
949 872 ++iCountNumMb;
950 pDeblockMb( pCurDqLayer, &pFilter, iBoundryFlag );873 if (iCountNumMb >= iTotalNumMb) {
951 874 break;
952 ++iCountNumMb;875 }
953 if ( iCountNumMb >= iTotalNumMb )876
954 {877 if (pSliceHeaderExt->sSliceHeader.pPps->uiNumSliceGroups > 1) {
955 break;878 iNextMbXyIndex = FmoNextMb (pFmo, iNextMbXyIndex);
956 }879 } else {
957 880 ++iNextMbXyIndex;
958 if ( pSliceHeaderExt->sSliceHeader.pPps->uiNumSliceGroups > 1 )881 }
959 {882 if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbCount) { // slice group boundary or end of a frame
960 iNextMbXyIndex = FmoNextMb( pFmo, iNextMbXyIndex );883 break;
961 }884 }
962 else885
963 {886 pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth;
964 ++iNextMbXyIndex;887 pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth;
965 }888 pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
966 if ( -1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbCount ) // slice group boundary or end of a frame889 } while (1);
967 {890 }
968 break;
969 }
970
971 pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth;
972 pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth;
973 pCurDqLayer->iMbXyIndex = iNextMbXyIndex;
974 } while ( 1 );
975 }
976}891}
977/*!892/*!
978 * \brief deblocking module initialize 893 * \brief deblocking module initialize
979 *894 *
980 * \param pf895 * \param pf
981 * cpu896 * cpu
982 *897 *
983 * \return NONE898 * \return NONE
984 */899 */
985 900
986void_t DeblockingInit( SDeblockingFunc *pFunc, int32_t iCpu )901void_t DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) {
987{902 pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c;
988 pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c;903 pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c;
989 pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c;904 pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c;
990 pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c;905 pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_c;
991 pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_c;906
992 907 pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_c;
993 pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_c;908 pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_c;
994 pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_c;909 pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c;
995 pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c;910 pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_c;
996 pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_c;911
997 912#ifdef X86_ASM
998#ifdef X86_ASM913 if (iCpu & WELS_CPU_SSE2) {
999 if( iCpu & WELS_CPU_SSE2 ){914 pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_sse2;
1000 pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_sse2;915 pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_sse2;
1001 pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_sse2;916 pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_sse2;
1002 pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_sse2;917 pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_sse2;
1003 pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_sse2;918 pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_sse2;
1004 pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_sse2;919 pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_sse2;
1005 pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_sse2;920 pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_sse2;
1006 pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_sse2;921 pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_sse2;
1007 pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_sse2;922 }
1008 }
1009#endif923#endif
1010 924
1011}925}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t