Showing the changes to codec/encoder/core/src/deblocking.cpp (1 of 225 files). Show all
Unified · Split
| @@ -1,1091 +1,1012 @@ | |||
| 1 | /*! | 1 | /*! |
| 2 | * \copy | 2 | * \copy |
| 3 | * Copyright (c) 2009-2013, Cisco Systems | 3 | * Copyright (c) 2009-2013, Cisco Systems |
| 4 | * All rights reserved. | 4 | * All rights reserved. |
| 5 | * | 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions |
| 8 | * are met: | 8 | * are met: |
| 9 | * | 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright | 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * | 12 | * |
| 13 | * * Redistributions in binary form must reproduce the above copyright | 13 | * * Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in | 14 | * notice, this list of conditions and the following disclaimer in |
| 15 | * the documentation and/or other materials provided with the | 15 | * the documentation and/or other materials provided with the |
| 16 | * distribution. | 16 | * distribution. |
| 17 | * | 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 20 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | 21 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 22 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | 22 | * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 24 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 26 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 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 | 28 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. |
| 30 | * | 30 | * |
| 31 | * | 31 | * |
| 32 | * \file deblocking.c | 32 | * \file deblocking.c |
| 33 | * | 33 | * |
| 34 | * \brief Interfaces introduced in frame deblocking filtering | 34 | * \brief Interfaces introduced in frame deblocking filtering |
| 35 | * | 35 | * |
| 36 | * \date 08/03/2009 Created | 36 | * \date 08/03/2009 Created |
| 37 | * | 37 | * |
| 38 | ************************************************************************************* | 38 | ************************************************************************************* |
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | #include "as264_common.h" | 41 | #include "as264_common.h" |
| 42 | #include "deblocking.h" | 42 | #include "deblocking.h" |
| 43 | #include "cpu_core.h" | 43 | #include "cpu_core.h" |
| 44 | #include "array_stack_align.h" | 44 | #include "array_stack_align.h" |
| 45 | 45 | ||
| 46 | namespace WelsSVCEnc { | 46 | namespace WelsSVCEnc { |
| 47 | 47 | ||
| 48 | #define g_kuiAlphaTable(x) g_kuiAlphaTable[(x)] | 48 | #define g_kuiAlphaTable(x) g_kuiAlphaTable[(x)] |
| 49 | #define g_kiBetaTable(x) g_kiBetaTable[(x)] | 49 | #define g_kiBetaTable(x) g_kiBetaTable[(x)] |
| 50 | #define g_kiTc0Table(x) g_kiTc0Table[(x)] | 50 | #define g_kiTc0Table(x) g_kiTc0Table[(x)] |
| 51 | 51 | ||
| 52 | #define MB_BS_MV(sCurMv, sNeighMv, uiBIdx, uiBnIdx) \ | 52 | #define MB_BS_MV(sCurMv, sNeighMv, uiBIdx, uiBnIdx) \ |
| 53 | (\ | 53 | (\ |
| 54 | ( WELS_ABS( sCurMv[uiBIdx].iMvX - sNeighMv[uiBnIdx].iMvX ) >= 4 ) ||\ | 54 | ( WELS_ABS( sCurMv[uiBIdx].iMvX - sNeighMv[uiBnIdx].iMvX ) >= 4 ) ||\ |
| 55 | ( WELS_ABS( sCurMv[uiBIdx].iMvY - sNeighMv[uiBnIdx].iMvY ) >= 4 )\ | 55 | ( WELS_ABS( sCurMv[uiBIdx].iMvY - sNeighMv[uiBnIdx].iMvY ) >= 4 )\ |
| 56 | ) | 56 | ) |
| 57 | 57 | ||
| 58 | #define SMB_EDGE_MV(uiRefIndex, sMotionVector, uiBIdx, uiBnIdx) \ | 58 | #define SMB_EDGE_MV(uiRefIndex, sMotionVector, uiBIdx, uiBnIdx) \ |
| 59 | (\ | 59 | (\ |
| 60 | !!((WELS_ABS(sMotionVector[uiBIdx].iMvX - sMotionVector[uiBnIdx].iMvX) &(~3)) | (WELS_ABS(sMotionVector[uiBIdx].iMvY - sMotionVector[uiBnIdx].iMvY) &(~3)))\ | 60 | !!((WELS_ABS(sMotionVector[uiBIdx].iMvX - sMotionVector[uiBnIdx].iMvX) &(~3)) | (WELS_ABS(sMotionVector[uiBIdx].iMvY - sMotionVector[uiBnIdx].iMvY) &(~3)))\ |
| 61 | ) | 61 | ) |
| 62 | 62 | ||
| 63 | #define BS_EDGE(bsx1, uiRefIndex, sMotionVector, uiBIdx, uiBnIdx) \ | 63 | #define BS_EDGE(bsx1, uiRefIndex, sMotionVector, uiBIdx, uiBnIdx) \ |
| 64 | ( (bsx1|SMB_EDGE_MV(uiRefIndex, sMotionVector, uiBIdx, uiBnIdx))<<(bsx1?1:0)) | 64 | ( (bsx1|SMB_EDGE_MV(uiRefIndex, sMotionVector, uiBIdx, uiBnIdx))<<(bsx1?1:0)) |
| 65 | 65 | ||
| 66 | #define GET_ALPHA_BETA_FROM_QP(QP, iAlphaOffset, iBetaOffset, iIdexA, iAlpha, iBeta) \ | 66 | #define GET_ALPHA_BETA_FROM_QP(QP, iAlphaOffset, iBetaOffset, iIdexA, iAlpha, iBeta) \ |
| 67 | {\ | 67 | {\ |
| 68 | iIdexA = (QP + iAlphaOffset);\ | 68 | iIdexA = (QP + iAlphaOffset);\ |
| 69 | iIdexA = CLIP3_QP_0_51(iIdexA);\ | 69 | iIdexA = CLIP3_QP_0_51(iIdexA);\ |
| 70 | iAlpha = g_kuiAlphaTable(iIdexA);\ | 70 | iAlpha = g_kuiAlphaTable(iIdexA);\ |
| 71 | iBeta = g_kiBetaTable((CLIP3_QP_0_51(QP + iBetaOffset)));\ | 71 | iBeta = g_kiBetaTable((CLIP3_QP_0_51(QP + iBetaOffset)));\ |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | static const uint8_t g_kuiAlphaTable[52+12] = { //this table refers to Table 8-16 in H.264/AVC standard | 74 | static const uint8_t g_kuiAlphaTable[52 + 12] = { //this table refers to Table 8-16 in H.264/AVC standard |
| 75 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 75 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 76 | 0, 0, 0, 0, 0, 0, 4, 4, 5, 6, | 76 | 0, 0, 0, 0, 0, 0, 4, 4, 5, 6, |
| 77 | 7, 8, 9, 10, 12, 13, 15, 17, 20, 22, | 77 | 7, 8, 9, 10, 12, 13, 15, 17, 20, 22, |
| 78 | 25, 28, 32, 36, 40, 45, 50, 56, 63, 71, | 78 | 25, 28, 32, 36, 40, 45, 50, 56, 63, 71, |
| 79 | 80, 90,101,113,127,144,162,182,203,226, | 79 | 80, 90, 101, 113, 127, 144, 162, 182, 203, 226, |
| 80 | 255, 255 | 80 | 255, 255 |
| 81 | ,255, 255,255, 255,255, 255,255, 255,255, 255,255, 255 | 81 | , 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 |
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | static const int8_t g_kiBetaTable[52+12] = { //this table refers to Table 8-16 in H.264/AVC standard | 84 | static const int8_t g_kiBetaTable[52 + 12] = { //this table refers to Table 8-16 in H.264/AVC standard |
| 85 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | 85 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 86 | 0, 0, 0, 0, 0, 0, 2, 2, 2, 3, | 86 | 0, 0, 0, 0, 0, 0, 2, 2, 2, 3, |
| 87 | 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, | 87 | 3, 3, 3, 4, 4, 4, 6, 6, 7, 7, |
| 88 | 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, | 88 | 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, |
| 89 | 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, | 89 | 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, |
| 90 | 18, 18 | 90 | 18, 18 |
| 91 | ,18, 18,18, 18,18, 18,18, 18,18, 18,18, 18 | 91 | , 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18 |
| 92 | }; | 92 | }; |
| 93 | 93 | ||
| 94 | static const int8_t g_kiTc0Table[52+12][4] = { //this table refers Table 8-17 in H.264/AVC standard | 94 | static const int8_t g_kiTc0Table[52 + 12][4] = { //this table refers Table 8-17 in H.264/AVC standard |
| 95 | { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, | 95 | { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, |
| 96 | { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, | 96 | { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, |
| 97 | { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 1 }, | 97 | { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 0 }, { -1, 0, 0, 1 }, |
| 98 | { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 1, 1 }, { -1, 0, 1, 1 }, { -1, 1, 1, 1 }, | 98 | { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 0, 1 }, { -1, 0, 1, 1 }, { -1, 0, 1, 1 }, { -1, 1, 1, 1 }, |
| 99 | { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 }, | 99 | { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 1 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 }, { -1, 1, 1, 2 }, |
| 100 | { -1, 1, 1, 2 }, { -1, 1, 2, 3 }, { -1, 1, 2, 3 }, { -1, 2, 2, 3 }, { -1, 2, 2, 4 }, { -1, 2, 3, 4 }, | 100 | { -1, 1, 1, 2 }, { -1, 1, 2, 3 }, { -1, 1, 2, 3 }, { -1, 2, 2, 3 }, { -1, 2, 2, 4 }, { -1, 2, 3, 4 }, |
| 101 | { -1, 2, 3, 4 }, { -1, 3, 3, 5 }, { -1, 3, 4, 6 }, { -1, 3, 4, 6 }, { -1, 4, 5, 7 }, { -1, 4, 5, 8 }, | 101 | { -1, 2, 3, 4 }, { -1, 3, 3, 5 }, { -1, 3, 4, 6 }, { -1, 3, 4, 6 }, { -1, 4, 5, 7 }, { -1, 4, 5, 8 }, |
| 102 | { -1, 4, 6, 9 }, { -1, 5, 7,10 }, { -1, 6, 8,11 }, { -1, 6, 8,13 }, { -1, 7,10,14 }, { -1, 8,11,16 }, | 102 | { -1, 4, 6, 9 }, { -1, 5, 7, 10 }, { -1, 6, 8, 11 }, { -1, 6, 8, 13 }, { -1, 7, 10, 14 }, { -1, 8, 11, 16 }, |
| 103 | { -1, 9,12,18 }, { -1, 10,13,20 }, {-1,11,15,23 }, { -1,13,17,25 } | 103 | { -1, 9, 12, 18 }, { -1, 10, 13, 20 }, { -1, 11, 15, 23 }, { -1, 13, 17, 25 } |
| 104 | ,{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 } | 104 | , { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 } |
| 105 | ,{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 },{ -1,13,17,25 } | 105 | , { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 }, { -1, 13, 17, 25 } |
| 106 | }; | 106 | }; |
| 107 | 107 | ||
| 108 | static const uint8_t g_kuiTableBIdx[2][8] = | 108 | static const uint8_t g_kuiTableBIdx[2][8] = { |
| 109 | { | 109 | { |
| 110 | {0, 4, 8, 12, // g_kuiTableBIdx | 110 | 0, 4, 8, 12, // g_kuiTableBIdx |
| 111 | 3, 7, 11, 15}, // table_bn_idx | 111 | 3, 7, 11, 15 |
| 112 | 112 | }, // table_bn_idx | |
| 113 | {0, 1, 2, 3 , // g_kuiTableBIdx | 113 | |
| 114 | 12, 13, 14, 15}, // table_bn_idx | 114 | { |
| 115 | }; | 115 | 0, 1, 2, 3 , // g_kuiTableBIdx |
| 116 | 116 | 12, 13, 14, 15 | |
| 117 | static const ALIGNED_DECLARE(int32_t,g_kiTableBlock8x8Idx[2][4][4],16) = | 117 | }, // table_bn_idx |
| 118 | { | 118 | }; |
| 119 | {0, 0, 2, 2, | 119 | |
| 120 | 0, 0, 2, 2, | 120 | static const ALIGNED_DECLARE (int32_t, g_kiTableBlock8x8Idx[2][4][4], 16) = { |
| 121 | 1, 1, 3, 3, | 121 | { |
| 122 | 1, 1, 3, 3}, | 122 | 0, 0, 2, 2, |
| 123 | 123 | 0, 0, 2, 2, | |
| 124 | {0, 0, 1, 1, | 124 | 1, 1, 3, 3, |
| 125 | 0, 0, 1, 1, | 125 | 1, 1, 3, 3 |
| 126 | 2, 2, 3, 3, | 126 | }, |
| 127 | 2, 2, 3, 3} | 127 | |
| 128 | }; | 128 | { |
| 129 | static const ALIGNED_DECLARE(int32_t,g_kiTableBlock8x8NIdx[2][4][4],16) = | 129 | 0, 0, 1, 1, |
| 130 | { | 130 | 0, 0, 1, 1, |
| 131 | {1, 1, 3, 3, | 131 | 2, 2, 3, 3, |
| 132 | 0, 0, 2, 2, | 132 | 2, 2, 3, 3 |
| 133 | 0, 0, 2, 2, | 133 | } |
| 134 | 1, 1, 3, 3}, | 134 | }; |
| 135 | 135 | static const ALIGNED_DECLARE (int32_t, g_kiTableBlock8x8NIdx[2][4][4], 16) = { | |
| 136 | {2, 2, 3, 3, | 136 | { |
| 137 | 0, 0, 1, 1, | 137 | 1, 1, 3, 3, |
| 138 | 0, 0, 1, 1, | 138 | 0, 0, 2, 2, |
| 139 | 2, 2, 3, 3} | 139 | 0, 0, 2, 2, |
| 140 | }; | 140 | 1, 1, 3, 3 |
| 141 | 141 | }, | |
| 142 | #define TC0_TBL_LOOKUP(iTc, iIdexA, pBS, bchroma) \ | 142 | |
| 143 | {\ | 143 | { |
| 144 | iTc[0] = g_kiTc0Table(iIdexA)[pBS[0]] + bchroma;\ | 144 | 2, 2, 3, 3, |
| 145 | iTc[1] = g_kiTc0Table(iIdexA)[pBS[1]] + bchroma;\ | 145 | 0, 0, 1, 1, |
| 146 | iTc[2] = g_kiTc0Table(iIdexA)[pBS[2]] + bchroma;\ | 146 | 0, 0, 1, 1, |
| 147 | iTc[3] = g_kiTc0Table(iIdexA)[pBS[3]] + bchroma;\ | 147 | 2, 2, 3, 3 |
| 148 | } | 148 | } |
| 149 | 149 | }; | |
| 150 | void inline DeblockingBSInsideMBAvsbase( int8_t* pNnzTab, uint8_t uiBS[2][4][4], int32_t iLShiftFactor ) | 150 | |
| 151 | { | 151 | #define TC0_TBL_LOOKUP(iTc, iIdexA, pBS, bchroma) \ |
| 152 | uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | 152 | {\ |
| 153 | ENFORCE_STACK_ALIGN_1D( uint8_t, uiBsx3, 4, 4 ); | 153 | iTc[0] = g_kiTc0Table(iIdexA)[pBS[0]] + bchroma;\ |
| 154 | 154 | iTc[1] = g_kiTc0Table(iIdexA)[pBS[1]] + bchroma;\ | |
| 155 | uiNnz32b0 = *(uint32_t *)(pNnzTab+0); | 155 | iTc[2] = g_kiTc0Table(iIdexA)[pBS[2]] + bchroma;\ |
| 156 | uiNnz32b1 = *(uint32_t *)(pNnzTab+4); | 156 | iTc[3] = g_kiTc0Table(iIdexA)[pBS[3]] + bchroma;\ |
| 157 | uiNnz32b2 = *(uint32_t *)(pNnzTab+8); | 157 | } |
| 158 | uiNnz32b3 = *(uint32_t *)(pNnzTab+12); | 158 | |
| 159 | 159 | void inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t uiBS[2][4][4], int32_t iLShiftFactor) { | |
| 160 | *(uint32_t *)uiBsx3 = (uiNnz32b0|(uiNnz32b0>>8))<<iLShiftFactor; | 160 | uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; |
| 161 | uiBS[0][1][0] = uiBsx3[0]; | 161 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx3, 4, 4); |
| 162 | uiBS[0][2][0] = uiBsx3[1]; | 162 | |
| 163 | uiBS[0][3][0] = uiBsx3[2]; | 163 | uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); |
| 164 | 164 | uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | |
| 165 | *(uint32_t *)uiBsx3 = (uiNnz32b1|(uiNnz32b1>>8))<<iLShiftFactor; | 165 | uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); |
| 166 | uiBS[0][1][1] = uiBsx3[0]; | 166 | uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); |
| 167 | uiBS[0][2][1] = uiBsx3[1]; | 167 | |
| 168 | uiBS[0][3][1] = uiBsx3[2]; | 168 | * (uint32_t*)uiBsx3 = (uiNnz32b0 | (uiNnz32b0 >> 8)) << iLShiftFactor; |
| 169 | *(uint32_t *)uiBS[1][1] = (uiNnz32b0|uiNnz32b1)<<iLShiftFactor; | 169 | uiBS[0][1][0] = uiBsx3[0]; |
| 170 | 170 | uiBS[0][2][0] = uiBsx3[1]; | |
| 171 | *(uint32_t *)uiBsx3 = (uiNnz32b2|(uiNnz32b2>>8))<<iLShiftFactor; | 171 | uiBS[0][3][0] = uiBsx3[2]; |
| 172 | uiBS[0][1][2] = uiBsx3[0]; | 172 | |
| 173 | uiBS[0][2][2] = uiBsx3[1]; | 173 | * (uint32_t*)uiBsx3 = (uiNnz32b1 | (uiNnz32b1 >> 8)) << iLShiftFactor; |
| 174 | uiBS[0][3][2] = uiBsx3[2]; | 174 | uiBS[0][1][1] = uiBsx3[0]; |
| 175 | *(uint32_t *)uiBS[1][2] = (uiNnz32b1|uiNnz32b2)<<iLShiftFactor; | 175 | uiBS[0][2][1] = uiBsx3[1]; |
| 176 | 176 | uiBS[0][3][1] = uiBsx3[2]; | |
| 177 | *(uint32_t *)uiBsx3 = (uiNnz32b3|(uiNnz32b3>>8))<<iLShiftFactor; | 177 | * (uint32_t*)uiBS[1][1] = (uiNnz32b0 | uiNnz32b1) << iLShiftFactor; |
| 178 | uiBS[0][1][3] = uiBsx3[0]; | 178 | |
| 179 | uiBS[0][2][3] = uiBsx3[1]; | 179 | * (uint32_t*)uiBsx3 = (uiNnz32b2 | (uiNnz32b2 >> 8)) << iLShiftFactor; |
| 180 | uiBS[0][3][3] = uiBsx3[2]; | 180 | uiBS[0][1][2] = uiBsx3[0]; |
| 181 | *(uint32_t *)uiBS[1][3] = (uiNnz32b2|uiNnz32b3)<<iLShiftFactor; | 181 | uiBS[0][2][2] = uiBsx3[1]; |
| 182 | 182 | uiBS[0][3][2] = uiBsx3[2]; | |
| 183 | } | 183 | * (uint32_t*)uiBS[1][2] = (uiNnz32b1 | uiNnz32b2) << iLShiftFactor; |
| 184 | 184 | ||
| 185 | void inline DeblockingBSInsideMBNormal( SMB* pCurMb, uint8_t uiBS[2][4][4], int8_t* pNnzTab ) | 185 | * (uint32_t*)uiBsx3 = (uiNnz32b3 | (uiNnz32b3 >> 8)) << iLShiftFactor; |
| 186 | { | 186 | uiBS[0][1][3] = uiBsx3[0]; |
| 187 | uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | 187 | uiBS[0][2][3] = uiBsx3[1]; |
| 188 | ENFORCE_STACK_ALIGN_1D( uint8_t, uiBsx4, 4, 4 ); | 188 | uiBS[0][3][3] = uiBsx3[2]; |
| 189 | 189 | * (uint32_t*)uiBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor; | |
| 190 | uiNnz32b0 = *(uint32_t *)(pNnzTab+0); | 190 | |
| 191 | uiNnz32b1 = *(uint32_t *)(pNnzTab+4); | 191 | } |
| 192 | uiNnz32b2 = *(uint32_t *)(pNnzTab+8); | 192 | |
| 193 | uiNnz32b3 = *(uint32_t *)(pNnzTab+12); | 193 | void inline DeblockingBSInsideMBNormal (SMB* pCurMb, uint8_t uiBS[2][4][4], int8_t* pNnzTab) { |
| 194 | 194 | uint32_t uiNnz32b0, uiNnz32b1, uiNnz32b2, uiNnz32b3; | |
| 195 | *(uint32_t *)uiBsx4 = (uiNnz32b0|(uiNnz32b0>>8)); | 195 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); |
| 196 | uiBS[0][1][0] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 1, 0); | 196 | |
| 197 | uiBS[0][2][0] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 2, 1); | 197 | uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); |
| 198 | uiBS[0][3][0] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 3, 2); | 198 | uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); |
| 199 | 199 | uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | |
| 200 | *(uint32_t *)uiBsx4 = (uiNnz32b1|(uiNnz32b1>>8)); | 200 | uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); |
| 201 | uiBS[0][1][1] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 5, 4); | 201 | |
| 202 | uiBS[0][2][1] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 6, 5); | 202 | * (uint32_t*)uiBsx4 = (uiNnz32b0 | (uiNnz32b0 >> 8)); |
| 203 | uiBS[0][3][1] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 7, 6); | 203 | uiBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 1, 0); |
| 204 | 204 | uiBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 2, 1); | |
| 205 | *(uint32_t *)uiBsx4 = (uiNnz32b2|(uiNnz32b2>>8)); | 205 | uiBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 3, 2); |
| 206 | uiBS[0][1][2] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 9, 8); | 206 | |
| 207 | uiBS[0][2][2] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 10,9); | 207 | * (uint32_t*)uiBsx4 = (uiNnz32b1 | (uiNnz32b1 >> 8)); |
| 208 | uiBS[0][3][2] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 11,10); | 208 | uiBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 5, 4); |
| 209 | 209 | uiBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 6, 5); | |
| 210 | *(uint32_t *)uiBsx4 = (uiNnz32b3|(uiNnz32b3>>8)); | 210 | uiBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 7, 6); |
| 211 | uiBS[0][1][3] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 13,12); | 211 | |
| 212 | uiBS[0][2][3] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 14,13); | 212 | * (uint32_t*)uiBsx4 = (uiNnz32b2 | (uiNnz32b2 >> 8)); |
| 213 | uiBS[0][3][3] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 15,14); | 213 | uiBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 9, 8); |
| 214 | 214 | uiBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 10, 9); | |
| 215 | //horizontal | 215 | uiBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 11, 10); |
| 216 | *(uint32_t *)uiBsx4 = (uiNnz32b0|uiNnz32b1); | 216 | |
| 217 | uiBS[1][1][0] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 4, 0); | 217 | * (uint32_t*)uiBsx4 = (uiNnz32b3 | (uiNnz32b3 >> 8)); |
| 218 | uiBS[1][1][1] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 5, 1); | 218 | uiBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 13, 12); |
| 219 | uiBS[1][1][2] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 6, 2); | 219 | uiBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 14, 13); |
| 220 | uiBS[1][1][3] = BS_EDGE(uiBsx4[3], iRefIdx, pCurMb->sMv, 7, 3); | 220 | uiBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 15, 14); |
| 221 | 221 | ||
| 222 | *(uint32_t *)uiBsx4 = (uiNnz32b1|uiNnz32b2); | 222 | //horizontal |
| 223 | uiBS[1][2][0] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 8, 4); | 223 | * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1); |
| 224 | uiBS[1][2][1] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 9, 5); | 224 | uiBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 4, 0); |
| 225 | uiBS[1][2][2] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 10, 6); | 225 | uiBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 5, 1); |
| 226 | uiBS[1][2][3] = BS_EDGE(uiBsx4[3], iRefIdx, pCurMb->sMv, 11, 7); | 226 | uiBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 6, 2); |
| 227 | 227 | uiBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIdx, pCurMb->sMv, 7, 3); | |
| 228 | *(uint32_t *)uiBsx4 = (uiNnz32b2|uiNnz32b3); | 228 | |
| 229 | uiBS[1][3][0] = BS_EDGE(uiBsx4[0], iRefIdx, pCurMb->sMv, 12, 8); | 229 | * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2); |
| 230 | uiBS[1][3][1] = BS_EDGE(uiBsx4[1], iRefIdx, pCurMb->sMv, 13, 9); | 230 | uiBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 8, 4); |
| 231 | uiBS[1][3][2] = BS_EDGE(uiBsx4[2], iRefIdx, pCurMb->sMv, 14, 10); | 231 | uiBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 9, 5); |
| 232 | uiBS[1][3][3] = BS_EDGE(uiBsx4[3], iRefIdx, pCurMb->sMv, 15, 11); | 232 | uiBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 10, 6); |
| 233 | } | 233 | uiBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIdx, pCurMb->sMv, 11, 7); |
| 234 | 234 | ||
| 235 | uint32_t DeblockingBSMarginalMBAvcbase( SMB* pCurMb, SMB* pNeighMb, int32_t iEdge) | 235 | * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3); |
| 236 | { | 236 | uiBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIdx, pCurMb->sMv, 12, 8); |
| 237 | int32_t i; | 237 | uiBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIdx, pCurMb->sMv, 13, 9); |
| 238 | uint32_t uiBSx4; | 238 | uiBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIdx, pCurMb->sMv, 14, 10); |
| 239 | uint8_t* pBS = (uint8_t*)(&uiBSx4); | 239 | uiBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIdx, pCurMb->sMv, 15, 11); |
| 240 | uint32_t uiBIdx = *(uint32_t *)(&g_kuiTableBIdx[iEdge][0]); | 240 | } |
| 241 | uint32_t uiBnIdx = *(uint32_t *)(&g_kuiTableBIdx[iEdge][4]); | 241 | |
| 242 | 242 | uint32_t DeblockingBSMarginalMBAvcbase (SMB* pCurMb, SMB* pNeighMb, int32_t iEdge) { | |
| 243 | for( i = 0; i < 4; i++ ) | 243 | int32_t i; |
| 244 | { | 244 | uint32_t uiBSx4; |
| 245 | if (pCurMb->pNonZeroCount[uiBIdx&0xff] | pNeighMb->pNonZeroCount[uiBnIdx&0xff]) | 245 | uint8_t* pBS = (uint8_t*) (&uiBSx4); |
| 246 | { | 246 | uint32_t uiBIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][0]); |
| 247 | pBS[i] = 2; | 247 | uint32_t uiBnIdx = * (uint32_t*) (&g_kuiTableBIdx[iEdge][4]); |
| 248 | } | 248 | |
| 249 | else | 249 | for (i = 0; i < 4; i++) { |
| 250 | { | 250 | if (pCurMb->pNonZeroCount[uiBIdx & 0xff] | pNeighMb->pNonZeroCount[uiBnIdx & 0xff]) { |
| 251 | pBS[i] = | 251 | pBS[i] = 2; |
| 252 | #ifndef SINGLE_REF_FRAME | 252 | } else { |
| 253 | (pCurMb->uiRefIndex[g_kiTableBlock8x8Idx[1][iEdge][i]] - pNeighMb->uiRefIndex[g_kiTableBlock8x8NIdx[1][iEdge][i]]) || | 253 | pBS[i] = |
| 254 | #endif | 254 | #ifndef SINGLE_REF_FRAME |
| 255 | MB_BS_MV(pCurMb->sMv, pNeighMb->sMv, (uiBIdx&0xff), (uiBnIdx&0xff)); | 255 | (pCurMb->uiRefIndex[g_kiTableBlock8x8Idx[1][iEdge][i]] - pNeighMb->uiRefIndex[g_kiTableBlock8x8NIdx[1][iEdge][i]]) || |
| 256 | } | 256 | #endif |
| 257 | uiBIdx = uiBIdx >> 8; | 257 | MB_BS_MV (pCurMb->sMv, pNeighMb->sMv, (uiBIdx & 0xff), (uiBnIdx & 0xff)); |
| 258 | uiBnIdx = uiBnIdx >> 8; | 258 | } |
| 259 | } | 259 | uiBIdx = uiBIdx >> 8; |
| 260 | return uiBSx4; | 260 | uiBnIdx = uiBnIdx >> 8; |
| 261 | } | 261 | } |
| 262 | 262 | return uiBSx4; | |
| 263 | void FilteringEdgeLumaH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS ) | 263 | } |
| 264 | { | 264 | |
| 265 | int32_t iIdexA; | 265 | void FilteringEdgeLumaH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, |
| 266 | int32_t iAlpha; | 266 | uint8_t* pBS) { |
| 267 | int32_t iBeta; | 267 | int32_t iIdexA; |
| 268 | ENFORCE_STACK_ALIGN_1D( int8_t, iTc, 4, 16 ); | 268 | int32_t iAlpha; |
| 269 | 269 | int32_t iBeta; | |
| 270 | GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 270 | ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); |
| 271 | 271 | ||
| 272 | if( iAlpha | iBeta ) | 272 | GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 273 | { | 273 | iBeta); |
| 274 | TC0_TBL_LOOKUP(iTc, iIdexA, pBS, 0); | 274 | |
| 275 | pfDeblocking->pfLumaDeblockingLT4Ver(pPix, iStride, iAlpha, iBeta, iTc); | 275 | if (iAlpha | iBeta) { |
| 276 | } | 276 | TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 0); |
| 277 | return; | 277 | pfDeblocking->pfLumaDeblockingLT4Ver (pPix, iStride, iAlpha, iBeta, iTc); |
| 278 | } | 278 | } |
| 279 | void FilteringEdgeLumaV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, uint8_t* pBS ) | 279 | return; |
| 280 | { | 280 | } |
| 281 | int32_t iIdexA; | 281 | void FilteringEdgeLumaV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, |
| 282 | int32_t iAlpha; | 282 | uint8_t* pBS) { |
| 283 | int32_t iBeta; | 283 | int32_t iIdexA; |
| 284 | ENFORCE_STACK_ALIGN_1D( int8_t, iTc, 4, 16 ); | 284 | int32_t iAlpha; |
| 285 | 285 | int32_t iBeta; | |
| 286 | GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 286 | ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); |
| 287 | 287 | ||
| 288 | if( iAlpha | iBeta ) | 288 | GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 289 | { | 289 | iBeta); |
| 290 | TC0_TBL_LOOKUP(iTc, iIdexA, pBS, 0); | 290 | |
| 291 | pfDeblocking->pfLumaDeblockingLT4Hor(pPix, iStride, iAlpha, iBeta, iTc); | 291 | if (iAlpha | iBeta) { |
| 292 | } | 292 | TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 0); |
| 293 | return; | 293 | pfDeblocking->pfLumaDeblockingLT4Hor (pPix, iStride, iAlpha, iBeta, iTc); |
| 294 | } | 294 | } |
| 295 | 295 | return; | |
| 296 | void FilteringEdgeLumaIntraH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,uint8_t* pBS ) | 296 | } |
| 297 | { | 297 | |
| 298 | int32_t iIdexA; | 298 | void FilteringEdgeLumaIntraH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, |
| 299 | int32_t iAlpha; | 299 | uint8_t* pBS) { |
| 300 | int32_t iBeta; | 300 | int32_t iIdexA; |
| 301 | 301 | int32_t iAlpha; | |
| 302 | GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 302 | int32_t iBeta; |
| 303 | 303 | ||
| 304 | if( iAlpha | iBeta ) | 304 | GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 305 | { | 305 | iBeta); |
| 306 | pfDeblocking->pfLumaDeblockingEQ4Ver(pPix, iStride, iAlpha, iBeta); | 306 | |
| 307 | } | 307 | if (iAlpha | iBeta) { |
| 308 | return; | 308 | pfDeblocking->pfLumaDeblockingEQ4Ver (pPix, iStride, iAlpha, iBeta); |
| 309 | } | 309 | } |
| 310 | 310 | return; | |
| 311 | void FilteringEdgeLumaIntraV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride,uint8_t* pBS) | 311 | } |
| 312 | { | 312 | |
| 313 | int32_t iIdexA; | 313 | void FilteringEdgeLumaIntraV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPix, int32_t iStride, |
| 314 | int32_t iAlpha; | 314 | uint8_t* pBS) { |
| 315 | int32_t iBeta; | 315 | int32_t iIdexA; |
| 316 | 316 | int32_t iAlpha; | |
| 317 | GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 317 | int32_t iBeta; |
| 318 | 318 | ||
| 319 | if( iAlpha | iBeta ) | 319 | GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 320 | { | 320 | iBeta); |
| 321 | pfDeblocking->pfLumaDeblockingEQ4Hor(pPix, iStride, iAlpha, iBeta); | 321 | |
| 322 | } | 322 | if (iAlpha | iBeta) { |
| 323 | return; | 323 | pfDeblocking->pfLumaDeblockingEQ4Hor (pPix, iStride, iAlpha, iBeta); |
| 324 | } | 324 | } |
| 325 | void FilteringEdgeChromaH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS ) | 325 | return; |
| 326 | { | 326 | } |
| 327 | int32_t iIdexA; | 327 | void FilteringEdgeChromaH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, |
| 328 | int32_t iAlpha; | 328 | int32_t iStride, uint8_t* pBS) { |
| 329 | int32_t iBeta; | 329 | int32_t iIdexA; |
| 330 | ENFORCE_STACK_ALIGN_1D( int8_t, iTc, 4, 16 ); | 330 | int32_t iAlpha; |
| 331 | 331 | int32_t iBeta; | |
| 332 | GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 332 | ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); |
| 333 | 333 | ||
| 334 | if( iAlpha | iBeta ) | 334 | GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 335 | { | 335 | iBeta); |
| 336 | TC0_TBL_LOOKUP(iTc, iIdexA, pBS, 1); | 336 | |
| 337 | pfDeblocking->pfChromaDeblockingLT4Ver(pPixCb, pPixCr, iStride,iAlpha, iBeta, iTc); | 337 | if (iAlpha | iBeta) { |
| 338 | } | 338 | TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 1); |
| 339 | return; | 339 | pfDeblocking->pfChromaDeblockingLT4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta, iTc); |
| 340 | } | 340 | } |
| 341 | void FilteringEdgeChromaV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS ) | 341 | return; |
| 342 | { | 342 | } |
| 343 | int32_t iIdexA; | 343 | void FilteringEdgeChromaV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, |
| 344 | int32_t iAlpha; | 344 | int32_t iStride, uint8_t* pBS) { |
| 345 | int32_t iBeta; | 345 | int32_t iIdexA; |
| 346 | ENFORCE_STACK_ALIGN_1D( int8_t, iTc, 4, 16 ); | 346 | int32_t iAlpha; |
| 347 | 347 | int32_t iBeta; | |
| 348 | GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 348 | ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); |
| 349 | 349 | ||
| 350 | if( iAlpha | iBeta ) | 350 | GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 351 | { | 351 | iBeta); |
| 352 | TC0_TBL_LOOKUP(iTc, iIdexA, pBS, 1); | 352 | |
| 353 | pfDeblocking->pfChromaDeblockingLT4Hor(pPixCb, pPixCr, iStride, iAlpha, iBeta, iTc); | 353 | if (iAlpha | iBeta) { |
| 354 | } | 354 | TC0_TBL_LOOKUP (iTc, iIdexA, pBS, 1); |
| 355 | return; | 355 | pfDeblocking->pfChromaDeblockingLT4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta, iTc); |
| 356 | } | 356 | } |
| 357 | 357 | return; | |
| 358 | void FilteringEdgeChromaIntraH( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS ) | 358 | } |
| 359 | { | 359 | |
| 360 | int32_t iIdexA; | 360 | void FilteringEdgeChromaIntraH (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, |
| 361 | int32_t iAlpha; | 361 | uint8_t* pPixCr, int32_t iStride, uint8_t* pBS) { |
| 362 | int32_t iBeta; | 362 | int32_t iIdexA; |
| 363 | 363 | int32_t iAlpha; | |
| 364 | GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 364 | int32_t iBeta; |
| 365 | 365 | ||
| 366 | if( iAlpha | iBeta ) | 366 | GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 367 | { | 367 | iBeta); |
| 368 | pfDeblocking->pfChromaDeblockingEQ4Ver(pPixCb, pPixCr, iStride, iAlpha, iBeta); | 368 | |
| 369 | } | 369 | if (iAlpha | iBeta) { |
| 370 | return; | 370 | pfDeblocking->pfChromaDeblockingEQ4Ver (pPixCb, pPixCr, iStride, iAlpha, iBeta); |
| 371 | } | 371 | } |
| 372 | 372 | return; | |
| 373 | void FilteringEdgeChromaIntraV( DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, uint8_t* pBS ) | 373 | } |
| 374 | { | 374 | |
| 375 | int32_t iIdexA; | 375 | void FilteringEdgeChromaIntraV (DeblockingFunc* pfDeblocking, SDeblockingFilter* pFilter, uint8_t* pPixCb, |
| 376 | int32_t iAlpha; | 376 | uint8_t* pPixCr, int32_t iStride, uint8_t* pBS) { |
| 377 | int32_t iBeta; | 377 | int32_t iIdexA; |
| 378 | 378 | int32_t iAlpha; | |
| 379 | GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 379 | int32_t iBeta; |
| 380 | 380 | ||
| 381 | if( iAlpha | iBeta ) | 381 | GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 382 | { | 382 | iBeta); |
| 383 | pfDeblocking->pfChromaDeblockinEQ4Hor(pPixCb, pPixCr, iStride, iAlpha, iBeta); | 383 | |
| 384 | } | 384 | if (iAlpha | iBeta) { |
| 385 | return; | 385 | pfDeblocking->pfChromaDeblockinEQ4Hor (pPixCb, pPixCr, iStride, iAlpha, iBeta); |
| 386 | } | 386 | } |
| 387 | 387 | return; | |
| 388 | void DeblockingInterMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter, uint8_t uiBS[2][4][4] ) | 388 | } |
| 389 | { | 389 | |
| 390 | int8_t iCurLumaQp = pCurMb->uiLumaQp; | 390 | void DeblockingInterMb (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter, uint8_t uiBS[2][4][4]) { |
| 391 | int8_t iCurChromaQp = pCurMb->uiChromaQp; | 391 | int8_t iCurLumaQp = pCurMb->uiLumaQp; |
| 392 | int32_t iLineSize = pFilter->iCsStride[0]; | 392 | int8_t iCurChromaQp = pCurMb->uiChromaQp; |
| 393 | int32_t iLineSizeUV = pFilter->iCsStride[1]; | 393 | int32_t iLineSize = pFilter->iCsStride[0]; |
| 394 | int32_t iMbStride = pFilter->iMbStride; | 394 | int32_t iLineSizeUV = pFilter->iCsStride[1]; |
| 395 | 395 | int32_t iMbStride = pFilter->iMbStride; | |
| 396 | int32_t iMbX = pCurMb->iMbX; | 396 | |
| 397 | int32_t iMbY = pCurMb->iMbY; | 397 | int32_t iMbX = pCurMb->iMbX; |
| 398 | 398 | int32_t iMbY = pCurMb->iMbY; | |
| 399 | BOOL_T bLeftBsValid[2] = {(iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | 399 | |
| 400 | BOOL_T bTopBsValid[2] = {(iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | 400 | BOOL_T bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; |
| 401 | 401 | BOOL_T bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | |
| 402 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; | 402 | |
| 403 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; | 403 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 404 | 404 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; | |
| 405 | uint8_t *pDestY, *pDestCb, *pDestCr; | 405 | |
| 406 | pDestY = pFilter->pCsData[0]; | 406 | uint8_t* pDestY, *pDestCb, *pDestCr; |
| 407 | pDestCb = pFilter->pCsData[1]; | 407 | pDestY = pFilter->pCsData[0]; |
| 408 | pDestCr = pFilter->pCsData[2]; | 408 | pDestCb = pFilter->pCsData[1]; |
| 409 | 409 | pDestCr = pFilter->pCsData[2]; | |
| 410 | if (iLeftFlag) | 410 | |
| 411 | { | 411 | if (iLeftFlag) { |
| 412 | pFilter->uiLumaQP = (iCurLumaQp + (pCurMb-1)->uiLumaQp + 1) >> 1; | 412 | pFilter->uiLumaQP = (iCurLumaQp + (pCurMb - 1)->uiLumaQp + 1) >> 1; |
| 413 | pFilter->uiChromaQP = (iCurChromaQp + (pCurMb-1)->uiChromaQp+ 1) >> 1; | 413 | pFilter->uiChromaQP = (iCurChromaQp + (pCurMb - 1)->uiChromaQp + 1) >> 1; |
| 414 | 414 | ||
| 415 | if( uiBS[0][0][0] == 0x04 ) | 415 | if (uiBS[0][0][0] == 0x04) { |
| 416 | { | 416 | FilteringEdgeLumaIntraV (pfDeblocking, pFilter, pDestY, iLineSize , NULL); |
| 417 | FilteringEdgeLumaIntraV( pfDeblocking, pFilter, pDestY, iLineSize ,NULL); | 417 | FilteringEdgeChromaIntraV (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, NULL); |
| 418 | FilteringEdgeChromaIntraV( pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, NULL ); | 418 | } else { |
| 419 | } | 419 | if (* (uint32_t*)uiBS[0][0] != 0) { |
| 420 | else | 420 | FilteringEdgeLumaV (pfDeblocking, pFilter, pDestY, iLineSize, uiBS[0][0]); |
| 421 | { | 421 | FilteringEdgeChromaV (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, uiBS[0][0]); |
| 422 | if(*(uint32_t *)uiBS[0][0] != 0) | 422 | } |
| 423 | { | 423 | } |
| 424 | FilteringEdgeLumaV( pfDeblocking, pFilter, pDestY, iLineSize, uiBS[0][0] ); | 424 | } |
| 425 | FilteringEdgeChromaV( pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, uiBS[0][0] ); | 425 | |
| 426 | } | 426 | pFilter->uiLumaQP = iCurLumaQp; |
| 427 | } | 427 | pFilter->uiChromaQP = iCurChromaQp; |
| 428 | } | 428 | |
| 429 | 429 | if (* (uint32_t*)uiBS[0][1] != 0) { | |
| 430 | pFilter->uiLumaQP = iCurLumaQp; | 430 | FilteringEdgeLumaV (pfDeblocking, pFilter, &pDestY[1 << 2], iLineSize, uiBS[0][1]); |
| 431 | pFilter->uiChromaQP = iCurChromaQp; | 431 | } |
| 432 | 432 | ||
| 433 | if(*(uint32_t *)uiBS[0][1] != 0) | 433 | if (* (uint32_t*)uiBS[0][2] != 0) { |
| 434 | { | 434 | FilteringEdgeLumaV (pfDeblocking, pFilter, &pDestY[2 << 2], iLineSize, uiBS[0][2]); |
| 435 | FilteringEdgeLumaV( pfDeblocking, pFilter, &pDestY[1<<2], iLineSize, uiBS[0][1]); | 435 | FilteringEdgeChromaV (pfDeblocking, pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, uiBS[0][2]); |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | if(*(uint32_t *)uiBS[0][2] != 0) | 438 | if (* (uint32_t*)uiBS[0][3] != 0) { |
| 439 | { | 439 | FilteringEdgeLumaV (pfDeblocking, pFilter, &pDestY[3 << 2], iLineSize, uiBS[0][3]); |
| 440 | FilteringEdgeLumaV( pfDeblocking, pFilter, &pDestY[2<<2], iLineSize, uiBS[0][2]); | 440 | } |
| 441 | FilteringEdgeChromaV( pfDeblocking, pFilter, &pDestCb[2<<1], &pDestCr[2<<1], iLineSizeUV, uiBS[0][2] ); | 441 | |
| 442 | } | 442 | if (iTopFlag) { |
| 443 | 443 | pFilter->uiLumaQP = (iCurLumaQp + (pCurMb - iMbStride)->uiLumaQp + 1) >> 1; | |
| 444 | if(*(uint32_t *)uiBS[0][3] != 0) | 444 | pFilter->uiChromaQP = (iCurChromaQp + (pCurMb - iMbStride)->uiChromaQp + 1) >> 1; |
| 445 | { | 445 | |
| 446 | FilteringEdgeLumaV( pfDeblocking, pFilter, &pDestY[3<<2], iLineSize, uiBS[0][3] ); | 446 | if (uiBS[1][0][0] == 0x04) { |
| 447 | } | 447 | FilteringEdgeLumaIntraH (pfDeblocking, pFilter, pDestY, iLineSize , NULL); |
| 448 | 448 | FilteringEdgeChromaIntraH (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, NULL); | |
| 449 | if (iTopFlag) | 449 | } else { |
| 450 | { | 450 | if (* (uint32_t*)uiBS[1][0] != 0) { |
| 451 | pFilter->uiLumaQP = (iCurLumaQp + (pCurMb-iMbStride)->uiLumaQp + 1) >> 1; | 451 | FilteringEdgeLumaH (pfDeblocking, pFilter, pDestY, iLineSize, uiBS[1][0]); |
| 452 | pFilter->uiChromaQP = (iCurChromaQp + (pCurMb-iMbStride)->uiChromaQp + 1) >> 1; | 452 | FilteringEdgeChromaH (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, uiBS[1][0]); |
| 453 | 453 | } | |
| 454 | if(uiBS[1][0][0] == 0x04) | 454 | } |
| 455 | { | 455 | } |
| 456 | FilteringEdgeLumaIntraH( pfDeblocking, pFilter, pDestY, iLineSize ,NULL); | 456 | |
| 457 | FilteringEdgeChromaIntraH( pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, NULL ); | 457 | pFilter->uiLumaQP = iCurLumaQp; |
| 458 | } | 458 | pFilter->uiChromaQP = iCurChromaQp; |
| 459 | else | 459 | |
| 460 | { | 460 | if (* (uint32_t*)uiBS[1][1] != 0) { |
| 461 | if(*(uint32_t *)uiBS[1][0] != 0) | 461 | FilteringEdgeLumaH (pfDeblocking, pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, uiBS[1][1]); |
| 462 | { | 462 | } |
| 463 | FilteringEdgeLumaH( pfDeblocking, pFilter, pDestY, iLineSize, uiBS[1][0] ); | 463 | |
| 464 | FilteringEdgeChromaH( pfDeblocking, pFilter, pDestCb, pDestCr, iLineSizeUV, uiBS[1][0] ); | 464 | if (* (uint32_t*)uiBS[1][2] != 0) { |
| 465 | } | 465 | FilteringEdgeLumaH (pfDeblocking, pFilter, &pDestY[ (2 << 2)*iLineSize], iLineSize, uiBS[1][2]); |
| 466 | } | 466 | FilteringEdgeChromaH (pfDeblocking, pFilter, &pDestCb[ (2 << 1)*iLineSizeUV], &pDestCr[ (2 << 1)*iLineSizeUV], |
| 467 | } | 467 | iLineSizeUV, uiBS[1][2]); |
| 468 | 468 | } | |
| 469 | pFilter->uiLumaQP = iCurLumaQp; | 469 | |
| 470 | pFilter->uiChromaQP = iCurChromaQp; | 470 | if (* (uint32_t*)uiBS[1][3] != 0) { |
| 471 | 471 | FilteringEdgeLumaH (pfDeblocking, pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, uiBS[1][3]); | |
| 472 | if(*(uint32_t *)uiBS[1][1] != 0) | 472 | } |
| 473 | { | 473 | } |
| 474 | FilteringEdgeLumaH( pfDeblocking, pFilter, &pDestY[(1<<2)*iLineSize], iLineSize, uiBS[1][1] ); | 474 | |
| 475 | } | 475 | void FilteringEdgeLumaHV (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter) { |
| 476 | 476 | int32_t iLineSize = pFilter->iCsStride[0]; | |
| 477 | if(*(uint32_t *)uiBS[1][2] != 0) | 477 | int32_t iMbStride = pFilter->iMbStride; |
| 478 | { | 478 | |
| 479 | FilteringEdgeLumaH( pfDeblocking, pFilter, &pDestY[(2<<2)*iLineSize], iLineSize, uiBS[1][2] ); | 479 | uint8_t* pDestY; |
| 480 | FilteringEdgeChromaH( pfDeblocking, pFilter, &pDestCb[(2<<1)*iLineSizeUV], &pDestCr[(2<<1)*iLineSizeUV], iLineSizeUV, uiBS[1][2] ); | 480 | int8_t iCurQp; |
| 481 | } | 481 | int32_t iIdexA, iAlpha, iBeta; |
| 482 | 482 | ||
| 483 | if(*(uint32_t *)uiBS[1][3] != 0) | 483 | int32_t iMbX = pCurMb->iMbX; |
| 484 | { | 484 | int32_t iMbY = pCurMb->iMbY; |
| 485 | FilteringEdgeLumaH( pfDeblocking, pFilter, &pDestY[(3<<2)*iLineSize], iLineSize, uiBS[1][3] ); | 485 | |
| 486 | } | 486 | BOOL_T bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; |
| 487 | } | 487 | BOOL_T bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; |
| 488 | 488 | ||
| 489 | void FilteringEdgeLumaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter ) | 489 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 490 | { | 490 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| 491 | int32_t iLineSize = pFilter->iCsStride[0]; | 491 | |
| 492 | int32_t iMbStride = pFilter->iMbStride; | 492 | ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); |
| 493 | 493 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4); | |
| 494 | uint8_t *pDestY; | 494 | |
| 495 | int8_t iCurQp; | 495 | pDestY = pFilter->pCsData[0]; |
| 496 | int32_t iIdexA, iAlpha, iBeta; | 496 | iCurQp = pCurMb->uiLumaQp; |
| 497 | 497 | ||
| 498 | int32_t iMbX = pCurMb->iMbX; | 498 | * (uint32_t*)uiBSx4 = 0x03030303; |
| 499 | int32_t iMbY = pCurMb->iMbY; | 499 | |
| 500 | 500 | // luma v | |
| 501 | BOOL_T bLeftBsValid[2] = {(iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | 501 | if (iLeftFlag) { |
| 502 | BOOL_T bTopBsValid[2] = {(iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | 502 | pFilter->uiLumaQP = (iCurQp + (pCurMb - 1)->uiLumaQp + 1) >> 1; |
| 503 | 503 | FilteringEdgeLumaIntraV (pfDeblocking, pFilter, pDestY, iLineSize, NULL); | |
| 504 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; | 504 | } |
| 505 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; | 505 | |
| 506 | 506 | pFilter->uiLumaQP = iCurQp; | |
| 507 | ENFORCE_STACK_ALIGN_1D(int8_t, iTc, 4, 16 ); | 507 | GET_ALPHA_BETA_FROM_QP (pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, |
| 508 | ENFORCE_STACK_ALIGN_1D(uint8_t, uiBSx4, 4, 4 ); | 508 | iBeta); |
| 509 | 509 | if (iAlpha | iBeta) { | |
| 510 | pDestY = pFilter->pCsData[0]; | 510 | TC0_TBL_LOOKUP (iTc, iIdexA, uiBSx4, 0); |
| 511 | iCurQp = pCurMb->uiLumaQp; | 511 | pfDeblocking->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc); |
| 512 | 512 | pfDeblocking->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc); | |
| 513 | *(uint32_t*)uiBSx4 = 0x03030303; | 513 | pfDeblocking->pfLumaDeblockingLT4Hor (&pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc); |
| 514 | 514 | ||
| 515 | // luma v | 515 | } |
| 516 | if (iLeftFlag) | 516 | |
| 517 | { | 517 | // luma h |
| 518 | pFilter->uiLumaQP = ( iCurQp + (pCurMb-1)->uiLumaQp + 1 ) >> 1; | 518 | if (iTopFlag) { |
| 519 | FilteringEdgeLumaIntraV( pfDeblocking, pFilter, pDestY, iLineSize,NULL ); | 519 | pFilter->uiLumaQP = (iCurQp + (pCurMb - iMbStride)->uiLumaQp + 1) >> 1; |
| 520 | } | 520 | FilteringEdgeLumaIntraH (pfDeblocking, pFilter, pDestY, iLineSize, NULL); |
| 521 | 521 | } | |
| 522 | pFilter->uiLumaQP = iCurQp; | 522 | |
| 523 | GET_ALPHA_BETA_FROM_QP(pFilter->uiLumaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 523 | pFilter->uiLumaQP = iCurQp; |
| 524 | if( iAlpha | iBeta ) | 524 | if (iAlpha | iBeta) { |
| 525 | { | 525 | pfDeblocking->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); |
| 526 | TC0_TBL_LOOKUP(iTc, iIdexA, uiBSx4, 0); | 526 | pfDeblocking->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); |
| 527 | pfDeblocking->pfLumaDeblockingLT4Hor( &pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc ); | 527 | pfDeblocking->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); |
| 528 | pfDeblocking->pfLumaDeblockingLT4Hor( &pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc ); | 528 | } |
| 529 | pfDeblocking->pfLumaDeblockingLT4Hor( &pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc ); | 529 | } |
| 530 | 530 | void FilteringEdgeChromaHV (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter) { | |
| 531 | } | 531 | int32_t iLineSize = pFilter->iCsStride[1]; |
| 532 | 532 | int32_t iMbStride = pFilter->iMbStride; | |
| 533 | // luma h | 533 | |
| 534 | if (iTopFlag) | 534 | uint8_t* pDestCb, *pDestCr; |
| 535 | { | 535 | int8_t iCurQp; |
| 536 | pFilter->uiLumaQP = ( iCurQp + (pCurMb-iMbStride)->uiLumaQp + 1 ) >> 1; | 536 | int32_t iIdexA, iAlpha, iBeta; |
| 537 | FilteringEdgeLumaIntraH( pfDeblocking, pFilter, pDestY, iLineSize,NULL ); | 537 | |
| 538 | } | 538 | int32_t iMbX = pCurMb->iMbX; |
| 539 | 539 | int32_t iMbY = pCurMb->iMbY; | |
| 540 | pFilter->uiLumaQP = iCurQp; | 540 | |
| 541 | if( iAlpha | iBeta ) | 541 | BOOL_T bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; |
| 542 | { | 542 | BOOL_T bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; |
| 543 | pfDeblocking->pfLumaDeblockingLT4Ver( &pDestY[(1<<2)*iLineSize],iLineSize,iAlpha, iBeta,iTc ); | 543 | |
| 544 | pfDeblocking->pfLumaDeblockingLT4Ver( &pDestY[(2<<2)*iLineSize],iLineSize,iAlpha, iBeta,iTc ); | 544 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 545 | pfDeblocking->pfLumaDeblockingLT4Ver( &pDestY[(3<<2)*iLineSize],iLineSize,iAlpha, iBeta,iTc ); | 545 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| 546 | } | 546 | |
| 547 | } | 547 | ENFORCE_STACK_ALIGN_1D (int8_t, iTc, 4, 16); |
| 548 | void FilteringEdgeChromaHV( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter ) | 548 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBSx4, 4, 4); |
| 549 | { | 549 | |
| 550 | int32_t iLineSize = pFilter->iCsStride[1]; | 550 | pDestCb = pFilter->pCsData[1]; |
| 551 | int32_t iMbStride = pFilter->iMbStride; | 551 | pDestCr = pFilter->pCsData[2]; |
| 552 | 552 | iCurQp = pCurMb->uiChromaQp; | |
| 553 | uint8_t *pDestCb, *pDestCr; | 553 | * (uint32_t*)uiBSx4 = 0x03030303; |
| 554 | int8_t iCurQp; | 554 | |
| 555 | int32_t iIdexA, iAlpha, iBeta; | 555 | // chroma v |
| 556 | 556 | if (iLeftFlag) { | |
| 557 | int32_t iMbX = pCurMb->iMbX; | 557 | pFilter->uiChromaQP = (iCurQp + (pCurMb - 1)->uiChromaQp + 1) >> 1; |
| 558 | int32_t iMbY = pCurMb->iMbY; | 558 | FilteringEdgeChromaIntraV (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSize, NULL); |
| 559 | 559 | } | |
| 560 | BOOL_T bLeftBsValid[2] = {(iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | 560 | |
| 561 | BOOL_T bTopBsValid[2] = {(iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | 561 | pFilter->uiChromaQP = iCurQp; |
| 562 | 562 | GET_ALPHA_BETA_FROM_QP (pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, | |
| 563 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; | 563 | iBeta); |
| 564 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; | 564 | if (iAlpha | iBeta) { |
| 565 | 565 | TC0_TBL_LOOKUP (iTc, iIdexA, uiBSx4, 1); | |
| 566 | ENFORCE_STACK_ALIGN_1D( int8_t, iTc, 4, 16 ); | 566 | pfDeblocking->pfChromaDeblockingLT4Hor (&pDestCb[2 << 1], &pDestCr[2 << 1], iLineSize, iAlpha, iBeta, iTc); |
| 567 | ENFORCE_STACK_ALIGN_1D( uint8_t, uiBSx4, 4, 4 ); | 567 | } |
| 568 | 568 | ||
| 569 | pDestCb = pFilter->pCsData[1]; | 569 | // chroma h |
| 570 | pDestCr = pFilter->pCsData[2]; | 570 | if (iTopFlag) { |
| 571 | iCurQp = pCurMb->uiChromaQp; | 571 | pFilter->uiChromaQP = (iCurQp + (pCurMb - iMbStride)->uiChromaQp + 1) >> 1; |
| 572 | *(uint32_t*)uiBSx4 = 0x03030303; | 572 | FilteringEdgeChromaIntraH (pfDeblocking, pFilter, pDestCb, pDestCr, iLineSize, NULL); |
| 573 | 573 | } | |
| 574 | // chroma v | 574 | |
| 575 | if (iLeftFlag) | 575 | pFilter->uiChromaQP = iCurQp; |
| 576 | { | 576 | if (iAlpha | iBeta) { |
| 577 | pFilter->uiChromaQP = ( iCurQp + (pCurMb-1)->uiChromaQp + 1 ) >> 1; | 577 | pfDeblocking->pfChromaDeblockingLT4Ver (&pDestCb[ (2 << 1)*iLineSize], &pDestCr[ (2 << 1)*iLineSize], iLineSize, iAlpha, |
| 578 | FilteringEdgeChromaIntraV( pfDeblocking, pFilter, pDestCb, pDestCr, iLineSize, NULL); | 578 | iBeta, iTc); |
| 579 | } | 579 | } |
| 580 | 580 | } | |
| 581 | pFilter->uiChromaQP = iCurQp; | 581 | |
| 582 | GET_ALPHA_BETA_FROM_QP(pFilter->uiChromaQP, pFilter->iSliceAlphaC0Offset, pFilter->iSliceBetaOffset, iIdexA, iAlpha, iBeta); | 582 | // merge h&v lookup table operation to save performance |
| 583 | if( iAlpha | iBeta ) | 583 | void DeblockingIntraMb (DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter) { |
| 584 | { | 584 | FilteringEdgeLumaHV (pfDeblocking, pCurMb, pFilter); |
| 585 | TC0_TBL_LOOKUP(iTc, iIdexA, uiBSx4, 1); | 585 | FilteringEdgeChromaHV (pfDeblocking, pCurMb, pFilter); |
| 586 | pfDeblocking->pfChromaDeblockingLT4Hor( &pDestCb[2<<1], &pDestCr[2<<1], iLineSize, iAlpha, iBeta, iTc ); | 586 | } |
| 587 | } | 587 | |
| 588 | 588 | void DeblockingMbAvcbase (SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilter* pFilter) { | |
| 589 | // chroma h | 589 | uint8_t uiBS[2][4][4] = { 0 }; |
| 590 | if (iTopFlag) | 590 | |
| 591 | { | 591 | Mb_Type uiCurMbType = pCurMb->uiMbType; |
| 592 | pFilter->uiChromaQP = ( iCurQp + (pCurMb-iMbStride)->uiChromaQp + 1 ) >> 1; | 592 | int32_t iMbStride = pFilter->iMbStride; |
| 593 | FilteringEdgeChromaIntraH( pfDeblocking, pFilter, pDestCb, pDestCr, iLineSize, NULL); | 593 | |
| 594 | } | 594 | int32_t iMbX = pCurMb->iMbX; |
| 595 | 595 | int32_t iMbY = pCurMb->iMbY; | |
| 596 | pFilter->uiChromaQP = iCurQp; | 596 | |
| 597 | if( iAlpha | iBeta ) | 597 | BOOL_T bLeftBsValid[2] = { (iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; |
| 598 | { | 598 | BOOL_T bTopBsValid[2] = { (iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; |
| 599 | pfDeblocking->pfChromaDeblockingLT4Ver( &pDestCb[(2<<1)*iLineSize], &pDestCr[(2<<1)*iLineSize], iLineSize, iAlpha, iBeta, iTc ); | 599 | |
| 600 | } | 600 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; |
| 601 | } | 601 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; |
| 602 | 602 | ||
| 603 | // merge h&v lookup table operation to save performance | 603 | switch (uiCurMbType) { |
| 604 | void DeblockingIntraMb( DeblockingFunc* pfDeblocking, SMB* pCurMb, SDeblockingFilter* pFilter ) | 604 | case MB_TYPE_INTRA4x4: |
| 605 | { | 605 | case MB_TYPE_INTRA16x16: |
| 606 | FilteringEdgeLumaHV( pfDeblocking, pCurMb, pFilter); | 606 | case MB_TYPE_INTRA_PCM: |
| 607 | FilteringEdgeChromaHV(pfDeblocking, pCurMb, pFilter); | 607 | DeblockingIntraMb (&pFunc->pfDeblocking, pCurMb, pFilter); |
| 608 | } | 608 | break; |
| 609 | 609 | default: | |
| 610 | void DeblockingMbAvcbase( SWelsFuncPtrList* pFunc, SMB* pCurMb, SDeblockingFilter * pFilter ) | 610 | if (iLeftFlag) { |
| 611 | { | 611 | * (uint32_t*)uiBS[0][0] = IS_INTRA ((pCurMb - 1)->uiMbType) ? 0x04040404 : DeblockingBSMarginalMBAvcbase (pCurMb, |
| 612 | uint8_t uiBS[2][4][4] = { 0 }; | 612 | pCurMb - 1, 0); |
| 613 | 613 | } else { | |
| 614 | Mb_Type uiCurMbType = pCurMb->uiMbType; | 614 | * (uint32_t*)uiBS[0][0] = 0; |
| 615 | int32_t iMbStride = pFilter->iMbStride; | 615 | } |
| 616 | 616 | if (iTopFlag) { | |
| 617 | int32_t iMbX = pCurMb->iMbX; | 617 | * (uint32_t*)uiBS[1][0] = IS_INTRA ((pCurMb - iMbStride)->uiMbType) ? 0x04040404 : DeblockingBSMarginalMBAvcbase ( |
| 618 | int32_t iMbY = pCurMb->iMbY; | 618 | pCurMb, (pCurMb - iMbStride), 1); |
| 619 | 619 | } else { | |
| 620 | BOOL_T bLeftBsValid[2] = {(iMbX > 0), ((iMbX > 0) && (pCurMb->uiSliceIdc == (pCurMb - 1)->uiSliceIdc))}; | 620 | * (uint32_t*)uiBS[1][0] = 0; |
| 621 | BOOL_T bTopBsValid[2] = {(iMbY > 0), ((iMbY > 0) && (pCurMb->uiSliceIdc == (pCurMb - iMbStride)->uiSliceIdc))}; | 621 | } |
| 622 | 622 | //SKIP MB_16x16 or others | |
| 623 | int32_t iLeftFlag = bLeftBsValid[pFilter->uiFilterIdc]; | 623 | if (uiCurMbType != MB_TYPE_SKIP) { |
| 624 | int32_t iTopFlag = bTopBsValid[pFilter->uiFilterIdc]; | 624 | pFunc->pfSetNZCZero (pCurMb->pNonZeroCount); // set all none-zero nzc to 1; dbk can be opti! |
| 625 | 625 | ||
| 626 | switch( uiCurMbType ) | 626 | if (uiCurMbType == MB_TYPE_16x16) { |
| 627 | { | 627 | DeblockingBSInsideMBAvsbase (pCurMb->pNonZeroCount, uiBS, 1); |
| 628 | case MB_TYPE_INTRA4x4: | 628 | } else { |
| 629 | case MB_TYPE_INTRA16x16: | 629 | DeblockingBSInsideMBNormal (pCurMb, uiBS, pCurMb->pNonZeroCount); |
| 630 | case MB_TYPE_INTRA_PCM: | 630 | } |
| 631 | DeblockingIntraMb( &pFunc->pfDeblocking, pCurMb, pFilter ); | 631 | } else { |
| 632 | break; | 632 | * (uint32_t*)uiBS[0][1] = * (uint32_t*)uiBS[0][2] = * (uint32_t*)uiBS[0][3] = |
| 633 | default: | 633 | * (uint32_t*)uiBS[1][1] = * (uint32_t*)uiBS[1][2] = * (uint32_t*)uiBS[1][3] = 0; |
| 634 | if (iLeftFlag) | 634 | } |
| 635 | { | 635 | |
| 636 | *(uint32_t*)uiBS[0][0] = IS_INTRA((pCurMb-1)->uiMbType)?0x04040404:DeblockingBSMarginalMBAvcbase( pCurMb, pCurMb-1, 0 ); | 636 | DeblockingInterMb (&pFunc->pfDeblocking, pCurMb, pFilter, uiBS); |
| 637 | } | 637 | break; |
| 638 | else | 638 | } |
| 639 | { | 639 | } |
| 640 | *(uint32_t*)uiBS[0][0] = 0; | 640 | |
| 641 | } | 641 | // C code only |
| 642 | if (iTopFlag) | 642 | |
| 643 | { | 643 | void DeblockLumaLt4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t* pTc) { |
| 644 | *(uint32_t*)uiBS[1][0] = IS_INTRA((pCurMb-iMbStride)->uiMbType)?0x04040404:DeblockingBSMarginalMBAvcbase( pCurMb, (pCurMb-iMbStride), 1 ); | 644 | for (int32_t i = 0; i < 16; i++) { |
| 645 | } | 645 | int32_t iTc0 = pTc[i >> 2]; |
| 646 | else | 646 | if (iTc0 >= 0) { |
| 647 | { | 647 | int32_t p0 = pPix[-iStrideX]; |
| 648 | *(uint32_t*)uiBS[1][0] = 0; | 648 | int32_t p1 = pPix[-2 * iStrideX]; |
| 649 | } | 649 | int32_t p2 = pPix[-3 * iStrideX]; |
| 650 | //SKIP MB_16x16 or others | 650 | int32_t q0 = pPix[0]; |
| 651 | if( uiCurMbType != MB_TYPE_SKIP ) | 651 | int32_t q1 = pPix[iStrideX]; |
| 652 | { | 652 | int32_t q2 = pPix[2 * iStrideX]; |
| 653 | pFunc->pfSetNZCZero(pCurMb->pNonZeroCount);// set all none-zero nzc to 1; dbk can be opti! | 653 | bool_t bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha; |
| 654 | 654 | bool_t bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta; | |
| 655 | if( uiCurMbType == MB_TYPE_16x16 ) | 655 | bool_t bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta; |
| 656 | { | 656 | int32_t iTc = iTc0; |
| 657 | DeblockingBSInsideMBAvsbase( pCurMb->pNonZeroCount, uiBS, 1 ); | 657 | if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) { |
| 658 | } | 658 | bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta; |
| 659 | else | 659 | bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta; |
| 660 | { | 660 | if (bDetaP2P0) { |
| 661 | DeblockingBSInsideMBNormal(pCurMb, uiBS, pCurMb->pNonZeroCount); | 661 | pPix[-2 * iStrideX] = p1 + WELS_CLIP3 ((p2 + ((p0 + q0 + 1) >> 1) - (p1 << 1)) >> 1, -iTc0, iTc0); |
| 662 | } | 662 | iTc++; |
| 663 | } | 663 | } |
| 664 | else | 664 | if (bDetaQ2Q0) { |
| 665 | { | 665 | pPix[iStrideX] = q1 + WELS_CLIP3 ((q2 + ((p0 + q0 + 1) >> 1) - (q1 << 1)) >> 1, -iTc0, iTc0); |
| 666 | *(uint32_t*)uiBS[0][1] = *(uint32_t*)uiBS[0][2] = *(uint32_t*)uiBS[0][3] = | 666 | iTc++; |
| 667 | *(uint32_t*)uiBS[1][1] = *(uint32_t*)uiBS[1][2] = *(uint32_t*)uiBS[1][3] = 0; | 667 | } |
| 668 | } | 668 | int32_t iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc, iTc); |
| 669 | 669 | pPix[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */ | |
| 670 | DeblockingInterMb( &pFunc->pfDeblocking, pCurMb, pFilter, uiBS ); | 670 | pPix[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */ |
| 671 | break; | 671 | } |
| 672 | } | 672 | } |
| 673 | } | 673 | pPix += iStrideY; |
| 674 | 674 | } | |
| 675 | // C code only | 675 | } |
| 676 | 676 | ||
| 677 | void DeblockLumaLt4_c( uint8_t *pPix, int32_t iStrideX,int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc ) | 677 | |
| 678 | { | 678 | void DeblockLumaEq4_c (uint8_t* pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta) { |
| 679 | for( int32_t i = 0;i<16;i++) | 679 | int32_t p0, p1, p2, q0, q1, q2; |
| 680 | { | 680 | int32_t iDetaP0Q0; |
| 681 | int32_t iTc0 = pTc[i>>2]; | 681 | bool_t bDetaP1P0, bDetaQ1Q0; |
| 682 | if(iTc0>=0) | 682 | for (int32_t i = 0; i < 16; i++) { |
| 683 | { | 683 | p0 = pPix[-iStrideX]; |
| 684 | int32_t p0 = pPix[-iStrideX]; | 684 | p1 = pPix[-2 * iStrideX]; |
| 685 | int32_t p1 = pPix[-2*iStrideX]; | 685 | p2 = pPix[-3 * iStrideX]; |
| 686 | int32_t p2 = pPix[-3*iStrideX]; | 686 | q0 = pPix[0]; |
| 687 | int32_t q0 = pPix[0]; | 687 | q1 = pPix[iStrideX]; |
| 688 | int32_t q1 = pPix[iStrideX]; | 688 | q2 = pPix[2 * iStrideX]; |
| 689 | int32_t q2 = pPix[2*iStrideX]; | 689 | iDetaP0Q0 = WELS_ABS (p0 - q0); |
| 690 | bool_t bDetaP0Q0= WELS_ABS( p0 - q0 )<iAlpha; | 690 | bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta; |
| 691 | bool_t bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta; | 691 | bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta; |
| 692 | bool_t bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta; | 692 | if ((iDetaP0Q0 < iAlpha) && bDetaP1P0 && bDetaQ1Q0) { |
| 693 | int32_t iTc = iTc0; | 693 | if (iDetaP0Q0 < ((iAlpha >> 2) + 2)) { |
| 694 | if ( bDetaP0Q0&& bDetaP1P0 && bDetaQ1Q0 ) | 694 | bool_t bDetaP2P0 = WELS_ABS (p2 - p0) < iBeta; |
| 695 | { | 695 | bool_t bDetaQ2Q0 = WELS_ABS (q2 - q0) < iBeta; |
| 696 | bool_t bDetaP2P0 = WELS_ABS( p2 - p0 ) < iBeta; | 696 | if (bDetaP2P0) { |
| 697 | bool_t bDetaQ2Q0 = WELS_ABS( q2 - q0 ) < iBeta; | 697 | const int32_t p3 = pPix[-4 * iStrideX]; |
| 698 | if ( bDetaP2P0) | 698 | pPix[-iStrideX] = (p2 + (p1 << 1) + (p0 << 1) + (q0 << 1) + q1 + 4) >> 3; //p0 |
| 699 | { | 699 | pPix[-2 * iStrideX] = (p2 + p1 + p0 + q0 + 2) >> 2; //p1 |
| 700 | pPix[-2*iStrideX] = p1 + WELS_CLIP3( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -iTc0, iTc0 ); | 700 | pPix[-3 * iStrideX] = ((p3 << 1) + p2 + (p2 << 1) + p1 + p0 + q0 + 4) >> 3;//p2 |
| 701 | iTc++; | 701 | } else { |
| 702 | } | 702 | pPix[-1 * iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0 |
| 703 | if (bDetaQ2Q0) | 703 | } |
| 704 | { | 704 | if (bDetaQ2Q0) { |
| 705 | pPix[iStrideX] = q1 + WELS_CLIP3( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -iTc0, iTc0 ); | 705 | const int32_t q3 = pPix[3 * iStrideX]; |
| 706 | iTc++; | 706 | pPix[0] = (p1 + (p0 << 1) + (q0 << 1) + (q1 << 1) + q2 + 4) >> 3; //q0 |
| 707 | } | 707 | pPix[iStrideX] = (p0 + q0 + q1 + q2 + 2) >> 2; //q1 |
| 708 | int32_t iDeta = WELS_CLIP3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -iTc, iTc ); | 708 | pPix[2 * iStrideX] = ((q3 << 1) + q2 + (q2 << 1) + q1 + q0 + p0 + 4) >> 3;//q2 |
| 709 | pPix[-iStrideX] = WELS_CLIP1( p0 + iDeta ); /* p0' */ | 709 | } else { |
| 710 | pPix[0] = WELS_CLIP1( q0 - iDeta ); /* q0' */ | 710 | pPix[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0 |
| 711 | } | 711 | } |
| 712 | } | 712 | } else { |
| 713 | pPix +=iStrideY; | 713 | pPix[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; //p0 |
| 714 | } | 714 | pPix[ 0] = ((q1 << 1) + q0 + p1 + 2) >> 2; //q0 |
| 715 | } | 715 | } |
| 716 | 716 | } | |
| 717 | 717 | pPix += iStrideY; | |
| 718 | void DeblockLumaEq4_c( uint8_t *pPix, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta ) | 718 | } |
| 719 | { | 719 | } |
| 720 | int32_t p0,p1,p2,q0,q1,q2; | 720 | void DeblockLumaLt4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* iTc) { |
| 721 | int32_t iDetaP0Q0; | 721 | DeblockLumaLt4_c (pPix, iStride, 1, iAlpha, iBeta, iTc); |
| 722 | bool_t bDetaP1P0,bDetaQ1Q0; | 722 | } |
| 723 | for (int32_t i = 0;i<16;i++) | 723 | void DeblockLumaLt4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* iTc) { |
| 724 | { | 724 | DeblockLumaLt4_c (pPix, 1, iStride, iAlpha, iBeta, iTc); |
| 725 | p0 = pPix[-iStrideX]; | 725 | } |
| 726 | p1 = pPix[-2*iStrideX]; | 726 | void DeblockLumaEq4V_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) { |
| 727 | p2 = pPix[-3*iStrideX]; | 727 | DeblockLumaEq4_c (pPix, iStride, 1, iAlpha, iBeta); |
| 728 | q0 = pPix[0]; | 728 | } |
| 729 | q1 = pPix[iStrideX]; | 729 | void DeblockLumaEq4H_c (uint8_t* pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta) { |
| 730 | q2 = pPix[2*iStrideX]; | 730 | DeblockLumaEq4_c (pPix, 1, iStride, iAlpha, iBeta); |
| 731 | iDetaP0Q0 = WELS_ABS( p0 - q0 ); | 731 | } |
| 732 | bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta; | 732 | void DeblockChromaLt4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, |
| 733 | bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta; | 733 | int32_t iBeta, int8_t* pTc) { |
| 734 | if ((iDetaP0Q0<iAlpha) && bDetaP1P0 &&bDetaQ1Q0) | 734 | int32_t p0, p1, q0, q1, iDeta; |
| 735 | { | 735 | bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0; |
| 736 | if (iDetaP0Q0< (( iAlpha >> 2 ) + 2 ) ) | 736 | |
| 737 | { | 737 | for (int32_t i = 0; i < 8; i++) { |
| 738 | bool_t bDetaP2P0 = WELS_ABS( p2 - p0 ) < iBeta; | 738 | int32_t iTc0 = pTc[i >> 1]; |
| 739 | bool_t bDetaQ2Q0 = WELS_ABS( q2 - q0 ) < iBeta; | 739 | if (iTc0 > 0) { |
| 740 | if(bDetaP2P0) | 740 | p0 = pPixCb[-iStrideX]; |
| 741 | { | 741 | p1 = pPixCb[-2 * iStrideX]; |
| 742 | const int32_t p3 = pPix[-4*iStrideX]; | 742 | q0 = pPixCb[0]; |
| 743 | pPix[-iStrideX] = ( p2 + (p1 << 1) + (p0 << 1) + (q0 << 1) + q1 + 4 ) >> 3; //p0 | 743 | q1 = pPixCb[iStrideX]; |
| 744 | pPix[-2*iStrideX] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; //p1 | 744 | |
| 745 | pPix[-3*iStrideX] = ( (p3 << 1) + p2 + (p2 << 1) + p1 + p0 + q0 + 4 ) >> 3;//p2 | 745 | bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha; |
| 746 | } | 746 | bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta; |
| 747 | else | 747 | bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta; |
| 748 | { | 748 | if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) { |
| 749 | pPix[-1*iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; //p0 | 749 | iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0); |
| 750 | } | 750 | pPixCb[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */ |
| 751 | if (bDetaQ2Q0) | 751 | pPixCb[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */ |
| 752 | { | 752 | } |
| 753 | const int32_t q3 = pPix[3*iStrideX]; | 753 | |
| 754 | pPix[0] = ( p1 + (p0 << 1) + (q0 << 1) + (q1 << 1) + q2 + 4 ) >> 3; //q0 | 754 | |
| 755 | pPix[iStrideX] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; //q1 | 755 | p0 = pPixCr[-iStrideX]; |
| 756 | pPix[2*iStrideX] = ( (q3 << 1) + q2 + (q2 << 1) + q1 + q0 + p0 + 4 ) >> 3;//q2 | 756 | p1 = pPixCr[-2 * iStrideX]; |
| 757 | } | 757 | q0 = pPixCr[0]; |
| 758 | else | 758 | q1 = pPixCr[iStrideX]; |
| 759 | { | 759 | |
| 760 | pPix[0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; //q0 | 760 | bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha; |
| 761 | } | 761 | bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta; |
| 762 | } | 762 | bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta; |
| 763 | else | 763 | |
| 764 | { | 764 | if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) { |
| 765 | pPix[-iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; //p0 | 765 | iDeta = WELS_CLIP3 ((((q0 - p0) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0); |
| 766 | pPix[ 0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; //q0 | 766 | pPixCr[-iStrideX] = WELS_CLIP1 (p0 + iDeta); /* p0' */ |
| 767 | } | 767 | pPixCr[0] = WELS_CLIP1 (q0 - iDeta); /* q0' */ |
| 768 | } | 768 | } |
| 769 | pPix += iStrideY; | 769 | } |
| 770 | } | 770 | pPixCb += iStrideY; |
| 771 | } | 771 | pPixCr += iStrideY; |
| 772 | void DeblockLumaLt4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc ) | 772 | } |
| 773 | { | 773 | } |
| 774 | DeblockLumaLt4_c( pPix, iStride, 1, iAlpha, iBeta, iTc ); | 774 | void DeblockChromaEq4_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, |
| 775 | } | 775 | int32_t iBeta) { |
| 776 | void DeblockLumaLt4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc ) | 776 | int32_t i = 0, d = 0; |
| 777 | { | 777 | int32_t p0, p1, q0, q1; |
| 778 | DeblockLumaLt4_c( pPix, 1, iStride, iAlpha, iBeta, iTc ); | 778 | bool_t bDetaP0Q0, bDetaP1P0, bDetaQ1Q0; |
| 779 | } | 779 | for (int32_t i = 0; i < 8; i++) { |
| 780 | void DeblockLumaEq4V_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta ) | 780 | //cb |
| 781 | { | 781 | p0 = pPixCb[-iStrideX]; |
| 782 | DeblockLumaEq4_c( pPix, iStride, 1, iAlpha, iBeta); | 782 | p1 = pPixCb[-2 * iStrideX]; |
| 783 | } | 783 | q0 = pPixCb[0]; |
| 784 | void DeblockLumaEq4H_c( uint8_t *pPix, int32_t iStride, int32_t iAlpha, int32_t iBeta ) | 784 | q1 = pPixCb[iStrideX]; |
| 785 | { | 785 | bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha; |
| 786 | DeblockLumaEq4_c( pPix, 1, iStride, iAlpha, iBeta ); | 786 | bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta; |
| 787 | } | 787 | bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta; |
| 788 | void DeblockChromaLt4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta, int8_t *pTc ) | 788 | if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) { |
| 789 | { | 789 | pPixCb[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */ |
| 790 | int32_t p0, p1, q0, q1,iDeta; | 790 | pPixCb[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */ |
| 791 | bool_t bDetaP0Q0,bDetaP1P0,bDetaQ1Q0; | 791 | } |
| 792 | 792 | ||
| 793 | for(int32_t i = 0;i<8;i++) | 793 | //cr |
| 794 | { | 794 | p0 = pPixCr[-iStrideX]; |
| 795 | int32_t iTc0 = pTc[i>>1]; | 795 | p1 = pPixCr[-2 * iStrideX]; |
| 796 | if(iTc0 >0) | 796 | q0 = pPixCr[0]; |
| 797 | { | 797 | q1 = pPixCr[iStrideX]; |
| 798 | p0 = pPixCb[-iStrideX]; | 798 | bDetaP0Q0 = WELS_ABS (p0 - q0) < iAlpha; |
| 799 | p1 = pPixCb[-2*iStrideX]; | 799 | bDetaP1P0 = WELS_ABS (p1 - p0) < iBeta; |
| 800 | q0 = pPixCb[0]; | 800 | bDetaQ1Q0 = WELS_ABS (q1 - q0) < iBeta; |
| 801 | q1 = pPixCb[iStrideX]; | 801 | if (bDetaP0Q0 && bDetaP1P0 && bDetaQ1Q0) { |
| 802 | 802 | pPixCr[-iStrideX] = ((p1 << 1) + p0 + q1 + 2) >> 2; /* p0' */ | |
| 803 | bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha; | 803 | pPixCr[0] = ((q1 << 1) + q0 + p1 + 2) >> 2; /* q0' */ |
| 804 | bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta; | 804 | } |
| 805 | bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta; | 805 | pPixCr += iStrideY; |
| 806 | if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0) | 806 | pPixCb += iStrideY; |
| 807 | { | 807 | } |
| 808 | iDeta = WELS_CLIP3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0 ); | 808 | } |
| 809 | pPixCb[-iStrideX] = WELS_CLIP1( p0 + iDeta ); /* p0' */ | 809 | void DeblockChromaLt4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, |
| 810 | pPixCb[0] = WELS_CLIP1( q0 - iDeta ); /* q0' */ | 810 | int8_t* iTc) { |
| 811 | } | 811 | DeblockChromaLt4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, iTc); |
| 812 | 812 | } | |
| 813 | 813 | void DeblockChromaLt4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, | |
| 814 | p0 = pPixCr[-iStrideX]; | 814 | int8_t* iTc) { |
| 815 | p1 = pPixCr[-2*iStrideX]; | 815 | DeblockChromaLt4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, iTc); |
| 816 | q0 = pPixCr[0]; | 816 | } |
| 817 | q1 = pPixCr[iStrideX]; | 817 | void DeblockChromaEq4V_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) { |
| 818 | 818 | DeblockChromaEq4_c (pPixCb, pPixCr, iStride, 1, iAlpha, iBeta); | |
| 819 | bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha; | 819 | } |
| 820 | bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta; | 820 | void DeblockChromaEq4H_c (uint8_t* pPixCb, uint8_t* pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta) { |
| 821 | bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta; | 821 | DeblockChromaEq4_c (pPixCb, pPixCr, 1, iStride, iAlpha, iBeta); |
| 822 | 822 | } | |
| 823 | if( bDetaP0Q0&&bDetaP1P0 && bDetaQ1Q0) | 823 | |
| 824 | { | 824 | |
| 825 | iDeta = WELS_CLIP3( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -iTc0, iTc0 ); | 825 | void DeblockingFilterFrameAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc) { |
| 826 | pPixCr[-iStrideX] = WELS_CLIP1( p0 + iDeta ); /* p0' */ | 826 | int32_t i, j; |
| 827 | pPixCr[0] = WELS_CLIP1( q0 - iDeta ); /* q0' */ | 827 | const int32_t kiMbWidth = pCurDq->iMbWidth; |
| 828 | } | 828 | const int32_t kiMbHeight = pCurDq->iMbHeight; |
| 829 | } | 829 | SMB* pCurrentMbBlock = pCurDq->sMbDataP; |
| 830 | pPixCb += iStrideY; | 830 | SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[0].sSliceHeaderExt; |
| 831 | pPixCr += iStrideY; | 831 | SDeblockingFilter pFilter; |
| 832 | } | 832 | |
| 833 | } | 833 | /* Step1: parameters set */ |
| 834 | void DeblockChromaEq4_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStrideX, int32_t iStrideY, int32_t iAlpha, int32_t iBeta ) | 834 | if (sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc == 1) |
| 835 | { | 835 | return; |
| 836 | int32_t i = 0, d = 0; | 836 | |
| 837 | int32_t p0, p1, q0, q1; | 837 | pFilter.uiFilterIdc = (sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc != 0); |
| 838 | bool_t bDetaP0Q0,bDetaP1P0,bDetaQ1Q0; | 838 | |
| 839 | for(int32_t i =0;i<8;i++) | 839 | pFilter.iCsStride[0] = pCurDq->pDecPic->iLineSize[0]; |
| 840 | { | 840 | pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1]; |
| 841 | //cb | 841 | pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2]; |
| 842 | p0 = pPixCb[-iStrideX]; | 842 | |
| 843 | p1 = pPixCb[-2*iStrideX]; | 843 | pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; |
| 844 | q0 = pPixCb[0]; | 844 | pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; |
| 845 | q1 = pPixCb[iStrideX]; | 845 | |
| 846 | bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha; | 846 | pFilter.iMbStride = kiMbWidth; |
| 847 | bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta; | 847 | |
| 848 | bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta; | 848 | for (j = 0; j < kiMbHeight; ++j) { |
| 849 | if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0) | 849 | pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((j * pFilter.iCsStride[0]) << 4); |
| 850 | { | 850 | pFilter.pCsData[1] = pCurDq->pDecPic->pData[1] + ((j * pFilter.iCsStride[1]) << 3); |
| 851 | pPixCb[-iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; /* p0' */ | 851 | pFilter.pCsData[2] = pCurDq->pDecPic->pData[2] + ((j * pFilter.iCsStride[2]) << 3); |
| 852 | pPixCb[0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; /* q0' */ | 852 | for (i = 0; i < kiMbWidth; i++) { |
| 853 | } | 853 | DeblockingMbAvcbase (pFunc, pCurrentMbBlock, &pFilter); |
| 854 | 854 | ++pCurrentMbBlock; | |
| 855 | //cr | 855 | pFilter.pCsData[0] += MB_WIDTH_LUMA; |
| 856 | p0 = pPixCr[-iStrideX]; | 856 | pFilter.pCsData[1] += MB_WIDTH_CHROMA; |
| 857 | p1 = pPixCr[-2*iStrideX]; | 857 | pFilter.pCsData[2] += MB_WIDTH_CHROMA; |
| 858 | q0 = pPixCr[0]; | 858 | } |
| 859 | q1 = pPixCr[iStrideX]; | 859 | } |
| 860 | bDetaP0Q0 = WELS_ABS( p0 - q0 ) < iAlpha; | 860 | } |
| 861 | bDetaP1P0 = WELS_ABS( p1 - p0 ) < iBeta; | 861 | |
| 862 | bDetaQ1Q0 = WELS_ABS( q1 - q0 ) < iBeta; | 862 | void DeblockingFilterSliceAvcbase (SDqLayer* pCurDq, SWelsFuncPtrList* pFunc, const int32_t kiSliceIdx) { |
| 863 | if(bDetaP0Q0&&bDetaP1P0&&bDetaQ1Q0) | 863 | SSliceCtx* pSliceCtx = pCurDq->pSliceEncCtx; |
| 864 | { | 864 | SMB* pMbList = pCurDq->sMbDataP; |
| 865 | pPixCr[-iStrideX] = ( (p1 << 1) + p0 + q1 + 2 ) >> 2; /* p0' */ | 865 | SSliceHeaderExt* sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt; |
| 866 | pPixCr[0] = ( (q1 << 1) + q0 + p1 + 2 ) >> 2; /* q0' */ | 866 | SMB* pCurrentMbBlock; |
| 867 | } | 867 | |
| 868 | pPixCr += iStrideY; | 868 | const int32_t kiMbWidth = pCurDq->iMbWidth; |
| 869 | pPixCb += iStrideY; | 869 | const int32_t kiMbHeight = pCurDq->iMbHeight; |
| 870 | } | 870 | const int32_t kiTotalNumMb = kiMbWidth * kiMbHeight; |
| 871 | } | 871 | int32_t iCurMbIdx = 0, iNextMbIdx = 0, iNumMbFiltered = 0; |
| 872 | void DeblockChromaLt4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc ) | 872 | |
| 873 | { | 873 | /* Step1: parameters set */ |
| 874 | DeblockChromaLt4_c( pPixCb, pPixCr, iStride, 1, iAlpha, iBeta, iTc ); | 874 | if (sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc == 1) |
| 875 | } | 875 | return; |
| 876 | void DeblockChromaLt4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *iTc ) | 876 | |
| 877 | { | 877 | SDeblockingFilter pFilter; |
| 878 | DeblockChromaLt4_c( pPixCb, pPixCr, 1, iStride, iAlpha, iBeta, iTc ); | 878 | |
| 879 | } | 879 | pFilter.uiFilterIdc = (sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc != 0); |
| 880 | void DeblockChromaEq4V_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta ) | 880 | pFilter.iCsStride[0] = pCurDq->pDecPic->iLineSize[0]; |
| 881 | { | 881 | pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1]; |
| 882 | DeblockChromaEq4_c( pPixCb, pPixCr, iStride, 1, iAlpha, iBeta ); | 882 | pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2]; |
| 883 | } | 883 | pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; |
| 884 | void DeblockChromaEq4H_c( uint8_t *pPixCb, uint8_t *pPixCr, int32_t iStride, int32_t iAlpha, int32_t iBeta ) | 884 | pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; |
| 885 | { | 885 | pFilter.iMbStride = kiMbWidth; |
| 886 | DeblockChromaEq4_c( pPixCb, pPixCr, 1, iStride, iAlpha, iBeta ); | 886 | |
| 887 | } | 887 | iNextMbIdx = sSliceHeaderExt->sSliceHeader.iFirstMbInSlice; |
| 888 | 888 | ||
| 889 | 889 | for (; ;) { | |
| 890 | void DeblockingFilterFrameAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc ) | 890 | iCurMbIdx = iNextMbIdx; |
| 891 | { | 891 | pCurrentMbBlock = &pMbList[ iCurMbIdx ]; |
| 892 | int32_t i,j; | 892 | |
| 893 | const int32_t kiMbWidth = pCurDq->iMbWidth; | 893 | pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0]) |
| 894 | const int32_t kiMbHeight = pCurDq->iMbHeight; | 894 | << 4); |
| 895 | SMB * pCurrentMbBlock = pCurDq->sMbDataP; | 895 | pFilter.pCsData[1] = pCurDq->pDecPic->pData[1] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[1]) |
| 896 | SSliceHeaderExt *sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[0].sSliceHeaderExt; | 896 | << 3); |
| 897 | SDeblockingFilter pFilter; | 897 | pFilter.pCsData[2] = pCurDq->pDecPic->pData[2] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[2]) |
| 898 | 898 | << 3); | |
| 899 | /* Step1: parameters set */ | 899 | |
| 900 | if ( sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc == 1 ) | 900 | DeblockingMbAvcbase (pFunc, pCurrentMbBlock, &pFilter); |
| 901 | return; | 901 | |
| 902 | 902 | ++iNumMbFiltered; | |
| 903 | pFilter.uiFilterIdc = (sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc != 0); | 903 | iNextMbIdx = WelsGetNextMbOfSlice (pSliceCtx, iCurMbIdx); |
| 904 | 904 | //whether all of MB in current slice filtered or not | |
| 905 | pFilter.iCsStride[0] = pCurDq->pDecPic->iLineSize[0]; | 905 | if (iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbFiltered >= kiTotalNumMb) { |
| 906 | pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1]; | 906 | break; |
| 907 | pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2]; | 907 | } |
| 908 | 908 | } | |
| 909 | pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; | 909 | } |
| 910 | pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; | 910 | |
| 911 | 911 | void PerformDeblockingFilter (sWelsEncCtx* pEnc) { | |
| 912 | pFilter.iMbStride = kiMbWidth; | 912 | const int32_t kiCurDid = pEnc->uiDependencyId; |
| 913 | 913 | SWelsSvcCodingParam* pSvcParam = pEnc->pSvcParam; | |
| 914 | for( j = 0; j < kiMbHeight; ++j ){ | 914 | SDLayerParam* pDlp = &pSvcParam->sDependencyLayers[kiCurDid]; |
| 915 | pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((j*pFilter.iCsStride[0])<<4); | 915 | SDqLayer* pCurLayer = pEnc->pCurDqLayer; |
| 916 | pFilter.pCsData[1] = pCurDq->pDecPic->pData[1] + ((j*pFilter.iCsStride[1])<<3); | 916 | |
| 917 | pFilter.pCsData[2] = pCurDq->pDecPic->pData[2] + ((j*pFilter.iCsStride[2])<<3); | 917 | if (pCurLayer->iLoopFilterDisableIdc == 0) { |
| 918 | for( i=0;i<kiMbWidth; i++ ){ | 918 | DeblockingFilterFrameAvcbase (pCurLayer, pEnc->pFuncList); |
| 919 | DeblockingMbAvcbase( pFunc, pCurrentMbBlock, &pFilter ); | 919 | } else if (pCurLayer->iLoopFilterDisableIdc == 2) { |
| 920 | ++pCurrentMbBlock; | 920 | int32_t iSliceCount = 0; |
| 921 | pFilter.pCsData[0] += MB_WIDTH_LUMA; | 921 | int32_t iSliceIdx = 0; |
| 922 | pFilter.pCsData[1] += MB_WIDTH_CHROMA; | 922 | |
| 923 | pFilter.pCsData[2] += MB_WIDTH_CHROMA; | 923 | if (SM_DYN_SLICE != pDlp->sMso.uiSliceMode) { |
| 924 | } | 924 | iSliceCount = GetCurrentSliceNum (pCurLayer->pSliceEncCtx); |
| 925 | } | 925 | do { |
| 926 | } | 926 | DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx); |
| 927 | 927 | ++ iSliceIdx; | |
| 928 | void DeblockingFilterSliceAvcbase( SDqLayer *pCurDq, SWelsFuncPtrList *pFunc, const int32_t kiSliceIdx ) | 928 | } while (iSliceIdx < iSliceCount); |
| 929 | { | 929 | } else { // for dynamic slicing mode |
| 930 | SSliceCtx * pSliceCtx = pCurDq->pSliceEncCtx; | 930 | const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; |
| 931 | SMB *pMbList = pCurDq->sMbDataP; | 931 | int32_t iPartitionIdx = 0; |
| 932 | SSliceHeaderExt *sSliceHeaderExt = &pCurDq->sLayerInfo.pSliceInLayer[kiSliceIdx].sSliceHeaderExt; | 932 | |
| 933 | SMB * pCurrentMbBlock; | 933 | while (iPartitionIdx < kiNumPicPartition) { |
| 934 | 934 | iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx]; | |
| 935 | const int32_t kiMbWidth = pCurDq->iMbWidth; | 935 | iSliceIdx = iPartitionIdx; |
| 936 | const int32_t kiMbHeight = pCurDq->iMbHeight; | 936 | do { |
| 937 | const int32_t kiTotalNumMb = kiMbWidth * kiMbHeight; | 937 | DeblockingFilterSliceAvcbase (pCurLayer, pEnc->pFuncList, iSliceIdx); |
| 938 | int32_t iCurMbIdx = 0, iNextMbIdx = 0, iNumMbFiltered = 0; | 938 | iSliceIdx += kiNumPicPartition; |
| 939 | 939 | } while (iSliceIdx < iSliceCount); | |
| 940 | /* Step1: parameters set */ | 940 | ++ iPartitionIdx; |
| 941 | if ( sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc == 1 ) | 941 | } |
| 942 | return; | 942 | } |
| 943 | 943 | } | |
| 944 | SDeblockingFilter pFilter; | 944 | } |
| 945 | 945 | ||
| 946 | pFilter.uiFilterIdc = (sSliceHeaderExt->sSliceHeader.uiDisableDeblockingFilterIdc != 0); | 946 | void WelsNonZeroCount_c (int8_t* pNonZeroCount) { |
| 947 | pFilter.iCsStride[0] = pCurDq->pDecPic->iLineSize[0]; | 947 | int32_t i; |
| 948 | pFilter.iCsStride[1] = pCurDq->pDecPic->iLineSize[1]; | 948 | int32_t iIndex; |
| 949 | pFilter.iCsStride[2] = pCurDq->pDecPic->iLineSize[2]; | 949 | |
| 950 | pFilter.iSliceAlphaC0Offset = sSliceHeaderExt->sSliceHeader.iSliceAlphaC0Offset; | 950 | for (i = 0; i < 24; i++) { |
| 951 | pFilter.iSliceBetaOffset = sSliceHeaderExt->sSliceHeader.iSliceBetaOffset; | 951 | iIndex = g_kuiMbCountScan4Idx[i]; |
| 952 | pFilter.iMbStride = kiMbWidth; | 952 | pNonZeroCount[iIndex] = !!pNonZeroCount[iIndex]; |
| 953 | 953 | } | |
| 954 | iNextMbIdx = sSliceHeaderExt->sSliceHeader.iFirstMbInSlice; | 954 | } |
| 955 | 955 | void WelsBlockFuncInit (PSetNoneZeroCountZeroFunc* pfSetNZCZero, int32_t iCpu) { | |
| 956 | for ( ; ; ) | 956 | *pfSetNZCZero = WelsNonZeroCount_c; |
| 957 | { | 957 | } |
| 958 | iCurMbIdx = iNextMbIdx; | 958 | |
| 959 | pCurrentMbBlock = &pMbList[ iCurMbIdx ]; | 959 | |
| 960 | 960 | #ifdef X86_ASM | |
| 961 | pFilter.pCsData[0] = pCurDq->pDecPic->pData[0] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[0]) << 4); | 961 | |
| 962 | pFilter.pCsData[1] = pCurDq->pDecPic->pData[1] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[1]) << 3); | 962 | extern "C" { |
| 963 | pFilter.pCsData[2] = pCurDq->pDecPic->pData[2] + ((pCurrentMbBlock->iMbX + pCurrentMbBlock->iMbY * pFilter.iCsStride[2]) << 3); | 963 | void DeblockLumaLt4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t* pTc) { |
| 964 | 964 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16); | |
| 965 | DeblockingMbAvcbase( pFunc, pCurrentMbBlock, &pFilter); | 965 | |
| 966 | 966 | DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]); | |
| 967 | ++iNumMbFiltered; | 967 | DeblockLumaLt4V_sse2 (&uiBuf[4 * 16], 16, iAlpha, iBeta, pTc); |
| 968 | iNextMbIdx = WelsGetNextMbOfSlice( pSliceCtx, iCurMbIdx ); | 968 | DeblockLumaTransposeV2H_sse2 (pPixY - 4, iStride, &uiBuf[0]); |
| 969 | //whether all of MB in current slice filtered or not | 969 | } |
| 970 | if ( iNextMbIdx == -1 || iNextMbIdx >= kiTotalNumMb || iNumMbFiltered >= kiTotalNumMb ) | 970 | |
| 971 | { | 971 | void DeblockLumaEq4H_sse2 (uint8_t* pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta) { |
| 972 | break; | 972 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBuf, 16 * 8, 16); |
| 973 | } | 973 | |
| 974 | } | 974 | DeblockLumaTransposeH2V_sse2 (pPixY - 4, iStride, &uiBuf[0]); |
| 975 | } | 975 | DeblockLumaEq4V_sse2 (&uiBuf[4 * 16], 16, iAlpha, iBeta); |
| 976 | 976 | DeblockLumaTransposeV2H_sse2 (pPixY - 4, iStride, &uiBuf[0]); | |
| 977 | void PerformDeblockingFilter( sWelsEncCtx *pEnc ) | 977 | } |
| 978 | { | 978 | |
| 979 | const int32_t kiCurDid = pEnc->uiDependencyId; | 979 | } |
| 980 | SWelsSvcCodingParam *pSvcParam = pEnc->pSvcParam; | 980 | |
| 981 | SDLayerParam *pDlp = &pSvcParam->sDependencyLayers[kiCurDid]; | 981 | #endif |
| 982 | SDqLayer *pCurLayer = pEnc->pCurDqLayer; | 982 | |
| 983 | 983 | ||
| 984 | if ( pCurLayer->iLoopFilterDisableIdc == 0 ) | 984 | void DeblockingInit (DeblockingFunc* pFunc, int32_t iCpu) { |
| 985 | { | 985 | pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c; |
| 986 | DeblockingFilterFrameAvcbase( pCurLayer, pEnc->pFuncList ); | 986 | pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c; |
| 987 | } | 987 | pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c; |
| 988 | else if ( pCurLayer->iLoopFilterDisableIdc == 2 ) | 988 | pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_c; |
| 989 | { | 989 | |
| 990 | int32_t iSliceCount = 0; | 990 | pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_c; |
| 991 | int32_t iSliceIdx = 0; | 991 | pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_c; |
| 992 | 992 | pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c; | |
| 993 | if ( SM_DYN_SLICE != pDlp->sMso.uiSliceMode ) | 993 | pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_c; |
| 994 | { | 994 | |
| 995 | iSliceCount = GetCurrentSliceNum( pCurLayer->pSliceEncCtx ); | 995 | |
| 996 | do { | 996 | #ifdef X86_ASM |
| 997 | DeblockingFilterSliceAvcbase( pCurLayer, pEnc->pFuncList, iSliceIdx ); | 997 | if (iCpu & WELS_CPU_SSE2) { |
| 998 | ++ iSliceIdx; | 998 | pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_sse2; |
| 999 | } while(iSliceIdx < iSliceCount); | 999 | pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_sse2; |
| 1000 | } | 1000 | pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_sse2; |
| 1001 | else // for dynamic slicing mode | 1001 | pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_sse2; |
| 1002 | { | 1002 | pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_sse2; |
| 1003 | const int32_t kiNumPicPartition = pEnc->iActiveThreadsNum; //pSvcParam->iCountThreadsNum; | 1003 | pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_sse2; |
| 1004 | int32_t iPartitionIdx = 0; | 1004 | pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_sse2; |
| 1005 | 1005 | pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_sse2; | |
| 1006 | while ( iPartitionIdx < kiNumPicPartition ) | 1006 | } |
| 1007 | { | 1007 | #endif |
| 1008 | iSliceCount = pCurLayer->pNumSliceCodedOfPartition[iPartitionIdx]; | 1008 | } |
| 1009 | iSliceIdx = iPartitionIdx; | 1009 | |
| 1010 | do { | 1010 | |
| 1011 | DeblockingFilterSliceAvcbase( pCurLayer, pEnc->pFuncList, iSliceIdx ); | 1011 | } // namespace WelsSVCEnc |
| 1012 | iSliceIdx += kiNumPicPartition; | 1012 | |
| 1013 | } while(iSliceIdx < iSliceCount); | ||
| 1014 | ++ iPartitionIdx; | ||
| 1015 | } | ||
| 1016 | } | ||
| 1017 | } | ||
| 1018 | } | ||
| 1019 | |||
| 1020 | void WelsNonZeroCount_c(int8_t* pNonZeroCount) | ||
| 1021 | { | ||
| 1022 | int32_t i; | ||
| 1023 | int32_t iIndex; | ||
| 1024 | |||
| 1025 | for( i=0;i<24;i++ ){ | ||
| 1026 | iIndex = g_kuiMbCountScan4Idx[i]; | ||
| 1027 | pNonZeroCount[iIndex] = !!pNonZeroCount[iIndex]; | ||
| 1028 | } | ||
| 1029 | } | ||
| 1030 | void WelsBlockFuncInit( PSetNoneZeroCountZeroFunc *pfSetNZCZero, int32_t iCpu ) | ||
| 1031 | { | ||
| 1032 | *pfSetNZCZero = WelsNonZeroCount_c; | ||
| 1033 | } | ||
| 1034 | |||
| 1035 | |||
| 1036 | #ifdef X86_ASM | ||
| 1037 | |||
| 1038 | extern "C" { | ||
| 1039 | void DeblockLumaLt4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta, int8_t *pTc) | ||
| 1040 | { | ||
| 1041 | ENFORCE_STACK_ALIGN_1D(uint8_t, uiBuf, 16*8, 16); | ||
| 1042 | |||
| 1043 | DeblockLumaTransposeH2V_sse2(pPixY - 4, iStride, &uiBuf[0]); | ||
| 1044 | DeblockLumaLt4V_sse2(&uiBuf[4*16], 16, iAlpha, iBeta, pTc); | ||
| 1045 | DeblockLumaTransposeV2H_sse2(pPixY - 4, iStride, &uiBuf[0]); | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | void DeblockLumaEq4H_sse2(uint8_t *pPixY, int32_t iStride, int32_t iAlpha, int32_t iBeta) | ||
| 1049 | { | ||
| 1050 | ENFORCE_STACK_ALIGN_1D(uint8_t, uiBuf, 16*8, 16); | ||
| 1051 | |||
| 1052 | DeblockLumaTransposeH2V_sse2(pPixY - 4, iStride, &uiBuf[0]); | ||
| 1053 | DeblockLumaEq4V_sse2(&uiBuf[4*16], 16, iAlpha, iBeta); | ||
| 1054 | DeblockLumaTransposeV2H_sse2(pPixY - 4, iStride, &uiBuf[0]); | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | } | ||
| 1058 | |||
| 1059 | #endif | ||
| 1060 | |||
| 1061 | |||
| 1062 | void DeblockingInit( DeblockingFunc * pFunc, int32_t iCpu ) | ||
| 1063 | { | ||
| 1064 | pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_c; | ||
| 1065 | pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_c; | ||
| 1066 | pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_c; | ||
| 1067 | pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_c; | ||
| 1068 | |||
| 1069 | pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_c; | ||
| 1070 | pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_c; | ||
| 1071 | pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_c; | ||
| 1072 | pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_c; | ||
| 1073 | |||
| 1074 | |||
| 1075 | #ifdef X86_ASM | ||
| 1076 | if( iCpu & WELS_CPU_SSE2 ){ | ||
| 1077 | pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_sse2; | ||
| 1078 | pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_sse2; | ||
| 1079 | pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_sse2; | ||
| 1080 | pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_sse2; | ||
| 1081 | pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_sse2; | ||
| 1082 | pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_sse2; | ||
| 1083 | pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_sse2; | ||
| 1084 | pFunc->pfChromaDeblockinEQ4Hor = DeblockChromaEq4H_sse2; | ||
| 1085 | } | ||
| 1086 | #endif | ||
| 1087 | } | ||
| 1088 | |||
| 1089 | |||
| 1090 | } // namespace WelsSVCEnc | ||
| 1091 | |||