Showing the changes to codec/decoder/core/src/deblocking.cpp (1 of 55 files). Show all
Unified · Split
| @@ -1,1003 +1,1383 @@ | ||
| 1 | −/*! | |
| 2 | − * \copy | |
| 3 | − * Copyright (c) 2010-2013, Cisco Systems | |
| 4 | − * All rights reserved. | |
| 5 | − * | |
| 6 | − * Redistribution and use in source and binary forms, with or without | |
| 7 | − * modification, are permitted provided that the following conditions | |
| 8 | − * are met: | |
| 9 | − * | |
| 10 | − * * Redistributions of source code must retain the above copyright | |
| 11 | − * notice, this list of conditions and the following disclaimer. | |
| 12 | − * | |
| 13 | − * * Redistributions in binary form must reproduce the above copyright | |
| 14 | − * notice, this list of conditions and the following disclaimer in | |
| 15 | − * the documentation and/or other materials provided with the | |
| 16 | − * distribution. | |
| 17 | − * | |
| 18 | − * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 | − * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 | − * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 21 | − * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 22 | − * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 23 | − * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 24 | − * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 25 | − * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 26 | − * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 27 | − * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 28 | − * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 29 | − * POSSIBILITY OF SUCH DAMAGE. | |
| 30 | − * | |
| 31 | − * | |
| 32 | − * \file deblocking.c | |
| 33 | − * | |
| 34 | − * \brief Interfaces introduced in frame deblocking filtering | |
| 35 | − * | |
| 36 | − * \date 08/02/2010 | |
| 37 | − * | |
| 38 | − ************************************************************************************* | |
| 39 | − */ | |
| 40 | − | |
| 41 | −#include "deblocking.h" | |
| 42 | −#include "deblocking_common.h" | |
| 43 | −#include "cpu_core.h" | |
| 44 | − | |
| 45 | −namespace WelsDec { | |
| 46 | − | |
| 47 | −#define NO_SUPPORTED_FILTER_IDX (-1) | |
| 48 | −#define LEFT_FLAG_BIT 0 | |
| 49 | −#define TOP_FLAG_BIT 1 | |
| 50 | −#define LEFT_FLAG_MASK 0x01 | |
| 51 | −#define TOP_FLAG_MASK 0x02 | |
| 52 | − | |
| 53 | −#define SAME_MB_DIFF_REFIDX | |
| 54 | −#define g_kuiAlphaTable(x) g_kuiAlphaTable[(x)+12] | |
| 55 | −#define g_kiBetaTable(x) g_kiBetaTable[(x)+12] | |
| 56 | −#define g_kiTc0Table(x) g_kiTc0Table[(x)+12] | |
| 57 | − | |
| 58 | −#define MB_BS_MV(iRefIndex, iMotionVector, iMbXy, iMbBn, iIndex, iNeighIndex) \ | |
| 59 | −(\ | |
| 60 | − ( iRefIndex[iMbXy][iIndex] - iRefIndex[iMbBn][iNeighIndex] )||\ | |
| 61 | − ( WELS_ABS( iMotionVector[iMbXy][iIndex][0] - iMotionVector[iMbBn][iNeighIndex][0] ) >= 4 ) ||\ | |
| 62 | − ( WELS_ABS( iMotionVector[iMbXy][iIndex][1] - iMotionVector[iMbBn][iNeighIndex][1] ) >= 4 )\ | |
| 63 | −) | |
| 64 | − | |
| 65 | −#if defined(SAME_MB_DIFF_REFIDX) | |
| 66 | −#define SMB_EDGE_MV(iRefIndex, iMotionVector, iIndex, iNeighIndex) \ | |
| 67 | −(\ | |
| 68 | − ( iRefIndex[iIndex] - iRefIndex[iNeighIndex] )||(\ | |
| 69 | − ( WELS_ABS( iMotionVector[iIndex][0] - iMotionVector[iNeighIndex][0] ) &(~3) ) |\ | |
| 70 | − ( WELS_ABS( iMotionVector[iIndex][1] - iMotionVector[iNeighIndex][1] ) &(~3) ))\ | |
| 71 | −) | |
| 72 | −#else | |
| 73 | −#define SMB_EDGE_MV(iRefIndex, iMotionVector, iIndex, iNeighIndex) \ | |
| 74 | −(\ | |
| 75 | − !!(( WELS_ABS( iMotionVector[iIndex][0] - iMotionVector[iNeighIndex][0] ) &(~3) ) |( WELS_ABS( iMotionVector[iIndex][1] - iMotionVector[iNeighIndex][1] ) &(~3) ))\ | |
| 76 | −) | |
| 77 | −#endif | |
| 78 | − | |
| 79 | −#define BS_EDGE(bsx1, iRefIndex, iMotionVector, iIndex, iNeighIndex) \ | |
| 80 | −( (bsx1|SMB_EDGE_MV(iRefIndex, iMotionVector, iIndex, iNeighIndex))<<((uint8_t)(!!bsx1))) | |
| 81 | − | |
| 82 | −#define GET_ALPHA_BETA_FROM_QP(iQp, iAlphaOffset, iBetaOffset, iIndex, iAlpha, iBeta) \ | |
| 83 | −{\ | |
| 84 | − iIndex = (iQp + iAlphaOffset);\ | |
| 85 | − iAlpha = g_kuiAlphaTable(iIndex);\ | |
| 86 | − iBeta = g_kiBetaTable((iQp + iBetaOffset));\ | |
| 87 | −} | |
| 88 | − | |
| 89 | −static 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, | |
| 91 | − 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 92 | − 0, 0, 0, 0, 0, 0, 4, 4, 5, 6, | |
| 93 | − 7, 8, 9, 10, 12, 13, 15, 17, 20, 22, | |
| 94 | − 25, 28, 32, 36, 40, 45, 50, 56, 63, 71, | |
| 95 | − 80, 90, 101, 113, 127, 144, 162, 182, 203, 226, | |
| 96 | − 255, 255 | |
| 97 | − , 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 | |
| 98 | −}; | |
| 99 | − | |
| 100 | −static 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, | |
| 102 | − 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 103 | − 0, 0, 0, 0, 0, 0, 2, 2, 2, 3, | |
| 104 | − 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, | |
| 105 | − 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, | |
| 106 | − 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, | |
| 107 | − 18, 18 | |
| 108 | − , 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 | |
| 109 | −}; | |
| 110 | − | |
| 111 | −static 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 } | |
| 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 } | |
| 125 | −}; | |
| 126 | − | |
| 127 | −static const uint8_t g_kuiTableBIdx[2][8] = { | |
| 128 | − { | |
| 129 | − 0, 4, 8, 12, | |
| 130 | − 3, 7, 11, 15 | |
| 131 | − }, | |
| 132 | − | |
| 133 | − { | |
| 134 | − 0, 1, 2, 3, | |
| 135 | − 12, 13, 14, 15 | |
| 136 | − }, | |
| 137 | −}; | |
| 138 | − | |
| 139 | −static const uint8_t g_kuiTableB8x8Idx[2][16] = { | |
| 140 | − { | |
| 141 | − 0, 1, 4, 5, 8, 9, 12, 13, // 0 1 | 2 3 | |
| 142 | − 2, 3, 6, 7, 10, 11, 14, 15 // 4 5 | 6 7 | |
| 143 | − }, // ------------ | |
| 144 | − // 8 9 | 10 11 | |
| 145 | − { | |
| 146 | − // 12 13 | 14 15 | |
| 147 | − 0, 1, 4, 5, 2, 3, 6, 7, | |
| 148 | − 8, 9, 12, 13, 10, 11, 14, 15 | |
| 149 | − }, | |
| 150 | −}; | |
| 151 | − | |
| 152 | −#define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \ | |
| 153 | −{\ | |
| 154 | − tc[0] = g_kiTc0Table(iIndexA)[pBS[0]] + bChroma;\ | |
| 155 | − tc[1] = g_kiTc0Table(iIndexA)[pBS[1]] + bChroma;\ | |
| 156 | − tc[2] = g_kiTc0Table(iIndexA)[pBS[2]] + bChroma;\ | |
| 157 | − tc[3] = g_kiTc0Table(iIndexA)[pBS[3]] + bChroma;\ | |
| 158 | −} | |
| 159 | − | |
| 160 | −void inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) { | |
| 161 | − uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | |
| 162 | − | |
| 163 | − uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); | |
| 164 | − uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | |
| 165 | − uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | |
| 166 | − uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); | |
| 167 | − | |
| 168 | − nBS[0][1][0] = (pNnzTab[0] | pNnzTab[1]) << iLShiftFactor; | |
| 169 | − nBS[0][2][0] = (pNnzTab[1] | pNnzTab[2]) << iLShiftFactor; | |
| 170 | − nBS[0][3][0] = (pNnzTab[2] | pNnzTab[3]) << iLShiftFactor; | |
| 171 | − | |
| 172 | − nBS[0][1][1] = (pNnzTab[4] | pNnzTab[5]) << iLShiftFactor; | |
| 173 | − nBS[0][2][1] = (pNnzTab[5] | pNnzTab[6]) << iLShiftFactor; | |
| 174 | − nBS[0][3][1] = (pNnzTab[6] | pNnzTab[7]) << iLShiftFactor; | |
| 175 | − * (uint32_t*)nBS[1][1] = (uiNnz32b0 | uiNnz32b1) << iLShiftFactor; | |
| 176 | − | |
| 177 | − nBS[0][1][2] = (pNnzTab[8] | pNnzTab[9]) << iLShiftFactor; | |
| 178 | − nBS[0][2][2] = (pNnzTab[9] | pNnzTab[10]) << iLShiftFactor; | |
| 179 | − nBS[0][3][2] = (pNnzTab[10] | pNnzTab[11]) << iLShiftFactor; | |
| 180 | − * (uint32_t*)nBS[1][2] = (uiNnz32b1 | uiNnz32b2) << iLShiftFactor; | |
| 181 | − | |
| 182 | − nBS[0][1][3] = (pNnzTab[12] | pNnzTab[13]) << iLShiftFactor; | |
| 183 | − nBS[0][2][3] = (pNnzTab[13] | pNnzTab[14]) << iLShiftFactor; | |
| 184 | − nBS[0][3][3] = (pNnzTab[14] | pNnzTab[15]) << iLShiftFactor; | |
| 185 | − * (uint32_t*)nBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor; | |
| 186 | −} | |
| 187 | − | |
| 188 | −void inline DeblockingBSInsideMBAvsbase8x8 (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) { | |
| 189 | − int8_t i8x8NnzTab[4]; | |
| 190 | − for (int32_t i = 0; i < 4; i++) { | |
| 191 | − int32_t iBlkIdx = i << 2; | |
| 192 | − i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | | |
| 193 | − pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); | |
| 194 | − } | |
| 195 | − | |
| 196 | − //vertical | |
| 197 | − nBS[0][2][0] = nBS[0][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[1]) << iLShiftFactor; | |
| 198 | − nBS[0][2][2] = nBS[0][2][3] = (i8x8NnzTab[2] | i8x8NnzTab[3]) << iLShiftFactor; | |
| 199 | − //horizontal | |
| 200 | − nBS[1][2][0] = nBS[1][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[2]) << iLShiftFactor; | |
| 201 | − nBS[1][2][2] = nBS[1][2][3] = (i8x8NnzTab[1] | i8x8NnzTab[3]) << iLShiftFactor; | |
| 202 | −} | |
| 203 | − | |
| 204 | −void static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, | |
| 205 | − int32_t iMbXy) { | |
| 206 | − uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | |
| 207 | − int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy]; | |
| 208 | − ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); | |
| 209 | − | |
| 210 | − int8_t i8x8NnzTab[4]; | |
| 211 | − | |
| 212 | − if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 213 | − for (int32_t i = 0; i < 4; i++) { | |
| 214 | − int32_t iBlkIdx = i << 2; | |
| 215 | − i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | | |
| 216 | − pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); | |
| 217 | − } | |
| 218 | − //vertical | |
| 219 | − nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 220 | − g_kuiMbCountScan4Idx[1 << 2], g_kuiMbCountScan4Idx[0]); | |
| 221 | − nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 222 | − g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[2 << 2]); | |
| 223 | − | |
| 224 | − //horizontal | |
| 225 | − nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 226 | − g_kuiMbCountScan4Idx[2 << 2], g_kuiMbCountScan4Idx[0]); | |
| 227 | − nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 228 | − g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[1 << 2]); | |
| 229 | − } else { | |
| 230 | − uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); | |
| 231 | − uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | |
| 232 | − uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | |
| 233 | − uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); | |
| 234 | − | |
| 235 | − for (int i = 0; i < 3; i++) | |
| 236 | − uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1]; | |
| 237 | − nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0); | |
| 238 | − nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1); | |
| 239 | − nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2); | |
| 240 | − | |
| 241 | − for (int i = 0; i < 3; i++) | |
| 242 | − uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1]; | |
| 243 | − nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4); | |
| 244 | − nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5); | |
| 245 | − nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6); | |
| 246 | − | |
| 247 | − for (int i = 0; i < 3; i++) | |
| 248 | − uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1]; | |
| 249 | − nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8); | |
| 250 | − nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9); | |
| 251 | − nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10); | |
| 252 | − | |
| 253 | − for (int i = 0; i < 3; i++) | |
| 254 | − uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1]; | |
| 255 | − nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12); | |
| 256 | − nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13); | |
| 257 | − nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14); | |
| 258 | − | |
| 259 | − // horizontal | |
| 260 | − * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1); | |
| 261 | − nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0); | |
| 262 | − nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1); | |
| 263 | − nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2); | |
| 264 | − nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3); | |
| 265 | − | |
| 266 | − * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2); | |
| 267 | − nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4); | |
| 268 | − nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5); | |
| 269 | − nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6); | |
| 270 | − nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7); | |
| 271 | − | |
| 272 | − * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3); | |
| 273 | − nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8); | |
| 274 | − nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9); | |
| 275 | − nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10); | |
| 276 | − nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11); | |
| 277 | − } | |
| 278 | −} | |
| 279 | − | |
| 280 | −uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { | |
| 281 | − int32_t i, j; | |
| 282 | − uint32_t uiBSx4; | |
| 283 | − uint8_t* pBS = (uint8_t*) (&uiBSx4); | |
| 284 | − const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0]; | |
| 285 | − const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4]; | |
| 286 | − const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0]; | |
| 287 | − const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8]; | |
| 288 | − | |
| 289 | − if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { | |
| 290 | − for (i = 0; i < 2; i++) { | |
| 291 | − uint8_t uiNzc = 0; | |
| 292 | − for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 293 | − uiNzc |= (pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)] | pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]); | |
| 294 | − } | |
| 295 | − if (uiNzc) { | |
| 296 | − pBS[i << 1] = pBS[1 + (i << 1)] = 2; | |
| 297 | − } else { | |
| 298 | − pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, | |
| 299 | − *pB8x8Idx, *pBn8x8Idx); | |
| 300 | − } | |
| 301 | − pB8x8Idx += 4; | |
| 302 | − pBn8x8Idx += 4; | |
| 303 | − } | |
| 304 | − } else if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 305 | − for (i = 0; i < 2; i++) { | |
| 306 | − uint8_t uiNzc = 0; | |
| 307 | − for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 308 | − uiNzc |= pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)]; | |
| 309 | − } | |
| 310 | − for (j = 0; j < 2; j++) { | |
| 311 | − if (uiNzc | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | |
| 312 | − pBS[j + (i << 1)] = 2; | |
| 313 | − } else { | |
| 314 | − pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pB8x8Idx, | |
| 315 | − *pBnIdx); | |
| 316 | − } | |
| 317 | − pBnIdx++; | |
| 318 | − } | |
| 319 | − pB8x8Idx += 4; | |
| 320 | − } | |
| 321 | − } else if (pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { | |
| 322 | − for (i = 0; i < 2; i++) { | |
| 323 | − uint8_t uiNzc = 0; | |
| 324 | − for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 325 | − uiNzc |= pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]; | |
| 326 | − } | |
| 327 | − for (j = 0; j < 2; j++) { | |
| 328 | − if (uiNzc | pCurDqLayer->pNzc[iMbXy][*pBIdx]) { | |
| 329 | − pBS[j + (i << 1)] = 2; | |
| 330 | − } else { | |
| 331 | − pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, | |
| 332 | − *pBn8x8Idx); | |
| 333 | − } | |
| 334 | − pBIdx++; | |
| 335 | − } | |
| 336 | − pBn8x8Idx += 4; | |
| 337 | − } | |
| 338 | − } else { | |
| 339 | − // only 4x4 transform | |
| 340 | − for (i = 0; i < 4; i++) { | |
| 341 | − if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | |
| 342 | − pBS[i] = 2; | |
| 343 | − } else { | |
| 344 | − pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, | |
| 345 | − *pBnIdx); | |
| 346 | − } | |
| 347 | − pBIdx++; | |
| 348 | − pBnIdx++; | |
| 349 | − } | |
| 350 | − } | |
| 351 | − | |
| 352 | − return uiBSx4; | |
| 353 | −} | |
| 354 | −int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) { | |
| 355 | − int32_t iMbY = pCurDqLayer->iMbY; | |
| 356 | − int32_t iMbX = pCurDqLayer->iMbX; | |
| 357 | − int32_t iMbXy = pCurDqLayer->iMbXyIndex; | |
| 358 | − bool bLeftFlag = false; | |
| 359 | − bool bTopFlag = false; | |
| 360 | − | |
| 361 | − if (2 == iFilterIdc) { | |
| 362 | − bLeftFlag = (iMbX > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - 1]); | |
| 363 | − bTopFlag = (iMbY > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - pCurDqLayer->iMbWidth]); | |
| 364 | − } else { //if ( 0 == iFilterIdc ) | |
| 365 | − bLeftFlag = (iMbX > 0); | |
| 366 | − bTopFlag = (iMbY > 0); | |
| 367 | − } | |
| 368 | − return (bLeftFlag << LEFT_FLAG_BIT) | (bTopFlag << TOP_FLAG_BIT); | |
| 369 | −} | |
| 370 | − | |
| 371 | −void FilteringEdgeLumaH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 372 | − int32_t iIndexA; | |
| 373 | − int32_t iAlpha; | |
| 374 | − int32_t iBeta; | |
| 375 | − ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 376 | − | |
| 377 | − GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 378 | − iBeta); | |
| 379 | − | |
| 380 | − if (iAlpha | iBeta) { | |
| 381 | − TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0); | |
| 382 | − pFilter->pLoopf->pfLumaDeblockingLT4Ver (pPix, iStride, iAlpha, iBeta, tc); | |
| 383 | − } | |
| 384 | − return; | |
| 385 | −} | |
| 386 | − | |
| 387 | − | |
| 388 | −void FilteringEdgeLumaV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 389 | − int32_t iIndexA; | |
| 390 | − int32_t iAlpha; | |
| 391 | − int32_t iBeta; | |
| 392 | − ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 393 | − | |
| 394 | − GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 395 | − iBeta); | |
| 396 | − | |
| 397 | − if (iAlpha | iBeta) { | |
| 398 | − TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0); | |
| 399 | − pFilter->pLoopf->pfLumaDeblockingLT4Hor (pPix, iStride, iAlpha, iBeta, tc); | |
| 400 | − } | |
| 401 | − return; | |
| 402 | −} | |
| 403 | − | |
| 404 | − | |
| 405 | −void FilteringEdgeLumaIntraH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 406 | − int32_t iIndexA; | |
| 407 | − int32_t iAlpha; | |
| 408 | − int32_t iBeta; | |
| 409 | − | |
| 410 | − GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 411 | − iBeta); | |
| 412 | − | |
| 413 | − if (iAlpha | iBeta) { | |
| 414 | − pFilter->pLoopf->pfLumaDeblockingEQ4Ver (pPix, iStride, iAlpha, iBeta); | |
| 415 | − } | |
| 416 | − return; | |
| 417 | −} | |
| 418 | − | |
| 419 | −void FilteringEdgeLumaIntraV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 420 | − int32_t iIndexA; | |
| 421 | − int32_t iAlpha; | |
| 422 | − int32_t iBeta; | |
| 423 | − | |
| 424 | − GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 425 | − iBeta); | |
| 426 | − | |
| 427 | − if (iAlpha | iBeta) { | |
| 428 | − pFilter->pLoopf->pfLumaDeblockingEQ4Hor (pPix, iStride, iAlpha, iBeta); | |
| 429 | − } | |
| 430 | − return; | |
| 431 | −} | |
| 432 | −void FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 433 | − uint8_t* pBS) { | |
| 434 | − int32_t iIndexA; | |
| 435 | − int32_t iAlpha; | |
| 436 | − int32_t iBeta; | |
| 437 | − ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 438 | − if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 439 | − | |
| 440 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 441 | − iBeta); | |
| 442 | − | |
| 443 | − if (iAlpha | iBeta) { | |
| 444 | − TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 445 | − pFilter->pLoopf->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc); | |
| 446 | − } | |
| 447 | − } else { | |
| 448 | − | |
| 449 | − for (int i = 0; i < 2; i++) { | |
| 450 | − | |
| 451 | − | |
| 452 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 453 | − iBeta); | |
| 454 | − | |
| 455 | − if (iAlpha | iBeta) { | |
| 456 | − uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 457 | − TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 458 | − pFilter->pLoopf->pfChromaDeblockingLT4Ver2 (pPixCbCr, iStride, iAlpha, iBeta, tc); | |
| 459 | − } | |
| 460 | − | |
| 461 | − | |
| 462 | − | |
| 463 | − } | |
| 464 | − | |
| 465 | − } | |
| 466 | − return; | |
| 467 | −} | |
| 468 | −void FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 469 | − uint8_t* pBS) { | |
| 470 | − int32_t iIndexA; | |
| 471 | − int32_t iAlpha; | |
| 472 | − int32_t iBeta; | |
| 473 | − ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 474 | − if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 475 | − | |
| 476 | − | |
| 477 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 478 | − iBeta); | |
| 479 | − | |
| 480 | − if (iAlpha | iBeta) { | |
| 481 | − TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 482 | − pFilter->pLoopf->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc); | |
| 483 | − } | |
| 484 | − | |
| 485 | − | |
| 486 | − } else { | |
| 487 | − | |
| 488 | − for (int i = 0; i < 2; i++) { | |
| 489 | − | |
| 490 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 491 | − iBeta); | |
| 492 | − | |
| 493 | − if (iAlpha | iBeta) { | |
| 494 | − uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 495 | − TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 496 | − pFilter->pLoopf->pfChromaDeblockingLT4Hor2 (pPixCbCr, iStride, iAlpha, iBeta, tc); | |
| 497 | − } | |
| 498 | − | |
| 499 | − | |
| 500 | − } | |
| 501 | − } | |
| 502 | − return; | |
| 503 | −} | |
| 504 | − | |
| 505 | −void FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 506 | − uint8_t* pBS) { | |
| 507 | − int32_t iIndexA; | |
| 508 | − int32_t iAlpha; | |
| 509 | − int32_t iBeta; | |
| 510 | − if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 511 | − | |
| 512 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 513 | − iBeta); | |
| 514 | − | |
| 515 | − if (iAlpha | iBeta) { | |
| 516 | − pFilter->pLoopf->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta); | |
| 517 | − } | |
| 518 | − } else { | |
| 519 | − | |
| 520 | − for (int i = 0; i < 2; i++) { | |
| 521 | − | |
| 522 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 523 | − iBeta); | |
| 524 | − | |
| 525 | − if (iAlpha | iBeta) { | |
| 526 | − uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 527 | − pFilter->pLoopf->pfChromaDeblockingEQ4Ver2 (pPixCbCr, iStride, iAlpha, iBeta); | |
| 528 | − } | |
| 529 | − | |
| 530 | − } | |
| 531 | − } | |
| 532 | − return; | |
| 533 | −} | |
| 534 | − | |
| 535 | −void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 536 | − uint8_t* pBS) { | |
| 537 | − int32_t iIndexA; | |
| 538 | − int32_t iAlpha; | |
| 539 | − int32_t iBeta; | |
| 540 | − if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { // QP of cb and cr are the same | |
| 541 | − | |
| 542 | − | |
| 543 | − | |
| 544 | − | |
| 545 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 546 | − iBeta); | |
| 547 | − if (iAlpha | iBeta) { | |
| 548 | − pFilter->pLoopf->pfChromaDeblockingEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta); | |
| 549 | − } | |
| 550 | − } else { | |
| 551 | − | |
| 552 | − for (int i = 0; i < 2; i++) { | |
| 553 | − | |
| 554 | − | |
| 555 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 556 | − iBeta); | |
| 557 | − if (iAlpha | iBeta) { | |
| 558 | − uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 559 | − pFilter->pLoopf->pfChromaDeblockingEQ4Hor2 (pPixCbCr, iStride, iAlpha, iBeta); | |
| 560 | − } | |
| 561 | − } | |
| 562 | − | |
| 563 | − } | |
| 564 | − return; | |
| 565 | −} | |
| 566 | − | |
| 567 | − | |
| 568 | −void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], | |
| 569 | − int32_t iBoundryFlag) { | |
| 570 | − int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 571 | − int32_t iMbX = pCurDqLayer->iMbX; | |
| 572 | − int32_t iMbY = pCurDqLayer->iMbY; | |
| 573 | − | |
| 574 | − int32_t iCurLumaQp = pCurDqLayer->pLumaQp[iMbXyIndex]; | |
| 575 | − //int32_t* iCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex]; | |
| 576 | − int8_t* pCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex]; | |
| 577 | − int32_t iLineSize = pFilter->iCsStride[0]; | |
| 578 | − int32_t iLineSizeUV = pFilter->iCsStride[1]; | |
| 579 | − | |
| 580 | − uint8_t* pDestY, * pDestCb, * pDestCr; | |
| 581 | − pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4); | |
| 582 | − pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSizeUV + iMbX) << 3); | |
| 583 | − pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSizeUV + iMbX) << 3); | |
| 584 | − | |
| 585 | −//Vertical margrin | |
| 586 | − if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 587 | − int32_t iLeftXyIndex = iMbXyIndex - 1; | |
| 588 | − pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iLeftXyIndex] + 1) >> 1; | |
| 589 | − for (int i = 0; i < 2; i++) { | |
| 590 | − pFilter->iChromaQP[i] = (pCurChromaQp[i] + pCurDqLayer->pChromaQp[iLeftXyIndex][i] + 1) >> 1; | |
| 591 | − } | |
| 592 | − if (nBS[0][0][0] == 0x04) { | |
| 593 | − FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL); | |
| 594 | − FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL); | |
| 595 | − } else { | |
| 596 | − if (* (uint32_t*)nBS[0][0] != 0) { | |
| 597 | − FilteringEdgeLumaV (pFilter, pDestY, iLineSize, nBS[0][0]); | |
| 598 | − FilteringEdgeChromaV (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[0][0]); | |
| 599 | − } | |
| 600 | − } | |
| 601 | − } | |
| 602 | − | |
| 603 | − pFilter->iLumaQP = iCurLumaQp; | |
| 604 | − pFilter->iChromaQP[0] = pCurChromaQp[0]; | |
| 605 | − pFilter->iChromaQP[1] = pCurChromaQp[1]; | |
| 606 | − | |
| 607 | − if (* (uint32_t*)nBS[0][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 608 | − FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]); | |
| 609 | − } | |
| 610 | − | |
| 611 | − if (* (uint32_t*)nBS[0][2] != 0) { | |
| 612 | − FilteringEdgeLumaV (pFilter, &pDestY[2 << 2], iLineSize, nBS[0][2]); | |
| 613 | − FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]); | |
| 614 | − } | |
| 615 | − | |
| 616 | − if (* (uint32_t*)nBS[0][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 617 | − FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]); | |
| 618 | − } | |
| 619 | − | |
| 620 | − if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 621 | − int32_t iTopXyIndex = iMbXyIndex - pCurDqLayer->iMbWidth; | |
| 622 | − pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iTopXyIndex] + 1) >> 1; | |
| 623 | − for (int i = 0; i < 2; i++) { | |
| 624 | − pFilter->iChromaQP[i] = (pCurChromaQp[i] + pCurDqLayer->pChromaQp[iTopXyIndex][i] + 1) >> 1; | |
| 625 | − } | |
| 626 | − | |
| 627 | − if (nBS[1][0][0] == 0x04) { | |
| 628 | − FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL); | |
| 629 | − FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL); | |
| 630 | − } else { | |
| 631 | − if (* (uint32_t*)nBS[1][0] != 0) { | |
| 632 | − FilteringEdgeLumaH (pFilter, pDestY, iLineSize, nBS[1][0]); | |
| 633 | − FilteringEdgeChromaH (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[1][0]); | |
| 634 | − } | |
| 635 | − } | |
| 636 | − } | |
| 637 | − | |
| 638 | − pFilter->iLumaQP = iCurLumaQp; | |
| 639 | − pFilter->iChromaQP[0] = pCurChromaQp[0]; | |
| 640 | − pFilter->iChromaQP[1] = pCurChromaQp[1]; | |
| 641 | − | |
| 642 | − if (* (uint32_t*)nBS[1][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 643 | − FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]); | |
| 644 | − } | |
| 645 | − | |
| 646 | − if (* (uint32_t*)nBS[1][2] != 0) { | |
| 647 | − FilteringEdgeLumaH (pFilter, &pDestY[ (2 << 2)*iLineSize], iLineSize, nBS[1][2]); | |
| 648 | − FilteringEdgeChromaH (pFilter, &pDestCb[ (2 << 1)*iLineSizeUV], &pDestCr[ (2 << 1)*iLineSizeUV], iLineSizeUV, | |
| 649 | − nBS[1][2]); | |
| 650 | − } | |
| 651 | − | |
| 652 | − if (* (uint32_t*)nBS[1][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 653 | − FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]); | |
| 654 | − } | |
| 655 | −} | |
| 656 | − | |
| 657 | −void FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 658 | − int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 659 | − int32_t iMbX = pCurDqLayer->iMbX; | |
| 660 | − int32_t iMbY = pCurDqLayer->iMbY; | |
| 661 | − int32_t iMbWidth = pCurDqLayer->iMbWidth; | |
| 662 | − int32_t iLineSize = pFilter->iCsStride[0]; | |
| 663 | − | |
| 664 | − uint8_t* pDestY; | |
| 665 | − int32_t iCurQp; | |
| 666 | − int32_t iIndexA, iAlpha, iBeta; | |
| 667 | − | |
| 668 | − ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); | |
| 669 | − ENFORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4); | |
| 670 | − | |
| 671 | − pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4); | |
| 672 | − iCurQp = pCurDqLayer->pLumaQp[iMbXyIndex]; | |
| 673 | − | |
| 674 | − * (uint32_t*)uiBSx4 = 0x03030303; | |
| 675 | − | |
| 676 | − // luma v | |
| 677 | − if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 678 | − pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - 1] + 1) >> 1; | |
| 679 | − FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL); | |
| 680 | − } | |
| 681 | − | |
| 682 | − pFilter->iLumaQP = iCurQp; | |
| 683 | − GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 684 | − iBeta); | |
| 685 | − if (iAlpha | iBeta) { | |
| 686 | − TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 0); | |
| 687 | − | |
| 688 | − if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 689 | − pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 690 | − } | |
| 691 | − | |
| 692 | − pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 693 | − | |
| 694 | − if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 695 | − pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 696 | − } | |
| 697 | − } | |
| 698 | − | |
| 699 | − // luma h | |
| 700 | − if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 701 | − pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - iMbWidth] + 1) >> 1; | |
| 702 | − FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL); | |
| 703 | − } | |
| 704 | − | |
| 705 | − pFilter->iLumaQP = iCurQp; | |
| 706 | − if (iAlpha | iBeta) { | |
| 707 | − if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 708 | − pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | |
| 709 | − } | |
| 710 | − | |
| 711 | − pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | |
| 712 | − | |
| 713 | − if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 714 | − pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | |
| 715 | − } | |
| 716 | − } | |
| 717 | −} | |
| 718 | −void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 719 | − int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 720 | − int32_t iMbX = pCurDqLayer->iMbX; | |
| 721 | − int32_t iMbY = pCurDqLayer->iMbY; | |
| 722 | − int32_t iMbWidth = pCurDqLayer->iMbWidth; | |
| 723 | − int32_t iLineSize = pFilter->iCsStride[1]; | |
| 724 | − | |
| 725 | − uint8_t* pDestCb; | |
| 726 | − uint8_t* pDestCr; | |
| 727 | − //int32_t iCurQp; | |
| 728 | − int8_t* pCurQp; | |
| 729 | − int32_t iIndexA, iAlpha, iBeta; | |
| 730 | − | |
| 731 | − ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); | |
| 732 | − ENFORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4); | |
| 733 | − | |
| 734 | − pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSize + iMbX) << 3); | |
| 735 | − pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSize + iMbX) << 3); | |
| 736 | − pCurQp = pCurDqLayer->pChromaQp[iMbXyIndex]; | |
| 737 | − | |
| 738 | − * (uint32_t*)uiBSx4 = 0x03030303; | |
| 739 | − | |
| 740 | − | |
| 741 | −// chroma v | |
| 742 | − if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 743 | − | |
| 744 | − for (int i = 0; i < 2; i++) { | |
| 745 | − pFilter->iChromaQP[i] = (pCurQp[i] + pCurDqLayer->pChromaQp[iMbXyIndex - 1][i] + 1) >> 1; | |
| 746 | − | |
| 747 | − } | |
| 748 | − FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSize, NULL); | |
| 749 | − } | |
| 750 | − | |
| 751 | − pFilter->iChromaQP[0] = pCurQp[0]; | |
| 752 | − pFilter->iChromaQP[1] = pCurQp[1]; | |
| 753 | − if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 754 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 755 | − iBeta); | |
| 756 | − if (iAlpha | iBeta) { | |
| 757 | − TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 758 | − pFilter->pLoopf->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc); | |
| 759 | − } | |
| 760 | − } else { | |
| 761 | − | |
| 762 | − for (int i = 0; i < 2; i++) { | |
| 763 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 764 | − iBeta); | |
| 765 | − if (iAlpha | iBeta) { | |
| 766 | − uint8_t* pDestCbCr = (i == 0) ? &pDestCb[2 << 1] : &pDestCr[2 << 1]; | |
| 767 | − TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 768 | − pFilter->pLoopf->pfChromaDeblockingLT4Hor2 (pDestCbCr, iLineSize, iAlpha, iBeta, iTc); | |
| 769 | − } | |
| 770 | − | |
| 771 | − } | |
| 772 | − } | |
| 773 | − | |
| 774 | − // chroma h | |
| 775 | − | |
| 776 | − if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 777 | − for (int i = 0; i < 2; i++) { | |
| 778 | − pFilter->iChromaQP[i] = (pCurQp[i] + pCurDqLayer->pChromaQp[iMbXyIndex - iMbWidth][i] + 1) >> 1; | |
| 779 | − } | |
| 780 | − FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSize, NULL); | |
| 781 | − } | |
| 782 | − | |
| 783 | − pFilter->iChromaQP[0] = pCurQp[0]; | |
| 784 | − pFilter->iChromaQP[1] = pCurQp[1]; | |
| 785 | − | |
| 786 | − if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 787 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 788 | − iBeta); | |
| 789 | − if (iAlpha | iBeta) { | |
| 790 | − TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 791 | − pFilter->pLoopf->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize, | |
| 792 | − iAlpha, iBeta, iTc); | |
| 793 | − } | |
| 794 | − } else { | |
| 795 | − for (int i = 0; i < 2; i++) { | |
| 796 | − | |
| 797 | − GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 798 | − iBeta); | |
| 799 | − if (iAlpha | iBeta) { | |
| 800 | − TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 801 | − uint8_t* pDestCbCr = (i == 0) ? &pDestCb[ (2 << 1) * iLineSize] : &pDestCr[ (2 << 1) * iLineSize]; | |
| 802 | − pFilter->pLoopf->pfChromaDeblockingLT4Ver2 (pDestCbCr, iLineSize, | |
| 803 | − iAlpha, iBeta, iTc); | |
| 804 | − } | |
| 805 | − } | |
| 806 | − | |
| 807 | − | |
| 808 | − } | |
| 809 | −} | |
| 810 | − | |
| 811 | −// merge h&v lookup table operation to save performance | |
| 812 | −void DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 813 | − FilteringEdgeLumaHV (pCurDqLayer, pFilter, iBoundryFlag); | |
| 814 | − FilteringEdgeChromaHV (pCurDqLayer, pFilter, iBoundryFlag); | |
| 815 | −} | |
| 816 | − | |
| 817 | −void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 818 | − uint8_t nBS[2][4][4] = {{{ 0 }}}; | |
| 819 | − | |
| 820 | − int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 821 | − int32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex]; | |
| 822 | − int32_t iMbNb; | |
| 823 | − | |
| 824 | − switch (iCurMbType) { | |
| 825 | − case MB_TYPE_INTRA4x4: | |
| 826 | − case MB_TYPE_INTRA8x8: | |
| 827 | − case MB_TYPE_INTRA16x16: | |
| 828 | − case MB_TYPE_INTRA_PCM: | |
| 829 | − DeblockingIntraMb (pCurDqLayer, pFilter, iBoundryFlag); | |
| 830 | − break; | |
| 831 | − default: | |
| 832 | − | |
| 833 | − if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 834 | − iMbNb = iMbXyIndex - 1; | |
| 835 | − * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( | |
| 836 | − pCurDqLayer, 0, iMbNb, iMbXyIndex); | |
| 837 | − } else { | |
| 838 | − * (uint32_t*)nBS[0][0] = 0; | |
| 839 | − } | |
| 840 | − if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 841 | − iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth; | |
| 842 | − * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( | |
| 843 | − pCurDqLayer, 1, iMbNb, iMbXyIndex); | |
| 844 | − } else { | |
| 845 | − * (uint32_t*)nBS[1][0] = 0; | |
| 846 | − } | |
| 847 | − //SKIP MB_16x16 or others | |
| 848 | − if (iCurMbType != MB_TYPE_SKIP) { | |
| 849 | − if (iCurMbType == MB_TYPE_16x16) { | |
| 850 | − if (!pCurDqLayer->pTransformSize8x8Flag[pCurDqLayer->iMbXyIndex]) { | |
| 851 | − DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1); | |
| 852 | − } else { | |
| 853 | − DeblockingBSInsideMBAvsbase8x8 (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1); | |
| 854 | − } | |
| 855 | − } else { | |
| 856 | − DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); | |
| 857 | − } | |
| 858 | − } else { | |
| 859 | − * (uint32_t*)nBS[0][1] = * (uint32_t*)nBS[0][2] = * (uint32_t*)nBS[0][3] = | |
| 860 | − * (uint32_t*)nBS[1][1] = * (uint32_t*)nBS[1][2] = * (uint32_t*)nBS[1][3] = 0; | |
| 861 | − } | |
| 862 | − DeblockingInterMb (pCurDqLayer, pFilter, nBS, iBoundryFlag); | |
| 863 | − break; | |
| 864 | − } | |
| 865 | −} | |
| 866 | − | |
| 867 | −/*! | |
| 868 | − * \brief AVC slice deblocking filtering target layer | |
| 869 | − * | |
| 870 | − * \param dec Wels avc decoder context | |
| 871 | − * | |
| 872 | − * \return NONE | |
| 873 | − */ | |
| 874 | −void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb) { | |
| 875 | − PDqLayer pCurDqLayer = pCtx->pCurDqLayer; | |
| 876 | − PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt; | |
| 877 | − int32_t iMbWidth = pCurDqLayer->iMbWidth; | |
| 878 | − int32_t iTotalMbCount = pSliceHeaderExt->sSliceHeader.pSps->uiTotalMbCount; | |
| 879 | − | |
| 880 | − SDeblockingFilter pFilter; | |
| 881 | − memset (&pFilter, 0, sizeof (pFilter)); | |
| 882 | − PFmo pFmo = pCtx->pFmo; | |
| 883 | − int32_t iNextMbXyIndex = 0; | |
| 884 | − int32_t iTotalNumMb = pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice; | |
| 885 | − int32_t iCountNumMb = 0; | |
| 886 | − int32_t iBoundryFlag; | |
| 887 | − int32_t iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc; | |
| 888 | − | |
| 889 | − /* Step1: parameters set */ | |
| 890 | − pFilter.pCsData[0] = pCtx->pDec->pData[0]; | |
| 891 | − pFilter.pCsData[1] = pCtx->pDec->pData[1]; | |
| 892 | − pFilter.pCsData[2] = pCtx->pDec->pData[2]; | |
| 893 | − | |
| 894 | − pFilter.iCsStride[0] = pCtx->pDec->iLinesize[0]; | |
| 895 | − pFilter.iCsStride[1] = pCtx->pDec->iLinesize[1]; | |
| 896 | − | |
| 897 | − pFilter.eSliceType = (EWelsSliceType) pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType; | |
| 898 | − | |
| 899 | − pFilter.iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; | |
| 900 | − pFilter.iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset; | |
| 901 | − | |
| 902 | − pFilter.pLoopf = &pCtx->sDeblockingFunc; | |
| 903 | − | |
| 904 | − /* Step2: macroblock deblocking */ | |
| 905 | − if (0 == iFilterIdc || 2 == iFilterIdc) { | |
| 906 | − iNextMbXyIndex = pSliceHeaderExt->sSliceHeader.iFirstMbInSlice; | |
| 907 | − pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth; | |
| 908 | − pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth; | |
| 909 | − pCurDqLayer->iMbXyIndex = iNextMbXyIndex; | |
| 910 | − | |
| 911 | − do { | |
| 912 | − iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, iFilterIdc); | |
| 913 | − | |
| 914 | − pDeblockMb (pCurDqLayer, &pFilter, iBoundryFlag); | |
| 915 | − | |
| 916 | − ++iCountNumMb; | |
| 917 | − if (iCountNumMb >= iTotalNumMb) { | |
| 918 | − break; | |
| 919 | − } | |
| 920 | − | |
| 921 | − if (pSliceHeaderExt->sSliceHeader.pPps->uiNumSliceGroups > 1) { | |
| 922 | − iNextMbXyIndex = FmoNextMb (pFmo, iNextMbXyIndex); | |
| 923 | − } else { | |
| 924 | − ++iNextMbXyIndex; | |
| 925 | − } | |
| 926 | − if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbCount) { // slice group boundary or end of a frame | |
| 927 | − break; | |
| 928 | − } | |
| 929 | − | |
| 930 | − pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth; | |
| 931 | − pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth; | |
| 932 | − pCurDqLayer->iMbXyIndex = iNextMbXyIndex; | |
| 933 | − } while (1); | |
| 934 | − } | |
| 935 | −} | |
| 936 | −/*! | |
| 937 | − * \brief deblocking module initialize | |
| 938 | − * | |
| 939 | − * \param pf | |
| 940 | − * cpu | |
| 941 | − * | |
| 942 | − * \return NONE | |
| 943 | − */ | |
| 944 | − | |
| 945 | −void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) { | |
| 946 | − pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c; | |
| 947 | − pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c; | |
| 948 | − pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c; | |
| 949 | − pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_c; | |
| 950 | − | |
| 951 | − pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_c; | |
| 952 | − pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_c; | |
| 953 | − pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c; | |
| 954 | − pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_c; | |
| 955 | − | |
| 956 | − pFunc->pfChromaDeblockingLT4Ver2 = DeblockChromaLt4V2_c; | |
| 957 | − pFunc->pfChromaDeblockingEQ4Ver2 = DeblockChromaEq4V2_c; | |
| 958 | − pFunc->pfChromaDeblockingLT4Hor2 = DeblockChromaLt4H2_c; | |
| 959 | − pFunc->pfChromaDeblockingEQ4Hor2 = DeblockChromaEq4H2_c; | |
| 960 | − | |
| 961 | −#ifdef X86_ASM | |
| 962 | − if (iCpu & WELS_CPU_SSSE3) { | |
| 963 | − pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_ssse3; | |
| 964 | − pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_ssse3; | |
| 965 | − pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_ssse3; | |
| 966 | − pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_ssse3; | |
| 967 | − pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_ssse3; | |
| 968 | − pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_ssse3; | |
| 969 | − pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_ssse3; | |
| 970 | − pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_ssse3; | |
| 971 | − } | |
| 972 | −#endif | |
| 973 | − | |
| 974 | −#if defined(HAVE_NEON) | |
| 975 | − if (iCpu & WELS_CPU_NEON) { | |
| 976 | − pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_neon; | |
| 977 | − pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_neon; | |
| 978 | − pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_neon; | |
| 979 | − pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_neon; | |
| 980 | − | |
| 981 | − pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_neon; | |
| 982 | − pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_neon; | |
| 983 | − pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_neon; | |
| 984 | − pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_neon; | |
| 985 | − } | |
| 986 | −#endif | |
| 987 | − | |
| 988 | −#if defined(HAVE_NEON_AARCH64) | |
| 989 | − if (iCpu & WELS_CPU_NEON) { | |
| 990 | − pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_AArch64_neon; | |
| 991 | − pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_AArch64_neon; | |
| 992 | − pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_AArch64_neon; | |
| 993 | − pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_AArch64_neon; | |
| 994 | − | |
| 995 | − pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_AArch64_neon; | |
| 996 | − pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_AArch64_neon; | |
| 997 | − pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_AArch64_neon; | |
| 998 | − pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_AArch64_neon; | |
| 999 | − } | |
| 1000 | −#endif | |
| 1001 | −} | |
| 1002 | − | |
| 1003 | −} // namespace WelsDec | |
| 1 | +/*! | |
| 2 | + * \copy | |
| 3 | + * Copyright (c) 2010-2013, Cisco Systems | |
| 4 | + * All rights reserved. | |
| 5 | + * | |
| 6 | + * Redistribution and use in source and binary forms, with or without | |
| 7 | + * modification, are permitted provided that the following conditions | |
| 8 | + * are met: | |
| 9 | + * | |
| 10 | + * * Redistributions of source code must retain the above copyright | |
| 11 | + * notice, this list of conditions and the following disclaimer. | |
| 12 | + * | |
| 13 | + * * Redistributions in binary form must reproduce the above copyright | |
| 14 | + * notice, this list of conditions and the following disclaimer in | |
| 15 | + * the documentation and/or other materials provided with the | |
| 16 | + * distribution. | |
| 17 | + * | |
| 18 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 19 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 20 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
| 21 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | |
| 22 | + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | |
| 23 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | |
| 24 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
| 25 | + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 26 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
| 27 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
| 28 | + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 29 | + * POSSIBILITY OF SUCH DAMAGE. | |
| 30 | + * | |
| 31 | + * | |
| 32 | + * \file deblocking.c | |
| 33 | + * | |
| 34 | + * \brief Interfaces introduced in frame deblocking filtering | |
| 35 | + * | |
| 36 | + * \date 08/02/2010 | |
| 37 | + * | |
| 38 | + ************************************************************************************* | |
| 39 | + */ | |
| 40 | + | |
| 41 | +#include "deblocking.h" | |
| 42 | +#include "deblocking_common.h" | |
| 43 | +#include "cpu_core.h" | |
| 44 | + | |
| 45 | +namespace WelsDec { | |
| 46 | + | |
| 47 | +#define NO_SUPPORTED_FILTER_IDX (-1) | |
| 48 | +#define LEFT_FLAG_BIT 0 | |
| 49 | +#define TOP_FLAG_BIT 1 | |
| 50 | +#define LEFT_FLAG_MASK 0x01 | |
| 51 | +#define TOP_FLAG_MASK 0x02 | |
| 52 | + | |
| 53 | +#define SAME_MB_DIFF_REFIDX | |
| 54 | +#define g_kuiAlphaTable(x) g_kuiAlphaTable[(x)+12] | |
| 55 | +#define g_kiBetaTable(x) g_kiBetaTable[(x)+12] | |
| 56 | +#define g_kiTc0Table(x) g_kiTc0Table[(x)+12] | |
| 57 | + | |
| 58 | +#define MB_BS_MV(iRefIndex, iMotionVector, iMbXy, iMbBn, iIndex, iNeighIndex) \ | |
| 59 | +(\ | |
| 60 | + ( iRefIndex[iMbXy][iIndex] - iRefIndex[iMbBn][iNeighIndex] )||\ | |
| 61 | + ( WELS_ABS( iMotionVector[iMbXy][iIndex][0] - iMotionVector[iMbBn][iNeighIndex][0] ) >= 4 ) ||\ | |
| 62 | + ( WELS_ABS( iMotionVector[iMbXy][iIndex][1] - iMotionVector[iMbBn][iNeighIndex][1] ) >= 4 )\ | |
| 63 | +) | |
| 64 | + | |
| 65 | +#if defined(SAME_MB_DIFF_REFIDX) | |
| 66 | +#define SMB_EDGE_MV(iRefIndex, iMotionVector, iIndex, iNeighIndex) \ | |
| 67 | +(\ | |
| 68 | + ( iRefIndex[iIndex] - iRefIndex[iNeighIndex] )||(\ | |
| 69 | + ( WELS_ABS( iMotionVector[iIndex][0] - iMotionVector[iNeighIndex][0] ) &(~3) ) |\ | |
| 70 | + ( WELS_ABS( iMotionVector[iIndex][1] - iMotionVector[iNeighIndex][1] ) &(~3) ))\ | |
| 71 | +) | |
| 72 | +#else | |
| 73 | +#define SMB_EDGE_MV(iRefIndex, iMotionVector, iIndex, iNeighIndex) \ | |
| 74 | +(\ | |
| 75 | + !!(( WELS_ABS( iMotionVector[iIndex][0] - iMotionVector[iNeighIndex][0] ) &(~3) ) |( WELS_ABS( iMotionVector[iIndex][1] - iMotionVector[iNeighIndex][1] ) &(~3) ))\ | |
| 76 | +) | |
| 77 | +#endif | |
| 78 | + | |
| 79 | +#define BS_EDGE(bsx1, iRefIndex, iMotionVector, iIndex, iNeighIndex) \ | |
| 80 | +( (bsx1|SMB_EDGE_MV(iRefIndex, iMotionVector, iIndex, iNeighIndex))<<((uint8_t)(!!bsx1))) | |
| 81 | + | |
| 82 | +#define GET_ALPHA_BETA_FROM_QP(iQp, iAlphaOffset, iBetaOffset, iIndex, iAlpha, iBeta) \ | |
| 83 | +{\ | |
| 84 | + iIndex = (iQp + iAlphaOffset);\ | |
| 85 | + iAlpha = g_kuiAlphaTable(iIndex);\ | |
| 86 | + iBeta = g_kiBetaTable((iQp + iBetaOffset));\ | |
| 87 | +} | |
| 88 | + | |
| 89 | +static 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, | |
| 91 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 92 | + 0, 0, 0, 0, 0, 0, 4, 4, 5, 6, | |
| 93 | + 7, 8, 9, 10, 12, 13, 15, 17, 20, 22, | |
| 94 | + 25, 28, 32, 36, 40, 45, 50, 56, 63, 71, | |
| 95 | + 80, 90, 101, 113, 127, 144, 162, 182, 203, 226, | |
| 96 | + 255, 255 | |
| 97 | + , 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 | |
| 98 | +}; | |
| 99 | + | |
| 100 | +static 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, | |
| 102 | + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
| 103 | + 0, 0, 0, 0, 0, 0, 2, 2, 2, 3, | |
| 104 | + 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, | |
| 105 | + 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, | |
| 106 | + 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, | |
| 107 | + 18, 18 | |
| 108 | + , 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 | |
| 109 | +}; | |
| 110 | + | |
| 111 | +static 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 }, | |
| 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 } | |
| 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 } | |
| 125 | +}; | |
| 126 | + | |
| 127 | +static const uint8_t g_kuiTableBIdx[2][8] = { | |
| 128 | + { | |
| 129 | + 0, 4, 8, 12, | |
| 130 | + 3, 7, 11, 15 | |
| 131 | + }, | |
| 132 | + | |
| 133 | + { | |
| 134 | + 0, 1, 2, 3, | |
| 135 | + 12, 13, 14, 15 | |
| 136 | + }, | |
| 137 | +}; | |
| 138 | + | |
| 139 | +static const uint8_t g_kuiTableB8x8Idx[2][16] = { | |
| 140 | + { | |
| 141 | + 0, 1, 4, 5, 8, 9, 12, 13, // 0 1 | 2 3 | |
| 142 | + 2, 3, 6, 7, 10, 11, 14, 15 // 4 5 | 6 7 | |
| 143 | + }, // ------------ | |
| 144 | + // 8 9 | 10 11 | |
| 145 | + { | |
| 146 | + // 12 13 | 14 15 | |
| 147 | + 0, 1, 4, 5, 2, 3, 6, 7, | |
| 148 | + 8, 9, 12, 13, 10, 11, 14, 15 | |
| 149 | + }, | |
| 150 | +}; | |
| 151 | + | |
| 152 | +#define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \ | |
| 153 | +{\ | |
| 154 | + tc[0] = g_kiTc0Table(iIndexA)[pBS[0]] + bChroma;\ | |
| 155 | + tc[1] = g_kiTc0Table(iIndexA)[pBS[1]] + bChroma;\ | |
| 156 | + tc[2] = g_kiTc0Table(iIndexA)[pBS[2]] + bChroma;\ | |
| 157 | + tc[3] = g_kiTc0Table(iIndexA)[pBS[3]] + bChroma;\ | |
| 158 | +} | |
| 159 | + | |
| 160 | +void inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) { | |
| 161 | + uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | |
| 162 | + | |
| 163 | + uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); | |
| 164 | + uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | |
| 165 | + uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | |
| 166 | + uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); | |
| 167 | + | |
| 168 | + nBS[0][1][0] = (pNnzTab[0] | pNnzTab[1]) << iLShiftFactor; | |
| 169 | + nBS[0][2][0] = (pNnzTab[1] | pNnzTab[2]) << iLShiftFactor; | |
| 170 | + nBS[0][3][0] = (pNnzTab[2] | pNnzTab[3]) << iLShiftFactor; | |
| 171 | + | |
| 172 | + nBS[0][1][1] = (pNnzTab[4] | pNnzTab[5]) << iLShiftFactor; | |
| 173 | + nBS[0][2][1] = (pNnzTab[5] | pNnzTab[6]) << iLShiftFactor; | |
| 174 | + nBS[0][3][1] = (pNnzTab[6] | pNnzTab[7]) << iLShiftFactor; | |
| 175 | + * (uint32_t*)nBS[1][1] = (uiNnz32b0 | uiNnz32b1) << iLShiftFactor; | |
| 176 | + | |
| 177 | + nBS[0][1][2] = (pNnzTab[8] | pNnzTab[9]) << iLShiftFactor; | |
| 178 | + nBS[0][2][2] = (pNnzTab[9] | pNnzTab[10]) << iLShiftFactor; | |
| 179 | + nBS[0][3][2] = (pNnzTab[10] | pNnzTab[11]) << iLShiftFactor; | |
| 180 | + * (uint32_t*)nBS[1][2] = (uiNnz32b1 | uiNnz32b2) << iLShiftFactor; | |
| 181 | + | |
| 182 | + nBS[0][1][3] = (pNnzTab[12] | pNnzTab[13]) << iLShiftFactor; | |
| 183 | + nBS[0][2][3] = (pNnzTab[13] | pNnzTab[14]) << iLShiftFactor; | |
| 184 | + nBS[0][3][3] = (pNnzTab[14] | pNnzTab[15]) << iLShiftFactor; | |
| 185 | + * (uint32_t*)nBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor; | |
| 186 | +} | |
| 187 | + | |
| 188 | +void inline DeblockingBSInsideMBAvsbase8x8 (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) { | |
| 189 | + int8_t i8x8NnzTab[4]; | |
| 190 | + for (int32_t i = 0; i < 4; i++) { | |
| 191 | + int32_t iBlkIdx = i << 2; | |
| 192 | + i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | | |
| 193 | + pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); | |
| 194 | + } | |
| 195 | + | |
| 196 | + //vertical | |
| 197 | + nBS[0][2][0] = nBS[0][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[1]) << iLShiftFactor; | |
| 198 | + nBS[0][2][2] = nBS[0][2][3] = (i8x8NnzTab[2] | i8x8NnzTab[3]) << iLShiftFactor; | |
| 199 | + //horizontal | |
| 200 | + nBS[1][2][0] = nBS[1][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[2]) << iLShiftFactor; | |
| 201 | + nBS[1][2][2] = nBS[1][2][3] = (i8x8NnzTab[1] | i8x8NnzTab[3]) << iLShiftFactor; | |
| 202 | +} | |
| 203 | + | |
| 204 | +void static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, | |
| 205 | + int32_t iMbXy) { | |
| 206 | + uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | |
| 207 | + int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy]; | |
| 208 | + ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); | |
| 209 | + | |
| 210 | + int8_t i8x8NnzTab[4]; | |
| 211 | + | |
| 212 | + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 213 | + for (int32_t i = 0; i < 4; i++) { | |
| 214 | + int32_t iBlkIdx = i << 2; | |
| 215 | + i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | | |
| 216 | + pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); | |
| 217 | + } | |
| 218 | + //vertical | |
| 219 | + nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 220 | + g_kuiMbCountScan4Idx[1 << 2], g_kuiMbCountScan4Idx[0]); | |
| 221 | + nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 222 | + g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[2 << 2]); | |
| 223 | + | |
| 224 | + //horizontal | |
| 225 | + nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 226 | + g_kuiMbCountScan4Idx[2 << 2], g_kuiMbCountScan4Idx[0]); | |
| 227 | + nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], | |
| 228 | + g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[1 << 2]); | |
| 229 | + } else { | |
| 230 | + uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); | |
| 231 | + uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | |
| 232 | + uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | |
| 233 | + uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); | |
| 234 | + | |
| 235 | + for (int i = 0; i < 3; i++) | |
| 236 | + uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1]; | |
| 237 | + nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0); | |
| 238 | + nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1); | |
| 239 | + nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2); | |
| 240 | + | |
| 241 | + for (int i = 0; i < 3; i++) | |
| 242 | + uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1]; | |
| 243 | + nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4); | |
| 244 | + nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5); | |
| 245 | + nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6); | |
| 246 | + | |
| 247 | + for (int i = 0; i < 3; i++) | |
| 248 | + uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1]; | |
| 249 | + nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8); | |
| 250 | + nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9); | |
| 251 | + nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10); | |
| 252 | + | |
| 253 | + for (int i = 0; i < 3; i++) | |
| 254 | + uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1]; | |
| 255 | + nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12); | |
| 256 | + nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13); | |
| 257 | + nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14); | |
| 258 | + | |
| 259 | + // horizontal | |
| 260 | + * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1); | |
| 261 | + nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0); | |
| 262 | + nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1); | |
| 263 | + nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2); | |
| 264 | + nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3); | |
| 265 | + | |
| 266 | + * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2); | |
| 267 | + nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4); | |
| 268 | + nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5); | |
| 269 | + nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6); | |
| 270 | + nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7); | |
| 271 | + | |
| 272 | + * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3); | |
| 273 | + nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8); | |
| 274 | + nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9); | |
| 275 | + nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10); | |
| 276 | + nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11); | |
| 277 | + } | |
| 278 | +} | |
| 279 | + | |
| 280 | +void static inline DeblockingBSliceBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, | |
| 281 | + int32_t iMbXy) { | |
| 282 | + uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | |
| 283 | + int8_t* iRefIndex[LIST_A]; | |
| 284 | + iRefIndex[LIST_0] = pCurDqLayer->pRefIndex[LIST_0][iMbXy]; | |
| 285 | + iRefIndex[LIST_1] = pCurDqLayer->pRefIndex[LIST_1][iMbXy]; | |
| 286 | + ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); | |
| 287 | + | |
| 288 | + int8_t i8x8NnzTab[4]; | |
| 289 | + | |
| 290 | + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 291 | + for (int32_t i = 0; i < 4; i++) { | |
| 292 | + int32_t iBlkIdx = i << 2; | |
| 293 | + i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | | |
| 294 | + pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); | |
| 295 | + } | |
| 296 | + //vertical | |
| 297 | + int8_t iIndex = g_kuiMbCountScan4Idx[1 << 2]; | |
| 298 | + int8_t iNeigborIndex = g_kuiMbCountScan4Idx[0]; | |
| 299 | + nBS[0][2][0] = nBS[0][2][1] = 1; | |
| 300 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 301 | + if (iRefIndex[listIdx][iIndex] > REF_NOT_IN_LIST && iRefIndex[listIdx][iNeigborIndex] > REF_NOT_IN_LIST) { | |
| 302 | + nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefIndex[listIdx], | |
| 303 | + pCurDqLayer->pMv[listIdx][iMbXy], | |
| 304 | + iIndex, iNeigborIndex); | |
| 305 | + break; | |
| 306 | + } | |
| 307 | + } | |
| 308 | + iIndex = g_kuiMbCountScan4Idx[3 << 2]; | |
| 309 | + iNeigborIndex = g_kuiMbCountScan4Idx[2 << 2]; | |
| 310 | + nBS[0][2][2] = nBS[0][2][3] = 1; | |
| 311 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 312 | + if (iRefIndex[listIdx][iIndex] > REF_NOT_IN_LIST && iRefIndex[listIdx][iNeigborIndex] > REF_NOT_IN_LIST) { | |
| 313 | + nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefIndex[listIdx], | |
| 314 | + pCurDqLayer->pMv[listIdx][iMbXy], | |
| 315 | + iIndex, iNeigborIndex); | |
| 316 | + break; | |
| 317 | + } | |
| 318 | + } | |
| 319 | + | |
| 320 | + //horizontal | |
| 321 | + iIndex = g_kuiMbCountScan4Idx[2 << 2]; | |
| 322 | + iNeigborIndex = g_kuiMbCountScan4Idx[0]; | |
| 323 | + nBS[1][2][0] = nBS[1][2][1] = 1; | |
| 324 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 325 | + if (iRefIndex[listIdx][iIndex] > REF_NOT_IN_LIST && iRefIndex[listIdx][iNeigborIndex] > REF_NOT_IN_LIST) { | |
| 326 | + nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefIndex[listIdx], | |
| 327 | + pCurDqLayer->pMv[listIdx][iMbXy], | |
| 328 | + iIndex, iNeigborIndex); | |
| 329 | + break; | |
| 330 | + } | |
| 331 | + } | |
| 332 | + | |
| 333 | + iIndex = g_kuiMbCountScan4Idx[3 << 2]; | |
| 334 | + iNeigborIndex = g_kuiMbCountScan4Idx[1 << 2]; | |
| 335 | + nBS[1][2][2] = nBS[1][2][3] = 1; | |
| 336 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 337 | + if (iRefIndex[listIdx][iIndex] > REF_NOT_IN_LIST && iRefIndex[listIdx][iNeigborIndex] > REF_NOT_IN_LIST) { | |
| 338 | + nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefIndex[listIdx], | |
| 339 | + pCurDqLayer->pMv[listIdx][iMbXy], | |
| 340 | + iIndex, iNeigborIndex); | |
| 341 | + break; | |
| 342 | + } | |
| 343 | + } | |
| 344 | + } else { | |
| 345 | + uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); | |
| 346 | + uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | |
| 347 | + uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | |
| 348 | + uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); | |
| 349 | + | |
| 350 | + for (int i = 0; i < 3; i++) | |
| 351 | + uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1]; | |
| 352 | + nBS[0][1][0] = 1; | |
| 353 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 354 | + if (iRefIndex[listIdx][1] > REF_NOT_IN_LIST && iRefIndex[listIdx][0] > REF_NOT_IN_LIST) { | |
| 355 | + nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 1, 0); | |
| 356 | + break; | |
| 357 | + } | |
| 358 | + } | |
| 359 | + nBS[0][2][0] = 1; | |
| 360 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 361 | + if (iRefIndex[listIdx][2] > REF_NOT_IN_LIST && iRefIndex[listIdx][1] > REF_NOT_IN_LIST) { | |
| 362 | + nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 2, 1); | |
| 363 | + break; | |
| 364 | + } | |
| 365 | + } | |
| 366 | + nBS[0][3][0] = 1; | |
| 367 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 368 | + if (iRefIndex[listIdx][3] > REF_NOT_IN_LIST && iRefIndex[listIdx][2] > REF_NOT_IN_LIST) { | |
| 369 | + nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 3, 2); | |
| 370 | + break; | |
| 371 | + } | |
| 372 | + } | |
| 373 | + | |
| 374 | + for (int i = 0; i < 3; i++) | |
| 375 | + uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1]; | |
| 376 | + nBS[0][1][1] = 1; | |
| 377 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 378 | + if (iRefIndex[listIdx][5] > REF_NOT_IN_LIST && iRefIndex[listIdx][4] > REF_NOT_IN_LIST) { | |
| 379 | + nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 5, 4); | |
| 380 | + break; | |
| 381 | + } | |
| 382 | + } | |
| 383 | + nBS[0][2][1] = 1; | |
| 384 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 385 | + if (iRefIndex[listIdx][6] > REF_NOT_IN_LIST && iRefIndex[listIdx][5] > REF_NOT_IN_LIST) { | |
| 386 | + nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 6, 5); | |
| 387 | + break; | |
| 388 | + } | |
| 389 | + } | |
| 390 | + nBS[0][3][1] = 1; | |
| 391 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 392 | + if (iRefIndex[listIdx][7] > REF_NOT_IN_LIST && iRefIndex[listIdx][6] > REF_NOT_IN_LIST) { | |
| 393 | + nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 7, 6); | |
| 394 | + break; | |
| 395 | + } | |
| 396 | + } | |
| 397 | + | |
| 398 | + for (int i = 0; i < 3; i++) | |
| 399 | + uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1]; | |
| 400 | + nBS[0][1][2] = 1; | |
| 401 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 402 | + if (iRefIndex[listIdx][9] > REF_NOT_IN_LIST && iRefIndex[listIdx][8] > REF_NOT_IN_LIST) { | |
| 403 | + nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 9, 8); | |
| 404 | + break; | |
| 405 | + } | |
| 406 | + } | |
| 407 | + nBS[0][2][2] = 1; | |
| 408 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 409 | + if (iRefIndex[listIdx][10] > REF_NOT_IN_LIST && iRefIndex[listIdx][9] > REF_NOT_IN_LIST) { | |
| 410 | + nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 10, 9); | |
| 411 | + break; | |
| 412 | + } | |
| 413 | + } | |
| 414 | + nBS[0][3][2] = 1; | |
| 415 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 416 | + if (iRefIndex[listIdx][11] > REF_NOT_IN_LIST && iRefIndex[listIdx][10] > REF_NOT_IN_LIST) { | |
| 417 | + nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 11, 10); | |
| 418 | + break; | |
| 419 | + } | |
| 420 | + } | |
| 421 | + | |
| 422 | + for (int i = 0; i < 3; i++) | |
| 423 | + uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1]; | |
| 424 | + nBS[0][1][3] = 1; | |
| 425 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 426 | + if (iRefIndex[listIdx][13] > REF_NOT_IN_LIST && iRefIndex[listIdx][12] > REF_NOT_IN_LIST) { | |
| 427 | + nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 13, 12); | |
| 428 | + break; | |
| 429 | + } | |
| 430 | + } | |
| 431 | + nBS[0][2][3] = 1; | |
| 432 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 433 | + if (iRefIndex[listIdx][14] > REF_NOT_IN_LIST && iRefIndex[listIdx][13] > REF_NOT_IN_LIST) { | |
| 434 | + nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 14, 13); | |
| 435 | + break; | |
| 436 | + } | |
| 437 | + } | |
| 438 | + nBS[0][3][3] = 1; | |
| 439 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 440 | + if (iRefIndex[listIdx][15] > REF_NOT_IN_LIST && iRefIndex[listIdx][14] > REF_NOT_IN_LIST) { | |
| 441 | + nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 15, 14); | |
| 442 | + break; | |
| 443 | + } | |
| 444 | + } | |
| 445 | + | |
| 446 | + // horizontal | |
| 447 | + * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1); | |
| 448 | + nBS[1][1][0] = 1; | |
| 449 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 450 | + if (iRefIndex[listIdx][4] > REF_NOT_IN_LIST && iRefIndex[listIdx][0] > REF_NOT_IN_LIST) { | |
| 451 | + nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 4, 0); | |
| 452 | + break; | |
| 453 | + } | |
| 454 | + } | |
| 455 | + nBS[1][1][1] = 1; | |
| 456 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 457 | + if (iRefIndex[listIdx][5] > REF_NOT_IN_LIST && iRefIndex[listIdx][1] > REF_NOT_IN_LIST) { | |
| 458 | + nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 5, 1); | |
| 459 | + break; | |
| 460 | + } | |
| 461 | + } | |
| 462 | + nBS[1][1][2] = 1; | |
| 463 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 464 | + if (iRefIndex[listIdx][6] > REF_NOT_IN_LIST && iRefIndex[listIdx][2] > REF_NOT_IN_LIST) { | |
| 465 | + nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 6, 2); | |
| 466 | + break; | |
| 467 | + } | |
| 468 | + } | |
| 469 | + nBS[1][1][3] = 1; | |
| 470 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 471 | + if (iRefIndex[listIdx][7] > REF_NOT_IN_LIST && iRefIndex[listIdx][3] > REF_NOT_IN_LIST) { | |
| 472 | + nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 7, 3); | |
| 473 | + break; | |
| 474 | + } | |
| 475 | + } | |
| 476 | + | |
| 477 | + * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2); | |
| 478 | + nBS[1][2][0] = 1; | |
| 479 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 480 | + if (iRefIndex[listIdx][8] > REF_NOT_IN_LIST && iRefIndex[listIdx][4] > REF_NOT_IN_LIST) { | |
| 481 | + nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 8, 4); | |
| 482 | + break; | |
| 483 | + } | |
| 484 | + } | |
| 485 | + nBS[1][2][1] = 1; | |
| 486 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 487 | + if (iRefIndex[listIdx][9] > REF_NOT_IN_LIST && iRefIndex[listIdx][5] > REF_NOT_IN_LIST) { | |
| 488 | + nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 9, 5); | |
| 489 | + break; | |
| 490 | + } | |
| 491 | + } | |
| 492 | + nBS[1][2][2] = 1; | |
| 493 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 494 | + if (iRefIndex[listIdx][10] > REF_NOT_IN_LIST && iRefIndex[listIdx][6] > REF_NOT_IN_LIST) { | |
| 495 | + nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 10, 6); | |
| 496 | + break; | |
| 497 | + } | |
| 498 | + } | |
| 499 | + nBS[1][2][3] = 1; | |
| 500 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 501 | + if (iRefIndex[listIdx][11] > REF_NOT_IN_LIST && iRefIndex[listIdx][7] > REF_NOT_IN_LIST) { | |
| 502 | + nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 11, 7); | |
| 503 | + break; | |
| 504 | + } | |
| 505 | + } | |
| 506 | + | |
| 507 | + * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3); | |
| 508 | + nBS[1][3][0] = 1; | |
| 509 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 510 | + if (iRefIndex[listIdx][12] > REF_NOT_IN_LIST && iRefIndex[listIdx][8] > REF_NOT_IN_LIST) { | |
| 511 | + nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 12, 8); | |
| 512 | + break; | |
| 513 | + } | |
| 514 | + } | |
| 515 | + nBS[1][3][1] = 1; | |
| 516 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 517 | + if (iRefIndex[listIdx][13] > REF_NOT_IN_LIST && iRefIndex[listIdx][9] > REF_NOT_IN_LIST) { | |
| 518 | + nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 13, 9); | |
| 519 | + break; | |
| 520 | + } | |
| 521 | + } | |
| 522 | + nBS[1][3][2] = 1; | |
| 523 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 524 | + if (iRefIndex[listIdx][14] > REF_NOT_IN_LIST && iRefIndex[listIdx][10] > REF_NOT_IN_LIST) { | |
| 525 | + nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 14, 10); | |
| 526 | + break; | |
| 527 | + } | |
| 528 | + } | |
| 529 | + nBS[1][3][3] = 1; | |
| 530 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 531 | + if (iRefIndex[listIdx][15] > REF_NOT_IN_LIST && iRefIndex[listIdx][11] > REF_NOT_IN_LIST) { | |
| 532 | + nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex[listIdx], pCurDqLayer->pMv[listIdx][iMbXy], 15, 11); | |
| 533 | + break; | |
| 534 | + } | |
| 535 | + } | |
| 536 | + } | |
| 537 | +} | |
| 538 | + | |
| 539 | + | |
| 540 | +uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { | |
| 541 | + int32_t i, j; | |
| 542 | + uint32_t uiBSx4; | |
| 543 | + uint8_t* pBS = (uint8_t*) (&uiBSx4); | |
| 544 | + const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0]; | |
| 545 | + const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4]; | |
| 546 | + const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0]; | |
| 547 | + const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8]; | |
| 548 | + | |
| 549 | + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { | |
| 550 | + for (i = 0; i < 2; i++) { | |
| 551 | + uint8_t uiNzc = 0; | |
| 552 | + for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 553 | + uiNzc |= (pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)] | pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]); | |
| 554 | + } | |
| 555 | + if (uiNzc) { | |
| 556 | + pBS[i << 1] = pBS[1 + (i << 1)] = 2; | |
| 557 | + } else { | |
| 558 | + pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, | |
| 559 | + *pB8x8Idx, *pBn8x8Idx); | |
| 560 | + } | |
| 561 | + pB8x8Idx += 4; | |
| 562 | + pBn8x8Idx += 4; | |
| 563 | + } | |
| 564 | + } else if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 565 | + for (i = 0; i < 2; i++) { | |
| 566 | + uint8_t uiNzc = 0; | |
| 567 | + for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 568 | + uiNzc |= pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)]; | |
| 569 | + } | |
| 570 | + for (j = 0; j < 2; j++) { | |
| 571 | + if (uiNzc | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | |
| 572 | + pBS[j + (i << 1)] = 2; | |
| 573 | + } else { | |
| 574 | + pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pB8x8Idx, | |
| 575 | + *pBnIdx); | |
| 576 | + } | |
| 577 | + pBnIdx++; | |
| 578 | + } | |
| 579 | + pB8x8Idx += 4; | |
| 580 | + } | |
| 581 | + } else if (pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { | |
| 582 | + for (i = 0; i < 2; i++) { | |
| 583 | + uint8_t uiNzc = 0; | |
| 584 | + for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 585 | + uiNzc |= pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]; | |
| 586 | + } | |
| 587 | + for (j = 0; j < 2; j++) { | |
| 588 | + if (uiNzc | pCurDqLayer->pNzc[iMbXy][*pBIdx]) { | |
| 589 | + pBS[j + (i << 1)] = 2; | |
| 590 | + } else { | |
| 591 | + pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, | |
| 592 | + *pBn8x8Idx); | |
| 593 | + } | |
| 594 | + pBIdx++; | |
| 595 | + } | |
| 596 | + pBn8x8Idx += 4; | |
| 597 | + } | |
| 598 | + } else { | |
| 599 | + // only 4x4 transform | |
| 600 | + for (i = 0; i < 4; i++) { | |
| 601 | + if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | |
| 602 | + pBS[i] = 2; | |
| 603 | + } else { | |
| 604 | + pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, | |
| 605 | + *pBnIdx); | |
| 606 | + } | |
| 607 | + pBIdx++; | |
| 608 | + pBnIdx++; | |
| 609 | + } | |
| 610 | + } | |
| 611 | + | |
| 612 | + return uiBSx4; | |
| 613 | +} | |
| 614 | +uint32_t DeblockingBSliceBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { | |
| 615 | + int32_t i, j; | |
| 616 | + uint32_t uiBSx4; | |
| 617 | + uint8_t* pBS = (uint8_t*) (&uiBSx4); | |
| 618 | + const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0]; | |
| 619 | + const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4]; | |
| 620 | + const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0]; | |
| 621 | + const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8]; | |
| 622 | + | |
| 623 | + if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { | |
| 624 | + for (i = 0; i < 2; i++) { | |
| 625 | + uint8_t uiNzc = 0; | |
| 626 | + for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 627 | + uiNzc |= (pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)] | pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]); | |
| 628 | + } | |
| 629 | + if (uiNzc) { | |
| 630 | + pBS[i << 1] = pBS[1 + (i << 1)] = 2; | |
| 631 | + } else { | |
| 632 | + pBS[i << 1] = pBS[1 + (i << 1)] = 1; | |
| 633 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 634 | + if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST | |
| 635 | + && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) { | |
| 636 | + pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[listIdx], pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, | |
| 637 | + *pB8x8Idx, *pBn8x8Idx); | |
| 638 | + break; | |
| 639 | + } | |
| 640 | + } | |
| 641 | + } | |
| 642 | + pB8x8Idx += 4; | |
| 643 | + pBn8x8Idx += 4; | |
| 644 | + } | |
| 645 | + } else if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { | |
| 646 | + for (i = 0; i < 2; i++) { | |
| 647 | + uint8_t uiNzc = 0; | |
| 648 | + for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 649 | + uiNzc |= pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)]; | |
| 650 | + } | |
| 651 | + for (j = 0; j < 2; j++) { | |
| 652 | + if (uiNzc | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | |
| 653 | + pBS[j + (i << 1)] = 2; | |
| 654 | + } else { | |
| 655 | + pBS[j + (i << 1)] = 1; | |
| 656 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 657 | + if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pB8x8Idx] > REF_NOT_IN_LIST | |
| 658 | + && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) { | |
| 659 | + pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[listIdx], pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pB8x8Idx, | |
| 660 | + *pBnIdx); | |
| 661 | + break; | |
| 662 | + } | |
| 663 | + } | |
| 664 | + } | |
| 665 | + pBnIdx++; | |
| 666 | + } | |
| 667 | + pB8x8Idx += 4; | |
| 668 | + } | |
| 669 | + } else if (pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { | |
| 670 | + for (i = 0; i < 2; i++) { | |
| 671 | + uint8_t uiNzc = 0; | |
| 672 | + for (j = 0; uiNzc == 0 && j < 4; j++) { | |
| 673 | + uiNzc |= pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]; | |
| 674 | + } | |
| 675 | + for (j = 0; j < 2; j++) { | |
| 676 | + if (uiNzc | pCurDqLayer->pNzc[iMbXy][*pBIdx]) { | |
| 677 | + pBS[j + (i << 1)] = 2; | |
| 678 | + } else { | |
| 679 | + pBS[j + (i << 1)] = 1; | |
| 680 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 681 | + if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST | |
| 682 | + && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBn8x8Idx] > REF_NOT_IN_LIST) { | |
| 683 | + pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[listIdx], pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, | |
| 684 | + *pBn8x8Idx); | |
| 685 | + break; | |
| 686 | + } | |
| 687 | + } | |
| 688 | + } | |
| 689 | + pBIdx++; | |
| 690 | + } | |
| 691 | + pBn8x8Idx += 4; | |
| 692 | + } | |
| 693 | + } else { | |
| 694 | + // only 4x4 transform | |
| 695 | + for (i = 0; i < 4; i++) { | |
| 696 | + if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | |
| 697 | + pBS[i] = 2; | |
| 698 | + } else { | |
| 699 | + pBS[i] = 1; | |
| 700 | + for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) { | |
| 701 | + if (pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBIdx] > REF_NOT_IN_LIST | |
| 702 | + && pCurDqLayer->pRefIndex[listIdx][iMbXy][*pBnIdx] > REF_NOT_IN_LIST) { | |
| 703 | + pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[listIdx], pCurDqLayer->pMv[listIdx], iMbXy, iNeighMb, *pBIdx, *pBnIdx); | |
| 704 | + break; | |
| 705 | + } | |
| 706 | + } | |
| 707 | + } | |
| 708 | + pBIdx++; | |
| 709 | + pBnIdx++; | |
| 710 | + } | |
| 711 | + } | |
| 712 | + | |
| 713 | + return uiBSx4; | |
| 714 | +} | |
| 715 | +int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) { | |
| 716 | + int32_t iMbY = pCurDqLayer->iMbY; | |
| 717 | + int32_t iMbX = pCurDqLayer->iMbX; | |
| 718 | + int32_t iMbXy = pCurDqLayer->iMbXyIndex; | |
| 719 | + bool bLeftFlag = false; | |
| 720 | + bool bTopFlag = false; | |
| 721 | + | |
| 722 | + if (2 == iFilterIdc) { | |
| 723 | + bLeftFlag = (iMbX > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - 1]); | |
| 724 | + bTopFlag = (iMbY > 0) && (pCurDqLayer->pSliceIdc[iMbXy] == pCurDqLayer->pSliceIdc[iMbXy - pCurDqLayer->iMbWidth]); | |
| 725 | + } else { //if ( 0 == iFilterIdc ) | |
| 726 | + bLeftFlag = (iMbX > 0); | |
| 727 | + bTopFlag = (iMbY > 0); | |
| 728 | + } | |
| 729 | + return (bLeftFlag << LEFT_FLAG_BIT) | (bTopFlag << TOP_FLAG_BIT); | |
| 730 | +} | |
| 731 | + | |
| 732 | +void FilteringEdgeLumaH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 733 | + int32_t iIndexA; | |
| 734 | + int32_t iAlpha; | |
| 735 | + int32_t iBeta; | |
| 736 | + ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 737 | + | |
| 738 | + GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 739 | + iBeta); | |
| 740 | + | |
| 741 | + if (iAlpha | iBeta) { | |
| 742 | + TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0); | |
| 743 | + pFilter->pLoopf->pfLumaDeblockingLT4Ver (pPix, iStride, iAlpha, iBeta, tc); | |
| 744 | + } | |
| 745 | + return; | |
| 746 | +} | |
| 747 | + | |
| 748 | + | |
| 749 | +void FilteringEdgeLumaV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 750 | + int32_t iIndexA; | |
| 751 | + int32_t iAlpha; | |
| 752 | + int32_t iBeta; | |
| 753 | + ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 754 | + | |
| 755 | + GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 756 | + iBeta); | |
| 757 | + | |
| 758 | + if (iAlpha | iBeta) { | |
| 759 | + TC0_TBL_LOOKUP (tc, iIndexA, pBS, 0); | |
| 760 | + pFilter->pLoopf->pfLumaDeblockingLT4Hor (pPix, iStride, iAlpha, iBeta, tc); | |
| 761 | + } | |
| 762 | + return; | |
| 763 | +} | |
| 764 | + | |
| 765 | + | |
| 766 | +void FilteringEdgeLumaIntraH (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 767 | + int32_t iIndexA; | |
| 768 | + int32_t iAlpha; | |
| 769 | + int32_t iBeta; | |
| 770 | + | |
| 771 | + GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 772 | + iBeta); | |
| 773 | + | |
| 774 | + if (iAlpha | iBeta) { | |
| 775 | + pFilter->pLoopf->pfLumaDeblockingEQ4Ver (pPix, iStride, iAlpha, iBeta); | |
| 776 | + } | |
| 777 | + return; | |
| 778 | +} | |
| 779 | + | |
| 780 | +void FilteringEdgeLumaIntraV (SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS) { | |
| 781 | + int32_t iIndexA; | |
| 782 | + int32_t iAlpha; | |
| 783 | + int32_t iBeta; | |
| 784 | + | |
| 785 | + GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 786 | + iBeta); | |
| 787 | + | |
| 788 | + if (iAlpha | iBeta) { | |
| 789 | + pFilter->pLoopf->pfLumaDeblockingEQ4Hor (pPix, iStride, iAlpha, iBeta); | |
| 790 | + } | |
| 791 | + return; | |
| 792 | +} | |
| 793 | +void FilteringEdgeChromaH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 794 | + uint8_t* pBS) { | |
| 795 | + int32_t iIndexA; | |
| 796 | + int32_t iAlpha; | |
| 797 | + int32_t iBeta; | |
| 798 | + ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 799 | + if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 800 | + | |
| 801 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 802 | + iBeta); | |
| 803 | + | |
| 804 | + if (iAlpha | iBeta) { | |
| 805 | + TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 806 | + pFilter->pLoopf->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc); | |
| 807 | + } | |
| 808 | + } else { | |
| 809 | + | |
| 810 | + for (int i = 0; i < 2; i++) { | |
| 811 | + | |
| 812 | + | |
| 813 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 814 | + iBeta); | |
| 815 | + | |
| 816 | + if (iAlpha | iBeta) { | |
| 817 | + uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 818 | + TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 819 | + pFilter->pLoopf->pfChromaDeblockingLT4Ver2 (pPixCbCr, iStride, iAlpha, iBeta, tc); | |
| 820 | + } | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + } | |
| 825 | + | |
| 826 | + } | |
| 827 | + return; | |
| 828 | +} | |
| 829 | +void FilteringEdgeChromaV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 830 | + uint8_t* pBS) { | |
| 831 | + int32_t iIndexA; | |
| 832 | + int32_t iAlpha; | |
| 833 | + int32_t iBeta; | |
| 834 | + ENFORCE_STACK_ALIGN_1D (int8_t, tc, 4, 16); | |
| 835 | + if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 836 | + | |
| 837 | + | |
| 838 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 839 | + iBeta); | |
| 840 | + | |
| 841 | + if (iAlpha | iBeta) { | |
| 842 | + TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 843 | + pFilter->pLoopf->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, tc); | |
| 844 | + } | |
| 845 | + | |
| 846 | + | |
| 847 | + } else { | |
| 848 | + | |
| 849 | + for (int i = 0; i < 2; i++) { | |
| 850 | + | |
| 851 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 852 | + iBeta); | |
| 853 | + | |
| 854 | + if (iAlpha | iBeta) { | |
| 855 | + uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 856 | + TC0_TBL_LOOKUP (tc, iIndexA, pBS, 1); | |
| 857 | + pFilter->pLoopf->pfChromaDeblockingLT4Hor2 (pPixCbCr, iStride, iAlpha, iBeta, tc); | |
| 858 | + } | |
| 859 | + | |
| 860 | + | |
| 861 | + } | |
| 862 | + } | |
| 863 | + return; | |
| 864 | +} | |
| 865 | + | |
| 866 | +void FilteringEdgeChromaIntraH (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 867 | + uint8_t* pBS) { | |
| 868 | + int32_t iIndexA; | |
| 869 | + int32_t iAlpha; | |
| 870 | + int32_t iBeta; | |
| 871 | + if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 872 | + | |
| 873 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 874 | + iBeta); | |
| 875 | + | |
| 876 | + if (iAlpha | iBeta) { | |
| 877 | + pFilter->pLoopf->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta); | |
| 878 | + } | |
| 879 | + } else { | |
| 880 | + | |
| 881 | + for (int i = 0; i < 2; i++) { | |
| 882 | + | |
| 883 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 884 | + iBeta); | |
| 885 | + | |
| 886 | + if (iAlpha | iBeta) { | |
| 887 | + uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 888 | + pFilter->pLoopf->pfChromaDeblockingEQ4Ver2 (pPixCbCr, iStride, iAlpha, iBeta); | |
| 889 | + } | |
| 890 | + | |
| 891 | + } | |
| 892 | + } | |
| 893 | + return; | |
| 894 | +} | |
| 895 | + | |
| 896 | +void FilteringEdgeChromaIntraV (SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, | |
| 897 | + uint8_t* pBS) { | |
| 898 | + int32_t iIndexA; | |
| 899 | + int32_t iAlpha; | |
| 900 | + int32_t iBeta; | |
| 901 | + if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { // QP of cb and cr are the same | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 907 | + iBeta); | |
| 908 | + if (iAlpha | iBeta) { | |
| 909 | + pFilter->pLoopf->pfChromaDeblockingEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta); | |
| 910 | + } | |
| 911 | + } else { | |
| 912 | + | |
| 913 | + for (int i = 0; i < 2; i++) { | |
| 914 | + | |
| 915 | + | |
| 916 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 917 | + iBeta); | |
| 918 | + if (iAlpha | iBeta) { | |
| 919 | + uint8_t* pPixCbCr = (i == 0) ? pPixCb : pPixCr; | |
| 920 | + pFilter->pLoopf->pfChromaDeblockingEQ4Hor2 (pPixCbCr, iStride, iAlpha, iBeta); | |
| 921 | + } | |
| 922 | + } | |
| 923 | + | |
| 924 | + } | |
| 925 | + return; | |
| 926 | +} | |
| 927 | + | |
| 928 | + | |
| 929 | +void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_t nBS[2][4][4], | |
| 930 | + int32_t iBoundryFlag) { | |
| 931 | + int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 932 | + int32_t iMbX = pCurDqLayer->iMbX; | |
| 933 | + int32_t iMbY = pCurDqLayer->iMbY; | |
| 934 | + | |
| 935 | + int32_t iCurLumaQp = pCurDqLayer->pLumaQp[iMbXyIndex]; | |
| 936 | + //int32_t* iCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex]; | |
| 937 | + int8_t* pCurChromaQp = pCurDqLayer->pChromaQp[iMbXyIndex]; | |
| 938 | + int32_t iLineSize = pFilter->iCsStride[0]; | |
| 939 | + int32_t iLineSizeUV = pFilter->iCsStride[1]; | |
| 940 | + | |
| 941 | + uint8_t* pDestY, * pDestCb, * pDestCr; | |
| 942 | + pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4); | |
| 943 | + pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSizeUV + iMbX) << 3); | |
| 944 | + pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSizeUV + iMbX) << 3); | |
| 945 | + | |
| 946 | +//Vertical margrin | |
| 947 | + if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 948 | + int32_t iLeftXyIndex = iMbXyIndex - 1; | |
| 949 | + pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iLeftXyIndex] + 1) >> 1; | |
| 950 | + for (int i = 0; i < 2; i++) { | |
| 951 | + pFilter->iChromaQP[i] = (pCurChromaQp[i] + pCurDqLayer->pChromaQp[iLeftXyIndex][i] + 1) >> 1; | |
| 952 | + } | |
| 953 | + if (nBS[0][0][0] == 0x04) { | |
| 954 | + FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL); | |
| 955 | + FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL); | |
| 956 | + } else { | |
| 957 | + if (* (uint32_t*)nBS[0][0] != 0) { | |
| 958 | + FilteringEdgeLumaV (pFilter, pDestY, iLineSize, nBS[0][0]); | |
| 959 | + FilteringEdgeChromaV (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[0][0]); | |
| 960 | + } | |
| 961 | + } | |
| 962 | + } | |
| 963 | + | |
| 964 | + pFilter->iLumaQP = iCurLumaQp; | |
| 965 | + pFilter->iChromaQP[0] = pCurChromaQp[0]; | |
| 966 | + pFilter->iChromaQP[1] = pCurChromaQp[1]; | |
| 967 | + | |
| 968 | + if (* (uint32_t*)nBS[0][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 969 | + FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]); | |
| 970 | + } | |
| 971 | + | |
| 972 | + if (* (uint32_t*)nBS[0][2] != 0) { | |
| 973 | + FilteringEdgeLumaV (pFilter, &pDestY[2 << 2], iLineSize, nBS[0][2]); | |
| 974 | + FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]); | |
| 975 | + } | |
| 976 | + | |
| 977 | + if (* (uint32_t*)nBS[0][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 978 | + FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]); | |
| 979 | + } | |
| 980 | + | |
| 981 | + if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 982 | + int32_t iTopXyIndex = iMbXyIndex - pCurDqLayer->iMbWidth; | |
| 983 | + pFilter->iLumaQP = (iCurLumaQp + pCurDqLayer->pLumaQp[iTopXyIndex] + 1) >> 1; | |
| 984 | + for (int i = 0; i < 2; i++) { | |
| 985 | + pFilter->iChromaQP[i] = (pCurChromaQp[i] + pCurDqLayer->pChromaQp[iTopXyIndex][i] + 1) >> 1; | |
| 986 | + } | |
| 987 | + | |
| 988 | + if (nBS[1][0][0] == 0x04) { | |
| 989 | + FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL); | |
| 990 | + FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSizeUV, NULL); | |
| 991 | + } else { | |
| 992 | + if (* (uint32_t*)nBS[1][0] != 0) { | |
| 993 | + FilteringEdgeLumaH (pFilter, pDestY, iLineSize, nBS[1][0]); | |
| 994 | + FilteringEdgeChromaH (pFilter, pDestCb, pDestCr, iLineSizeUV, nBS[1][0]); | |
| 995 | + } | |
| 996 | + } | |
| 997 | + } | |
| 998 | + | |
| 999 | + pFilter->iLumaQP = iCurLumaQp; | |
| 1000 | + pFilter->iChromaQP[0] = pCurChromaQp[0]; | |
| 1001 | + pFilter->iChromaQP[1] = pCurChromaQp[1]; | |
| 1002 | + | |
| 1003 | + if (* (uint32_t*)nBS[1][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 1004 | + FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]); | |
| 1005 | + } | |
| 1006 | + | |
| 1007 | + if (* (uint32_t*)nBS[1][2] != 0) { | |
| 1008 | + FilteringEdgeLumaH (pFilter, &pDestY[ (2 << 2)*iLineSize], iLineSize, nBS[1][2]); | |
| 1009 | + FilteringEdgeChromaH (pFilter, &pDestCb[ (2 << 1)*iLineSizeUV], &pDestCr[ (2 << 1)*iLineSizeUV], iLineSizeUV, | |
| 1010 | + nBS[1][2]); | |
| 1011 | + } | |
| 1012 | + | |
| 1013 | + if (* (uint32_t*)nBS[1][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 1014 | + FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]); | |
| 1015 | + } | |
| 1016 | +} | |
| 1017 | + | |
| 1018 | +void FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 1019 | + int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 1020 | + int32_t iMbX = pCurDqLayer->iMbX; | |
| 1021 | + int32_t iMbY = pCurDqLayer->iMbY; | |
| 1022 | + int32_t iMbWidth = pCurDqLayer->iMbWidth; | |
| 1023 | + int32_t iLineSize = pFilter->iCsStride[0]; | |
| 1024 | + | |
| 1025 | + uint8_t* pDestY; | |
| 1026 | + int32_t iCurQp; | |
| 1027 | + int32_t iIndexA, iAlpha, iBeta; | |
| 1028 | + | |
| 1029 | + ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); | |
| 1030 | + ENFORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4); | |
| 1031 | + | |
| 1032 | + pDestY = pFilter->pCsData[0] + ((iMbY * iLineSize + iMbX) << 4); | |
| 1033 | + iCurQp = pCurDqLayer->pLumaQp[iMbXyIndex]; | |
| 1034 | + | |
| 1035 | + * (uint32_t*)uiBSx4 = 0x03030303; | |
| 1036 | + | |
| 1037 | + // luma v | |
| 1038 | + if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 1039 | + pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - 1] + 1) >> 1; | |
| 1040 | + FilteringEdgeLumaIntraV (pFilter, pDestY, iLineSize, NULL); | |
| 1041 | + } | |
| 1042 | + | |
| 1043 | + pFilter->iLumaQP = iCurQp; | |
| 1044 | + GET_ALPHA_BETA_FROM_QP (pFilter->iLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 1045 | + iBeta); | |
| 1046 | + if (iAlpha | iBeta) { | |
| 1047 | + TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 0); | |
| 1048 | + | |
| 1049 | + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 1050 | + pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 1051 | + } | |
| 1052 | + | |
| 1053 | + pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 1054 | + | |
| 1055 | + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 1056 | + pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 1057 | + } | |
| 1058 | + } | |
| 1059 | + | |
| 1060 | + // luma h | |
| 1061 | + if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 1062 | + pFilter->iLumaQP = (iCurQp + pCurDqLayer->pLumaQp[iMbXyIndex - iMbWidth] + 1) >> 1; | |
| 1063 | + FilteringEdgeLumaIntraH (pFilter, pDestY, iLineSize, NULL); | |
| 1064 | + } | |
| 1065 | + | |
| 1066 | + pFilter->iLumaQP = iCurQp; | |
| 1067 | + if (iAlpha | iBeta) { | |
| 1068 | + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 1069 | + pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | |
| 1070 | + } | |
| 1071 | + | |
| 1072 | + pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | |
| 1073 | + | |
| 1074 | + if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { | |
| 1075 | + pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | |
| 1076 | + } | |
| 1077 | + } | |
| 1078 | +} | |
| 1079 | +void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 1080 | + int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 1081 | + int32_t iMbX = pCurDqLayer->iMbX; | |
| 1082 | + int32_t iMbY = pCurDqLayer->iMbY; | |
| 1083 | + int32_t iMbWidth = pCurDqLayer->iMbWidth; | |
| 1084 | + int32_t iLineSize = pFilter->iCsStride[1]; | |
| 1085 | + | |
| 1086 | + uint8_t* pDestCb; | |
| 1087 | + uint8_t* pDestCr; | |
| 1088 | + //int32_t iCurQp; | |
| 1089 | + int8_t* pCurQp; | |
| 1090 | + int32_t iIndexA, iAlpha, iBeta; | |
| 1091 | + | |
| 1092 | + ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); | |
| 1093 | + ENFORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4); | |
| 1094 | + | |
| 1095 | + pDestCb = pFilter->pCsData[1] + ((iMbY * iLineSize + iMbX) << 3); | |
| 1096 | + pDestCr = pFilter->pCsData[2] + ((iMbY * iLineSize + iMbX) << 3); | |
| 1097 | + pCurQp = pCurDqLayer->pChromaQp[iMbXyIndex]; | |
| 1098 | + | |
| 1099 | + * (uint32_t*)uiBSx4 = 0x03030303; | |
| 1100 | + | |
| 1101 | + | |
| 1102 | +// chroma v | |
| 1103 | + if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 1104 | + | |
| 1105 | + for (int i = 0; i < 2; i++) { | |
| 1106 | + pFilter->iChromaQP[i] = (pCurQp[i] + pCurDqLayer->pChromaQp[iMbXyIndex - 1][i] + 1) >> 1; | |
| 1107 | + | |
| 1108 | + } | |
| 1109 | + FilteringEdgeChromaIntraV (pFilter, pDestCb, pDestCr, iLineSize, NULL); | |
| 1110 | + } | |
| 1111 | + | |
| 1112 | + pFilter->iChromaQP[0] = pCurQp[0]; | |
| 1113 | + pFilter->iChromaQP[1] = pCurQp[1]; | |
| 1114 | + if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 1115 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 1116 | + iBeta); | |
| 1117 | + if (iAlpha | iBeta) { | |
| 1118 | + TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 1119 | + pFilter->pLoopf->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc); | |
| 1120 | + } | |
| 1121 | + } else { | |
| 1122 | + | |
| 1123 | + for (int i = 0; i < 2; i++) { | |
| 1124 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 1125 | + iBeta); | |
| 1126 | + if (iAlpha | iBeta) { | |
| 1127 | + uint8_t* pDestCbCr = (i == 0) ? &pDestCb[2 << 1] : &pDestCr[2 << 1]; | |
| 1128 | + TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 1129 | + pFilter->pLoopf->pfChromaDeblockingLT4Hor2 (pDestCbCr, iLineSize, iAlpha, iBeta, iTc); | |
| 1130 | + } | |
| 1131 | + | |
| 1132 | + } | |
| 1133 | + } | |
| 1134 | + | |
| 1135 | + // chroma h | |
| 1136 | + | |
| 1137 | + if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 1138 | + for (int i = 0; i < 2; i++) { | |
| 1139 | + pFilter->iChromaQP[i] = (pCurQp[i] + pCurDqLayer->pChromaQp[iMbXyIndex - iMbWidth][i] + 1) >> 1; | |
| 1140 | + } | |
| 1141 | + FilteringEdgeChromaIntraH (pFilter, pDestCb, pDestCr, iLineSize, NULL); | |
| 1142 | + } | |
| 1143 | + | |
| 1144 | + pFilter->iChromaQP[0] = pCurQp[0]; | |
| 1145 | + pFilter->iChromaQP[1] = pCurQp[1]; | |
| 1146 | + | |
| 1147 | + if (pFilter->iChromaQP[0] == pFilter->iChromaQP[1]) { | |
| 1148 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[0], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 1149 | + iBeta); | |
| 1150 | + if (iAlpha | iBeta) { | |
| 1151 | + TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 1152 | + pFilter->pLoopf->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize, | |
| 1153 | + iAlpha, iBeta, iTc); | |
| 1154 | + } | |
| 1155 | + } else { | |
| 1156 | + for (int i = 0; i < 2; i++) { | |
| 1157 | + | |
| 1158 | + GET_ALPHA_BETA_FROM_QP (pFilter->iChromaQP[i], pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIndexA, iAlpha, | |
| 1159 | + iBeta); | |
| 1160 | + if (iAlpha | iBeta) { | |
| 1161 | + TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 1); | |
| 1162 | + uint8_t* pDestCbCr = (i == 0) ? &pDestCb[ (2 << 1) * iLineSize] : &pDestCr[ (2 << 1) * iLineSize]; | |
| 1163 | + pFilter->pLoopf->pfChromaDeblockingLT4Ver2 (pDestCbCr, iLineSize, | |
| 1164 | + iAlpha, iBeta, iTc); | |
| 1165 | + } | |
| 1166 | + } | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + } | |
| 1170 | +} | |
| 1171 | + | |
| 1172 | +// merge h&v lookup table operation to save performance | |
| 1173 | +void DeblockingIntraMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 1174 | + FilteringEdgeLumaHV (pCurDqLayer, pFilter, iBoundryFlag); | |
| 1175 | + FilteringEdgeChromaHV (pCurDqLayer, pFilter, iBoundryFlag); | |
| 1176 | +} | |
| 1177 | + | |
| 1178 | +void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | |
| 1179 | + uint8_t nBS[2][4][4] = {{{ 0 }}}; | |
| 1180 | + | |
| 1181 | + int32_t iMbXyIndex = pCurDqLayer->iMbXyIndex; | |
| 1182 | + uint32_t iCurMbType = pCurDqLayer->pMbType[iMbXyIndex]; | |
| 1183 | + int32_t iMbNb; | |
| 1184 | + | |
| 1185 | + PSlice pSlice = &pCurDqLayer->sLayerInfo.sSliceInLayer; | |
| 1186 | + PSliceHeader pSliceHeader = &pSlice->sSliceHeaderExt.sSliceHeader; | |
| 1187 | + bool bBSlice = pSliceHeader->eSliceType == B_SLICE; | |
| 1188 | + | |
| 1189 | + switch (iCurMbType) { | |
| 1190 | + case MB_TYPE_INTRA4x4: | |
| 1191 | + case MB_TYPE_INTRA8x8: | |
| 1192 | + case MB_TYPE_INTRA16x16: | |
| 1193 | + case MB_TYPE_INTRA_PCM: | |
| 1194 | + DeblockingIntraMb (pCurDqLayer, pFilter, iBoundryFlag); | |
| 1195 | + break; | |
| 1196 | + default: | |
| 1197 | + | |
| 1198 | + if (iBoundryFlag & LEFT_FLAG_MASK) { | |
| 1199 | + iMbNb = iMbXyIndex - 1; | |
| 1200 | + if (bBSlice) { | |
| 1201 | + * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBSliceBsMarginalMBAvcbase ( | |
| 1202 | + pCurDqLayer, 0, iMbNb, iMbXyIndex); | |
| 1203 | + } else { | |
| 1204 | + * (uint32_t*)nBS[0][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( | |
| 1205 | + pCurDqLayer, 0, iMbNb, iMbXyIndex); | |
| 1206 | + } | |
| 1207 | + } else { | |
| 1208 | + * (uint32_t*)nBS[0][0] = 0; | |
| 1209 | + } | |
| 1210 | + if (iBoundryFlag & TOP_FLAG_MASK) { | |
| 1211 | + iMbNb = iMbXyIndex - pCurDqLayer->iMbWidth; | |
| 1212 | + if (bBSlice) { | |
| 1213 | + * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBSliceBsMarginalMBAvcbase ( | |
| 1214 | + pCurDqLayer, 1, iMbNb, iMbXyIndex); | |
| 1215 | + } else { | |
| 1216 | + * (uint32_t*)nBS[1][0] = IS_INTRA (pCurDqLayer->pMbType[iMbNb]) ? 0x04040404 : DeblockingBsMarginalMBAvcbase ( | |
| 1217 | + pCurDqLayer, 1, iMbNb, iMbXyIndex); | |
| 1218 | + } | |
| 1219 | + } else { | |
| 1220 | + * (uint32_t*)nBS[1][0] = 0; | |
| 1221 | + } | |
| 1222 | + //SKIP MB_16x16 or others | |
| 1223 | + if (IS_SKIP (iCurMbType)) { | |
| 1224 | + * (uint32_t*)nBS[0][1] = * (uint32_t*)nBS[0][2] = * (uint32_t*)nBS[0][3] = | |
| 1225 | + * (uint32_t*)nBS[1][1] = * (uint32_t*)nBS[1][2] = * (uint32_t*)nBS[1][3] = 0; | |
| 1226 | + } else { | |
| 1227 | + if (IS_INTER_16x16 (iCurMbType)) { | |
| 1228 | + if (!pCurDqLayer->pTransformSize8x8Flag[pCurDqLayer->iMbXyIndex]) { | |
| 1229 | + DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1); | |
| 1230 | + } else { | |
| 1231 | + DeblockingBSInsideMBAvsbase8x8 (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1); | |
| 1232 | + } | |
| 1233 | + } else { | |
| 1234 | + | |
| 1235 | + if (bBSlice) { | |
| 1236 | + DeblockingBSliceBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); | |
| 1237 | + } else { | |
| 1238 | + DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); | |
| 1239 | + } | |
| 1240 | + } | |
| 1241 | + } | |
| 1242 | + DeblockingInterMb (pCurDqLayer, pFilter, nBS, iBoundryFlag); | |
| 1243 | + break; | |
| 1244 | + } | |
| 1245 | +} | |
| 1246 | + | |
| 1247 | +/*! | |
| 1248 | + * \brief AVC slice deblocking filtering target layer | |
| 1249 | + * | |
| 1250 | + * \param dec Wels avc decoder context | |
| 1251 | + * | |
| 1252 | + * \return NONE | |
| 1253 | + */ | |
| 1254 | +void WelsDeblockingFilterSlice (PWelsDecoderContext pCtx, PDeblockingFilterMbFunc pDeblockMb) { | |
| 1255 | + PDqLayer pCurDqLayer = pCtx->pCurDqLayer; | |
| 1256 | + PSliceHeaderExt pSliceHeaderExt = &pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt; | |
| 1257 | + int32_t iMbWidth = pCurDqLayer->iMbWidth; | |
| 1258 | + int32_t iTotalMbCount = pSliceHeaderExt->sSliceHeader.pSps->uiTotalMbCount; | |
| 1259 | + | |
| 1260 | + SDeblockingFilter pFilter; | |
| 1261 | + memset (&pFilter, 0, sizeof (pFilter)); | |
| 1262 | + PFmo pFmo = pCtx->pFmo; | |
| 1263 | + int32_t iNextMbXyIndex = 0; | |
| 1264 | + int32_t iTotalNumMb = pCurDqLayer->sLayerInfo.sSliceInLayer.iTotalMbInCurSlice; | |
| 1265 | + int32_t iCountNumMb = 0; | |
| 1266 | + int32_t iBoundryFlag; | |
| 1267 | + int32_t iFilterIdc = pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.uiDisableDeblockingFilterIdc; | |
| 1268 | + | |
| 1269 | + /* Step1: parameters set */ | |
| 1270 | + pFilter.pCsData[0] = pCtx->pDec->pData[0]; | |
| 1271 | + pFilter.pCsData[1] = pCtx->pDec->pData[1]; | |
| 1272 | + pFilter.pCsData[2] = pCtx->pDec->pData[2]; | |
| 1273 | + | |
| 1274 | + pFilter.iCsStride[0] = pCtx->pDec->iLinesize[0]; | |
| 1275 | + pFilter.iCsStride[1] = pCtx->pDec->iLinesize[1]; | |
| 1276 | + | |
| 1277 | + pFilter.eSliceType = (EWelsSliceType) pCurDqLayer->sLayerInfo.sSliceInLayer.eSliceType; | |
| 1278 | + | |
| 1279 | + pFilter.iSliceAlphaC0Offset = pSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; | |
| 1280 | + pFilter.iSliceBetaOffset = pSliceHeaderExt->sSliceHeader.iSliceBetaOffset; | |
| 1281 | + | |
| 1282 | + pFilter.pLoopf = &pCtx->sDeblockingFunc; | |
| 1283 | + | |
| 1284 | + /* Step2: macroblock deblocking */ | |
| 1285 | + if (0 == iFilterIdc || 2 == iFilterIdc) { | |
| 1286 | + iNextMbXyIndex = pSliceHeaderExt->sSliceHeader.iFirstMbInSlice; | |
| 1287 | + pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth; | |
| 1288 | + pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth; | |
| 1289 | + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; | |
| 1290 | + | |
| 1291 | + do { | |
| 1292 | + iBoundryFlag = DeblockingAvailableNoInterlayer (pCurDqLayer, iFilterIdc); | |
| 1293 | + | |
| 1294 | + pDeblockMb (pCurDqLayer, &pFilter, iBoundryFlag); | |
| 1295 | + | |
| 1296 | + ++iCountNumMb; | |
| 1297 | + if (iCountNumMb >= iTotalNumMb) { | |
| 1298 | + break; | |
| 1299 | + } | |
| 1300 | + | |
| 1301 | + if (pSliceHeaderExt->sSliceHeader.pPps->uiNumSliceGroups > 1) { | |
| 1302 | + iNextMbXyIndex = FmoNextMb (pFmo, iNextMbXyIndex); | |
| 1303 | + } else { | |
| 1304 | + ++iNextMbXyIndex; | |
| 1305 | + } | |
| 1306 | + if (-1 == iNextMbXyIndex || iNextMbXyIndex >= iTotalMbCount) { // slice group boundary or end of a frame | |
| 1307 | + break; | |
| 1308 | + } | |
| 1309 | + | |
| 1310 | + pCurDqLayer->iMbX = iNextMbXyIndex % iMbWidth; | |
| 1311 | + pCurDqLayer->iMbY = iNextMbXyIndex / iMbWidth; | |
| 1312 | + pCurDqLayer->iMbXyIndex = iNextMbXyIndex; | |
| 1313 | + } while (1); | |
| 1314 | + } | |
| 1315 | +} | |
| 1316 | +/*! | |
| 1317 | + * \brief deblocking module initialize | |
| 1318 | + * | |
| 1319 | + * \param pf | |
| 1320 | + * cpu | |
| 1321 | + * | |
| 1322 | + * \return NONE | |
| 1323 | + */ | |
| 1324 | + | |
| 1325 | +void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) { | |
| 1326 | + pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c; | |
| 1327 | + pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c; | |
| 1328 | + pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c; | |
| 1329 | + pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_c; | |
| 1330 | + | |
| 1331 | + pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_c; | |
| 1332 | + pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_c; | |
| 1333 | + pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c; | |
| 1334 | + pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_c; | |
| 1335 | + | |
| 1336 | + pFunc->pfChromaDeblockingLT4Ver2 = DeblockChromaLt4V2_c; | |
| 1337 | + pFunc->pfChromaDeblockingEQ4Ver2 = DeblockChromaEq4V2_c; | |
| 1338 | + pFunc->pfChromaDeblockingLT4Hor2 = DeblockChromaLt4H2_c; | |
| 1339 | + pFunc->pfChromaDeblockingEQ4Hor2 = DeblockChromaEq4H2_c; | |
| 1340 | + | |
| 1341 | +#ifdef X86_ASM | |
| 1342 | + if (iCpu & WELS_CPU_SSSE3) { | |
| 1343 | + pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_ssse3; | |
| 1344 | + pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_ssse3; | |
| 1345 | + pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_ssse3; | |
| 1346 | + pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_ssse3; | |
| 1347 | + pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_ssse3; | |
| 1348 | + pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_ssse3; | |
| 1349 | + pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_ssse3; | |
| 1350 | + pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_ssse3; | |
| 1351 | + } | |
| 1352 | +#endif | |
| 1353 | + | |
| 1354 | +#if defined(HAVE_NEON) | |
| 1355 | + if (iCpu & WELS_CPU_NEON) { | |
| 1356 | + pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_neon; | |
| 1357 | + pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_neon; | |
| 1358 | + pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_neon; | |
| 1359 | + pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_neon; | |
| 1360 | + | |
| 1361 | + pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_neon; | |
| 1362 | + pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_neon; | |
| 1363 | + pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_neon; | |
| 1364 | + pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_neon; | |
| 1365 | + } | |
| 1366 | +#endif | |
| 1367 | + | |
| 1368 | +#if defined(HAVE_NEON_AARCH64) | |
| 1369 | + if (iCpu & WELS_CPU_NEON) { | |
| 1370 | + pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_AArch64_neon; | |
| 1371 | + pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_AArch64_neon; | |
| 1372 | + pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_AArch64_neon; | |
| 1373 | + pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_AArch64_neon; | |
| 1374 | + | |
| 1375 | + pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_AArch64_neon; | |
| 1376 | + pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_AArch64_neon; | |
| 1377 | + pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_AArch64_neon; | |
| 1378 | + pFunc->pfChromaDeblockingEQ4Hor = DeblockChromaEq4H_AArch64_neon; | |
| 1379 | + } | |
| 1380 | +#endif | |
| 1381 | +} | |
| 1382 | + | |
| 1383 | +} // namespace WelsDec | |