History

Restore unix newlines after "Merge pull request #2991 from xiaotianshi2/master"

Some newlines were fixed in "Merge pull request #2997 from GuangweiWang/fix-issue-external", but lots were still left behind.

Martin Storsjö committed 8 years ago

Commit 1fb2f7d1 parent d43bfc114 files · +9238 −9238Browse files

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

Unified · Split

codec/decoder/core/src/rec_mb.cpp+1044−1044
@@ -1,1044 +1,1044 @@
1/*!1/*!
2 * \copy2 * \copy
3 * Copyright (c) 2009-2013, Cisco Systems3 * 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 without6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions7 * 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 copyright10 * * 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 copyright13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the15 * 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 CONTRIBUTORS18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE21 * 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) HOWEVER25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE28 * 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 rec_mb.c32 * \file rec_mb.c
33 *33 *
34 * \brief implementation for all macroblock decoding process after mb syntax parsing and residual decoding with cavlc.34 * \brief implementation for all macroblock decoding process after mb syntax parsing and residual decoding with cavlc.
35 *35 *
36 * \date 3/18/2009 Created36 * \date 3/18/2009 Created
37 *37 *
38 *************************************************************************************38 *************************************************************************************
39 */39 */
40 40
41 41
42#include "rec_mb.h"42#include "rec_mb.h"
43#include "decode_slice.h"43#include "decode_slice.h"
44 44
45namespace WelsDec {45namespace WelsDec {
46 46
47void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurLayer) {47void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer pCurLayer) {
48 PPicture pCurPic = pCtx->pDec;48 PPicture pCurPic = pCtx->pDec;
49 int32_t iLumaStride = pCurPic->iLinesize[0];49 int32_t iLumaStride = pCurPic->iLinesize[0];
50 int32_t iChromaStride = pCurPic->iLinesize[1];50 int32_t iChromaStride = pCurPic->iLinesize[1];
51 int32_t iMbX = pCurLayer->iMbX;51 int32_t iMbX = pCurLayer->iMbX;
52 int32_t iMbY = pCurLayer->iMbY;52 int32_t iMbY = pCurLayer->iMbY;
53 53
54 pCurLayer->iLumaStride = iLumaStride;54 pCurLayer->iLumaStride = iLumaStride;
55 pCurLayer->iChromaStride = iChromaStride;55 pCurLayer->iChromaStride = iChromaStride;
56 56
57 if (bOutput) {57 if (bOutput) {
58 pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);58 pCurLayer->pPred[0] = pCurPic->pData[0] + ((iMbY * iLumaStride + iMbX) << 4);
59 pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);59 pCurLayer->pPred[1] = pCurPic->pData[1] + ((iMbY * iChromaStride + iMbX) << 3);
60 pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);60 pCurLayer->pPred[2] = pCurPic->pData[2] + ((iMbY * iChromaStride + iMbX) << 3);
61 }61 }
62}62}
63 63
64int32_t RecI8x8Mb (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {64int32_t RecI8x8Mb (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
65 RecI8x8Luma (iMbXy, pCtx, pScoeffLevel, pDqLayer);65 RecI8x8Luma (iMbXy, pCtx, pScoeffLevel, pDqLayer);
66 RecI4x4Chroma (iMbXy, pCtx, pScoeffLevel, pDqLayer);66 RecI4x4Chroma (iMbXy, pCtx, pScoeffLevel, pDqLayer);
67 return ERR_NONE;67 return ERR_NONE;
68}68}
69 69
70int32_t RecI8x8Luma (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {70int32_t RecI8x8Luma (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
71 /*****get local variable from outer variable********/71 /*****get local variable from outer variable********/
72 /*prediction info*/72 /*prediction info*/
73 uint8_t* pPred = pDqLayer->pPred[0];73 uint8_t* pPred = pDqLayer->pPred[0];
74 74
75 int32_t iLumaStride = pDqLayer->iLumaStride;75 int32_t iLumaStride = pDqLayer->iLumaStride;
76 int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;76 int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;
77 PGetIntraPred8x8Func* pGetI8x8LumaPredFunc = pCtx->pGetI8x8LumaPredFunc;77 PGetIntraPred8x8Func* pGetI8x8LumaPredFunc = pCtx->pGetI8x8LumaPredFunc;
78 78
79 int8_t* pIntra8x8PredMode = pDqLayer->pIntra4x4FinalMode[iMbXy]; // I_NxN79 int8_t* pIntra8x8PredMode = pDqLayer->pIntra4x4FinalMode[iMbXy]; // I_NxN
80 int16_t* pRS = pScoeffLevel;80 int16_t* pRS = pScoeffLevel;
81 /*itransform info*/81 /*itransform info*/
82 PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8;82 PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8;
83 83
84 /*************local variable********************/84 /*************local variable********************/
85 uint8_t i = 0;85 uint8_t i = 0;
86 bool bTLAvail[4], bTRAvail[4];86 bool bTLAvail[4], bTRAvail[4];
87 // Top-Right : Left : Top-Left : Top87 // Top-Right : Left : Top-Left : Top
88 bTLAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x02);88 bTLAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x02);
89 bTLAvail[1] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x01);89 bTLAvail[1] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x01);
90 bTLAvail[2] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x04);90 bTLAvail[2] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x04);
91 bTLAvail[3] = true;91 bTLAvail[3] = true;
92 92
93 bTRAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x01);93 bTRAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x01);
94 bTRAvail[1] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x08);94 bTRAvail[1] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x08);
95 bTRAvail[2] = true;95 bTRAvail[2] = true;
96 bTRAvail[3] = false;96 bTRAvail[3] = false;
97 97
98 /*************real process*********************/98 /*************real process*********************/
99 for (i = 0; i < 4; i++) {99 for (i = 0; i < 4; i++) {
100 100
101 uint8_t* pPredI8x8 = pPred + pBlockOffset[i << 2];101 uint8_t* pPredI8x8 = pPred + pBlockOffset[i << 2];
102 uint8_t uiMode = pIntra8x8PredMode[g_kuiScan4[i << 2]];102 uint8_t uiMode = pIntra8x8PredMode[g_kuiScan4[i << 2]];
103 103
104 pGetI8x8LumaPredFunc[uiMode] (pPredI8x8, iLumaStride, bTLAvail[i], bTRAvail[i]);104 pGetI8x8LumaPredFunc[uiMode] (pPredI8x8, iLumaStride, bTLAvail[i], bTRAvail[i]);
105 105
106 int32_t iIndex = g_kuiMbCountScan4Idx[i << 2];106 int32_t iIndex = g_kuiMbCountScan4Idx[i << 2];
107 if (pDqLayer->pNzc[iMbXy][iIndex] || pDqLayer->pNzc[iMbXy][iIndex + 1] || pDqLayer->pNzc[iMbXy][iIndex + 4]107 if (pDqLayer->pNzc[iMbXy][iIndex] || pDqLayer->pNzc[iMbXy][iIndex + 1] || pDqLayer->pNzc[iMbXy][iIndex + 4]
108 || pDqLayer->pNzc[iMbXy][iIndex + 5]) {108 || pDqLayer->pNzc[iMbXy][iIndex + 5]) {
109 int16_t* pRSI8x8 = &pRS[i << 6];109 int16_t* pRSI8x8 = &pRS[i << 6];
110 pIdctResAddPredFunc (pPredI8x8, iLumaStride, pRSI8x8);110 pIdctResAddPredFunc (pPredI8x8, iLumaStride, pRSI8x8);
111 }111 }
112 }112 }
113 113
114 return ERR_NONE;114 return ERR_NONE;
115}115}
116 116
117int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {117int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
118 RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer);118 RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
119 RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);119 RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
120 return ERR_NONE;120 return ERR_NONE;
121}121}
122 122
123 123
124int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {124int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
125 /*****get local variable from outer variable********/125 /*****get local variable from outer variable********/
126 /*prediction info*/126 /*prediction info*/
127 uint8_t* pPred = pDqLayer->pPred[0];127 uint8_t* pPred = pDqLayer->pPred[0];
128 128
129 int32_t iLumaStride = pDqLayer->iLumaStride;129 int32_t iLumaStride = pDqLayer->iLumaStride;
130 int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;130 int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;
131 PGetIntraPredFunc* pGetI4x4LumaPredFunc = pCtx->pGetI4x4LumaPredFunc;131 PGetIntraPredFunc* pGetI4x4LumaPredFunc = pCtx->pGetI4x4LumaPredFunc;
132 132
133 int8_t* pIntra4x4PredMode = pDqLayer->pIntra4x4FinalMode[iMBXY];133 int8_t* pIntra4x4PredMode = pDqLayer->pIntra4x4FinalMode[iMBXY];
134 int16_t* pRS = pScoeffLevel;134 int16_t* pRS = pScoeffLevel;
135 /*itransform info*/135 /*itransform info*/
136 PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;136 PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc;
137 137
138 138
139 /*************local variable********************/139 /*************local variable********************/
140 uint8_t i = 0;140 uint8_t i = 0;
141 141
142 /*************real process*********************/142 /*************real process*********************/
143 for (i = 0; i < 16; i++) {143 for (i = 0; i < 16; i++) {
144 144
145 uint8_t* pPredI4x4 = pPred + pBlockOffset[i];145 uint8_t* pPredI4x4 = pPred + pBlockOffset[i];
146 uint8_t uiMode = pIntra4x4PredMode[g_kuiScan4[i]];146 uint8_t uiMode = pIntra4x4PredMode[g_kuiScan4[i]];
147 147
148 pGetI4x4LumaPredFunc[uiMode] (pPredI4x4, iLumaStride);148 pGetI4x4LumaPredFunc[uiMode] (pPredI4x4, iLumaStride);
149 149
150 if (pDqLayer->pNzc[iMBXY][g_kuiMbCountScan4Idx[i]]) {150 if (pDqLayer->pNzc[iMBXY][g_kuiMbCountScan4Idx[i]]) {
151 int16_t* pRSI4x4 = &pRS[i << 4];151 int16_t* pRSI4x4 = &pRS[i << 4];
152 pIdctResAddPredFunc (pPredI4x4, iLumaStride, pRSI4x4);152 pIdctResAddPredFunc (pPredI4x4, iLumaStride, pRSI4x4);
153 }153 }
154 }154 }
155 155
156 return ERR_NONE;156 return ERR_NONE;
157}157}
158 158
159 159
160int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {160int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
161 int32_t iChromaStride = pCtx->pCurDqLayer->pDec->iLinesize[1];161 int32_t iChromaStride = pCtx->pCurDqLayer->pDec->iLinesize[1];
162 162
163 int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];163 int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
164 164
165 PGetIntraPredFunc* pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;165 PGetIntraPredFunc* pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;
166 166
167 uint8_t* pPred = pDqLayer->pPred[1];167 uint8_t* pPred = pDqLayer->pPred[1];
168 168
169 pGetIChromaPredFunc[iChromaPredMode] (pPred, iChromaStride);169 pGetIChromaPredFunc[iChromaPredMode] (pPred, iChromaStride);
170 pPred = pDqLayer->pPred[2];170 pPred = pDqLayer->pPred[2];
171 pGetIChromaPredFunc[iChromaPredMode] (pPred, iChromaStride);171 pGetIChromaPredFunc[iChromaPredMode] (pPred, iChromaStride);
172 172
173 RecChroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);173 RecChroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
174 174
175 return ERR_NONE;175 return ERR_NONE;
176}176}
177 177
178 178
179int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {179int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
180 /*decoder use, encoder no use*/180 /*decoder use, encoder no use*/
181 int8_t iI16x16PredMode = pDqLayer->pIntraPredMode[iMBXY][7];181 int8_t iI16x16PredMode = pDqLayer->pIntraPredMode[iMBXY][7];
182 int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];182 int8_t iChromaPredMode = pDqLayer->pChromaPredMode[iMBXY];
183 PGetIntraPredFunc* pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;183 PGetIntraPredFunc* pGetIChromaPredFunc = pCtx->pGetIChromaPredFunc;
184 PGetIntraPredFunc* pGetI16x16LumaPredFunc = pCtx->pGetI16x16LumaPredFunc;184 PGetIntraPredFunc* pGetI16x16LumaPredFunc = pCtx->pGetI16x16LumaPredFunc;
185 int32_t iUVStride = pCtx->pCurDqLayer->pDec->iLinesize[1];185 int32_t iUVStride = pCtx->pCurDqLayer->pDec->iLinesize[1];
186 186
187 /*common use by decoder&encoder*/187 /*common use by decoder&encoder*/
188 int32_t iYStride = pDqLayer->iLumaStride;188 int32_t iYStride = pDqLayer->iLumaStride;
189 int16_t* pRS = pScoeffLevel;189 int16_t* pRS = pScoeffLevel;
190 190
191 uint8_t* pPred = pDqLayer->pPred[0];191 uint8_t* pPred = pDqLayer->pPred[0];
192 192
193 PIdctFourResAddPredFunc pIdctFourResAddPredFunc = pCtx->pIdctFourResAddPredFunc;193 PIdctFourResAddPredFunc pIdctFourResAddPredFunc = pCtx->pIdctFourResAddPredFunc;
194 194
195 /*decode i16x16 y*/195 /*decode i16x16 y*/
196 pGetI16x16LumaPredFunc[iI16x16PredMode] (pPred, iYStride);196 pGetI16x16LumaPredFunc[iI16x16PredMode] (pPred, iYStride);
197 197
198 /*1 mb is divided 16 4x4_block to idct*/198 /*1 mb is divided 16 4x4_block to idct*/
199 const int8_t* pNzc = pDqLayer->pNzc[iMBXY];199 const int8_t* pNzc = pDqLayer->pNzc[iMBXY];
200 pIdctFourResAddPredFunc (pPred + 0 * iYStride + 0, iYStride, pRS + 0 * 64, pNzc + 0);200 pIdctFourResAddPredFunc (pPred + 0 * iYStride + 0, iYStride, pRS + 0 * 64, pNzc + 0);
201 pIdctFourResAddPredFunc (pPred + 0 * iYStride + 8, iYStride, pRS + 1 * 64, pNzc + 2);201 pIdctFourResAddPredFunc (pPred + 0 * iYStride + 8, iYStride, pRS + 1 * 64, pNzc + 2);
202 pIdctFourResAddPredFunc (pPred + 8 * iYStride + 0, iYStride, pRS + 2 * 64, pNzc + 8);202 pIdctFourResAddPredFunc (pPred + 8 * iYStride + 0, iYStride, pRS + 2 * 64, pNzc + 8);
203 pIdctFourResAddPredFunc (pPred + 8 * iYStride + 8, iYStride, pRS + 3 * 64, pNzc + 10);203 pIdctFourResAddPredFunc (pPred + 8 * iYStride + 8, iYStride, pRS + 3 * 64, pNzc + 10);
204 204
205 /*decode intra mb cb&cr*/205 /*decode intra mb cb&cr*/
206 pPred = pDqLayer->pPred[1];206 pPred = pDqLayer->pPred[1];
207 pGetIChromaPredFunc[iChromaPredMode] (pPred, iUVStride);207 pGetIChromaPredFunc[iChromaPredMode] (pPred, iUVStride);
208 pPred = pDqLayer->pPred[2];208 pPred = pDqLayer->pPred[2];
209 pGetIChromaPredFunc[iChromaPredMode] (pPred, iUVStride);209 pGetIChromaPredFunc[iChromaPredMode] (pPred, iUVStride);
210 RecChroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);210 RecChroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
211 211
212 return ERR_NONE;212 return ERR_NONE;
213}213}
214 214
215 215
216//according to current 8*8 block ref_index to gain reference picture216//according to current 8*8 block ref_index to gain reference picture
217static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList,217static inline void GetRefPic (sMCRefMember* pMCRefMem, PWelsDecoderContext pCtx, int8_t* pRefIdxList,
218 int32_t iIndex, int32_t listIdx) {218 int32_t iIndex, int32_t listIdx) {
219 PPicture pRefPic;219 PPicture pRefPic;
220 220
221 int8_t iRefIdx = pRefIdxList[iIndex];221 int8_t iRefIdx = pRefIdxList[iIndex];
222 if (iRefIdx >= 0) {222 if (iRefIdx >= 0) {
223 pRefPic = pCtx->sRefPic.pRefList[listIdx][iRefIdx];223 pRefPic = pCtx->sRefPic.pRefList[listIdx][iRefIdx];
224 224
225 if (pRefPic != NULL) {225 if (pRefPic != NULL) {
226 pMCRefMem->iSrcLineLuma = pRefPic->iLinesize[0];226 pMCRefMem->iSrcLineLuma = pRefPic->iLinesize[0];
227 pMCRefMem->iSrcLineChroma = pRefPic->iLinesize[1];227 pMCRefMem->iSrcLineChroma = pRefPic->iLinesize[1];
228 228
229 pMCRefMem->pSrcY = pRefPic->pData[0];229 pMCRefMem->pSrcY = pRefPic->pData[0];
230 pMCRefMem->pSrcU = pRefPic->pData[1];230 pMCRefMem->pSrcU = pRefPic->pData[1];
231 pMCRefMem->pSrcV = pRefPic->pData[2];231 pMCRefMem->pSrcV = pRefPic->pData[2];
232 }232 }
233 }233 }
234}234}
235 235
236 236
237#ifndef MC_FLOW_SIMPLE_JUDGE237#ifndef MC_FLOW_SIMPLE_JUDGE
238#define MC_FLOW_SIMPLE_JUDGE 1238#define MC_FLOW_SIMPLE_JUDGE 1
239#endif //MC_FLOW_SIMPLE_JUDGE239#endif //MC_FLOW_SIMPLE_JUDGE
240void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,240void BaseMC (sMCRefMember* pMCRefMem, int32_t iXOffset, int32_t iYOffset, SMcFunc* pMCFunc,
241 int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {241 int32_t iBlkWidth, int32_t iBlkHeight, int16_t iMVs[2]) {
242 int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel242 int32_t iFullMVx = (iXOffset << 2) + iMVs[0]; //quarter pixel
243 int32_t iFullMVy = (iYOffset << 2) + iMVs[1];243 int32_t iFullMVy = (iYOffset << 2) + iMVs[1];
244 iFullMVx = WELS_CLIP3 (iFullMVx, ((-PADDING_LENGTH + 2) * (1 << 2)),244 iFullMVx = WELS_CLIP3 (iFullMVx, ((-PADDING_LENGTH + 2) * (1 << 2)),
245 ((pMCRefMem->iPicWidth + PADDING_LENGTH - 19) * (1 << 2)));245 ((pMCRefMem->iPicWidth + PADDING_LENGTH - 19) * (1 << 2)));
246 iFullMVy = WELS_CLIP3 (iFullMVy, ((-PADDING_LENGTH + 2) * (1 << 2)),246 iFullMVy = WELS_CLIP3 (iFullMVy, ((-PADDING_LENGTH + 2) * (1 << 2)),
247 ((pMCRefMem->iPicHeight + PADDING_LENGTH - 19) * (1 << 2)));247 ((pMCRefMem->iPicHeight + PADDING_LENGTH - 19) * (1 << 2)));
248 248
249 int32_t iSrcPixOffsetLuma = (iFullMVx >> 2) + (iFullMVy >> 2) * pMCRefMem->iSrcLineLuma;249 int32_t iSrcPixOffsetLuma = (iFullMVx >> 2) + (iFullMVy >> 2) * pMCRefMem->iSrcLineLuma;
250 int32_t iSrcPixOffsetChroma = (iFullMVx >> 3) + (iFullMVy >> 3) * pMCRefMem->iSrcLineChroma;250 int32_t iSrcPixOffsetChroma = (iFullMVx >> 3) + (iFullMVy >> 3) * pMCRefMem->iSrcLineChroma;
251 251
252 int32_t iBlkWidthChroma = iBlkWidth >> 1;252 int32_t iBlkWidthChroma = iBlkWidth >> 1;
253 int32_t iBlkHeightChroma = iBlkHeight >> 1;253 int32_t iBlkHeightChroma = iBlkHeight >> 1;
254 254
255 uint8_t* pSrcY = pMCRefMem->pSrcY + iSrcPixOffsetLuma;255 uint8_t* pSrcY = pMCRefMem->pSrcY + iSrcPixOffsetLuma;
256 uint8_t* pSrcU = pMCRefMem->pSrcU + iSrcPixOffsetChroma;256 uint8_t* pSrcU = pMCRefMem->pSrcU + iSrcPixOffsetChroma;
257 uint8_t* pSrcV = pMCRefMem->pSrcV + iSrcPixOffsetChroma;257 uint8_t* pSrcV = pMCRefMem->pSrcV + iSrcPixOffsetChroma;
258 uint8_t* pDstY = pMCRefMem->pDstY;258 uint8_t* pDstY = pMCRefMem->pDstY;
259 uint8_t* pDstU = pMCRefMem->pDstU;259 uint8_t* pDstU = pMCRefMem->pDstU;
260 uint8_t* pDstV = pMCRefMem->pDstV;260 uint8_t* pDstV = pMCRefMem->pDstV;
261 261
262 pMCFunc->pMcLumaFunc (pSrcY, pMCRefMem->iSrcLineLuma, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth,262 pMCFunc->pMcLumaFunc (pSrcY, pMCRefMem->iSrcLineLuma, pDstY, pMCRefMem->iDstLineLuma, iFullMVx, iFullMVy, iBlkWidth,
263 iBlkHeight);263 iBlkHeight);
264 pMCFunc->pMcChromaFunc (pSrcU, pMCRefMem->iSrcLineChroma, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,264 pMCFunc->pMcChromaFunc (pSrcU, pMCRefMem->iSrcLineChroma, pDstU, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,
265 iBlkWidthChroma, iBlkHeightChroma);265 iBlkWidthChroma, iBlkHeightChroma);
266 pMCFunc->pMcChromaFunc (pSrcV, pMCRefMem->iSrcLineChroma, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,266 pMCFunc->pMcChromaFunc (pSrcV, pMCRefMem->iSrcLineChroma, pDstV, pMCRefMem->iDstLineChroma, iFullMVx, iFullMVy,
267 iBlkWidthChroma, iBlkHeightChroma);267 iBlkWidthChroma, iBlkHeightChroma);
268 268
269}269}
270 270
271static void WeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, int32_t listIdx, int32_t iRefIdx,271static void WeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, int32_t listIdx, int32_t iRefIdx,
272 int32_t iBlkWidth,272 int32_t iBlkWidth,
273 int32_t iBlkHeight) {273 int32_t iBlkHeight) {
274 274
275 275
276 int32_t iLog2denom, iWoc, iOoc;276 int32_t iLog2denom, iWoc, iOoc;
277 int32_t iPredTemp, iLineStride;277 int32_t iPredTemp, iLineStride;
278 int32_t iPixel = 0;278 int32_t iPixel = 0;
279 uint8_t* pDst;279 uint8_t* pDst;
280 //luma280 //luma
281 iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;281 iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;
282 iWoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iLumaWeight[iRefIdx];282 iWoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iLumaWeight[iRefIdx];
283 iOoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iLumaOffset[iRefIdx];283 iOoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iLumaOffset[iRefIdx];
284 iLineStride = pMCRefMem->iDstLineLuma;284 iLineStride = pMCRefMem->iDstLineLuma;
285 285
286 for (int i = 0; i < iBlkHeight; i++) {286 for (int i = 0; i < iBlkHeight; i++) {
287 for (int j = 0; j < iBlkWidth; j++) {287 for (int j = 0; j < iBlkWidth; j++) {
288 iPixel = j + i * (iLineStride);288 iPixel = j + i * (iLineStride);
289 if (iLog2denom >= 1) {289 if (iLog2denom >= 1) {
290 iPredTemp = ((pMCRefMem->pDstY[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc;290 iPredTemp = ((pMCRefMem->pDstY[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc;
291 291
292 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);292 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
293 } else {293 } else {
294 iPredTemp = pMCRefMem->pDstY[iPixel] * iWoc + iOoc;294 iPredTemp = pMCRefMem->pDstY[iPixel] * iWoc + iOoc;
295 295
296 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);296 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
297 297
298 }298 }
299 }299 }
300 }300 }
301 301
302 302
303 //UV303 //UV
304 iBlkWidth = iBlkWidth >> 1;304 iBlkWidth = iBlkWidth >> 1;
305 iBlkHeight = iBlkHeight >> 1;305 iBlkHeight = iBlkHeight >> 1;
306 iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;306 iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;
307 iLineStride = pMCRefMem->iDstLineChroma;307 iLineStride = pMCRefMem->iDstLineChroma;
308 308
309 for (int i = 0; i < 2; i++) {309 for (int i = 0; i < 2; i++) {
310 310
311 311
312 //iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;312 //iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;
313 iWoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iChromaWeight[iRefIdx][i];313 iWoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iChromaWeight[iRefIdx][i];
314 iOoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iChromaOffset[iRefIdx][i];314 iOoc = pCurDqLayer->pPredWeightTable->sPredList[listIdx].iChromaOffset[iRefIdx][i];
315 pDst = i ? pMCRefMem->pDstV : pMCRefMem->pDstU;315 pDst = i ? pMCRefMem->pDstV : pMCRefMem->pDstU;
316 //iLineStride = pMCRefMem->iDstLineChroma;316 //iLineStride = pMCRefMem->iDstLineChroma;
317 317
318 for (int i = 0; i < iBlkHeight ; i++) {318 for (int i = 0; i < iBlkHeight ; i++) {
319 for (int j = 0; j < iBlkWidth; j++) {319 for (int j = 0; j < iBlkWidth; j++) {
320 iPixel = j + i * (iLineStride);320 iPixel = j + i * (iLineStride);
321 if (iLog2denom >= 1) {321 if (iLog2denom >= 1) {
322 iPredTemp = ((pDst[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc;322 iPredTemp = ((pDst[iPixel] * iWoc + (1 << (iLog2denom - 1))) >> iLog2denom) + iOoc;
323 323
324 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);324 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
325 } else {325 } else {
326 iPredTemp = pDst[iPixel] * iWoc + iOoc;326 iPredTemp = pDst[iPixel] * iWoc + iOoc;
327 327
328 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);328 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
329 329
330 }330 }
331 }331 }
332 332
333 }333 }
334 334
335 335
336 }336 }
337}337}
338 338
339static void BiWeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, sMCRefMember* pTempMCRefMem,339static void BiWeightPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, sMCRefMember* pTempMCRefMem,
340 int32_t iRefIdx1, int32_t iRefIdx2, bool bWeightedBipredIdcIs1, int32_t iBlkWidth,340 int32_t iRefIdx1, int32_t iRefIdx2, bool bWeightedBipredIdcIs1, int32_t iBlkWidth,
341 int32_t iBlkHeight) {341 int32_t iBlkHeight) {
342 int32_t iWoc1 = 0, iOoc1 = 0, iWoc2 = 0, iOoc2 = 0;342 int32_t iWoc1 = 0, iOoc1 = 0, iWoc2 = 0, iOoc2 = 0;
343 int32_t iPredTemp, iLineStride;343 int32_t iPredTemp, iLineStride;
344 int32_t iPixel = 0;344 int32_t iPixel = 0;
345 //luma345 //luma
346 int32_t iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;346 int32_t iLog2denom = pCurDqLayer->pPredWeightTable->uiLumaLog2WeightDenom;
347 if (bWeightedBipredIdcIs1) {347 if (bWeightedBipredIdcIs1) {
348 iWoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaWeight[iRefIdx1];348 iWoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaWeight[iRefIdx1];
349 iOoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaOffset[iRefIdx1];349 iOoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iLumaOffset[iRefIdx1];
350 iWoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iLumaWeight[iRefIdx2];350 iWoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iLumaWeight[iRefIdx2];
351 iOoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iLumaOffset[iRefIdx2];351 iOoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iLumaOffset[iRefIdx2];
352 } else {352 } else {
353 iWoc1 = pCurDqLayer->pPredWeightTable->iImplicitWeight[iRefIdx1][iRefIdx2];353 iWoc1 = pCurDqLayer->pPredWeightTable->iImplicitWeight[iRefIdx1][iRefIdx2];
354 iWoc2 = 64 - iWoc1;354 iWoc2 = 64 - iWoc1;
355 }355 }
356 iLineStride = pMCRefMem->iDstLineLuma;356 iLineStride = pMCRefMem->iDstLineLuma;
357 357
358 for (int i = 0; i < iBlkHeight; i++) {358 for (int i = 0; i < iBlkHeight; i++) {
359 for (int j = 0; j < iBlkWidth; j++) {359 for (int j = 0; j < iBlkWidth; j++) {
360 iPixel = j + i * (iLineStride);360 iPixel = j + i * (iLineStride);
361 iPredTemp = ((pMCRefMem->pDstY[iPixel] * iWoc1 + pTempMCRefMem->pDstY[iPixel] * iWoc2 + (1 << iLog2denom)) >>361 iPredTemp = ((pMCRefMem->pDstY[iPixel] * iWoc1 + pTempMCRefMem->pDstY[iPixel] * iWoc2 + (1 << iLog2denom)) >>
362 (iLog2denom + 1)) + ((iOoc1 + iOoc2 + 1) >> 1);362 (iLog2denom + 1)) + ((iOoc1 + iOoc2 + 1) >> 1);
363 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);363 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
364 }364 }
365 }365 }
366 366
367 //UV367 //UV
368 iBlkWidth = iBlkWidth >> 1;368 iBlkWidth = iBlkWidth >> 1;
369 iBlkHeight = iBlkHeight >> 1;369 iBlkHeight = iBlkHeight >> 1;
370 iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;370 iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;
371 iLineStride = pMCRefMem->iDstLineChroma;371 iLineStride = pMCRefMem->iDstLineChroma;
372 372
373 uint8_t* pDst;373 uint8_t* pDst;
374 uint8_t* pTempDst;374 uint8_t* pTempDst;
375 for (int k = 0; k < 2; k++) {375 for (int k = 0; k < 2; k++) {
376 //iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;376 //iLog2denom = pCurDqLayer->pPredWeightTable->uiChromaLog2WeightDenom;
377 if (bWeightedBipredIdcIs1) {377 if (bWeightedBipredIdcIs1) {
378 iWoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaWeight[iRefIdx1][k];378 iWoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaWeight[iRefIdx1][k];
379 iOoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaOffset[iRefIdx1][k];379 iOoc1 = pCurDqLayer->pPredWeightTable->sPredList[LIST_0].iChromaOffset[iRefIdx1][k];
380 iWoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iChromaWeight[iRefIdx2][k];380 iWoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iChromaWeight[iRefIdx2][k];
381 iOoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iChromaOffset[iRefIdx2][k];381 iOoc2 = pCurDqLayer->pPredWeightTable->sPredList[LIST_1].iChromaOffset[iRefIdx2][k];
382 }382 }
383 pDst = k ? pMCRefMem->pDstV : pMCRefMem->pDstU;383 pDst = k ? pMCRefMem->pDstV : pMCRefMem->pDstU;
384 pTempDst = k ? pTempMCRefMem->pDstV : pTempMCRefMem->pDstU;384 pTempDst = k ? pTempMCRefMem->pDstV : pTempMCRefMem->pDstU;
385 //iLineStride = pMCRefMem->iDstLineChroma;385 //iLineStride = pMCRefMem->iDstLineChroma;
386 386
387 for (int i = 0; i < iBlkHeight; i++) {387 for (int i = 0; i < iBlkHeight; i++) {
388 for (int j = 0; j < iBlkWidth; j++) {388 for (int j = 0; j < iBlkWidth; j++) {
389 iPixel = j + i * (iLineStride);389 iPixel = j + i * (iLineStride);
390 iPredTemp = ((pDst[iPixel] * iWoc1 + pTempDst[iPixel] * iWoc2 + (1 << iLog2denom)) >> (iLog2denom + 1)) + ((390 iPredTemp = ((pDst[iPixel] * iWoc1 + pTempDst[iPixel] * iWoc2 + (1 << iLog2denom)) >> (iLog2denom + 1)) + ((
391 iOoc1 + iOoc2 + 1) >> 1);391 iOoc1 + iOoc2 + 1) >> 1);
392 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);392 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
393 }393 }
394 }394 }
395 }395 }
396}396}
397 397
398static void BiPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, sMCRefMember* pTempMCRefMem, int32_t iBlkWidth,398static void BiPrediction (PDqLayer pCurDqLayer, sMCRefMember* pMCRefMem, sMCRefMember* pTempMCRefMem, int32_t iBlkWidth,
399 int32_t iBlkHeight) {399 int32_t iBlkHeight) {
400 int32_t iPredTemp, iLineStride;400 int32_t iPredTemp, iLineStride;
401 int32_t iPixel = 0;401 int32_t iPixel = 0;
402 //luma402 //luma
403 iLineStride = pMCRefMem->iDstLineLuma;403 iLineStride = pMCRefMem->iDstLineLuma;
404 404
405 for (int i = 0; i < iBlkHeight; i++) {405 for (int i = 0; i < iBlkHeight; i++) {
406 for (int j = 0; j < iBlkWidth; j++) {406 for (int j = 0; j < iBlkWidth; j++) {
407 iPixel = j + i * (iLineStride);407 iPixel = j + i * (iLineStride);
408 iPredTemp = (pMCRefMem->pDstY[iPixel] + pTempMCRefMem->pDstY[iPixel] + 1) >> 1;408 iPredTemp = (pMCRefMem->pDstY[iPixel] + pTempMCRefMem->pDstY[iPixel] + 1) >> 1;
409 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);409 pMCRefMem->pDstY[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
410 }410 }
411 }411 }
412 412
413 //UV413 //UV
414 iBlkWidth = iBlkWidth >> 1;414 iBlkWidth = iBlkWidth >> 1;
415 iBlkHeight = iBlkHeight >> 1;415 iBlkHeight = iBlkHeight >> 1;
416 iLineStride = pMCRefMem->iDstLineChroma;416 iLineStride = pMCRefMem->iDstLineChroma;
417 417
418 uint8_t* pDst;418 uint8_t* pDst;
419 uint8_t* pTempDst;419 uint8_t* pTempDst;
420 for (int k = 0; k < 2; k++) {420 for (int k = 0; k < 2; k++) {
421 pDst = k ? pMCRefMem->pDstV : pMCRefMem->pDstU;421 pDst = k ? pMCRefMem->pDstV : pMCRefMem->pDstU;
422 pTempDst = k ? pTempMCRefMem->pDstV : pTempMCRefMem->pDstU;422 pTempDst = k ? pTempMCRefMem->pDstV : pTempMCRefMem->pDstU;
423 //iLineStride = pMCRefMem->iDstLineChroma;423 //iLineStride = pMCRefMem->iDstLineChroma;
424 424
425 for (int i = 0; i < iBlkHeight; i++) {425 for (int i = 0; i < iBlkHeight; i++) {
426 for (int j = 0; j < iBlkWidth; j++) {426 for (int j = 0; j < iBlkWidth; j++) {
427 iPixel = j + i * (iLineStride);427 iPixel = j + i * (iLineStride);
428 iPredTemp = (pDst[iPixel] + pTempDst[iPixel] + 1) >> 1;428 iPredTemp = (pDst[iPixel] + pTempDst[iPixel] + 1) >> 1;
429 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);429 pDst[iPixel] = WELS_CLIP3 (iPredTemp, 0, 255);
430 }430 }
431 }431 }
432 }432 }
433}433}
434 434
435void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {435void GetInterPred (uint8_t* pPredY, uint8_t* pPredCb, uint8_t* pPredCr, PWelsDecoderContext pCtx) {
436 sMCRefMember pMCRefMem;436 sMCRefMember pMCRefMem;
437 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;437 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
438 SMcFunc* pMCFunc = &pCtx->sMcFunc;438 SMcFunc* pMCFunc = &pCtx->sMcFunc;
439 439
440 int32_t iMBXY = pCurDqLayer->iMbXyIndex;440 int32_t iMBXY = pCurDqLayer->iMbXyIndex;
441 441
442 int16_t iMVs[2] = {0};442 int16_t iMVs[2] = {0};
443 443
444 uint32_t iMBType = pCurDqLayer->pMbType[iMBXY];444 uint32_t iMBType = pCurDqLayer->pMbType[iMBXY];
445 445
446 int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;446 int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;
447 int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;447 int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;
448 448
449 int32_t iDstLineLuma = pCtx->pDec->iLinesize[0];449 int32_t iDstLineLuma = pCtx->pDec->iLinesize[0];
450 int32_t iDstLineChroma = pCtx->pDec->iLinesize[1];450 int32_t iDstLineChroma = pCtx->pDec->iLinesize[1];
451 451
452 int32_t iBlk8X, iBlk8Y, iBlk4X, iBlk4Y, i, j, iIIdx, iJIdx;452 int32_t iBlk8X, iBlk8Y, iBlk4X, iBlk4Y, i, j, iIIdx, iJIdx;
453 453
454 pMCRefMem.iPicWidth = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbWidth << 4);454 pMCRefMem.iPicWidth = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbWidth << 4);
455 pMCRefMem.iPicHeight = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbHeight << 4);455 pMCRefMem.iPicHeight = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbHeight << 4);
456 456
457 pMCRefMem.pDstY = pPredY;457 pMCRefMem.pDstY = pPredY;
458 pMCRefMem.pDstU = pPredCb;458 pMCRefMem.pDstU = pPredCb;
459 pMCRefMem.pDstV = pPredCr;459 pMCRefMem.pDstV = pPredCr;
460 460
461 pMCRefMem.iDstLineLuma = iDstLineLuma;461 pMCRefMem.iDstLineLuma = iDstLineLuma;
462 pMCRefMem.iDstLineChroma = iDstLineChroma;462 pMCRefMem.iDstLineChroma = iDstLineChroma;
463 463
464 int32_t iRefIndex = 0;464 int32_t iRefIndex = 0;
465 465
466 switch (iMBType) {466 switch (iMBType) {
467 case MB_TYPE_SKIP:467 case MB_TYPE_SKIP:
468 case MB_TYPE_16x16:468 case MB_TYPE_16x16:
469 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];469 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
470 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];470 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
471 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0);471 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0);
472 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);472 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
473 473
474 if (pCurDqLayer->bUseWeightPredictionFlag) {474 if (pCurDqLayer->bUseWeightPredictionFlag) {
475 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];475 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
476 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 16);476 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 16);
477 }477 }
478 break;478 break;
479 case MB_TYPE_16x8:479 case MB_TYPE_16x8:
480 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];480 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
481 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];481 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
482 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0);482 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0);
483 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);483 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 8, iMVs);
484 484
485 if (pCurDqLayer->bUseWeightPredictionFlag) {485 if (pCurDqLayer->bUseWeightPredictionFlag) {
486 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];486 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
487 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8);487 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8);
488 }488 }
489 489
490 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];490 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][8][0];
491 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];491 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][8][1];
492 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8, LIST_0);492 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 8, LIST_0);
493 pMCRefMem.pDstY = pPredY + (iDstLineLuma << 3);493 pMCRefMem.pDstY = pPredY + (iDstLineLuma << 3);
494 pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);494 pMCRefMem.pDstU = pPredCb + (iDstLineChroma << 2);
495 pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);495 pMCRefMem.pDstV = pPredCr + (iDstLineChroma << 2);
496 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs);496 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + 8, pMCFunc, 16, 8, iMVs);
497 497
498 if (pCurDqLayer->bUseWeightPredictionFlag) {498 if (pCurDqLayer->bUseWeightPredictionFlag) {
499 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][8];499 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][8];
500 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8);500 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 16, 8);
501 }501 }
502 break;502 break;
503 case MB_TYPE_8x16:503 case MB_TYPE_8x16:
504 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];504 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][0][0];
505 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];505 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][0][1];
506 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0);506 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 0, LIST_0);
507 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);507 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 8, 16, iMVs);
508 if (pCurDqLayer->bUseWeightPredictionFlag) {508 if (pCurDqLayer->bUseWeightPredictionFlag) {
509 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];509 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][0];
510 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16);510 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16);
511 }511 }
512 512
513 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];513 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][2][0];
514 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];514 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][2][1];
515 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 2, LIST_0);515 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], 2, LIST_0);
516 pMCRefMem.pDstY = pPredY + 8;516 pMCRefMem.pDstY = pPredY + 8;
517 pMCRefMem.pDstU = pPredCb + 4;517 pMCRefMem.pDstU = pPredCb + 4;
518 pMCRefMem.pDstV = pPredCr + 4;518 pMCRefMem.pDstV = pPredCr + 4;
519 BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);519 BaseMC (&pMCRefMem, iMBOffsetX + 8, iMBOffsetY, pMCFunc, 8, 16, iMVs);
520 520
521 if (pCurDqLayer->bUseWeightPredictionFlag) {521 if (pCurDqLayer->bUseWeightPredictionFlag) {
522 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][2];522 iRefIndex = pCurDqLayer->pRefIndex[0][iMBXY][2];
523 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16);523 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 16);
524 }524 }
525 break;525 break;
526 case MB_TYPE_8x8:526 case MB_TYPE_8x8:
527 case MB_TYPE_8x8_REF0: {527 case MB_TYPE_8x8_REF0: {
528 uint32_t iSubMBType;528 uint32_t iSubMBType;
529 int32_t iXOffset, iYOffset;529 int32_t iXOffset, iYOffset;
530 uint8_t* pDstY, *pDstU, *pDstV;530 uint8_t* pDstY, *pDstU, *pDstV;
531 for (i = 0; i < 4; i++) {531 for (i = 0; i < 4; i++) {
532 iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];532 iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];
533 iBlk8X = (i & 1) << 3;533 iBlk8X = (i & 1) << 3;
534 iBlk8Y = (i >> 1) << 3;534 iBlk8Y = (i >> 1) << 3;
535 iXOffset = iMBOffsetX + iBlk8X;535 iXOffset = iMBOffsetX + iBlk8X;
536 iYOffset = iMBOffsetY + iBlk8Y;536 iYOffset = iMBOffsetY + iBlk8Y;
537 537
538 iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);538 iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
539 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx, LIST_0);539 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[0][iMBXY], iIIdx, LIST_0);
540 iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0;540 iRefIndex = pCurDqLayer->bUseWeightPredictionFlag ? pCurDqLayer->pRefIndex[0][iMBXY][iIIdx] : 0;
541 541
542 pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;542 pDstY = pPredY + iBlk8X + iBlk8Y * iDstLineLuma;
543 pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;543 pDstU = pPredCb + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
544 pDstV = pPredCr + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;544 pDstV = pPredCr + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
545 pMCRefMem.pDstY = pDstY;545 pMCRefMem.pDstY = pDstY;
546 pMCRefMem.pDstU = pDstU;546 pMCRefMem.pDstU = pDstU;
547 pMCRefMem.pDstV = pDstV;547 pMCRefMem.pDstV = pDstV;
548 switch (iSubMBType) {548 switch (iSubMBType) {
549 case SUB_MB_TYPE_8x8:549 case SUB_MB_TYPE_8x8:
550 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];550 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
551 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];551 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
552 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);552 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
553 if (pCurDqLayer->bUseWeightPredictionFlag) {553 if (pCurDqLayer->bUseWeightPredictionFlag) {
554 554
555 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 8);555 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 8);
556 }556 }
557 557
558 break;558 break;
559 case SUB_MB_TYPE_8x4:559 case SUB_MB_TYPE_8x4:
560 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];560 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
561 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];561 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
562 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);562 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
563 if (pCurDqLayer->bUseWeightPredictionFlag) {563 if (pCurDqLayer->bUseWeightPredictionFlag) {
564 564
565 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 4);565 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 4);
566 }566 }
567 567
568 568
569 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];569 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][0];
570 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1];570 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 4][1];
571 pMCRefMem.pDstY += (iDstLineLuma << 2);571 pMCRefMem.pDstY += (iDstLineLuma << 2);
572 pMCRefMem.pDstU += (iDstLineChroma << 1);572 pMCRefMem.pDstU += (iDstLineChroma << 1);
573 pMCRefMem.pDstV += (iDstLineChroma << 1);573 pMCRefMem.pDstV += (iDstLineChroma << 1);
574 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);574 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
575 if (pCurDqLayer->bUseWeightPredictionFlag) {575 if (pCurDqLayer->bUseWeightPredictionFlag) {
576 576
577 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 4);577 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 8, 4);
578 }578 }
579 579
580 break;580 break;
581 case SUB_MB_TYPE_4x8:581 case SUB_MB_TYPE_4x8:
582 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];582 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx][0];
583 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];583 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx][1];
584 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);584 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
585 if (pCurDqLayer->bUseWeightPredictionFlag) {585 if (pCurDqLayer->bUseWeightPredictionFlag) {
586 586
587 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 8);587 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 8);
588 }588 }
589 589
590 590
591 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];591 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][0];
592 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1];592 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + 1][1];
593 pMCRefMem.pDstY += 4;593 pMCRefMem.pDstY += 4;
594 pMCRefMem.pDstU += 2;594 pMCRefMem.pDstU += 2;
595 pMCRefMem.pDstV += 2;595 pMCRefMem.pDstV += 2;
596 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);596 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
597 if (pCurDqLayer->bUseWeightPredictionFlag) {597 if (pCurDqLayer->bUseWeightPredictionFlag) {
598 598
599 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 8);599 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 8);
600 }600 }
601 601
602 break;602 break;
603 case SUB_MB_TYPE_4x4: {603 case SUB_MB_TYPE_4x4: {
604 for (j = 0; j < 4; j++) {604 for (j = 0; j < 4; j++) {
605 int32_t iUVLineStride;605 int32_t iUVLineStride;
606 iJIdx = ((j >> 1) << 2) + (j & 1);606 iJIdx = ((j >> 1) << 2) + (j & 1);
607 607
608 iBlk4X = (j & 1) << 2;608 iBlk4X = (j & 1) << 2;
609 iBlk4Y = (j >> 1) << 2;609 iBlk4Y = (j >> 1) << 2;
610 610
611 iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;611 iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;
612 pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;612 pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;
613 pMCRefMem.pDstU = pDstU + iUVLineStride;613 pMCRefMem.pDstU = pDstU + iUVLineStride;
614 pMCRefMem.pDstV = pDstV + iUVLineStride;614 pMCRefMem.pDstV = pDstV + iUVLineStride;
615 615
616 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];616 iMVs[0] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][0];
617 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];617 iMVs[1] = pCurDqLayer->pMv[0][iMBXY][iIIdx + iJIdx][1];
618 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);618 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
619 if (pCurDqLayer->bUseWeightPredictionFlag) {619 if (pCurDqLayer->bUseWeightPredictionFlag) {
620 620
621 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 4);621 WeightPrediction (pCurDqLayer, &pMCRefMem, LIST_0, iRefIndex, 4, 4);
622 }622 }
623 623
624 }624 }
625 }625 }
626 break;626 break;
627 default:627 default:
628 break;628 break;
629 }629 }
630 }630 }
631 }631 }
632 break;632 break;
633 default:633 default:
634 break;634 break;
635 }635 }
636}636}
637 637
638void GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWelsDecoderContext pCtx) {638void GetInterBPred (uint8_t* pPredYCbCr[3], uint8_t* pTempPredYCbCr[3], PWelsDecoderContext pCtx) {
639 sMCRefMember pMCRefMem;639 sMCRefMember pMCRefMem;
640 sMCRefMember pTempMCRefMem;640 sMCRefMember pTempMCRefMem;
641 641
642 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;642 PDqLayer pCurDqLayer = pCtx->pCurDqLayer;
643 SMcFunc* pMCFunc = &pCtx->sMcFunc;643 SMcFunc* pMCFunc = &pCtx->sMcFunc;
644 644
645 int32_t iMBXY = pCurDqLayer->iMbXyIndex;645 int32_t iMBXY = pCurDqLayer->iMbXyIndex;
646 646
647 int16_t iMVs[2] = { 0 };647 int16_t iMVs[2] = { 0 };
648 648
649 uint32_t iMBType = pCurDqLayer->pMbType[iMBXY];649 uint32_t iMBType = pCurDqLayer->pMbType[iMBXY];
650 650
651 int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;651 int32_t iMBOffsetX = pCurDqLayer->iMbX << 4;
652 int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;652 int32_t iMBOffsetY = pCurDqLayer->iMbY << 4;
653 653
654 int32_t iDstLineLuma = pCtx->pDec->iLinesize[0];654 int32_t iDstLineLuma = pCtx->pDec->iLinesize[0];
655 int32_t iDstLineChroma = pCtx->pDec->iLinesize[1];655 int32_t iDstLineChroma = pCtx->pDec->iLinesize[1];
656 656
657 657
658 pMCRefMem.iPicWidth = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbWidth << 4);658 pMCRefMem.iPicWidth = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbWidth << 4);
659 pMCRefMem.iPicHeight = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbHeight << 4);659 pMCRefMem.iPicHeight = (pCurDqLayer->sLayerInfo.sSliceInLayer.sSliceHeaderExt.sSliceHeader.iMbHeight << 4);
660 660
661 pMCRefMem.pDstY = pPredYCbCr[0];661 pMCRefMem.pDstY = pPredYCbCr[0];
662 pMCRefMem.pDstU = pPredYCbCr[1];662 pMCRefMem.pDstU = pPredYCbCr[1];
663 pMCRefMem.pDstV = pPredYCbCr[2];663 pMCRefMem.pDstV = pPredYCbCr[2];
664 664
665 pMCRefMem.iDstLineLuma = iDstLineLuma;665 pMCRefMem.iDstLineLuma = iDstLineLuma;
666 pMCRefMem.iDstLineChroma = iDstLineChroma;666 pMCRefMem.iDstLineChroma = iDstLineChroma;
667 667
668 pTempMCRefMem = pMCRefMem;668 pTempMCRefMem = pMCRefMem;
669 pTempMCRefMem.pDstY = pTempPredYCbCr[0];669 pTempMCRefMem.pDstY = pTempPredYCbCr[0];
670 pTempMCRefMem.pDstU = pTempPredYCbCr[1];670 pTempMCRefMem.pDstU = pTempPredYCbCr[1];
671 pTempMCRefMem.pDstV = pTempPredYCbCr[2];671 pTempMCRefMem.pDstV = pTempPredYCbCr[2];
672 672
673 673
674 int32_t iRefIndex1 = 0;674 int32_t iRefIndex1 = 0;
675 int32_t iRefIndex2 = 0;675 int32_t iRefIndex2 = 0;
676 676
677 bool bWeightedBipredIdcIs1 = pCurDqLayer->sLayerInfo.pPps->uiWeightedBipredIdc == 1;677 bool bWeightedBipredIdcIs1 = pCurDqLayer->sLayerInfo.pPps->uiWeightedBipredIdc == 1;
678 678
679 if (IS_INTER_16x16 (iMBType)) {679 if (IS_INTER_16x16 (iMBType)) {
680 if (IS_TYPE_L0 (iMBType) && IS_TYPE_L1 (iMBType)) {680 if (IS_TYPE_L0 (iMBType) && IS_TYPE_L1 (iMBType)) {
681 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][0][0];681 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][0][0];
682 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][0][1];682 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][0][1];
683 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], 0, LIST_0);683 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], 0, LIST_0);
684 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);684 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
685 685
686 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][0][0];686 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][0][0];
687 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][0][1];687 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][0][1];
688 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], 0, LIST_1);688 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], 0, LIST_1);
689 BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);689 BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
690 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][0];690 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][0];
691 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][0];691 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][0];
692 if (pCurDqLayer->bUseWeightedBiPredIdc) {692 if (pCurDqLayer->bUseWeightedBiPredIdc) {
693 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 16);693 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 16);
694 } else {694 } else {
695 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 16);695 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 16);
696 }696 }
697 } else {697 } else {
698 int32_t listIdx = (iMBType & MB_TYPE_P0L0) ? LIST_0 : LIST_1;698 int32_t listIdx = (iMBType & MB_TYPE_P0L0) ? LIST_0 : LIST_1;
699 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][0][0];699 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][0][0];
700 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][0][1];700 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][0][1];
701 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], 0, listIdx);701 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], 0, listIdx);
702 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);702 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY, pMCFunc, 16, 16, iMVs);
703 if (bWeightedBipredIdcIs1) {703 if (bWeightedBipredIdcIs1) {
704 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][0];704 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][0];
705 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 16, 16);705 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 16, 16);
706 }706 }
707 }707 }
708 } else if (IS_INTER_16x8 (iMBType)) {708 } else if (IS_INTER_16x8 (iMBType)) {
709 for (int32_t i = 0; i < 2; ++i) {709 for (int32_t i = 0; i < 2; ++i) {
710 int32_t iPartIdx = i << 3;710 int32_t iPartIdx = i << 3;
711 uint32_t listCount = 0;711 uint32_t listCount = 0;
712 int32_t lastListIdx = LIST_0;712 int32_t lastListIdx = LIST_0;
713 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {713 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
714 if (IS_DIR (iMBType, i, listIdx)) {714 if (IS_DIR (iMBType, i, listIdx)) {
715 lastListIdx = listIdx;715 lastListIdx = listIdx;
716 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][0];716 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][0];
717 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][1];717 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iPartIdx][1];
718 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iPartIdx, listIdx);718 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iPartIdx, listIdx);
719 if (i) {719 if (i) {
720 pMCRefMem.pDstY += (iDstLineLuma << 3);720 pMCRefMem.pDstY += (iDstLineLuma << 3);
721 pMCRefMem.pDstU += (iDstLineChroma << 2);721 pMCRefMem.pDstU += (iDstLineChroma << 2);
722 pMCRefMem.pDstV += (iDstLineChroma << 2);722 pMCRefMem.pDstV += (iDstLineChroma << 2);
723 }723 }
724 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs);724 BaseMC (&pMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs);
725 if (++listCount == 2) {725 if (++listCount == 2) {
726 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][0];726 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][0];
727 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][1];727 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iPartIdx][1];
728 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iPartIdx, LIST_1);728 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iPartIdx, LIST_1);
729 if (i) {729 if (i) {
730 pTempMCRefMem.pDstY += (iDstLineLuma << 3);730 pTempMCRefMem.pDstY += (iDstLineLuma << 3);
731 pTempMCRefMem.pDstU += (iDstLineChroma << 2);731 pTempMCRefMem.pDstU += (iDstLineChroma << 2);
732 pTempMCRefMem.pDstV += (iDstLineChroma << 2);732 pTempMCRefMem.pDstV += (iDstLineChroma << 2);
733 }733 }
734 BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs);734 BaseMC (&pTempMCRefMem, iMBOffsetX, iMBOffsetY + iPartIdx, pMCFunc, 16, 8, iMVs);
735 if (pCurDqLayer->bUseWeightedBiPredIdc) {735 if (pCurDqLayer->bUseWeightedBiPredIdc) {
736 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iPartIdx];736 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iPartIdx];
737 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iPartIdx];737 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iPartIdx];
738 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 8);738 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 16, 8);
739 } else {739 } else {
740 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 8);740 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 16, 8);
741 }741 }
742 }742 }
743 }743 }
744 }744 }
745 if (listCount == 1) {745 if (listCount == 1) {
746 if (bWeightedBipredIdcIs1) {746 if (bWeightedBipredIdcIs1) {
747 int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][iPartIdx];747 int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][iPartIdx];
748 WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 16, 8);748 WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 16, 8);
749 }749 }
750 }750 }
751 }751 }
752 } else if (IS_INTER_8x16 (iMBType)) {752 } else if (IS_INTER_8x16 (iMBType)) {
753 for (int32_t i = 0; i < 2; ++i) {753 for (int32_t i = 0; i < 2; ++i) {
754 uint32_t listCount = 0;754 uint32_t listCount = 0;
755 int32_t lastListIdx = LIST_0;755 int32_t lastListIdx = LIST_0;
756 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {756 for (int32_t listIdx = LIST_0; listIdx < LIST_A; ++listIdx) {
757 if (IS_DIR (iMBType, i, listIdx)) {757 if (IS_DIR (iMBType, i, listIdx)) {
758 lastListIdx = listIdx;758 lastListIdx = listIdx;
759 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][0];759 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][0];
760 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][1];760 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][i << 1][1];
761 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], i << 1, listIdx);761 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], i << 1, listIdx);
762 if (i) {762 if (i) {
763 pMCRefMem.pDstY += 8;763 pMCRefMem.pDstY += 8;
764 pMCRefMem.pDstU += 4;764 pMCRefMem.pDstU += 4;
765 pMCRefMem.pDstV += 4;765 pMCRefMem.pDstV += 4;
766 }766 }
767 BaseMC (&pMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs);767 BaseMC (&pMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs);
768 if (++listCount == 2) {768 if (++listCount == 2) {
769 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][0];769 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][0];
770 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][1];770 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][i << 1][1];
771 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], i << 1, LIST_1);771 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], i << 1, LIST_1);
772 if (i) {772 if (i) {
773 pTempMCRefMem.pDstY += 8;773 pTempMCRefMem.pDstY += 8;
774 pTempMCRefMem.pDstU += 4;774 pTempMCRefMem.pDstU += 4;
775 pTempMCRefMem.pDstV += 4;775 pTempMCRefMem.pDstV += 4;
776 }776 }
777 BaseMC (&pTempMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs);777 BaseMC (&pTempMCRefMem, iMBOffsetX + (i ? 8 : 0), iMBOffsetY, pMCFunc, 8, 16, iMVs);
778 if (pCurDqLayer->bUseWeightedBiPredIdc) {778 if (pCurDqLayer->bUseWeightedBiPredIdc) {
779 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][i << 1];779 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][i << 1];
780 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][i << 1];780 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][i << 1];
781 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 16);781 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 16);
782 } else {782 } else {
783 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 16);783 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 16);
784 }784 }
785 }785 }
786 }786 }
787 }787 }
788 if (listCount == 1) {788 if (listCount == 1) {
789 if (bWeightedBipredIdcIs1) {789 if (bWeightedBipredIdcIs1) {
790 int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][i << 1];790 int32_t iRefIndex = pCurDqLayer->pRefIndex[lastListIdx][iMBXY][i << 1];
791 WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 8, 16);791 WeightPrediction (pCurDqLayer, &pMCRefMem, lastListIdx, iRefIndex, 8, 16);
792 }792 }
793 }793 }
794 }794 }
795 } else if (IS_Inter_8x8 (iMBType)) {795 } else if (IS_Inter_8x8 (iMBType)) {
796 int32_t iBlk8X, iBlk8Y, iBlk4X, iBlk4Y, iIIdx, iJIdx;796 int32_t iBlk8X, iBlk8Y, iBlk4X, iBlk4Y, iIIdx, iJIdx;
797 uint32_t iSubMBType;797 uint32_t iSubMBType;
798 int32_t iXOffset, iYOffset;798 int32_t iXOffset, iYOffset;
799 uint8_t* pDstY, *pDstU, *pDstV;799 uint8_t* pDstY, *pDstU, *pDstV;
800 uint8_t* pDstY2, *pDstU2, *pDstV2;800 uint8_t* pDstY2, *pDstU2, *pDstV2;
801 for (int32_t i = 0; i < 4; i++) {801 for (int32_t i = 0; i < 4; i++) {
802 iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];802 iSubMBType = pCurDqLayer->pSubMbType[iMBXY][i];
803 iBlk8X = (i & 1) << 3;803 iBlk8X = (i & 1) << 3;
804 iBlk8Y = (i >> 1) << 3;804 iBlk8Y = (i >> 1) << 3;
805 iXOffset = iMBOffsetX + iBlk8X;805 iXOffset = iMBOffsetX + iBlk8X;
806 iYOffset = iMBOffsetY + iBlk8Y;806 iYOffset = iMBOffsetY + iBlk8Y;
807 807
808 iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);808 iIIdx = ((i >> 1) << 3) + ((i & 1) << 1);
809 809
810 pDstY = pPredYCbCr[0] + iBlk8X + iBlk8Y * iDstLineLuma;810 pDstY = pPredYCbCr[0] + iBlk8X + iBlk8Y * iDstLineLuma;
811 pDstU = pPredYCbCr[1] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;811 pDstU = pPredYCbCr[1] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
812 pDstV = pPredYCbCr[2] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;812 pDstV = pPredYCbCr[2] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
813 pMCRefMem.pDstY = pDstY;813 pMCRefMem.pDstY = pDstY;
814 pMCRefMem.pDstU = pDstU;814 pMCRefMem.pDstU = pDstU;
815 pMCRefMem.pDstV = pDstV;815 pMCRefMem.pDstV = pDstV;
816 816
817 pTempMCRefMem = pMCRefMem;817 pTempMCRefMem = pMCRefMem;
818 pDstY2 = pTempPredYCbCr[0] + iBlk8X + iBlk8Y * iDstLineLuma;818 pDstY2 = pTempPredYCbCr[0] + iBlk8X + iBlk8Y * iDstLineLuma;
819 pDstU2 = pTempPredYCbCr[1] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;819 pDstU2 = pTempPredYCbCr[1] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
820 pDstV2 = pTempPredYCbCr[2] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;820 pDstV2 = pTempPredYCbCr[2] + (iBlk8X >> 1) + (iBlk8Y >> 1) * iDstLineChroma;
821 821
822 pTempMCRefMem.pDstY = pDstY2;822 pTempMCRefMem.pDstY = pDstY2;
823 pTempMCRefMem.pDstU = pDstU2;823 pTempMCRefMem.pDstU = pDstU2;
824 pTempMCRefMem.pDstV = pDstV2;824 pTempMCRefMem.pDstV = pDstV2;
825 825
826 if ((IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType))) {826 if ((IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType))) {
827 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iIIdx];827 iRefIndex1 = pCurDqLayer->pRefIndex[LIST_0][iMBXY][iIIdx];
828 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], iIIdx, LIST_0);828 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_0][iMBXY], iIIdx, LIST_0);
829 829
830 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iIIdx];830 iRefIndex2 = pCurDqLayer->pRefIndex[LIST_1][iMBXY][iIIdx];
831 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iIIdx, LIST_1);831 GetRefPic (&pTempMCRefMem, pCtx, pCurDqLayer->pRefIndex[LIST_1][iMBXY], iIIdx, LIST_1);
832 } else {832 } else {
833 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;833 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
834 iRefIndex1 = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];834 iRefIndex1 = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
835 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iIIdx, listIdx);835 GetRefPic (&pMCRefMem, pCtx, pCurDqLayer->pRefIndex[listIdx][iMBXY], iIIdx, listIdx);
836 }836 }
837 837
838 if (IS_SUB_8x8 (iSubMBType)) {838 if (IS_SUB_8x8 (iSubMBType)) {
839 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) {839 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) {
840 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];840 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];
841 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];841 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];
842 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);842 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
843 843
844 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];844 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];
845 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];845 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];
846 BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);846 BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
847 847
848 if (pCurDqLayer->bUseWeightedBiPredIdc) {848 if (pCurDqLayer->bUseWeightedBiPredIdc) {
849 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 8);849 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 8);
850 } else {850 } else {
851 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 8);851 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 8);
852 }852 }
853 } else {853 } else {
854 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;854 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
855 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];855 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];
856 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];856 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];
857 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);857 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 8, iMVs);
858 if (bWeightedBipredIdcIs1) {858 if (bWeightedBipredIdcIs1) {
859 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];859 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
860 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 8);860 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 8);
861 }861 }
862 }862 }
863 } else if (IS_SUB_8x4 (iSubMBType)) {863 } else if (IS_SUB_8x4 (iSubMBType)) {
864 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_8x4864 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_8x4
865 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];865 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];
866 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];866 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];
867 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);867 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
868 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];868 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];
869 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];869 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];
870 BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);870 BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
871 871
872 if (pCurDqLayer->bUseWeightedBiPredIdc) {872 if (pCurDqLayer->bUseWeightedBiPredIdc) {
873 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 4);873 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 4);
874 } else {874 } else {
875 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 4);875 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 4);
876 }876 }
877 877
878 pMCRefMem.pDstY += (iDstLineLuma << 2);878 pMCRefMem.pDstY += (iDstLineLuma << 2);
879 pMCRefMem.pDstU += (iDstLineChroma << 1);879 pMCRefMem.pDstU += (iDstLineChroma << 1);
880 pMCRefMem.pDstV += (iDstLineChroma << 1);880 pMCRefMem.pDstV += (iDstLineChroma << 1);
881 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][0];881 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][0];
882 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][1];882 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 4][1];
883 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);883 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
884 884
885 pTempMCRefMem.pDstY += (iDstLineLuma << 2);885 pTempMCRefMem.pDstY += (iDstLineLuma << 2);
886 pTempMCRefMem.pDstU += (iDstLineChroma << 1);886 pTempMCRefMem.pDstU += (iDstLineChroma << 1);
887 pTempMCRefMem.pDstV += (iDstLineChroma << 1);887 pTempMCRefMem.pDstV += (iDstLineChroma << 1);
888 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][0];888 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][0];
889 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][1];889 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 4][1];
890 BaseMC (&pTempMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);890 BaseMC (&pTempMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
891 891
892 if (pCurDqLayer->bUseWeightedBiPredIdc) {892 if (pCurDqLayer->bUseWeightedBiPredIdc) {
893 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 4);893 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 8, 4);
894 } else {894 } else {
895 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 4);895 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 8, 4);
896 }896 }
897 } else { //B_L0_8x4 B_L1_8x4897 } else { //B_L0_8x4 B_L1_8x4
898 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;898 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
899 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];899 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];
900 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];900 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];
901 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);901 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 8, 4, iMVs);
902 pMCRefMem.pDstY += (iDstLineLuma << 2);902 pMCRefMem.pDstY += (iDstLineLuma << 2);
903 pMCRefMem.pDstU += (iDstLineChroma << 1);903 pMCRefMem.pDstU += (iDstLineChroma << 1);
904 pMCRefMem.pDstV += (iDstLineChroma << 1);904 pMCRefMem.pDstV += (iDstLineChroma << 1);
905 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][0];905 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][0];
906 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][1];906 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 4][1];
907 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);907 BaseMC (&pMCRefMem, iXOffset, iYOffset + 4, pMCFunc, 8, 4, iMVs);
908 if (bWeightedBipredIdcIs1) {908 if (bWeightedBipredIdcIs1) {
909 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];909 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
910 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 4);910 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 8, 4);
911 }911 }
912 }912 }
913 } else if (IS_SUB_4x8 (iSubMBType)) {913 } else if (IS_SUB_4x8 (iSubMBType)) {
914 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_4x8914 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) { //B_Bi_4x8
915 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];915 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][0];
916 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];916 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx][1];
917 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);917 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
918 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];918 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][0];
919 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];919 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx][1];
920 BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);920 BaseMC (&pTempMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
921 921
922 if (pCurDqLayer->bUseWeightedBiPredIdc) {922 if (pCurDqLayer->bUseWeightedBiPredIdc) {
923 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 8);923 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 8);
924 } else {924 } else {
925 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 8);925 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 8);
926 }926 }
927 927
928 pMCRefMem.pDstY += 4;928 pMCRefMem.pDstY += 4;
929 pMCRefMem.pDstU += 2;929 pMCRefMem.pDstU += 2;
930 pMCRefMem.pDstV += 2;930 pMCRefMem.pDstV += 2;
931 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][0];931 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][0];
932 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][1];932 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + 1][1];
933 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);933 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
934 934
935 pTempMCRefMem.pDstY += 4;935 pTempMCRefMem.pDstY += 4;
936 pTempMCRefMem.pDstU += 2;936 pTempMCRefMem.pDstU += 2;
937 pTempMCRefMem.pDstV += 2;937 pTempMCRefMem.pDstV += 2;
938 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][0];938 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][0];
939 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][1];939 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + 1][1];
940 BaseMC (&pTempMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);940 BaseMC (&pTempMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
941 941
942 if (pCurDqLayer->bUseWeightedBiPredIdc) {942 if (pCurDqLayer->bUseWeightedBiPredIdc) {
943 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 8);943 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 8);
944 } else {944 } else {
945 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 8);945 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 8);
946 }946 }
947 } else { //B_L0_4x8 B_L1_4x8947 } else { //B_L0_4x8 B_L1_4x8
948 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;948 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
949 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];949 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][0];
950 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];950 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx][1];
951 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);951 BaseMC (&pMCRefMem, iXOffset, iYOffset, pMCFunc, 4, 8, iMVs);
952 pMCRefMem.pDstY += 4;952 pMCRefMem.pDstY += 4;
953 pMCRefMem.pDstU += 2;953 pMCRefMem.pDstU += 2;
954 pMCRefMem.pDstV += 2;954 pMCRefMem.pDstV += 2;
955 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][0];955 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][0];
956 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][1];956 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + 1][1];
957 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);957 BaseMC (&pMCRefMem, iXOffset + 4, iYOffset, pMCFunc, 4, 8, iMVs);
958 if (bWeightedBipredIdcIs1) {958 if (bWeightedBipredIdcIs1) {
959 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];959 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
960 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 8);960 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 8);
961 }961 }
962 }962 }
963 } else if (IS_SUB_4x4 (iSubMBType)) {963 } else if (IS_SUB_4x4 (iSubMBType)) {
964 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) {964 if (IS_TYPE_L0 (iSubMBType) && IS_TYPE_L1 (iSubMBType)) {
965 for (int32_t j = 0; j < 4; j++) {965 for (int32_t j = 0; j < 4; j++) {
966 int32_t iUVLineStride;966 int32_t iUVLineStride;
967 iJIdx = ((j >> 1) << 2) + (j & 1);967 iJIdx = ((j >> 1) << 2) + (j & 1);
968 968
969 iBlk4X = (j & 1) << 2;969 iBlk4X = (j & 1) << 2;
970 iBlk4Y = (j >> 1) << 2;970 iBlk4Y = (j >> 1) << 2;
971 971
972 iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;972 iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;
973 pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;973 pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;
974 pMCRefMem.pDstU = pDstU + iUVLineStride;974 pMCRefMem.pDstU = pDstU + iUVLineStride;
975 pMCRefMem.pDstV = pDstV + iUVLineStride;975 pMCRefMem.pDstV = pDstV + iUVLineStride;
976 976
977 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][0];977 iMVs[0] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][0];
978 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][1];978 iMVs[1] = pCurDqLayer->pMv[LIST_0][iMBXY][iIIdx + iJIdx][1];
979 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);979 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
980 980
981 pTempMCRefMem.pDstY = pDstY2 + iBlk8X + iBlk8Y * iDstLineLuma;981 pTempMCRefMem.pDstY = pDstY2 + iBlk8X + iBlk8Y * iDstLineLuma;
982 pTempMCRefMem.pDstU = pDstU2 + iUVLineStride;982 pTempMCRefMem.pDstU = pDstU2 + iUVLineStride;
983 pTempMCRefMem.pDstV = pDstV2 + iUVLineStride;;983 pTempMCRefMem.pDstV = pDstV2 + iUVLineStride;;
984 984
985 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][0];985 iMVs[0] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][0];
986 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][1];986 iMVs[1] = pCurDqLayer->pMv[LIST_1][iMBXY][iIIdx + iJIdx][1];
987 BaseMC (&pTempMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);987 BaseMC (&pTempMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
988 988
989 if (pCurDqLayer->bUseWeightedBiPredIdc) {989 if (pCurDqLayer->bUseWeightedBiPredIdc) {
990 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 4);990 BiWeightPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, iRefIndex1, iRefIndex2, bWeightedBipredIdcIs1, 4, 4);
991 } else {991 } else {
992 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 4);992 BiPrediction (pCurDqLayer, &pMCRefMem, &pTempMCRefMem, 4, 4);
993 }993 }
994 }994 }
995 } else {995 } else {
996 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;996 int32_t listIdx = IS_TYPE_L0 (iSubMBType) ? LIST_0 : LIST_1;
997 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];997 int32_t iRefIndex = pCurDqLayer->pRefIndex[listIdx][iMBXY][iIIdx];
998 for (int32_t j = 0; j < 4; j++) {998 for (int32_t j = 0; j < 4; j++) {
999 int32_t iUVLineStride;999 int32_t iUVLineStride;
1000 iJIdx = ((j >> 1) << 2) + (j & 1);1000 iJIdx = ((j >> 1) << 2) + (j & 1);
1001 1001
1002 iBlk4X = (j & 1) << 2;1002 iBlk4X = (j & 1) << 2;
1003 iBlk4Y = (j >> 1) << 2;1003 iBlk4Y = (j >> 1) << 2;
1004 1004
1005 iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;1005 iUVLineStride = (iBlk4X >> 1) + (iBlk4Y >> 1) * iDstLineChroma;
1006 pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;1006 pMCRefMem.pDstY = pDstY + iBlk4X + iBlk4Y * iDstLineLuma;
1007 pMCRefMem.pDstU = pDstU + iUVLineStride;1007 pMCRefMem.pDstU = pDstU + iUVLineStride;
1008 pMCRefMem.pDstV = pDstV + iUVLineStride;1008 pMCRefMem.pDstV = pDstV + iUVLineStride;
1009 1009
1010 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][0];1010 iMVs[0] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][0];
1011 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][1];1011 iMVs[1] = pCurDqLayer->pMv[listIdx][iMBXY][iIIdx + iJIdx][1];
1012 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);1012 BaseMC (&pMCRefMem, iXOffset + iBlk4X, iYOffset + iBlk4Y, pMCFunc, 4, 4, iMVs);
1013 if (bWeightedBipredIdcIs1) {1013 if (bWeightedBipredIdcIs1) {
1014 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 4);1014 WeightPrediction (pCurDqLayer, &pMCRefMem, listIdx, iRefIndex, 4, 4);
1015 }1015 }
1016 }1016 }
1017 }1017 }
1018 }1018 }
1019 }1019 }
1020 }1020 }
1021}1021}
1022 1022
1023int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {1023int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
1024 int32_t iChromaStride = pCtx->pCurDqLayer->pDec->iLinesize[1];1024 int32_t iChromaStride = pCtx->pCurDqLayer->pDec->iLinesize[1];
1025 PIdctFourResAddPredFunc pIdctFourResAddPredFunc = pCtx->pIdctFourResAddPredFunc;1025 PIdctFourResAddPredFunc pIdctFourResAddPredFunc = pCtx->pIdctFourResAddPredFunc;
1026 1026
1027 uint8_t i = 0;1027 uint8_t i = 0;
1028 uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4;1028 uint8_t uiCbpC = pDqLayer->pCbp[iMBXY] >> 4;
1029 1029
1030 if (1 == uiCbpC || 2 == uiCbpC) {1030 if (1 == uiCbpC || 2 == uiCbpC) {
1031 for (i = 0; i < 2; i++) {1031 for (i = 0; i < 2; i++) {
1032 int16_t* pRS = pScoeffLevel + 256 + (i << 6);1032 int16_t* pRS = pScoeffLevel + 256 + (i << 6);
1033 uint8_t* pPred = pDqLayer->pPred[i + 1];1033 uint8_t* pPred = pDqLayer->pPred[i + 1];
1034 const int8_t* pNzc = pDqLayer->pNzc[iMBXY] + 16 + 2 * i;1034 const int8_t* pNzc = pDqLayer->pNzc[iMBXY] + 16 + 2 * i;
1035 1035
1036 /*1 chroma is divided 4 4x4_block to idct*/1036 /*1 chroma is divided 4 4x4_block to idct*/
1037 pIdctFourResAddPredFunc (pPred, iChromaStride, pRS, pNzc);1037 pIdctFourResAddPredFunc (pPred, iChromaStride, pRS, pNzc);
1038 }1038 }
1039 }1039 }
1040 1040
1041 return ERR_NONE;1041 return ERR_NONE;
1042}1042}
1043 1043
1044} // namespace WelsDec1044} // namespace WelsDec

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

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

Repository code

Go to file
t