History

Add Transform 8x8 support Add Intra 8x8 support Add no_deblocking support inside T8x8 Add CABAC parse support Add static data sheet for dequant Fix bugs and clean/astyle the code Remove build warnings Modify the UT cases Fix the ParseNalHeader bug

Haibo committed 11 years ago

Commit e9916c71 parent 473f2e325 files · +1808 −270Browse files

Showing the changes to codec/decoder (22 of 25 files). Show all

Unified · Split

22 files
  1. codec/decoder/core/inc/dec_frame.h +4 −2
  2. codec/decoder/core/inc/dec_golomb.h +12 −0
  3. codec/decoder/core/inc/decode_mb_aux.h +1 −0
  4. codec/decoder/core/inc/decoder_context.h +18 −4
  5. codec/decoder/core/inc/get_intra_predictor.h +15 −2
  6. codec/decoder/core/inc/parameter_sets.h +5 −1
  7. codec/decoder/core/inc/parse_mb_syn_cabac.h +4 −0
  8. codec/decoder/core/inc/parse_mb_syn_cavlc.h +29 −14
  9. codec/decoder/core/inc/rec_mb.h +4 −0
  10. codec/decoder/core/inc/wels_common_basis.h +55 −11
  11. codec/decoder/core/src/au_parser.cpp +19 −23
  12. codec/decoder/core/src/cabac_decoder.cpp +1 −1
  13. codec/decoder/core/src/deblocking.cpp +191 −70
  14. codec/decoder/core/src/decode_mb_aux.cpp +90 −0
  15. codec/decoder/core/src/decode_slice.cpp +370 −107
  16. codec/decoder/core/src/decoder.cpp +18 −1
  17. codec/decoder/core/src/decoder_core.cpp +30 −2
  18. codec/decoder/core/src/get_intra_predictor.cpp +501 −0
  19. codec/decoder/core/src/manage_dec_ref.cpp +1 −1
  20. codec/decoder/core/src/parse_mb_syn_cabac.cpp +87 −14
  21. codec/decoder/core/src/parse_mb_syn_cavlc.cpp +105 −10
  22. codec/decoder/core/src/rec_mb.cpp +54 −0
codec/decoder/core/inc/dec_frame.h+4−2
@@ -68,10 +68,12 @@ struct TagDqLayer { · 67 unmodified lines
6868 int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
6969 int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
7070 int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM];
71+ bool* pNoSubMbPartSizeLessThan8x8Flag;
72+ bool* pTransformSize8x8Flag;
7173 int8_t* pLumaQp;
7274 int8_t (*pChromaQp)[2];
7375 int8_t* pCbp;
74− uint8_t *pCbfDc;
76+ uint16_t *pCbfDc;
7577 int8_t (*pNzc)[24];
7678 int8_t (*pNzcRs)[24];
7779 int8_t* pResidualPredFlag;
@@ -81,6 +83,7 @@ struct TagDqLayer { · 3 unmodified lines
8183 int16_t (*pScaledTCoeff)[MB_COEFF_LIST_SIZE];
8284 int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
8385 int8_t (*pIntra4x4FinalMode)[MB_BLOCK4x4_NUM];
86+ uint8_t *pIntraNxNAvailFlag;
8487 int8_t* pChromaPredMode;
8588 //uint8_t (*motion_pred_flag[LIST_A])[MB_PARTITION_SIZE]; // 8x8
8689 int8_t (*pSubMbType)[MB_SUB_PARTITION_SIZE];
@@ -132,7 +135,6 @@ typedef struct TagGpuAvcLayer { · 45 unmodified lines
132135 int8_t* pCbp;
133136 int8_t (*pNzc)[24];
134137 int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
135−
136138 int32_t iMbX;
137139 int32_t iMbY;
138140 int32_t iMbXyIndex;
codec/decoder/core/inc/dec_golomb.h+12−0
@@ -232,6 +232,18 @@ static inline int32_t BsGetTrailingBits (uint8_t* pBuf) { · 231 unmodified lines
232232
233233 return 0;
234234 }
235+
236+/*
237+ * Check whether there is more rbsp data for processing
238+ */
239+static inline bool CheckMoreRBSPData(PBitStringAux pBsAux) {
240+ if ((pBsAux->iBits - ((pBsAux->pCurBuf - pBsAux->pStartBuf - 2) << 3) - pBsAux->iLeftBits) > 1) {
241+ return true;
242+ } else {
243+ return false;
244+ }
245+}
246+
235247 //define macros to check syntax elements
236248 #define WELS_CHECK_SE_BOTH_ERROR(val, lower_bound, upper_bound, syntax_name, ret_code) do {\
237249 if ((val < lower_bound) || (val > upper_bound)) {\
codec/decoder/core/inc/decode_mb_aux.h+1−0
@@ -39,6 +39,7 @@ · 38 unmodified lines
3939 namespace WelsDec {
4040
4141 void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
42+void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs);
4243
4344 #if defined(__cplusplus)
4445 extern "C" {
codec/decoder/core/inc/decoder_context.h+18−4
@@ -91,8 +91,15 @@ typedef struct { · 90 unmodified lines
9191 #define NEW_CTX_OFFSET_LAST 166
9292 #define NEW_CTX_OFFSET_ONE 227
9393 #define NEW_CTX_OFFSET_ABS 232
94+#define NEW_CTX_OFFSET_TS_8x8_FLAG 399
9495 #define CTX_NUM_MVD 7
9596 #define CTX_NUM_CBP 4
97+// Table 9-34 in Page 270
98+#define NEW_CTX_OFFSET_TRANSFORM_SIZE_8X8_FLAG 399
99+#define NEW_CTX_OFFSET_MAP_8x8 402
100+#define NEW_CTX_OFFSET_LAST_8x8 417
101+#define NEW_CTX_OFFSET_ONE_8x8 426
102+#define NEW_CTX_OFFSET_ABS_8x8 431 // Puzzle, where is the definition?
96103
97104 typedef struct TagDataBuffer {
98105 uint8_t* pHead;
@@ -131,6 +138,8 @@ typedef void (*PIdctResAddPredFunc) (uint8_t* pPred, const int32_t kiStride, int · 32 unmodified lines
131138 typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth,
132139 const int32_t kiPicHeight);
133140
141+typedef void (*PGetIntraPred8x8Func) (uint8_t* pPred, const int32_t kiLumaStride, bool bTLAvail, bool bTRAvail);
142+
134143 /**/
135144 typedef struct TagRefPic {
136145 PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme
@@ -262,15 +271,18 @@ typedef struct TagWelsDecoderContext { · 125 unmodified lines
262271 int16_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
263272 int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
264273 int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
274+ bool* pNoSubMbPartSizeLessThan8x8Flag[LAYER_NUM_EXCHANGEABLE];
275+ bool* pTransformSize8x8Flag[LAYER_NUM_EXCHANGEABLE];
265276 int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
266277 int8_t (*pChromaQp[LAYER_NUM_EXCHANGEABLE])[2]; /*mb chroma_qp*/
267278 int16_t (*pMvd[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
268− uint8_t* pCbfDc[LAYER_NUM_EXCHANGEABLE];
279+ uint16_t* pCbfDc[LAYER_NUM_EXCHANGEABLE];
269280 int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24];
270281 int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24];
271282 int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/
272283 int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16
273284 int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM];
285+ uint8_t* pIntraNxNAvailFlag[LAYER_NUM_EXCHANGEABLE];
274286 int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE];
275287 int8_t* pCbp[LAYER_NUM_EXCHANGEABLE];
276288 uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8
@@ -284,7 +296,6 @@ typedef struct TagWelsDecoderContext { · 7 unmodified lines
284296 uint32_t iMbHeight;
285297 } sMb;
286298
287−
288299 // reconstruction picture
289300 PPicture pDec; //pointer to current picture being reconstructed
290301
@@ -381,6 +392,9 @@ typedef struct TagWelsDecoderContext { · 90 unmodified lines
381392 PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t
382393 PIdctResAddPredFunc pIdctResAddPredFunc;
383394 SMcFunc sMcFunc;
395+ //Transform8x8
396+ PGetIntraPred8x8Func pGetI8x8LumaPredFunc[14];
397+ PIdctResAddPredFunc pIdctResAddPredFunc8x8;
384398
385399 //For error concealment
386400 SCopyFunc sCopyFunc;
@@ -395,8 +409,8 @@ typedef struct TagWelsDecoderContext { · 8 unmodified lines
395409 int32_t iCurSeqIntervalMaxPicWidth;
396410 int32_t iCurSeqIntervalMaxPicHeight;
397411
398− PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func;
399− PWelsMapNeighToSample pMap4x4NeighToSampleFunc;
412+ PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntraNxNFunc;
413+ PWelsMapNeighToSample pMapNxNNeighToSampleFunc;
400414 PWelsMap16NeighToSample pMap16x16NeighToSampleFunc;
401415
402416 //feedback whether or not have VCL in current AU, and the temporal ID
codec/decoder/core/inc/get_intra_predictor.h+15−2
@@ -60,6 +60,21 @@ void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride); · 59 unmodified lines
6060 void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride);
6161 void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride);
6262
63+void WelsI8x8LumaPredV_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
64+void WelsI8x8LumaPredH_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
65+void WelsI8x8LumaPredDc_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
66+void WelsI8x8LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
67+void WelsI8x8LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
68+void WelsI8x8LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
69+void WelsI8x8LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
70+void WelsI8x8LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
71+void WelsI8x8LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
72+void WelsI8x8LumaPredVL_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
73+void WelsI8x8LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
74+void WelsI8x8LumaPredVR_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
75+void WelsI8x8LumaPredHU_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
76+void WelsI8x8LumaPredHD_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail);
77+
6378 void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride);
6479 void WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride);
6580 void WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride);
@@ -96,8 +111,6 @@ void WelsDecoderIChromaPredV_mmx (uint8_t* pPred, const int32_t kiStride); · 30 unmodified lines
96111 void WelsDecoderIChromaPredDcLeft_mmx (uint8_t* pPred, const int32_t kiStride);
97112 void WelsDecoderIChromaPredDcNA_mmx (uint8_t* pPred, const int32_t kiStride);
98113
99−
100−
101114 void WelsDecoderI4x4LumaPredH_sse2 (uint8_t* pPred, const int32_t kiStride);
102115 void WelsDecoderI4x4LumaPredDDR_mmx (uint8_t* pPred, const int32_t kiStride);
103116 void WelsDecoderI4x4LumaPredHD_mmx (uint8_t* pPred, const int32_t kiStride);
codec/decoder/core/inc/parameter_sets.h+5−1
@@ -167,12 +167,16 @@ typedef struct TagPps { · 166 unmodified lines
167167 bool bRedundantPicCntPresentFlag;
168168 bool bWeightedPredFlag;
169169 uint8_t uiWeightedBipredIdc;
170− bool bTransform_8x8_mode_flag;
170+
171+ bool bTransform8x8ModeFlag;
171172 //Add for scalinglist support
172173 bool bPicScalingMatrixPresentFlag;
173174 bool bPicScalingListPresentFlag[12];
174175 uint8_t iScalingList4x4[6][16];
175176 uint8_t iScalingList8x8[6][64];
177+
178+ int32_t iSecondChromaQPIndexOffset; //second_chroma_qp_index_offset
179+
176180 } SPps, *PPps;
177181
178182 } // namespace WelsDec
codec/decoder/core/inc/parse_mb_syn_cabac.h+4−0
@@ -46,6 +46,7 @@ int32_t ParseEndOfSliceCabac (PWelsDecoderContext pCtx, uint32_t& uiBinVal); · 45 unmodified lines
4646 int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSkip);
4747 int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal);
4848 int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal);
49+int32_t ParseTransformSize8x8FlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, bool& bTransformSize8x8Flag);
4950 int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType);
5051 int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t& iBinVal);
5152 int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeighAvail, int32_t& iBinVal);
@@ -66,6 +67,9 @@ int32_t ParseSignificantCoeffCabac (int32_t* significant, int32_t iResProperty, · 14 unmodified lines
6667 int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux,
6768 int32_t index, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty, int16_t* sTCoeff, uint8_t uiQp,
6869 PWelsDecoderContext pCtx);
70+int32_t ParseResidualBlockCabac8x8 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux,
71+ int32_t index, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty, int16_t* sTCoeff, uint8_t uiQp,
72+ PWelsDecoderContext pCtx);
6973 int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx);
7074 }
7175 //#pragma pack()
codec/decoder/core/inc/parse_mb_syn_cavlc.h+29−14
@@ -53,9 +53,9 @@ namespace WelsDec { · 52 unmodified lines
5353
5454 void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer);
5555 void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer);
56−void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
56+void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
5757 PDqLayer pCurLayer);
58−void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
58+void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
5959 PDqLayer pCurLayer);
6060 void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount,
6161 int16_t iMvArray[LIST_A][30][MV_A], int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer);
@@ -64,29 +64,29 @@ void WelsFillCacheInter (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, · 2 unmodified lines
6464
6565 /*!
6666 * \brief check iPredMode for intra16x16 eligible or not
67− * \param input : current iPredMode
68− * \param output: 0 indicating decoding correctly; -1 means error occurence
67+ * \param input : current iPredMode
68+ * \param output: 0 indicating decoding correctly; -1 means error occurence
6969 */
7070 int32_t CheckIntra16x16PredMode (uint8_t uiSampleAvail, int8_t* pMode);
7171
7272 /*!
73− * \brief check iPredMode for intra4x4 eligible or not
74− * \param input : current iPredMode
75− * \param output: 0 indicating decoding correctly; -1 means error occurence
73+ * \brief check iPredMode for intraNxN eligible or not
74+ * \param input : current iPredMode
75+ * \param output: 0 indicating decoding correctly; -1 means error occurence
7676 */
77−int32_t CheckIntra4x4PredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex);
77+int32_t CheckIntraNxNPredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex, bool b8x8);
7878
7979 /*!
8080 * \brief check iPredMode for chroma eligible or not
81− * \param input : current iPredMode
82− * \param output: 0 indicating decoding correctly; -1 means error occurence
81+ * \param input : current iPredMode
82+ * \param output: 0 indicating decoding correctly; -1 means error occurence
8383 */
8484 int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode);
8585
8686 /*!
8787 * \brief predict the mode of intra4x4
88− * \param input : current intra4x4 block index
89− * \param output: mode index
88+ * \param input : current intra4x4 block index
89+ * \param output: mode index
9090 */
9191 int32_t PredIntra4x4Mode (int8_t* pIntraPredMode, int32_t iIdx4);
9292
@@ -107,10 +107,25 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, · 14 unmodified lines
107107 uint8_t uiQp,
108108 PWelsDecoderContext pCtx);
109109
110+// Transform8x8
111+int32_t WelsResidualBlockCavlc8x8 (SVlcTable* pVlcTable,
112+ uint8_t* pNonZeroCountCache,
113+ PBitStringAux pBs,
114+ /*int16_t* coeff_level,*/
115+ int32_t iIndex,
116+ int32_t iMaxNumCoeff,
117+ const uint8_t* kpZigzagTable,
118+ int32_t iResidualProperty,
119+ /*short *tCoeffLevel,*/
120+ int16_t* pTCoeff,
121+ int32_t iIdx4x4,
122+ uint8_t uiQp,
123+ PWelsDecoderContext pCtx);
124+
110125 /*!
111126 * \brief parsing inter info (including ref_index and pMvd)
112− * \param input : decoding context, current mb, bit-stream
113− * \param output: 0 indicating decoding correctly; -1 means error
127+ * \param input : decoding context, current mb, bit-stream
128+ * \param output: 0 indicating decoding correctly; -1 means error
114129 */
115130 int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
116131 PBitStringAux pBs);
codec/decoder/core/inc/rec_mb.h+4−0
@@ -78,6 +78,10 @@ int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLe · 77 unmodified lines
7878
7979 int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
8080
81+int32_t RecI8x8Mb (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
82+
83+int32_t RecI8x8Luma (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
84+
8185 int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
8286
8387 int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer);
codec/decoder/core/inc/wels_common_basis.h+55−11
@@ -72,16 +72,19 @@ typedef int32_t SubMbType; · 71 unmodified lines
7272 #define LUMA_DC_AC 3
7373 #define CHROMA_DC 4
7474 #define CHROMA_AC 5
75−#define CHROMA_DC_U 6
76−#define CHROMA_DC_V 7
77−#define CHROMA_AC_U 8
78−#define CHROMA_AC_V 9
79−#define LUMA_DC_AC_INTRA 10
80−#define LUMA_DC_AC_INTER 11
81−#define CHROMA_DC_U_INTER 12
82−#define CHROMA_DC_V_INTER 13
83−#define CHROMA_AC_U_INTER 14
84−#define CHROMA_AC_V_INTER 15
75+#define LUMA_DC_AC_8 6
76+#define CHROMA_DC_U 7
77+#define CHROMA_DC_V 8
78+#define CHROMA_AC_U 9
79+#define CHROMA_AC_V 10
80+#define LUMA_DC_AC_INTRA 11
81+#define LUMA_DC_AC_INTER 12
82+#define CHROMA_DC_U_INTER 13
83+#define CHROMA_DC_V_INTER 14
84+#define CHROMA_AC_U_INTER 15
85+#define CHROMA_AC_V_INTER 16
86+#define LUMA_DC_AC_INTRA_8 17
87+#define LUMA_DC_AC_INTER_8 18
8588
8689 #define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); }
8790 #define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; }
@@ -93,6 +96,38 @@ static const uint8_t g_kuiZigzagScan[16] = { //4*4block residual zig-zag scan or · 5 unmodified lines
9396 7, 11, 14, 15,
9497 };
9598
99+static const uint8_t g_kuiZigzagScan8x8[64] = { //8x8 block residual zig-zag scan order
100+ 0, 1, 8, 16, 9, 2, 3, 10,
101+ 17, 24, 32, 25, 18, 11, 4, 5,
102+ 12, 19, 26, 33, 40, 48, 41, 34,
103+ 27, 20, 13, 6, 7, 14, 21, 28,
104+ 35, 42, 49, 56, 57, 50, 43, 36,
105+ 29, 22, 15, 23, 30, 37, 44, 51,
106+ 58, 59, 52, 45, 38, 31, 39, 46,
107+ 53, 60, 61, 54, 47, 55, 62, 63,
108+};
109+
110+static const uint8_t g_kuiIdx2CtxSignificantCoeffFlag8x8[64] = { // Table 9-43, Page 289
111+ 0, 1, 2, 3, 4, 5, 5, 4,
112+ 4, 3, 3, 4, 4, 4, 5, 5,
113+ 4, 4, 4, 4, 3, 3, 6, 7,
114+ 7, 7, 8, 9, 10, 9, 8, 7,
115+ 7, 6, 11, 12, 13, 11, 6, 7,
116+ 8, 9, 14, 10, 9, 8, 6, 11,
117+ 12, 13, 11, 6, 9, 14, 10, 9,
118+ 11, 12, 13, 11 ,14, 10, 12, 14,
119+};
120+
121+static const uint8_t g_kuiIdx2CtxLastSignificantCoeffFlag8x8[64] = { // Table 9-43, Page 289
122+ 0, 1, 1, 1, 1, 1, 1, 1,
123+ 1, 1, 1, 1, 1, 1, 1, 1,
124+ 2, 2, 2, 2, 2, 2, 2, 2,
125+ 2, 2, 2, 2, 2, 2, 2, 2,
126+ 3, 3, 3, 3, 3, 3, 3, 3,
127+ 4, 4, 4, 4, 4, 4, 4, 4,
128+ 5, 5, 5, 5, 6, 6, 6, 6,
129+ 7, 7, 7, 7, 8, 8, 8, 8,
130+};
96131
97132 static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProperty,bool bCavlc)
98133 {
@@ -142,8 +177,17 @@ static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProp · 43 unmodified lines
142177 break;
143178 case CHROMA_AC_V_INTER:
144179 *pMBproperty = 5;
145− *pResidualProperty = bCavlc ?CHROMA_AC:CHROMA_AC_V;
180+ *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V;
146181 break;
182+ // Reference to Table 7-2
183+ case LUMA_DC_AC_INTRA_8:
184+ *pMBproperty = 6;
185+ *pResidualProperty = LUMA_DC_AC_8;
186+ break;
187+ case LUMA_DC_AC_INTER_8:
188+ *pMBproperty = 7;
189+ *pResidualProperty = LUMA_DC_AC_8;
190+ break;
147191 }
148192 }
149193
codec/decoder/core/src/au_parser.cpp+19−23
@@ -124,6 +124,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 123 unmodified lines
124124 uiBsZero = pSrcRbsp[iIndex];
125125 if (0 == uiBsZero) {
126126 --iNalSize;
127+ ++ (*pConsumedBytes);
127128 --iIndex;
128129 } else {
129130 break;
@@ -991,16 +992,10 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 861 unmodified lines
991992 WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag
992993 pSps->bSeqScalingMatrixPresentFlag = !!uiCode;
993994
994− if (pSps->bSeqScalingMatrixPresentFlag)// For high profile, it is not used in current application. FIXME
995−
995+ if (pSps->bSeqScalingMatrixPresentFlag) {
996996 WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4,
997997 pSps->iScalingList8x8));
998− //if exist, to parse scalinglist matrix value
999−
1000− // WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING,
1001− // "ParseSps(): seq_scaling_matrix_present_flag (%d). Feature not supported.",
1002− // pSps->bSeqScalingMatrixPresentFlag);
1003− //return GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_UNSUPPORTED_NON_BASELINE);
998+ }
1004999 }
10051000 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4
10061001 WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4",
@@ -1379,28 +1374,27 @@ int32_t ParsePps (PWelsDecoderContext pCtx, PPps pPpsList, PBitStringAux pBsAux, · 372 unmodified lines
13791374 pPps->bConstainedIntraPredFlag = !!uiCode;
13801375 WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag
13811376 pPps->bRedundantPicCntPresentFlag = !!uiCode;
1382− /*TODO: to judge whether going on to parse*/
1383−//going on to parse high profile syntax, need fix me
1384− if (0) {
1385− WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
1386− pPps->bTransform_8x8_mode_flag = !!uiCode;
1387− WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode));
1377+
1378+ if (CheckMoreRBSPData (pBsAux)) {
1379+ WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //transform_8x8_mode_flag
1380+ pPps->bTransform8x8ModeFlag = !!uiCode;
1381+ WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //pic_scaling_matrix_present_flag
13881382 pPps->bPicScalingMatrixPresentFlag = !!uiCode;
13891383 if (pPps->bPicScalingMatrixPresentFlag) {
1390− if (pCtx->bSpsAvailFlags[pPps->iSpsId])
1384+ if (pCtx->bSpsAvailFlags[pPps->iSpsId]) {
13911385 WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag,
13921386 pPps->iScalingList4x4, pPps->iScalingList8x8));
1393− else {
1387+ } else {
13941388 pCtx->bSpsLatePps = true;
13951389 WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4,
13961390 pPps->iScalingList8x8));
13971391 }
13981392 }
1399− //add second chroma qp parsing process
1400− WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //chroma_qp_index_offset,cr
1401− pPps->iChromaQpIndexOffset[1] = iCode;
1402− WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset[1], PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX,
1403− "second_chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));
1393+ WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //second_chroma_qp_index_offset
1394+ pPps->iChromaQpIndexOffset[1] = iCode;
1395+ WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset[1], PPS_CHROMA_QP_INDEX_OFFSET_MIN,
1396+ PPS_CHROMA_QP_INDEX_OFFSET_MAX, "chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS,
1397+ ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET));
14041398 }
14051399
14061400 if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) {
@@ -1481,6 +1475,7 @@ int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* b · 74 unmodified lines
14811475 int iNextScale = 8;
14821476 int iDeltaScale;
14831477 int32_t iCode;
1478+ int32_t iIdx;
14841479 for (int j = 0; j < iScalingListNum; j++) {
14851480 if (iNextScale != 0) {
14861481 WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode));
@@ -1492,8 +1487,9 @@ int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* b · 5 unmodified lines
14921487 if (*bUseDefaultScalingMatrixFlag)
14931488 break;
14941489 }
1495− pScalingList[g_kuiZigzagScan[j]] = (iNextScale == 0) ? iLastScale : iNextScale;
1496− iLastScale = pScalingList[g_kuiZigzagScan[j]];
1490+ iIdx = iScalingListNum == 16 ? g_kuiZigzagScan[j] : g_kuiZigzagScan8x8[j];
1491+ pScalingList[iIdx] = (iNextScale == 0) ? iLastScale : iNextScale;
1492+ iLastScale = pScalingList[iIdx];
14971493 }
14981494
14991495
codec/decoder/core/src/cabac_decoder.cpp+1−1
@@ -74,7 +74,7 @@ int32_t InitCabacDecEngineFromBS (PWelsCabacDecEngine pDecEngine, PBitStringAux · 73 unmodified lines
7474 uint8_t* pCurr;
7575
7676 pCurr = pBsAux->pCurBuf - iRemainingBytes;
77− if(pCurr >= (pBsAux->pEndBuf - 1)) {
77+ if (pCurr >= (pBsAux->pEndBuf - 1)) {
7878 return ERR_INFO_INVALID_ACCESS;
7979 }
8080 pDecEngine->uiOffset = ((pCurr[0] << 16) | (pCurr[1] << 8) | pCurr[2]);
codec/decoder/core/src/deblocking.cpp+191−70
@@ -136,6 +136,19 @@ static const uint8_t g_kuiTableBIdx[2][8] = { · 135 unmodified lines
136136 },
137137 };
138138
139+static const uint8_t g_kuiTableB8x8Idx[2][16] = {
140+ {
141+ 0, 1, 4, 5, 8, 9, 12, 13, // 0 1 | 2 3
142+ 2, 3, 6, 7, 10, 11, 14, 15 // 4 5 | 6 7
143+ }, // ------------
144+ // 8 9 | 10 11
145+ {
146+ // 12 13 | 14 15
147+ 0, 1, 4, 5, 2, 3, 6, 7,
148+ 8, 9, 12, 13, 10, 11, 14, 15
149+ },
150+};
151+
139152 #define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \
140153 {\
141154 tc[0] = g_kiTc0Table(iIndexA)[pBS[0]] + bChroma;\
@@ -170,7 +183,22 @@ void inline DeblockingBSInsideMBAvsbase (int8_t* pNnzTab, uint8_t nBS[2][4][4], · 28 unmodified lines
170183 nBS[0][2][3] = (pNnzTab[13] | pNnzTab[14]) << iLShiftFactor;
171184 nBS[0][3][3] = (pNnzTab[14] | pNnzTab[15]) << iLShiftFactor;
172185 * (uint32_t*)nBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor;
186+}
187+
188+void inline DeblockingBSInsideMBAvsbase8x8 (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) {
189+ int8_t i8x8NnzTab[4];
190+ for (int32_t i = 0; i < 4; i++) {
191+ int32_t iBlkIdx = i << 2;
192+ i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] |
193+ pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]);
194+ }
173195
196+ //vertical
197+ nBS[0][2][0] = nBS[0][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[1]) << iLShiftFactor;
198+ nBS[0][2][2] = nBS[0][2][3] = (i8x8NnzTab[2] | i8x8NnzTab[3]) << iLShiftFactor;
199+ //horizontal
200+ nBS[1][2][0] = nBS[1][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[2]) << iLShiftFactor;
201+ nBS[1][2][2] = nBS[1][2][3] = (i8x8NnzTab[1] | i8x8NnzTab[3]) << iLShiftFactor;
174202 }
175203
176204 void static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab,
@@ -179,73 +207,148 @@ void static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS · 2 unmodified lines
179207 int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy];
180208 ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4);
181209
182− uiNnz32b0 = * (uint32_t*) (pNnzTab + 0);
183− uiNnz32b1 = * (uint32_t*) (pNnzTab + 4);
184− uiNnz32b2 = * (uint32_t*) (pNnzTab + 8);
185− uiNnz32b3 = * (uint32_t*) (pNnzTab + 12);
210+ int8_t i8x8NnzTab[4];
186211
187− for (int i = 0; i < 3; i++)
188− uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
189− nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0);
190− nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1);
191− nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2);
192−
193− for (int i = 0; i < 3; i++)
194− uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
195− nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4);
196− nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5);
197− nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6);
198−
199− for (int i = 0; i < 3; i++)
200− uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
201− nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8);
202− nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9);
203− nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10);
204−
205− for (int i = 0; i < 3; i++)
206− uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
207− nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12);
208− nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13);
209− nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14);
210−
211− // horizontal
212− * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1);
213− nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0);
214− nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1);
215− nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2);
216− nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3);
217−
218− * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2);
219− nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4);
220− nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5);
221− nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6);
222− nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7);
223−
224− * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3);
225− nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8);
226− nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9);
227− nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10);
228− nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11);
212+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
213+ for (int32_t i = 0; i < 4; i++) {
214+ int32_t iBlkIdx = i << 2;
215+ i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] |
216+ pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]);
217+ }
218+ //vertical
219+ nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy],
220+ g_kuiMbCountScan4Idx[1 << 2], g_kuiMbCountScan4Idx[0]);
221+ nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy],
222+ g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[2 << 2]);
223+
224+ //horizontal
225+ nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy],
226+ g_kuiMbCountScan4Idx[2 << 2], g_kuiMbCountScan4Idx[0]);
227+ nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy],
228+ g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[1 << 2]);
229+ } else {
230+ uiNnz32b0 = * (uint32_t*) (pNnzTab + 0);
231+ uiNnz32b1 = * (uint32_t*) (pNnzTab + 4);
232+ uiNnz32b2 = * (uint32_t*) (pNnzTab + 8);
233+ uiNnz32b3 = * (uint32_t*) (pNnzTab + 12);
234+
235+ for (int i = 0; i < 3; i++)
236+ uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1];
237+ nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0);
238+ nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1);
239+ nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2);
240+
241+ for (int i = 0; i < 3; i++)
242+ uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1];
243+ nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4);
244+ nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5);
245+ nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6);
246+
247+ for (int i = 0; i < 3; i++)
248+ uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1];
249+ nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8);
250+ nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9);
251+ nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10);
252+
253+ for (int i = 0; i < 3; i++)
254+ uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1];
255+ nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12);
256+ nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13);
257+ nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14);
258+
259+ // horizontal
260+ * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1);
261+ nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0);
262+ nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1);
263+ nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2);
264+ nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3);
265+
266+ * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2);
267+ nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4);
268+ nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5);
269+ nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6);
270+ nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7);
271+
272+ * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3);
273+ nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8);
274+ nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9);
275+ nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10);
276+ nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11);
277+ }
229278 }
230279
231280 uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) {
232− int32_t i;
281+ int32_t i, j;
233282 uint32_t uiBSx4;
234− //uint8_t* bS = static_cast<uint8_t*>(&uiBSx4);
235283 uint8_t* pBS = (uint8_t*) (&uiBSx4);
236− const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0];
237− const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4];
238−
239− for (i = 0; i < 4; i++) {
240− if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) {
241− pBS[i] = 2;
242− } else {
243− pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx,
244− *pBnIdx);
284+ const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0];
285+ const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4];
286+ const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0];
287+ const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8];
288+
289+ if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) {
290+ for (i = 0; i < 2; i++) {
291+ uint8_t uiNzc = 0;
292+ for (j = 0; uiNzc == 0 && j < 4; j++) {
293+ uiNzc |= (pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)] | pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)]);
294+ }
295+ if (uiNzc) {
296+ pBS[i << 1] = pBS[1 + (i << 1)] = 2;
297+ } else {
298+ pBS[i << 1] = pBS[1 + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb,
299+ *pB8x8Idx, *pBn8x8Idx);
300+ }
301+ pB8x8Idx += 4;
302+ pBn8x8Idx += 4;
303+ }
304+ } else if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
305+ for (i = 0; i < 2; i++) {
306+ uint8_t uiNzc = 0;
307+ for (j = 0; uiNzc == 0 && j < 4; j++) {
308+ uiNzc |= pCurDqLayer->pNzc[iMbXy][* (pB8x8Idx + j)];
309+ }
310+ for (j = 0; j < 2; j++) {
311+ if (uiNzc | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) {
312+ pBS[j + (i << 1)] = 2;
313+ } else {
314+ pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pB8x8Idx,
315+ *pBnIdx);
316+ }
317+ pBnIdx++;
318+ }
319+ pB8x8Idx += 4;
320+ }
321+ } else if (pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) {
322+ for (i = 0; i < 2; i++) {
323+ uint8_t uiNzc = 0;
324+ for (j = 0; uiNzc == 0 && j < 4; j++) {
325+ uiNzc |= pCurDqLayer->pNzc[iNeighMb][* (pBn8x8Idx + j)];
326+ }
327+ for (j = 0; j < 2; j++) {
328+ if (uiNzc | pCurDqLayer->pNzc[iMbXy][*pBIdx]) {
329+ pBS[j + (i << 1)] = 2;
330+ } else {
331+ pBS[j + (i << 1)] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx,
332+ *pBn8x8Idx);
333+ }
334+ pBIdx++;
335+ }
336+ pBn8x8Idx += 4;
337+ }
338+ } else {
339+ // only 4x4 transform
340+ for (i = 0; i < 4; i++) {
341+ if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) {
342+ pBS[i] = 2;
343+ } else {
344+ pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx,
345+ *pBnIdx);
346+ }
347+ pBIdx++;
348+ pBnIdx++;
245349 }
246− pBIdx++;
247− pBnIdx++;
248350 }
351+
249352 return uiBSx4;
250353 }
251354 int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) {
@@ -501,7 +604,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 249 unmodified lines
501604 pFilter->iChromaQP[0] = pCurChromaQp[0];
502605 pFilter->iChromaQP[1] = pCurChromaQp[1];
503606
504− if (* (uint32_t*)nBS[0][1] != 0) {
607+ if (* (uint32_t*)nBS[0][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
505608 FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]);
506609 }
507610
@@ -510,7 +613,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 2 unmodified lines
510613 FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]);
511614 }
512615
513− if (* (uint32_t*)nBS[0][3] != 0) {
616+ if (* (uint32_t*)nBS[0][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
514617 FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]);
515618 }
516619
@@ -536,7 +639,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 19 unmodified lines
536639 pFilter->iChromaQP[0] = pCurChromaQp[0];
537640 pFilter->iChromaQP[1] = pCurChromaQp[1];
538641
539− if (* (uint32_t*)nBS[1][1] != 0) {
642+ if (* (uint32_t*)nBS[1][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
540643 FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]);
541644 }
542645
@@ -546,7 +649,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 3 unmodified lines
546649 nBS[1][2]);
547650 }
548651
549− if (* (uint32_t*)nBS[1][3] != 0) {
652+ if (* (uint32_t*)nBS[1][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
550653 FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]);
551654 }
552655 }
@@ -581,9 +684,16 @@ void FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int3 · 28 unmodified lines
581684 iBeta);
582685 if (iAlpha | iBeta) {
583686 TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 0);
584− pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc);
687+
688+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
689+ pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[1 << 2], iLineSize, iAlpha, iBeta, iTc);
690+ }
691+
585692 pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc);
586− pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc);
693+
694+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
695+ pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[3 << 2], iLineSize, iAlpha, iBeta, iTc);
696+ }
587697 }
588698
589699 // luma h
@@ -594,9 +704,15 @@ void FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int3 · 4 unmodified lines
594704
595705 pFilter->iLumaQP = iCurQp;
596706 if (iAlpha | iBeta) {
597− pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
707+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
708+ pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (1 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
709+ }
710+
598711 pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
599− pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
712+
713+ if (!pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) {
714+ pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (3 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc);
715+ }
600716 }
601717 }
602718 void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) {
@@ -705,6 +821,7 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t · 102 unmodified lines
705821
706822 switch (iCurMbType) {
707823 case MB_TYPE_INTRA4x4:
824+ case MB_TYPE_INTRA8x8:
708825 case MB_TYPE_INTRA16x16:
709826 case MB_TYPE_INTRA_PCM:
710827 DeblockingIntraMb (pCurDqLayer, pFilter, iBoundryFlag);
@@ -728,7 +845,11 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t · 17 unmodified lines
728845 //SKIP MB_16x16 or others
729846 if (iCurMbType != MB_TYPE_SKIP) {
730847 if (iCurMbType == MB_TYPE_16x16) {
731− DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1);
848+ if (!pCurDqLayer->pTransformSize8x8Flag[pCurDqLayer->iMbXyIndex]) {
849+ DeblockingBSInsideMBAvsbase (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1);
850+ } else {
851+ DeblockingBSInsideMBAvsbase8x8 (pCurDqLayer->pNzc[iMbXyIndex], nBS, 1);
852+ }
732853 } else {
733854 DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex);
734855 }
@@ -839,8 +960,8 @@ void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) { · 104 unmodified lines
839960 if (iCpu & WELS_CPU_SSSE3) {
840961 pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_ssse3;
841962 pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_ssse3;
842− pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_ssse3;
843− pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_ssse3;
963+ pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_ssse3;
964+ pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_ssse3;
844965 pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_ssse3;
845966 pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_ssse3;
846967 pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_ssse3;
codec/decoder/core/src/decode_mb_aux.cpp+90−0
@@ -76,6 +76,96 @@ void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { · 75 unmodified lines
7676 }
7777 }
7878
79+void IdctResAddPred8x8_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) {
80+ // To make the ASM code easy to write, should using one funciton to apply hor and ver together, such as we did on HEVC
81+ // Ugly code, just for easy debug, the final version need optimization
82+ int16_t p[8], b[8];
83+ int16_t a[4];
84+
85+ int16_t iTmp[64];
86+ int16_t iRes[64];
87+
88+ // Horizontal
89+ for (int i = 0; i < 8; i++) {
90+ for (int j = 0; j < 8; j++) {
91+ p[j] = pRs[j + (i << 3)];
92+ }
93+ a[0] = p[0] + p[4];
94+ a[1] = p[0] - p[4];
95+ a[2] = p[6] - (p[2] >> 1);
96+ a[3] = p[2] + (p[6] >> 1);
97+
98+ b[0] = a[0] + a[3];
99+ b[2] = a[1] - a[2];
100+ b[4] = a[1] + a[2];
101+ b[6] = a[0] - a[3];
102+
103+ a[0] = -p[3] + p[5] - p[7] - (p[7] >> 1);
104+ a[1] = p[1] + p[7] - p[3] - (p[3] >> 1);
105+ a[2] = -p[1] + p[7] + p[5] + (p[5] >> 1);
106+ a[3] = p[3] + p[5] + p[1] + (p[1] >> 1);
107+
108+ b[1] = a[0] + (a[3] >> 2);
109+ b[3] = a[1] + (a[2] >> 2);
110+ b[5] = a[2] - (a[1] >> 2);
111+ b[7] = a[3] - (a[0] >> 2);
112+
113+ iTmp[0 + (i << 3)] = b[0] + b[7];
114+ iTmp[1 + (i << 3)] = b[2] - b[5];
115+ iTmp[2 + (i << 3)] = b[4] + b[3];
116+ iTmp[3 + (i << 3)] = b[6] + b[1];
117+ iTmp[4 + (i << 3)] = b[6] - b[1];
118+ iTmp[5 + (i << 3)] = b[4] - b[3];
119+ iTmp[6 + (i << 3)] = b[2] + b[5];
120+ iTmp[7 + (i << 3)] = b[0] - b[7];
121+ }
122+
123+ //Vertical
124+ for (int i = 0; i < 8; i++) {
125+ for (int j = 0; j < 8; j++) {
126+ p[j] = iTmp[i + (j << 3)];
127+ }
128+
129+ a[0] = p[0] + p[4];
130+ a[1] = p[0] - p[4];
131+ a[2] = p[6] - (p[2] >> 1);
132+ a[3] = p[2] + (p[6] >> 1);
133+
134+ b[0] = a[0] + a[3];
135+ b[2] = a[1] - a[2];
136+ b[4] = a[1] + a[2];
137+ b[6] = a[0] - a[3];
138+
139+ a[0] = -p[3] + p[5] - p[7] - (p[7] >> 1);
140+ a[1] = p[1] + p[7] - p[3] - (p[3] >> 1);
141+ a[2] = -p[1] + p[7] + p[5] + (p[5] >> 1);
142+ a[3] = p[3] + p[5] + p[1] + (p[1] >> 1);
143+
144+
145+ b[1] = a[0] + (a[3] >> 2);
146+ b[7] = a[3] - (a[0] >> 2);
147+ b[3] = a[1] + (a[2] >> 2);
148+ b[5] = a[2] - (a[1] >> 2);
149+
150+ iRes[ (0 << 3) + i] = b[0] + b[7];
151+ iRes[ (1 << 3) + i] = b[2] - b[5];
152+ iRes[ (2 << 3) + i] = b[4] + b[3];
153+ iRes[ (3 << 3) + i] = b[6] + b[1];
154+ iRes[ (4 << 3) + i] = b[6] - b[1];
155+ iRes[ (5 << 3) + i] = b[4] - b[3];
156+ iRes[ (6 << 3) + i] = b[2] + b[5];
157+ iRes[ (7 << 3) + i] = b[0] - b[7];
158+ }
159+
160+ uint8_t* pDst = pPred;
161+ for (int i = 0; i < 8; i++) {
162+ for (int j = 0; j < 8; j++) {
163+ pDst[i * kiStride + j] = WelsClip1 (((32 + iRes[ (i << 3) + j]) >> 6) + pDst[i * kiStride + j]);
164+ }
165+ }
166+
167+}
168+
79169 void GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) {
80170 int32_t* pOffset = pBlockOffset;
81171 int32_t i;
codec/decoder/core/src/decode_slice.cpp+370−107
@@ -144,7 +144,6 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 143 unmodified lines
144144 return 0;//NO_SUPPORTED_FILTER_IDX
145145 } else {
146146 WelsDeblockingFilterSlice (pCtx, pDeblockMb);
147−
148147 }
149148 // any other filter_idc not supported here, 7/22/2010
150149
@@ -159,11 +158,22 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa · 8 unmodified lines
159158 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16
160159 WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4
161160
162− for (i = 0; i < 16; i++) { //luma
163− iIndex = g_kuiMbCountScan4Idx[i];
164− if (pCurLayer->pNzc[iMbXy][iIndex]) {
165− iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2);
166− pCtx->pIdctResAddPredFunc (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4));
161+ if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
162+ for (i = 0; i < 4; i++) {
163+ iIndex = g_kuiMbCountScan4Idx[i << 2];
164+ if (pCurLayer->pNzc[iMbXy][iIndex] || pCurLayer->pNzc[iMbXy][iIndex + 1] || pCurLayer->pNzc[iMbXy][iIndex + 4]
165+ || pCurLayer->pNzc[iMbXy][iIndex + 5]) {
166+ iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2);
167+ pCtx->pIdctResAddPredFunc8x8 (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 6));
168+ }
169+ }
170+ } else {
171+ for (i = 0; i < 16; i++) { //luma
172+ iIndex = g_kuiMbCountScan4Idx[i];
173+ if (pCurLayer->pNzc[iMbXy][iIndex]) {
174+ iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2);
175+ pCtx->pIdctResAddPredFunc (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 4));
176+ }
167177 }
168178 }
169179
@@ -258,6 +268,10 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 88 unmodified lines
258268 return 0;
259269 }
260270
271+ if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) {
272+ RecI8x8Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
273+ }
274+
261275 if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy]))
262276 RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer);
263277
@@ -326,7 +340,7 @@ void WelsChromaDcIdct (int16_t* pBlock) { · 62 unmodified lines
326340 pBlk[iStride1] = (iE - iB) >> 1;
327341 }
328342
329−void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
343+void WelsMapNxNNeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
330344 if (pNeighAvail->iLeftAvail) { //left
331345 pSampleAvail[ 6] =
332346 pSampleAvail[12] =
@@ -347,7 +361,7 @@ void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampl · 14 unmodified lines
347361 }
348362 }
349363
350−void WelsMap4x4NeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
364+void WelsMapNxNNeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) {
351365 if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left
352366 pSampleAvail[ 6] =
353367 pSampleAvail[12] =
@@ -401,7 +415,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 47 unmodified lines
401415 uint8_t uiNeighAvail = 0;
402416 uint32_t uiCode;
403417 int32_t iCode;
404− pCtx->pMap4x4NeighToSampleFunc (pNeighAvail, iSampleAvail);
418+ pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail);
405419 uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]);
406420 for (i = 0; i < 16; i++) {
407421 int32_t iPrevIntra4x4PredMode = 0;
@@ -429,7 +443,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 21 unmodified lines
429443 }
430444 }
431445
432− iFinalMode = CheckIntra4x4PredMode (&iSampleAvail[0], &iBestMode, i);
446+ iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i, false);
433447 if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {
434448 return ERR_INFO_INVALID_I4x4_PRED_MODE;
435449 }
@@ -469,6 +483,87 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 33 unmodified lines
469483 return ERR_NONE;
470484 }
471485
486+int32_t ParseIntra8x8Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, int8_t* pIntraPredMode,
487+ PBitStringAux pBs,
488+ PDqLayer pCurDqLayer) {
489+ // Similar with Intra_4x4, can put them together when needed
490+ int32_t iSampleAvail[5 * 6] = { 0 }; //initialize as 0
491+ int32_t iMbXy = pCurDqLayer->iMbXyIndex;
492+ int32_t iFinalMode, i;
493+
494+ uint8_t uiNeighAvail = 0;
495+ uint32_t uiCode;
496+ int32_t iCode;
497+ pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail);
498+ // Top-Right : Left : Top-Left : Top
499+ uiNeighAvail = (iSampleAvail[5] << 3) | (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]);
500+
501+ pCurDqLayer->pIntraNxNAvailFlag[iMbXy] = uiNeighAvail;
502+
503+ for (i = 0; i < 4; i++) {
504+ int32_t iPrevIntra4x4PredMode = 0;
505+ if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
506+ WELS_READ_VERIFY (ParseIntraPredModeLumaCabac (pCtx, iCode));
507+ iPrevIntra4x4PredMode = iCode;
508+ } else {
509+ WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode));
510+ iPrevIntra4x4PredMode = uiCode;
511+ }
512+ const int32_t kiPredMode = PredIntra4x4Mode (pIntraPredMode, i << 2);
513+
514+ int8_t iBestMode;
515+ if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
516+ if (iPrevIntra4x4PredMode == -1)
517+ iBestMode = kiPredMode;
518+ else
519+ iBestMode = iPrevIntra4x4PredMode + (iPrevIntra4x4PredMode >= kiPredMode);
520+ } else {
521+ if (iPrevIntra4x4PredMode) {
522+ iBestMode = kiPredMode;
523+ } else {
524+ WELS_READ_VERIFY (BsGetBits (pBs, 3, &uiCode));
525+ iBestMode = uiCode + ((int32_t) uiCode >= kiPredMode);
526+ }
527+ }
528+
529+ iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i << 2, true);
530+
531+ if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) {
532+ return ERR_INFO_INVALID_I4x4_PRED_MODE;
533+ }
534+
535+ for (int j = 0; j < 4; j++) {
536+ pCurDqLayer->pIntra4x4FinalMode[iMbXy][g_kuiScan4[ (i << 2) + j]] = iFinalMode;
537+ pIntraPredMode[g_kuiScan8[ (i << 2) + j]] = iBestMode;
538+ iSampleAvail[g_kuiCache30ScanIdx[ (i << 2) + j]] = 1;
539+ }
540+ }
541+ ST32 (&pCurDqLayer->pIntraPredMode[iMbXy][0], LD32 (&pIntraPredMode[1 + 8 * 4]));
542+ pCurDqLayer->pIntraPredMode[iMbXy][4] = pIntraPredMode[4 + 8 * 1];
543+ pCurDqLayer->pIntraPredMode[iMbXy][5] = pIntraPredMode[4 + 8 * 2];
544+ pCurDqLayer->pIntraPredMode[iMbXy][6] = pIntraPredMode[4 + 8 * 3];
545+ if (pCurDqLayer->sLayerInfo.pPps->bEntropyCodingModeFlag) {
546+ WELS_READ_VERIFY (ParseIntraPredModeChromaCabac (pCtx, uiNeighAvail, iCode));
547+ if (iCode > MAX_PRED_MODE_ID_CHROMA) {
548+ return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
549+ }
550+ pCurDqLayer->pChromaPredMode[iMbXy] = iCode;
551+ } else {
552+ WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //intra_chroma_pred_mode
553+ if (uiCode > MAX_PRED_MODE_ID_CHROMA) {
554+ return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
555+ }
556+ pCurDqLayer->pChromaPredMode[iMbXy] = uiCode;
557+ }
558+
559+ if (-1 == pCurDqLayer->pChromaPredMode[iMbXy]
560+ || CheckIntraChromaPredMode (uiNeighAvail, &pCurDqLayer->pChromaPredMode[iMbXy])) {
561+ return ERR_INFO_INVALID_I_CHROMA_PRED_MODE;
562+ }
563+
564+ return ERR_NONE;
565+}
566+
472567 int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs,
473568 PDqLayer pCurDqLayer) {
474569 int32_t iMbXy = pCurDqLayer->iMbXyIndex;
@@ -519,6 +614,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 44 unmodified lines
519614
520615 ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16);
521616
617+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
618+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
619+
522620 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
523621 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
524622 GetNeighborAvailMbType (&sNeighAvail, pCurLayer);
@@ -539,8 +637,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 14 unmodified lines
539637 } else if (0 == uiMbType) { //I4x4
540638 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
541639 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
542− pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
543− WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
640+ if (pCtx->pPps->bTransform8x8ModeFlag) {
641+ // Transform 8x8 cabac will be added soon
642+ WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, &sNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
643+ }
644+ if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
645+ uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
646+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
647+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
648+ } else {
649+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
650+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
651+ }
544652 //get uiCbp for I4x4
545653 WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp));
546654 pCurLayer->pCbp[iMbXy] = uiCbp;
@@ -549,6 +657,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 2 unmodified lines
549657 uiCbpLuma = uiCbp & 15;
550658 } else { //I16x16;
551659 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
660+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
661+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
552662 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
553663 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
554664 uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ;
@@ -565,7 +675,7 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 10 unmodified lines
565675 ST32 (&pCurLayer->pNzc[iMbXy][20], 0);
566676 pCurLayer->pCbfDc[iMbXy] = 0;
567677
568− if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) {
678+ if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) {
569679 pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp;
570680 for (i = 0; i < 2; i++) {
571681 pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] +
@@ -608,26 +718,43 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 36 unmodified lines
608718 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
609719 }
610720 } else { //non-MB_TYPE_INTRA16x16
611− for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
612− if (uiCbpLuma & (1 << iId8x8)) {
613− int32_t iIdx = (iId8x8 << 2);
614− for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
615− //Luma (DC and AC decoding together)
616− WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
617− g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
618− pCurLayer->pLumaQp[iMbXy],
619− pCtx));
620− iIdx++;
721+ if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
722+ // Transform 8x8 support for CABAC
723+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
724+ if (uiCbpLuma & (1 << iId8x8)) {
725+ WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (&sNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
726+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, LUMA_DC_AC_INTRA_8,
727+ pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
728+ } else {
729+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
730+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
621731 }
622− } else {
623− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
624− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
625732 }
733+ ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
734+ ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
735+ ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
736+ ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
737+ } else {
738+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
739+ if (uiCbpLuma & (1 << iId8x8)) {
740+ int32_t iIdx = (iId8x8 << 2);
741+ for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
742+ //Luma (DC and AC decoding together)
743+ WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
744+ g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
745+ pCurLayer->pLumaQp[iMbXy], pCtx));
746+ iIdx++;
747+ }
748+ } else {
749+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
750+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
751+ }
752+ }
753+ ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
754+ ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
755+ ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
756+ ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
626757 }
627− ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
628− ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
629− ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
630− ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
631758 }
632759 int32_t iMbResProperty;
633760 //chroma
@@ -730,10 +857,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 96 unmodified lines
730857 if (0 == uiMbType) { //Intra4x4
731858 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
732859 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
733− pCtx->pFillInfoCacheIntra4x4Func (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
734− WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
860+ if (pCtx->pPps->bTransform8x8ModeFlag) {
861+ WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail, pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]));
862+ }
863+ if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
864+ uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
865+ pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
866+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
867+ } else {
868+ pCtx->pFillInfoCacheIntraNxNFunc (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
869+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer));
870+ }
735871 } else { //Intra16x16
736872 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
873+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
874+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
737875 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
738876 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
739877 uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -761,6 +899,23 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 21 unmodified lines
761899 }
762900
763901 if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) {
902+
903+ if (MB_TYPE_INTRA16x16 != pCurLayer->pMbType[iMbXy]) {
904+ // Need modification when B picutre add in
905+ bool bNeedParseTransformSize8x8Flag =
906+ (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16)
907+ || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
908+ && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
909+ && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
910+ && ((pCurLayer->pCbp[iMbXy] & 0x0F) > 0)
911+ && (pCtx->pPps->bTransform8x8ModeFlag));
912+
913+ if (bNeedParseTransformSize8x8Flag) {
914+ WELS_READ_VERIFY (ParseTransformSize8x8FlagCabac (pCtx, pNeighAvail,
915+ pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy])); //transform_size_8x8_flag
916+ }
917+ }
918+
764919 memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0]));
765920
766921 int32_t iQpDelta, iId8x8, iId4x4;
@@ -798,27 +953,46 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 31 unmodified lines
798953 ST32 (&pCurLayer->pNzc[iMbXy][12], 0);
799954 }
800955 } else { //non-MB_TYPE_INTRA16x16
801− iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
802− for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
803− if (uiCbpLuma & (1 << iId8x8)) {
804− int32_t iIdx = (iId8x8 << 2);
805− for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
806− //Luma (DC and AC decoding together)
807− WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
808− g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
809− pCurLayer->pLumaQp[iMbXy],
810− pCtx));
811− iIdx++;
956+ if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) {
957+ // Transform 8x8 support for CABAC
958+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
959+ if (uiCbpLuma & (1 << iId8x8)) {
960+ WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2),
961+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart,
962+ IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8,
963+ pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx));
964+ } else {
965+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0);
966+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
967+ }
968+ }
969+ ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
970+ ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
971+ ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
972+ ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
973+ } else {
974+ iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
975+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
976+ if (uiCbpLuma & (1 << iId8x8)) {
977+ int32_t iIdx = (iId8x8 << 2);
978+ for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
979+ //Luma (DC and AC decoding together)
980+ WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1,
981+ g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4),
982+ pCurLayer->pLumaQp[iMbXy],
983+ pCtx));
984+ iIdx++;
985+ }
986+ } else {
987+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[iId8x8 << 2]], 0);
988+ ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
812989 }
813− } else {
814− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[iId8x8 << 2]], 0);
815− ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0);
816990 }
991+ ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
992+ ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
993+ ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
994+ ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
817995 }
818− ST32 (&pCurLayer->pNzc[iMbXy][0], LD32 (&pNonZeroCount[1 + 8 * 1]));
819− ST32 (&pCurLayer->pNzc[iMbXy][4], LD32 (&pNonZeroCount[1 + 8 * 2]));
820− ST32 (&pCurLayer->pNzc[iMbXy][8], LD32 (&pNonZeroCount[1 + 8 * 3]));
821− ST32 (&pCurLayer->pNzc[iMbXy][12], LD32 (&pNonZeroCount[1 + 8 * 4]));
822996 }
823997
824998 //chroma
@@ -886,8 +1060,12 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 61 unmodified lines
8861060 pCurLayer->pCbfDc[iMbXy] = 0;
8871061 pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC;
8881062
1063+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1064+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1065+
8891066 GetNeighborAvailMbType (&uiNeighAvail, pCurLayer);
8901067 WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode));
1068+
8911069 if (uiCode) {
8921070 int16_t pMv[2] = {0};
8931071 pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP;
@@ -943,30 +1121,23 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 49 unmodified lines
9431121 //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) {
9441122 if (!pCtx->pPps->bPicScalingListPresentFlag[i]) {
9451123 if (i < 6) {
946−
947−
9481124 if (i == 0 || i == 3)
9491125 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t));
9501126 else
9511127 memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t));
9521128 } else {
953−
9541129 if (i == 6 || i == 7)
9551130 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t));
9561131 else
9571132 memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pPps->iScalingList8x8[i - 8], 64 * sizeof (uint8_t));
958−
959−
9601133 }
961−
9621134 }
9631135 }
964−
965−
9661136 }
9671137 //Init dequant coeff value for different QP
9681138 for (i = 0; i < 6; i++) {
9691139 pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i];
1140+ pCtx->pDequant_coeff8x8[i] = pCtx->pDequant_coeff_buffer8x8[i];
9701141 for (q = 0; q < 51; q++) {
9711142 for (x = 0; x < 16; x++) {
9721143 pCtx->pDequant_coeff4x4[i][q][x] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList4x4[i][x] *
@@ -974,13 +1145,10 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 1 unmodified line
9741145 }
9751146 for (y = 0; y < 64; y++) {
9761147 pCtx->pDequant_coeff8x8[i][q][y] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList8x8[i][y] *
977− g_kuiDequantCoeff[q][x & 0x07] : pCtx->pSps->iScalingList8x8[i][y] * g_kuiDequantCoeff[q][x &
978− 0x07];//pseudo-code ,holding for 8x8transform into
1148+ g_kuiMatrixV[q % 6][y / 8][y % 8] : pCtx->pSps->iScalingList8x8[i][y] * g_kuiMatrixV[q % 6][y / 8][y % 8];
9791149 }
9801150 }
9811151 }
982−
983−
9841152 pCtx->bDequantCoeff4x4Init = true;
9851153 pCtx->iDequantCoeffPpsid = pCtx->pPps->iPpsId;
9861154 }
@@ -1027,12 +1195,12 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal · 40 unmodified lines
10271195 }
10281196
10291197 if (pSliceHeader->pPps->bConstainedIntraPredFlag) {
1030− pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain1Intra4x4;
1031− pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleConstrain1;
1198+ pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN;
1199+ pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleConstrain1;
10321200 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1;
10331201 } else {
1034− pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain0Intra4x4;
1035− pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleNormal;
1202+ pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain0IntraNxN;
1203+ pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleNormal;
10361204 pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal;
10371205 }
10381206
@@ -1117,6 +1285,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 78 unmodified lines
11171285 pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0;
11181286 pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag;
11191287
1288+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1289+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1290+
11201291 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType
11211292 uiMbType = uiCode;
11221293 if (uiMbType > 25)
@@ -1178,8 +1349,20 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 55 unmodified lines
11781349 } else if (0 == uiMbType) { //reference to JM
11791350 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
11801351 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
1181− pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
1182− WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
1352+ if (pCtx->pPps->bTransform8x8ModeFlag) {
1353+ WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
1354+ pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
1355+ if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1356+ uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
1357+ }
1358+ }
1359+ if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1360+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
1361+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
1362+ } else {
1363+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
1364+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
1365+ }
11831366
11841367 //uiCbp
11851368 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern
@@ -1199,6 +1382,8 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 13 unmodified lines
11991382 uiCbpL = uiCbp & 15;
12001383 } else { //I_PCM exclude, we can ignore it
12011384 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
1385+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1386+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
12021387 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
12031388 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
12041389 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -1266,27 +1451,51 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 61 unmodified lines
12661451 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
12671452 }
12681453 } else { //non-MB_TYPE_INTRA16x16
1269− for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1270− if (uiCbpL & (1 << iId8x8)) {
1271− int32_t iIndex = (iId8x8 << 2);
1272− for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1273− //Luma (DC and AC decoding together)
1274− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1275− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart,
1276− LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1277− return -1;//abnormal
1454+ if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1455+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1456+ iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
1457+ if (uiCbpL & (1 << iId8x8)) {
1458+ int32_t iIndex = (iId8x8 << 2);
1459+ for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1460+ if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex,
1461+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty,
1462+ pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) {
1463+ return -1;
1464+ }
1465+ iIndex++;
12781466 }
1279− iIndex++;
1467+ } else {
1468+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0);
1469+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
12801470 }
1281− } else {
1282− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2)]], 0);
1283− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
12841471 }
1472+ ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
1473+ ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2]));
1474+ ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3]));
1475+ ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
1476+ } else {
1477+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1478+ if (uiCbpL & (1 << iId8x8)) {
1479+ int32_t iIndex = (iId8x8 << 2);
1480+ for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1481+ //Luma (DC and AC decoding together)
1482+ if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1483+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart,
1484+ LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1485+ return -1;//abnormal
1486+ }
1487+ iIndex++;
1488+ }
1489+ } else {
1490+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2)]], 0);
1491+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
1492+ }
1493+ }
1494+ ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
1495+ ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2]));
1496+ ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3]));
1497+ ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
12851498 }
1286− ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
1287− ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2]));
1288− ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3]));
1289− ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
12901499 }
12911500
12921501 //chroma
@@ -1399,6 +1608,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 106 unmodified lines
13991608 int8_t iRefIndex[LIST_A][30];
14001609 pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType;
14011610 WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer);
1611+
14021612 if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) {
14031613 return -1;//abnormal
14041614 }
@@ -1484,12 +1694,24 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 79 unmodified lines
14841694 if (0 == uiMbType) {
14851695 ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16);
14861696 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4;
1487− pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
1488− if (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)) {
1489− return -1;
1697+ if (pCtx->pPps->bTransform8x8ModeFlag) {
1698+ WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
1699+ pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
1700+ if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1701+ uiMbType = pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA8x8;
1702+ }
1703+ }
1704+ if (!pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1705+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
1706+ WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
1707+ } else {
1708+ pCtx->pFillInfoCacheIntraNxNFunc (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer);
1709+ WELS_READ_VERIFY (ParseIntra8x8Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer));
14901710 }
14911711 } else { //I_PCM exclude, we can ignore it
14921712 pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16;
1713+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1714+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
14931715 pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3;
14941716 pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2];
14951717 uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0;
@@ -1510,7 +1732,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 14 unmodified lines
15101732 return ERR_INFO_INVALID_CBP;
15111733 if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15))
15121734 return ERR_INFO_INVALID_CBP;
1513− if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy]) {
1735+ if (MB_TYPE_INTRA4x4 == pCurLayer->pMbType[iMbXy] || MB_TYPE_INTRA8x8 == pCurLayer->pMbType[iMbXy]) {
15141736
15151737 uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp];
15161738 } else //inter
@@ -1520,6 +1742,20 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 3 unmodified lines
15201742 pCurLayer->pCbp[iMbXy] = uiCbp;
15211743 uiCbpC = pCurLayer->pCbp[iMbXy] >> 4;
15221744 uiCbpL = pCurLayer->pCbp[iMbXy] & 15;
1745+
1746+ // Need modification when B picutre add in
1747+ bool bNeedParseTransformSize8x8Flag =
1748+ (((pCurLayer->pMbType[iMbXy] >= MB_TYPE_16x16 && pCurLayer->pMbType[iMbXy] <= MB_TYPE_8x16)
1749+ || pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy])
1750+ && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA8x8)
1751+ && (pCurLayer->pMbType[iMbXy] != MB_TYPE_INTRA4x4)
1752+ && (uiCbpL > 0)
1753+ && (pCtx->pPps->bTransform8x8ModeFlag));
1754+
1755+ if (bNeedParseTransformSize8x8Flag) {
1756+ WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag
1757+ pCurLayer->pTransformSize8x8Flag[iMbXy] = !!uiCode;
1758+ }
15231759 }
15241760
15251761 ST32A4 (&pNzc[0], 0);
@@ -1577,28 +1813,52 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 51 unmodified lines
15771813 ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
15781814 }
15791815 } else { //non-MB_TYPE_INTRA16x16
1580− for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1581− iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
1582− if (uiCbpL & (1 << iId8x8)) {
1583− int32_t iIndex = (iId8x8 << 2);
1584− for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1585− //Luma (DC and AC decoding together)
1586− if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1587− iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty,
1588− pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1589− return -1;//abnormal
1816+ if (pCurLayer->pTransformSize8x8Flag[iMbXy]) {
1817+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1818+ iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
1819+ if (uiCbpL & (1 << iId8x8)) {
1820+ int32_t iIndex = (iId8x8 << 2);
1821+ for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1822+ if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex,
1823+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty,
1824+ pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) {
1825+ return -1;
1826+ }
1827+ iIndex++;
15901828 }
1591− iIndex++;
1829+ } else {
1830+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0);
1831+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
1832+ }
1833+ }
1834+ ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
1835+ ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2]));
1836+ ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3]));
1837+ ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
1838+ } else { // Normal T4x4
1839+ for (iId8x8 = 0; iId8x8 < 4; iId8x8++) {
1840+ iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER;
1841+ if (uiCbpL & (1 << iId8x8)) {
1842+ int32_t iIndex = (iId8x8 << 2);
1843+ for (iId4x4 = 0; iId4x4 < 4; iId4x4++) {
1844+ //Luma (DC and AC decoding together)
1845+ if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex,
1846+ iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty,
1847+ pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) {
1848+ return -1;//abnormal
1849+ }
1850+ iIndex++;
1851+ }
1852+ } else {
1853+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0);
1854+ ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
15921855 }
1593− } else {
1594− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0);
1595− ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0);
15961856 }
1857+ ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
1858+ ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2]));
1859+ ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3]));
1860+ ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
15971861 }
1598− ST32A4 (&pNzc[0], LD32 (&pNonZeroCount[1 + 8 * 1]));
1599− ST32A4 (&pNzc[4], LD32 (&pNonZeroCount[1 + 8 * 2]));
1600− ST32A4 (&pNzc[8], LD32 (&pNonZeroCount[1 + 8 * 3]));
1601− ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4]));
16021862 }
16031863
16041864
@@ -1661,6 +1921,9 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 56 unmodified lines
16611921 int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15
16621922 uint32_t uiCode;
16631923
1924+ pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true;
1925+ pCurLayer->pTransformSize8x8Flag[iMbXy] = false;
1926+
16641927 if (-1 == pSlice->iMbSkipRun) {
16651928 WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run
16661929 pSlice->iMbSkipRun = uiCode;
codec/decoder/core/src/decoder.cpp+18−1
@@ -862,6 +862,21 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 861 unmodified lines
862862 pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_c;
863863 pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_c;
864864
865+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_V ] = WelsI8x8LumaPredV_c;
866+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_H ] = WelsI8x8LumaPredH_c;
867+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DC ] = WelsI8x8LumaPredDc_c;
868+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DC_L ] = WelsI8x8LumaPredDcLeft_c;
869+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DC_T ] = WelsI8x8LumaPredDcTop_c;
870+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DC_128] = WelsI8x8LumaPredDcNA_c;
871+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DDL ] = WelsI8x8LumaPredDDL_c;
872+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DDL_TOP] = WelsI8x8LumaPredDDLTop_c;
873+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_DDR ] = WelsI8x8LumaPredDDR_c;
874+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_VL ] = WelsI8x8LumaPredVL_c;
875+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_VL_TOP] = WelsI8x8LumaPredVLTop_c;
876+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_VR ] = WelsI8x8LumaPredVR_c;
877+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_HU ] = WelsI8x8LumaPredHU_c;
878+ pCtx->pGetI8x8LumaPredFunc[I4_PRED_HD ] = WelsI8x8LumaPredHD_c;
879+
865880 pCtx->pGetIChromaPredFunc[C_PRED_DC ] = WelsIChromaPredDc_c;
866881 pCtx->pGetIChromaPredFunc[C_PRED_H ] = WelsIChromaPredH_c;
867882 pCtx->pGetIChromaPredFunc[C_PRED_V ] = WelsIChromaPredV_c;
@@ -872,6 +887,8 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 4 unmodified lines
872887
873888 pCtx->pIdctResAddPredFunc = IdctResAddPred_c;
874889
890+ pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c;
891+
875892 #if defined(HAVE_NEON)
876893 if (pCtx->uiCpuFlag & WELS_CPU_NEON) {
877894 pCtx->pIdctResAddPredFunc = IdctResAddPred_neon;
@@ -931,7 +948,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 53 unmodified lines
931948 if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) {
932949 pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx;
933950
934− /////////mmx code opt---
951+ ///////mmx code opt---
935952 pCtx->pGetIChromaPredFunc[C_PRED_H] = WelsDecoderIChromaPredH_mmx;
936953 pCtx->pGetIChromaPredFunc[C_PRED_V] = WelsDecoderIChromaPredV_mmx;
937954 pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsDecoderIChromaPredDcLeft_mmx;
codec/decoder/core/src/decoder_core.cpp+30−2
@@ -1238,11 +1238,16 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 1237 unmodified lines
12381238 int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]");
12391239 pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12401240 "pCtx->sMb.pLumaQp[]");
1241+ pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = (bool*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
1242+ bool),
1243+ "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]");
1244+ pCtx->sMb.pTransformSize8x8Flag[i] = (bool*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (bool),
1245+ "pCtx->sMb.pTransformSize8x8Flag[]");
12411246 pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2,
12421247 "pCtx->sMb.pChromaQp[]");
12431248 pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
12441249 int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]");
1245− pCtx->sMb.pCbfDc[i] = (uint8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint8_t),
1250+ pCtx->sMb.pCbfDc[i] = (uint16_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (uint16_t),
12461251 "pCtx->sMb.pCbfDc[]");
12471252 pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24,
12481253 "pCtx->sMb.pNzc[]");
@@ -1255,6 +1260,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 6 unmodified lines
12551260 "pCtx->sMb.pIntraPredMode[]");
12561261 pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight *
12571262 sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]");
1263+ pCtx->sMb.pIntraNxNAvailFlag[i] = (uint8_t (*))WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
1264+ "pCtx->sMb.pIntraNxNAvailFlag");
12581265 pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
12591266 "pCtx->sMb.pChromaPredMode[]");
12601267 pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
@@ -1341,6 +1348,18 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { · 80 unmodified lines
13411348 pCtx->sMb.pRefIndex[i][0] = NULL;
13421349 }
13431350
1351+ if (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i]) {
1352+ WelsFree (pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i], "pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[]");
1353+
1354+ pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[i] = NULL;
1355+ }
1356+
1357+ if (pCtx->sMb.pTransformSize8x8Flag[i]) {
1358+ WelsFree (pCtx->sMb.pTransformSize8x8Flag[i], "pCtx->sMb.pTransformSize8x8Flag[]");
1359+
1360+ pCtx->sMb.pTransformSize8x8Flag[i] = NULL;
1361+ }
1362+
13441363 if (pCtx->sMb.pLumaQp[i]) {
13451364 WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]");
13461365
@@ -1393,6 +1412,12 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { · 46 unmodified lines
13931412 pCtx->sMb.pIntra4x4FinalMode[i] = NULL;
13941413 }
13951414
1415+ if (pCtx->sMb.pIntraNxNAvailFlag[i]) {
1416+ WelsFree (pCtx->sMb.pIntraNxNAvailFlag[i], "pCtx->sMb.pIntraNxNAvailFlag");
1417+
1418+ pCtx->sMb.pIntraNxNAvailFlag[i] = NULL;
1419+ }
1420+
13961421 if (pCtx->sMb.pChromaPredMode[i]) {
13971422 WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]");
13981423
@@ -1989,7 +2014,7 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN · 590 unmodified lines
19892014 if (kuiQualityId == BASE_QUALITY_ID) {
19902015 pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering;
19912016 pDqLayer->pRefPicMarking = &pSh->sRefMarking;
1992−
2017+
19932018 if (pSh->pPps->bWeightedPredFlag) {
19942019 pDqLayer->bUseWeightPredictionFlag = true;
19952020 pDqLayer->pPredWeightTable = &pSh->sPredWeightTable;
@@ -2029,6 +2054,8 @@ void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { · 33 unmodified lines
20292054 pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0];
20302055 pCurDq->pMv[0] = pCtx->sMb.pMv[0][0];
20312056 pCurDq->pRefIndex[0] = pCtx->sMb.pRefIndex[0][0];
2057+ pCurDq->pNoSubMbPartSizeLessThan8x8Flag = pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[0];
2058+ pCurDq->pTransformSize8x8Flag = pCtx->sMb.pTransformSize8x8Flag[0];
20322059 pCurDq->pLumaQp = pCtx->sMb.pLumaQp[0];
20332060 pCurDq->pChromaQp = pCtx->sMb.pChromaQp[0];
20342061 pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0];
@@ -2038,6 +2065,7 @@ void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { · 3 unmodified lines
20382065 pCurDq->pScaledTCoeff = pCtx->sMb.pScaledTCoeff[0];
20392066 pCurDq->pIntraPredMode = pCtx->sMb.pIntraPredMode[0];
20402067 pCurDq->pIntra4x4FinalMode = pCtx->sMb.pIntra4x4FinalMode[0];
2068+ pCurDq->pIntraNxNAvailFlag = pCtx->sMb.pIntraNxNAvailFlag[0];
20412069 pCurDq->pChromaPredMode = pCtx->sMb.pChromaPredMode[0];
20422070 pCurDq->pCbp = pCtx->sMb.pCbp[0];
20432071 pCurDq->pSubMbType = pCtx->sMb.pSubMbType[0];
codec/decoder/core/src/get_intra_predictor.cpp+501−0
@@ -380,6 +380,507 @@ void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride) { · 379 unmodified lines
380380 ST32A4 (pPred + kiStride3, LD32 (kuiList));
381381 }
382382
383+void WelsI8x8LumaPredV_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
384+ uint64_t uiTop = 0;
385+ int32_t iStride[8];
386+ uint8_t uiPixelFilterT[8];
387+ int32_t i;
388+
389+ for (iStride[0] = 0, i = 1; i < 8; i++) {
390+ iStride[i] = iStride[i - 1] + kiStride;
391+ }
392+
393+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
394+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
395+ for (i = 1; i < 7; i++) {
396+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
397+ }
398+ uiPixelFilterT[7] = bTRAvail ? ((pPred[6 - kiStride] + (pPred[7 - kiStride] << 1) + pPred[8 - kiStride] + 2) >> 2) : ((
399+ pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
400+
401+ // 8-89
402+ for (i = 7; i >= 0; i--) {
403+ uiTop = ((uiTop << 8) | uiPixelFilterT[i]);
404+ }
405+
406+ for (i = 0; i < 8; i++) {
407+ ST64A8 (pPred + kiStride * i, uiTop);
408+ }
409+}
410+
411+void WelsI8x8LumaPredH_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
412+ uint64_t uiLeft;
413+ int32_t iStride[8];
414+ uint8_t uiPixelFilterL[8];
415+ int32_t i;
416+
417+ for (iStride[0] = 0, i = 1; i < 8; i++) {
418+ iStride[i] = iStride[i - 1] + kiStride;
419+ }
420+
421+ uiPixelFilterL[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2) : ((
422+ pPred[-1] * 3 + pPred[-1 + iStride[1]] + 2) >> 2);
423+ for (i = 1; i < 7; i++) {
424+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
425+ 2);
426+ }
427+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
428+
429+ // 8-90
430+ for (i = 0; i < 8; i++) {
431+ uiLeft = 0x0101010101010101U * uiPixelFilterL[i];
432+ ST64A8 (pPred + iStride[i], uiLeft);
433+ }
434+}
435+
436+void WelsI8x8LumaPredDc_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
437+ int32_t iStride[8];
438+ uint8_t uiPixelFilterL[8];
439+ uint8_t uiPixelFilterT[8];
440+ uint16_t uiTotal = 0;
441+ int32_t i;
442+
443+ for (iStride[0] = 0, i = 1; i < 8; i++) {
444+ iStride[i] = iStride[i - 1] + kiStride;
445+ }
446+
447+ uiPixelFilterL[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2) : ((
448+ pPred[-1] * 3 + pPred[-1 + iStride[1]] + 2) >> 2);
449+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
450+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
451+ for (i = 1; i < 7; i++) {
452+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
453+ 2);
454+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
455+ }
456+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
457+ uiPixelFilterT[7] = bTRAvail ? ((pPred[6 - kiStride] + (pPred[7 - kiStride] << 1) + pPred[8 - kiStride] + 2) >> 2) : ((
458+ pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
459+
460+ // 8-91
461+ for (i = 0; i < 8; i++) {
462+ uiTotal += uiPixelFilterL[i];
463+ uiTotal += uiPixelFilterT[i];
464+ }
465+
466+ const uint8_t kuiMean = ((uiTotal + 8) >> 4);
467+ const uint64_t kuiMean64 = 0x0101010101010101U * kuiMean;
468+
469+ for (i = 0; i < 8; i++) {
470+ ST64A8 (pPred + iStride[i], kuiMean64);
471+ }
472+}
473+
474+void WelsI8x8LumaPredDcLeft_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
475+ int32_t iStride[8];
476+ uint8_t uiPixelFilterL[8];
477+ uint16_t uiTotal = 0;
478+ int32_t i;
479+
480+ for (iStride[0] = 0, i = 1; i < 8; i++) {
481+ iStride[i] = iStride[i - 1] + kiStride;
482+ }
483+
484+ uiPixelFilterL[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2) : ((
485+ pPred[-1] * 3 + pPred[-1 + iStride[1]] + 2) >> 2);
486+ for (i = 1; i < 7; i++) {
487+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
488+ 2);
489+ }
490+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
491+
492+ // 8-92
493+ for (i = 0; i < 8; i++) {
494+ uiTotal += uiPixelFilterL[i];
495+ }
496+
497+ const uint8_t kuiMean = ((uiTotal + 4) >> 3);
498+ const uint64_t kuiMean64 = 0x0101010101010101U * kuiMean;
499+
500+ for (i = 0; i < 8; i++) {
501+ ST64A8 (pPred + iStride[i], kuiMean64);
502+ }
503+}
504+
505+void WelsI8x8LumaPredDcTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
506+ int32_t iStride[8];
507+ uint8_t uiPixelFilterT[8];
508+ uint16_t uiTotal = 0;
509+ int32_t i;
510+
511+ for (iStride[0] = 0, i = 1; i < 8; i++) {
512+ iStride[i] = iStride[i - 1] + kiStride;
513+ }
514+
515+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
516+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
517+ for (i = 1; i < 7; i++) {
518+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
519+ }
520+ uiPixelFilterT[7] = bTRAvail ? ((pPred[6 - kiStride] + (pPred[7 - kiStride] << 1) + pPred[8 - kiStride] + 2) >> 2) : ((
521+ pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
522+
523+ // 8-93
524+ for (i = 0; i < 8; i++) {
525+ uiTotal += uiPixelFilterT[i];
526+ }
527+
528+ const uint8_t kuiMean = ((uiTotal + 4) >> 3);
529+ const uint64_t kuiMean64 = 0x0101010101010101U * kuiMean;
530+
531+ for (i = 0; i < 8; i++) {
532+ ST64A8 (pPred + iStride[i], kuiMean64);
533+ }
534+}
535+
536+void WelsI8x8LumaPredDcNA_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
537+ // for normal 8 bit depth, 8-94
538+ const uint64_t kuiDC64 = 0x8080808080808080U;
539+
540+ int32_t iStride[8];
541+ int32_t i;
542+ ST64A8 (pPred, kuiDC64);
543+ for (iStride[0] = 0, i = 1; i < 8; i++) {
544+ iStride[i] = iStride[i - 1] + kiStride;
545+ ST64A8 (pPred + iStride[i], kuiDC64);
546+ }
547+}
548+
549+/*down pLeft*/
550+void WelsI8x8LumaPredDDL_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
551+ // Top and Top-right available
552+ int32_t iStride[8];
553+ uint8_t uiPixelFilterT[16];
554+ int32_t i, j;
555+
556+ for (iStride[0] = 0, i = 1; i < 8; i++) {
557+ iStride[i] = iStride[i - 1] + kiStride;
558+ }
559+
560+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
561+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
562+ for (i = 1; i < 15; i++) {
563+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
564+ }
565+ uiPixelFilterT[15] = ((pPred[14 - kiStride] + pPred[15 - kiStride] * 3 + 2) >> 2);
566+
567+ for (i = 0; i < 8; i++) { // y
568+ for (j = 0; j < 8; j++) { // x
569+ if (i == 7 && j == 7) { // 8-95
570+ pPred[j + iStride[i]] = (uiPixelFilterT[14] + 3 * uiPixelFilterT[15] + 2) >> 2;
571+ } else { // 8-96
572+ pPred[j + iStride[i]] = (uiPixelFilterT[i + j] + (uiPixelFilterT[i + j + 1] << 1) + uiPixelFilterT[i + j + 2] + 2) >> 2;
573+ }
574+ }
575+ }
576+}
577+
578+/*down pLeft*/
579+void WelsI8x8LumaPredDDLTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
580+ // Top available and Top-right unavailable
581+ int32_t iStride[8];
582+ uint8_t uiPixelFilterT[16];
583+ int32_t i, j;
584+
585+ for (iStride[0] = 0, i = 1; i < 8; i++) {
586+ iStride[i] = iStride[i - 1] + kiStride;
587+ }
588+
589+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
590+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
591+ for (i = 1; i < 7; i++) {
592+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
593+ }
594+ // p[x, -1] x=8...15 are replaced with p[7, -1]
595+ uiPixelFilterT[7] = ((pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
596+ for (i = 8; i < 16; i++) {
597+ uiPixelFilterT[i] = pPred[7 - kiStride];
598+ }
599+
600+ for (i = 0; i < 8; i++) { // y
601+ for (j = 0; j < 8; j++) { // x
602+ if (i == 7 && j == 7) { // 8-95
603+ pPred[j + iStride[i]] = (uiPixelFilterT[14] + 3 * uiPixelFilterT[15] + 2) >> 2;
604+ } else { // 8-96
605+ pPred[j + iStride[i]] = (uiPixelFilterT[i + j] + (uiPixelFilterT[i + j + 1] << 1) + uiPixelFilterT[i + j + 2] + 2) >> 2;
606+ }
607+ }
608+ }
609+}
610+
611+/*down right*/
612+void WelsI8x8LumaPredDDR_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
613+ // The TopLeft, Top, Left are all available under this mode
614+ int32_t iStride[8];
615+ uint8_t uiPixelFilterTL;
616+ uint8_t uiPixelFilterL[8];
617+ uint8_t uiPixelFilterT[8];
618+ int32_t i, j;
619+
620+ for (iStride[0] = 0, i = 1; i < 8; i++) {
621+ iStride[i] = iStride[i - 1] + kiStride;
622+ }
623+
624+ uiPixelFilterTL = (pPred[-1] + (pPred[-1 - kiStride] << 1) + pPred[-kiStride] + 2) >> 2;
625+
626+ uiPixelFilterL[0] = ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2);
627+ uiPixelFilterT[0] = ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2);
628+ for (i = 1; i < 7; i++) {
629+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
630+ 2);
631+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
632+ }
633+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
634+ uiPixelFilterT[7] = bTRAvail ? ((pPred[6 - kiStride] + (pPred[7 - kiStride] << 1) + pPred[8 - kiStride] + 2) >> 2) : ((
635+ pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
636+
637+ for (i = 0; i < 8; i++) { // y
638+ // 8-98, x < y-1
639+ for (j = 0; j < (i - 1); j++) {
640+ pPred[j + iStride[i]] = (uiPixelFilterL[i - j - 2] + (uiPixelFilterL[i - j - 1] << 1) + uiPixelFilterL[i - j] + 2) >> 2;
641+ }
642+ // 8-98, special case, x == y-1
643+ if (i >= 1) {
644+ j = i - 1;
645+ pPred[j + iStride[i]] = (uiPixelFilterTL + (uiPixelFilterL[0] << 1) + uiPixelFilterL[1] + 2) >> 2;
646+ }
647+ // 8-99, x==y
648+ j = i;
649+ pPred[j + iStride[i]] = (uiPixelFilterT[0] + (uiPixelFilterTL << 1) + uiPixelFilterL[0] + 2) >> 2;
650+ // 8-97, special case, x == y+1
651+ if (i < 7) {
652+ j = i + 1;
653+ pPred[j + iStride[i]] = (uiPixelFilterTL + (uiPixelFilterT[0] << 1) + uiPixelFilterT[1] + 2) >> 2;
654+ }
655+ for (j = i + 2; j < 8; j++) { // 8-97, x > y+1
656+ pPred[j + iStride[i]] = (uiPixelFilterT[j - i - 2] + (uiPixelFilterT[j - i - 1] << 1) + uiPixelFilterT[j - i] + 2) >> 2;
657+ }
658+ }
659+}
660+
661+/*vertical pLeft*/
662+void WelsI8x8LumaPredVL_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
663+ // Top and Top-right available
664+ int32_t iStride[8];
665+ uint8_t uiPixelFilterT[16];
666+ int32_t i, j;
667+
668+ for (iStride[0] = 0, i = 1; i < 8; i++) {
669+ iStride[i] = iStride[i - 1] + kiStride;
670+ }
671+
672+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
673+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
674+ for (i = 1; i < 15; i++) {
675+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
676+ }
677+ uiPixelFilterT[15] = ((pPred[14 - kiStride] + pPred[15 - kiStride] * 3 + 2) >> 2);
678+
679+ for (i = 0; i < 8; i++) { // y
680+ if ((i & 0x01) == 0) { // 8-108
681+ for (j = 0; j < 8; j++) { // x
682+ pPred[j + iStride[i]] = (uiPixelFilterT[j + (i >> 1)] + uiPixelFilterT[j + (i >> 1) + 1] + 1) >> 1;
683+ }
684+ } else { // 8-109
685+ for (j = 0; j < 8; j++) { // x
686+ pPred[j + iStride[i]] = (uiPixelFilterT[j + (i >> 1)] + (uiPixelFilterT[j + (i >> 1) + 1] << 1) + uiPixelFilterT[j +
687+ (i >> 1) + 2] + 2) >> 2;
688+ }
689+ }
690+ }
691+}
692+
693+/*vertical pLeft*/
694+void WelsI8x8LumaPredVLTop_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
695+ // Top available and Top-right unavailable
696+ int32_t iStride[8];
697+ uint8_t uiPixelFilterT[16];
698+ int32_t i, j;
699+
700+ for (iStride[0] = 0, i = 1; i < 8; i++) {
701+ iStride[i] = iStride[i - 1] + kiStride;
702+ }
703+
704+ uiPixelFilterT[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2) : ((
705+ pPred[-kiStride] * 3 + pPred[1 - kiStride] + 2) >> 2);
706+ for (i = 1; i < 7; i++) {
707+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
708+ }
709+ // p[x, -1] x=8...15 are replaced with p[7, -1]
710+ uiPixelFilterT[7] = ((pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
711+ for (i = 8; i < 16; i++) {
712+ uiPixelFilterT[i] = pPred[7 - kiStride];
713+ }
714+
715+ for (i = 0; i < 8; i++) { // y
716+ if ((i & 0x01) == 0) { // 8-108
717+ for (j = 0; j < 8; j++) { // x
718+ pPred[j + iStride[i]] = (uiPixelFilterT[j + (i >> 1)] + uiPixelFilterT[j + (i >> 1) + 1] + 1) >> 1;
719+ }
720+ } else { // 8-109
721+ for (j = 0; j < 8; j++) { // x
722+ pPred[j + iStride[i]] = (uiPixelFilterT[j + (i >> 1)] + (uiPixelFilterT[j + (i >> 1) + 1] << 1) + uiPixelFilterT[j +
723+ (i >> 1) + 2] + 2) >> 2;
724+ }
725+ }
726+ }
727+}
728+
729+/*vertical right*/
730+void WelsI8x8LumaPredVR_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
731+ // The TopLeft, Top, Left are always available under this mode
732+ int32_t iStride[8];
733+ uint8_t uiPixelFilterTL;
734+ uint8_t uiPixelFilterL[8];
735+ uint8_t uiPixelFilterT[8];
736+ int32_t i, j;
737+ int32_t izVR, izVRDiv;
738+
739+ for (iStride[0] = 0, i = 1; i < 8; i++) {
740+ iStride[i] = iStride[i - 1] + kiStride;
741+ }
742+
743+ uiPixelFilterTL = (pPred[-1] + (pPred[-1 - kiStride] << 1) + pPred[-kiStride] + 2) >> 2;
744+
745+ uiPixelFilterL[0] = ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2);
746+ uiPixelFilterT[0] = ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2);
747+ for (i = 1; i < 7; i++) {
748+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
749+ 2);
750+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
751+ }
752+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
753+ uiPixelFilterT[7] = bTRAvail ? ((pPred[6 - kiStride] + (pPred[7 - kiStride] << 1) + pPred[8 - kiStride] + 2) >> 2) : ((
754+ pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
755+
756+ for (i = 0; i < 8; i++) { // y
757+ for (j = 0; j < 8; j++) { // x
758+ izVR = (j << 1) - i; // 2 * x - y
759+ izVRDiv = j - (i >> 1);
760+ if (izVR >= 0) {
761+ if ((izVR & 0x01) == 0) { // 8-100
762+ if (izVRDiv > 0) {
763+ pPred[j + iStride[i]] = (uiPixelFilterT[izVRDiv - 1] + uiPixelFilterT[izVRDiv] + 1) >> 1;
764+ } else {
765+ pPred[j + iStride[i]] = (uiPixelFilterTL + uiPixelFilterT[0] + 1) >> 1;
766+ }
767+ } else { // 8-101
768+ if (izVRDiv > 1) {
769+ pPred[j + iStride[i]] = (uiPixelFilterT[izVRDiv - 2] + (uiPixelFilterT[izVRDiv - 1] << 1) + uiPixelFilterT[izVRDiv] + 2)
770+ >> 2;
771+ } else {
772+ pPred[j + iStride[i]] = (uiPixelFilterTL + (uiPixelFilterT[0] << 1) + uiPixelFilterT[1] + 2) >> 2;
773+ }
774+ }
775+ } else if (izVR == -1) { // 8-102
776+ pPred[j + iStride[i]] = (uiPixelFilterL[0] + (uiPixelFilterTL << 1) + uiPixelFilterT[0] + 2) >> 2;
777+ } else if (izVR < -2) { // 8-103
778+ pPred[j + iStride[i]] = (uiPixelFilterL[-izVR - 1] + (uiPixelFilterL[-izVR - 2] << 1) + uiPixelFilterL[-izVR - 3] + 2)
779+ >> 2;
780+ } else { // izVR==-2, 8-103, special case
781+ pPred[j + iStride[i]] = (uiPixelFilterL[1] + (uiPixelFilterL[0] << 1) + uiPixelFilterTL + 2) >> 2;
782+ }
783+ }
784+ }
785+}
786+
787+/*horizontal up*/
788+void WelsI8x8LumaPredHU_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
789+ int32_t iStride[8];
790+ uint8_t uiPixelFilterL[8];
791+ int32_t i, j;
792+ int32_t izHU;
793+
794+ for (iStride[0] = 0, i = 1; i < 8; i++) {
795+ iStride[i] = iStride[i - 1] + kiStride;
796+ }
797+
798+ uiPixelFilterL[0] = bTLAvail ? ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2) : ((
799+ pPred[-1] * 3 + pPred[-1 + iStride[1]] + 2) >> 2);
800+ for (i = 1; i < 7; i++) {
801+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
802+ 2);
803+ }
804+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
805+
806+ for (i = 0; i < 8; i++) { // y
807+ for (j = 0; j < 8; j++) { // x
808+ izHU = j + (i << 1); // x + 2 * y
809+ if (izHU < 13) {
810+ if ((izHU & 0x01) == 0) { // 8-110
811+ pPred[j + iStride[i]] = (uiPixelFilterL[izHU >> 1] + uiPixelFilterL[1 + (izHU >> 1)] + 1) >> 1;
812+ } else { // 8-111
813+ pPred[j + iStride[i]] = (uiPixelFilterL[izHU >> 1] + (uiPixelFilterL[1 + (izHU >> 1)] << 1) + uiPixelFilterL[2 +
814+ (izHU >> 1)] + 2) >> 2;
815+ }
816+ } else if (izHU == 13) { // 8-112
817+ pPred[j + iStride[i]] = (uiPixelFilterL[6] + 3 * uiPixelFilterL[7] + 2) >> 2;
818+ } else { // 8-113
819+ pPred[j + iStride[i]] = uiPixelFilterL[7];
820+ }
821+ }
822+ }
823+}
824+
825+/*horizontal down*/
826+void WelsI8x8LumaPredHD_c (uint8_t* pPred, const int32_t kiStride, bool bTLAvail, bool bTRAvail) {
827+ // The TopLeft, Top, Left are all available under this mode
828+ int32_t iStride[8];
829+ uint8_t uiPixelFilterTL;
830+ uint8_t uiPixelFilterL[8];
831+ uint8_t uiPixelFilterT[8];
832+ int32_t i, j;
833+ int32_t izHD, izHDDiv;
834+
835+ for (iStride[0] = 0, i = 1; i < 8; i++) {
836+ iStride[i] = iStride[i - 1] + kiStride;
837+ }
838+
839+ uiPixelFilterTL = (pPred[-1] + (pPred[-1 - kiStride] << 1) + pPred[-kiStride] + 2) >> 2;
840+
841+ uiPixelFilterL[0] = ((pPred[-1 - kiStride] + (pPred[-1] << 1) + pPred[-1 + iStride[1]] + 2) >> 2);
842+ uiPixelFilterT[0] = ((pPred[-1 - kiStride] + (pPred[-kiStride] << 1) + pPred[1 - kiStride] + 2) >> 2);
843+ for (i = 1; i < 7; i++) {
844+ uiPixelFilterL[i] = ((pPred[-1 + iStride[i - 1]] + (pPred[-1 + iStride[i]] << 1) + pPred[-1 + iStride[i + 1]] + 2) >>
845+ 2);
846+ uiPixelFilterT[i] = ((pPred[i - 1 - kiStride] + (pPred[i - kiStride] << 1) + pPred[i + 1 - kiStride] + 2) >> 2);
847+ }
848+ uiPixelFilterL[7] = ((pPred[-1 + iStride[6]] + pPred[-1 + iStride[7]] * 3 + 2) >> 2);
849+ uiPixelFilterT[7] = bTRAvail ? ((pPred[6 - kiStride] + (pPred[7 - kiStride] << 1) + pPred[8 - kiStride] + 2) >> 2) : ((
850+ pPred[6 - kiStride] + pPred[7 - kiStride] * 3 + 2) >> 2);
851+
852+ for (i = 0; i < 8; i++) { // y
853+ for (j = 0; j < 8; j++) { // x
854+ izHD = (i << 1) - j; // 2*y - x
855+ izHDDiv = i - (j >> 1);
856+ if (izHD >= 0) {
857+ if ((izHD & 0x01) == 0) { // 8-104
858+ if (izHDDiv == 0) {
859+ pPred[j + iStride[i]] = (uiPixelFilterTL + uiPixelFilterL[0] + 1) >> 1;
860+ } else {
861+ pPred[j + iStride[i]] = (uiPixelFilterL[izHDDiv - 1] + uiPixelFilterL[izHDDiv] + 1) >> 1;
862+ }
863+ } else { // 8-105
864+ if (izHDDiv == 1) {
865+ pPred[j + iStride[i]] = (uiPixelFilterTL + (uiPixelFilterL[0] << 1) + uiPixelFilterL[1] + 2) >> 2;
866+ } else {
867+ pPred[j + iStride[i]] = (uiPixelFilterL[izHDDiv - 2] + (uiPixelFilterL[izHDDiv - 1] << 1) + uiPixelFilterL[izHDDiv] + 2)
868+ >> 2;
869+ }
870+ }
871+ } else if (izHD == -1) { // 8-106
872+ pPred[j + iStride[i]] = (uiPixelFilterL[0] + (uiPixelFilterTL << 1) + uiPixelFilterT[0] + 2) >> 2;
873+ } else if (izHD < -2) { // 8-107
874+ pPred[j + iStride[i]] = (uiPixelFilterT[-izHD - 1] + (uiPixelFilterT[-izHD - 2] << 1) + uiPixelFilterT[-izHD - 3] + 2)
875+ >> 2;
876+ } else { // 8-107 special case, izHD==-2
877+ pPred[j + iStride[i]] = (uiPixelFilterT[1] + (uiPixelFilterT[0] << 1) + uiPixelFilterTL + 2) >> 2;
878+ }
879+ }
880+ }
881+}
882+
883+
383884 void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) {
384885 const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]);
385886 const int32_t kiStride2 = kiStride << 1;
codec/decoder/core/src/manage_dec_ref.cpp+1−1
@@ -127,7 +127,7 @@ int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) { · 126 unmodified lines
127127 || (ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->eErrorConMethod)
128128 || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR == pCtx->eErrorConMethod)
129129 || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->eErrorConMethod))
130− && (NULL != pCtx->pPreviousDecodedPictureInDpb);
130+ && (NULL != pCtx->pPreviousDecodedPictureInDpb);
131131 bCopyPrevious = bCopyPrevious && (pRef->iWidthInPixel == pCtx->pPreviousDecodedPictureInDpb->iWidthInPixel)
132132 && (pRef->iHeightInPixel == pCtx->pPreviousDecodedPictureInDpb->iHeightInPixel);
133133
codec/decoder/core/src/parse_mb_syn_cabac.cpp+87−14
@@ -35,13 +35,14 @@ · 34 unmodified lines
3535 #include "error_code.h"
3636 namespace WelsDec {
3737 #define IDX_UNUSED -1
38−static const int16_t g_kMaxPos [] = {IDX_UNUSED, 15, 14, 15, 3, 14, 3, 3, 14, 14};
39−static const int16_t g_kMaxC2 [] = {IDX_UNUSED, 4, 4, 4, 3, 4, 3, 3, 4, 4};
40−static const int16_t g_kBlockCat2CtxOffsetCBF[] = {IDX_UNUSED, 0, 4, 8, 12, 16, 12, 12, 16, 16};
41−static const int16_t g_kBlockCat2CtxOffsetMap [] = {IDX_UNUSED, 0, 15, 29, 44, 47, 44, 44, 47, 47};
42−static const int16_t g_kBlockCat2CtxOffsetLast[] = {IDX_UNUSED, 0, 15, 29, 44, 47, 44, 44, 47, 47};
43−static const int16_t g_kBlockCat2CtxOffsetOne [] = {IDX_UNUSED, 0 , 10, 20, 30, 39, 30, 30, 39, 39};
44−static const int16_t g_kBlockCat2CtxOffsetAbs [] = {IDX_UNUSED, 0 , 10, 20, 30, 39, 30, 30, 39, 39};
38+
39+static const int16_t g_kMaxPos [] = {IDX_UNUSED, 15, 14, 15, 3, 14, 63, 3, 3, 14, 14};
40+static const int16_t g_kMaxC2 [] = {IDX_UNUSED, 4, 4, 4, 3, 4, 4, 3, 3, 4, 4};
41+static const int16_t g_kBlockCat2CtxOffsetCBF[] = {IDX_UNUSED, 0, 4, 8, 12, 16, 0, 12, 12, 16, 16};
42+static const int16_t g_kBlockCat2CtxOffsetMap [] = {IDX_UNUSED, 0, 15, 29, 44, 47, 0, 44, 44, 47, 47};
43+static const int16_t g_kBlockCat2CtxOffsetLast[] = {IDX_UNUSED, 0, 15, 29, 44, 47, 0, 44, 44, 47, 47};
44+static const int16_t g_kBlockCat2CtxOffsetOne [] = {IDX_UNUSED, 0 , 10, 20, 30, 39, 0, 30, 30, 39, 39};
45+static const int16_t g_kBlockCat2CtxOffsetAbs [] = {IDX_UNUSED, 0 , 10, 20, 30, 39, 0, 30, 30, 39, 39};
4546
4647 const uint8_t g_kTopBlkInsideMb[24] = { //for index with z-order 0~23
4748 // 0 1 | 4 5 luma 8*8 block pNonZeroCount[16+8]
@@ -275,6 +276,24 @@ int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeigh · 227 unmodified lines
275276 }
276277 return ERR_NONE;
277278 }
279+
280+int32_t ParseTransformSize8x8FlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail,
281+ bool& bTransformSize8x8Flag) {
282+ uint32_t uiCode;
283+ int32_t iIdxA, iIdxB;
284+ int32_t iCtxInc;
285+ PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
286+ PWelsCabacCtx pBinCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_TS_8x8_FLAG;
287+ iIdxA = (pNeighAvail->iLeftAvail) && (pCtx->pCurDqLayer->pTransformSize8x8Flag[pCtx->pCurDqLayer->iMbXyIndex - 1]);
288+ iIdxB = (pNeighAvail->iTopAvail)
289+ && (pCtx->pCurDqLayer->pTransformSize8x8Flag[pCtx->pCurDqLayer->iMbXyIndex - pCtx->pCurDqLayer->iMbWidth]);
290+ iCtxInc = iIdxA + iIdxB;
291+ WELS_READ_VERIFY (DecodeBinCabac (pCabacDecEngine, pBinCtx + iCtxInc, uiCode));
292+ bTransformSize8x8Flag = !!uiCode;
293+
294+ return ERR_NONE;
295+}
296+
278297 int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType) {
279298 uint32_t uiCode;
280299 PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine;
@@ -471,6 +490,9 @@ int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNe · 190 unmodified lines
471490 pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType;
472491 pSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount;
473492 pPartW[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartWidth;
493+
494+ // Need modification when B picture add in, reference to 7.3.5
495+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] &= (uiSubMbType == 0);
474496 }
475497
476498 for (i = 0; i < 4; i++) {
@@ -721,7 +743,7 @@ int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int3 · 244 unmodified lines
721743 int32_t iCurrBlkXy = pCtx->pCurDqLayer->iMbXyIndex;
722744 int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring
723745 int32_t iLeftBlkXy = iCurrBlkXy - 1; //default value: MB neighboring
724− uint8_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc;
746+ uint16_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc;
725747 int16_t* pMbType = pCtx->pCurDqLayer->pMbType;
726748 int32_t iCtxInc;
727749 uiCbfBit = 0;
@@ -760,22 +782,30 @@ int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int3 · 32 unmodified lines
760782 int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty, PWelsDecoderContext pCtx,
761783 uint32_t& uiCoeffNum) {
762784 uint32_t uiCode;
763− PWelsCabacCtx pMapCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_MAP + g_kBlockCat2CtxOffsetMap [iResProperty];
764− PWelsCabacCtx pLastCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_LAST + g_kBlockCat2CtxOffsetLast[iResProperty];
785+
786+ PWelsCabacCtx pMapCtx = pCtx->pCabacCtx + (iResProperty == LUMA_DC_AC_8 ? NEW_CTX_OFFSET_MAP_8x8 : NEW_CTX_OFFSET_MAP)
787+ + g_kBlockCat2CtxOffsetMap [iResProperty];
788+ PWelsCabacCtx pLastCtx = pCtx->pCabacCtx + (iResProperty == LUMA_DC_AC_8 ? NEW_CTX_OFFSET_LAST_8x8 :
789+ NEW_CTX_OFFSET_LAST) + g_kBlockCat2CtxOffsetLast[iResProperty];
790+
765791
766792 int32_t i;
767793 uiCoeffNum = 0;
768794 int32_t i0 = 0;
769795 int32_t i1 = g_kMaxPos[iResProperty];
770796
797+ int32_t iCtx;
798+
771799 for (i = i0; i < i1; ++i) {
800+ iCtx = (iResProperty == LUMA_DC_AC_8 ? g_kuiIdx2CtxSignificantCoeffFlag8x8[i] : i);
772801 //read significant
773− WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pMapCtx + i, uiCode));
802+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pMapCtx + iCtx, uiCode));
774803 if (uiCode) {
775804 * (pSignificantMap++) = 1;
776805 ++ uiCoeffNum;
777806 //read last significant
778− WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pLastCtx + i, uiCode));
807+ iCtx = (iResProperty == LUMA_DC_AC_8 ? g_kuiIdx2CtxLastSignificantCoeffFlag8x8[i] : i);
808+ WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pLastCtx + iCtx, uiCode));
779809 if (uiCode) {
780810 memset (pSignificantMap, 0, (i1 - i) * sizeof (int32_t));
781811 return ERR_NONE;
@@ -796,8 +826,11 @@ int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty · 14 unmodified lines
796826
797827 int32_t ParseSignificantCoeffCabac (int32_t* pSignificant, int32_t iResProperty, PWelsDecoderContext pCtx) {
798828 uint32_t uiCode;
799− PWelsCabacCtx pOneCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_ONE + g_kBlockCat2CtxOffsetOne[iResProperty];
800− PWelsCabacCtx pAbsCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_ABS + g_kBlockCat2CtxOffsetAbs[iResProperty];
829+ PWelsCabacCtx pOneCtx = pCtx->pCabacCtx + (iResProperty == LUMA_DC_AC_8 ? NEW_CTX_OFFSET_ONE_8x8 : NEW_CTX_OFFSET_ONE) +
830+ g_kBlockCat2CtxOffsetOne[iResProperty];
831+ PWelsCabacCtx pAbsCtx = pCtx->pCabacCtx + (iResProperty == LUMA_DC_AC_8 ? NEW_CTX_OFFSET_ABS_8x8 : NEW_CTX_OFFSET_ABS) +
832+ g_kBlockCat2CtxOffsetAbs[iResProperty];
833+
801834 const int16_t iMaxType = g_kMaxC2[iResProperty];
802835 int32_t i = g_kMaxPos[iResProperty];
803836 int32_t* pCoff = pSignificant + i;
@@ -826,6 +859,46 @@ int32_t ParseSignificantCoeffCabac (int32_t* pSignificant, int32_t iResProperty, · 22 unmodified lines
826859 return ERR_NONE;
827860 }
828861
862+int32_t ParseResidualBlockCabac8x8 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux,
863+ int32_t iIndex, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty,
864+ short* sTCoeff, /*int mb_mode*/ uint8_t uiQp, PWelsDecoderContext pCtx) {
865+ uint32_t uiTotalCoeffNum = 0;
866+ uint32_t uiCbpBit;
867+ int32_t pSignificantMap[64] = {0};
868+
869+ int32_t iMbResProperty = 0;
870+ GetMbResProperty (&iMbResProperty, &iResProperty, false);
871+ const uint16_t* pDeQuantMul = (pCtx->bUseScalingList) ? pCtx->pDequant_coeff8x8[iMbResProperty - 6][uiQp] :
872+ g_kuiDequantCoeff8x8[uiQp];
873+
874+ uiCbpBit = 1; // for 8x8, MaxNumCoeff == 64 && uiCbpBit == 1
875+ if (uiCbpBit) { //has coeff
876+ WELS_READ_VERIFY (ParseSignificantMapCabac (pSignificantMap, iResProperty, pCtx, uiTotalCoeffNum));
877+ WELS_READ_VERIFY (ParseSignificantCoeffCabac (pSignificantMap, iResProperty, pCtx));
878+ }
879+
880+ pNonZeroCountCache[g_kCacheNzcScanIdx[iIndex]] =
881+ pNonZeroCountCache[g_kCacheNzcScanIdx[iIndex + 1]] =
882+ pNonZeroCountCache[g_kCacheNzcScanIdx[iIndex + 2]] =
883+ pNonZeroCountCache[g_kCacheNzcScanIdx[iIndex + 3]] = (uint8_t)uiTotalCoeffNum;
884+ if (uiTotalCoeffNum == 0) {
885+ return ERR_NONE;
886+ }
887+ int32_t j = 0, i;
888+ if (iResProperty == LUMA_DC_AC_8) {
889+ do {
890+ if (pSignificantMap[j] != 0) {
891+ i = pScanTable[ j ];
892+ sTCoeff[i] = uiQp >= 36 ? ((pSignificantMap[j] * pDeQuantMul[i]) << (uiQp / 6 - 6)) : ((
893+ pSignificantMap[j] * pDeQuantMul[i] + (1 << (5 - uiQp / 6))) >> (6 - uiQp / 6));
894+ }
895+ ++j;
896+ } while (j < 64);
897+ }
898+
899+ return ERR_NONE;
900+}
901+
829902 int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux,
830903 int32_t iIndex, int32_t iMaxNumCoeff,
831904 const uint8_t* pScanTable, int32_t iResProperty, short* sTCoeff, /*int mb_mode*/ uint8_t uiQp,
codec/decoder/core/src/parse_mb_syn_cavlc.cpp+105−10
@@ -151,7 +151,7 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo · 150 unmodified lines
151151 pNonZeroCount[5 + 8 * 5] = -1;//unavailable
152152 }
153153 }
154−void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
154+void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
155155 PDqLayer pCurLayer) { //no matter slice type
156156 int32_t iCurXy = pCurLayer->iMbXyIndex;
157157 int32_t iTopXy = 0;
@@ -197,7 +197,7 @@ void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 39 unmodified lines
197197 }
198198 }
199199
200−void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
200+void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode,
201201 PDqLayer pCurLayer) { //no matter slice type
202202 int32_t iCurXy = pCurLayer->iMbXyIndex;
203203 int32_t iTopXy = 0;
@@ -214,7 +214,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 10 unmodified lines
214214 }
215215
216216 //intra4x4_pred_mode
217− if (pNeighAvail->iTopAvail && IS_INTRA4x4 (pNeighAvail->iTopType)) { //top
217+ if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top
218218 ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0]));
219219 } else {
220220 int32_t iPred;
@@ -225,7 +225,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 4 unmodified lines
225225 ST32 (pIntraPredMode + 1, iPred);
226226 }
227227
228− if (pNeighAvail->iLeftAvail && IS_INTRA4x4 (pNeighAvail->iLeftType)) { //left
228+ if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left
229229 pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4];
230230 pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5];
231231 pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6];
@@ -565,12 +565,13 @@ int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode) { · 333 unmodified lines
565565 return 0;
566566 }
567567
568−int32_t CheckIntra4x4PredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex) {
568+int32_t CheckIntraNxNPredMode (int32_t* pSampleAvail, int8_t* pMode, int32_t iIndex, bool b8x8) {
569569 int8_t iIdx = g_kuiCache30ScanIdx[iIndex];
570+
570571 int32_t iLeftAvail = pSampleAvail[iIdx - 1];
571572 int32_t iTopAvail = pSampleAvail[iIdx - 6];
572573 int32_t bLeftTopAvail = pSampleAvail[iIdx - 7];
573− int32_t bRightTopAvail = pSampleAvail[iIdx - 5];
574+ int32_t bRightTopAvail = pSampleAvail[iIdx - (b8x8 ? 4 : 5)]; // Diff with 4x4 Pred
574575
575576 int8_t iFinalMode;
576577
@@ -900,6 +901,93 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 323 unmodified lines
900901 return 0;
901902 }
902903
904+int32_t WelsResidualBlockCavlc8x8 (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCache, PBitStringAux pBs, int32_t iIndex,
905+ int32_t iMaxNumCoeff, const uint8_t* kpZigzagTable, int32_t iResidualProperty,
906+ int16_t* pTCoeff, int32_t iIdx4x4, uint8_t uiQp,
907+ PWelsDecoderContext pCtx) {
908+ int32_t iLevel[16], iZerosLeft, iCoeffNum;
909+ int32_t iRun[16];
910+ int32_t iCurNonZeroCacheIdx, i;
911+
912+ int32_t iMbResProperty = 0;
913+ GetMbResProperty (&iMbResProperty, &iResidualProperty, 1);
914+
915+ const uint16_t* kpDequantCoeff = pCtx->bUseScalingList ? pCtx->pDequant_coeff8x8[iMbResProperty - 6][uiQp] :
916+ g_kuiDequantCoeff8x8[uiQp];
917+
918+ int8_t nA, nB, nC;
919+ uint8_t uiTotalCoeff, uiTrailingOnes;
920+ int32_t iUsedBits = 0;
921+ intX_t iCurIdx = pBs->iIndex;
922+ uint8_t* pBuf = ((uint8_t*)pBs->pStartBuf) + (iCurIdx >> 3);
923+ bool bChromaDc = (CHROMA_DC == iResidualProperty);
924+ uint8_t bChroma = (bChromaDc || CHROMA_AC == iResidualProperty);
925+ SReadBitsCache sReadBitsCache;
926+
927+ uint32_t uiCache32Bit = (uint32_t) ((((pBuf[0] << 8) | pBuf[1]) << 16) | (pBuf[2] << 8) | pBuf[3]);
928+ sReadBitsCache.uiCache32Bit = uiCache32Bit << (iCurIdx & 0x07);
929+ sReadBitsCache.uiRemainBits = 32 - (iCurIdx & 0x07);
930+ sReadBitsCache.pBuf = pBuf;
931+ //////////////////////////////////////////////////////////////////////////
932+
933+ if (bChroma) {
934+ iCurNonZeroCacheIdx = g_kuiCache48CountScan4Idx[iIndex];
935+ nA = pNonZeroCountCache[iCurNonZeroCacheIdx - 1];
936+ nB = pNonZeroCountCache[iCurNonZeroCacheIdx - 8];
937+ } else { //luma
938+ iCurNonZeroCacheIdx = g_kuiCache48CountScan4Idx[iIndex];
939+ nA = pNonZeroCountCache[iCurNonZeroCacheIdx - 1];
940+ nB = pNonZeroCountCache[iCurNonZeroCacheIdx - 8];
941+ }
942+
943+ WELS_NON_ZERO_COUNT_AVERAGE (nC, nA, nB);
944+
945+ iUsedBits += CavlcGetTrailingOnesAndTotalCoeff (uiTotalCoeff, uiTrailingOnes, &sReadBitsCache, pVlcTable, bChromaDc,
946+ nC);
947+
948+ if (iResidualProperty != CHROMA_DC && iResidualProperty != I16_LUMA_DC) {
949+ pNonZeroCountCache[iCurNonZeroCacheIdx] = uiTotalCoeff;
950+ //////////////////////////////////////////////////////////////////////////
951+ }
952+ if (0 == uiTotalCoeff) {
953+ pBs->iIndex += iUsedBits;
954+ return 0;
955+ }
956+ if ((uiTrailingOnes > 3) || (uiTotalCoeff > 16)) { /////////////////check uiTrailingOnes and uiTotalCoeff
957+ return ERR_INFO_CAVLC_INVALID_TOTAL_COEFF_OR_TRAILING_ONES;
958+ }
959+ if ((i = CavlcGetLevelVal (iLevel, &sReadBitsCache, uiTotalCoeff, uiTrailingOnes)) == -1) {
960+ return ERR_INFO_CAVLC_INVALID_LEVEL;
961+ }
962+ iUsedBits += i;
963+ if (uiTotalCoeff < iMaxNumCoeff) {
964+ iUsedBits += CavlcGetTotalZeros (iZerosLeft, &sReadBitsCache, uiTotalCoeff, pVlcTable, bChromaDc);
965+ } else {
966+ iZerosLeft = 0;
967+ }
968+
969+ if ((iZerosLeft < 0) || ((iZerosLeft + uiTotalCoeff) > iMaxNumCoeff)) {
970+ return ERR_INFO_CAVLC_INVALID_ZERO_LEFT;
971+ }
972+ if ((i = CavlcGetRunBefore (iRun, &sReadBitsCache, uiTotalCoeff, pVlcTable, iZerosLeft)) == -1) {
973+ return ERR_INFO_CAVLC_INVALID_RUN_BEFORE;
974+ }
975+ iUsedBits += i;
976+ pBs->iIndex += iUsedBits;
977+ iCoeffNum = -1;
978+
979+ for (i = uiTotalCoeff - 1; i >= 0; --i) { //FIXME merge into rundecode?
980+ int32_t j;
981+ iCoeffNum += iRun[i] + 1; //FIXME add 1 earlier ?
982+ j = (iCoeffNum << 2) + iIdx4x4;
983+ j = kpZigzagTable[ j ];
984+ pTCoeff[j] = uiQp >= 36 ? ((iLevel[i] * kpDequantCoeff[j]) << (uiQp / 6 - 6))
985+ : ((iLevel[i] * kpDequantCoeff[j] + (1 << (5 - uiQp / 6))) >> (6 - uiQp / 6));
986+ }
987+
988+ return 0;
989+}
990+
903991 int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30],
904992 PBitStringAux pBs) {
905993 PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer;
@@ -941,7 +1029,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 35 unmodified lines
9411029 return ERR_INFO_INVALID_REF_INDEX;
9421030 }
9431031 }
944− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx]&&ppRefPic[iRefIdx]->bIsComplete);
1032+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx]
1033+ && ppRefPic[iRefIdx]->bIsComplete);
9451034 } else {
9461035 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. ");
9471036 return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -981,7 +1070,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 33 unmodified lines
9811070 return ERR_INFO_INVALID_REF_INDEX;
9821071 }
9831072 }
984− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx[i]]&&ppRefPic[iRefIdx[i]]->bIsComplete);
1073+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
1074+ && ppRefPic[iRefIdx[i]]->bIsComplete);
9851075 }
9861076 for (i = 0; i < 2; i++) {
9871077 PredInter16x8Mv (iMvArray, iRefIdxArray, i << 3, iRefIdx[i], iMv);
@@ -1017,7 +1107,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 29 unmodified lines
10171107 return ERR_INFO_INVALID_REF_INDEX;
10181108 }
10191109 }
1020− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx[i]]&&ppRefPic[iRefIdx[i]]->bIsComplete);
1110+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
1111+ && ppRefPic[iRefIdx[i]]->bIsComplete);
10211112 } else {
10221113 WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. ");
10231114 return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP);
@@ -1056,6 +1147,9 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 32 unmodified lines
10561147 pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType;
10571148 iSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount;
10581149 iPartWidth[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartWidth;
1150+
1151+ // Need modification when B picture add in, reference to 7.3.5
1152+ pCurDqLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] &= (uiSubMbType == 0);
10591153 }
10601154
10611155 if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) {
@@ -1085,7 +1179,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 23 unmodified lines
10851179 return ERR_INFO_INVALID_REF_INDEX;
10861180 }
10871181 }
1088− pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || !(ppRefPic[iRefIdx[i]]&&ppRefPic[iRefIdx[i]]->bIsComplete);
1182+ pCtx->bMbRefConcealed = pCtx->bRPLRError || pCtx->bMbRefConcealed || ! (ppRefPic[iRefIdx[i]]
1183+ && ppRefPic[iRefIdx[i]]->bIsComplete);
10891184
10901185 pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] =
10911186 pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i];
codec/decoder/core/src/rec_mb.cpp+54−0
@@ -61,12 +61,66 @@ void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer p · 60 unmodified lines
6161 }
6262 }
6363
64+int32_t RecI8x8Mb (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
65+ RecI8x8Luma (iMbXy, pCtx, pScoeffLevel, pDqLayer);
66+ RecI4x4Chroma (iMbXy, pCtx, pScoeffLevel, pDqLayer);
67+ return ERR_NONE;
68+}
69+
70+int32_t RecI8x8Luma (int32_t iMbXy, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
71+ /*****get local variable from outer variable********/
72+ /*prediction info*/
73+ uint8_t* pPred = pDqLayer->pPred[0];
74+
75+ int32_t iLumaStride = pDqLayer->iLumaStride;
76+ int32_t* pBlockOffset = pCtx->iDecBlockOffsetArray;
77+ PGetIntraPred8x8Func* pGetI8x8LumaPredFunc = pCtx->pGetI8x8LumaPredFunc;
78+
79+ int8_t* pIntra8x8PredMode = pDqLayer->pIntra4x4FinalMode[iMbXy]; // I_NxN
80+ int16_t* pRS = pScoeffLevel;
81+ /*itransform info*/
82+ PIdctResAddPredFunc pIdctResAddPredFunc = pCtx->pIdctResAddPredFunc8x8;
83+
84+ /*************local variable********************/
85+ uint8_t i = 0;
86+ bool bTLAvail[4], bTRAvail[4];
87+ // Top-Right : Left : Top-Left : Top
88+ bTLAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x02);
89+ bTLAvail[1] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x01);
90+ bTLAvail[2] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x04);
91+ bTLAvail[3] = true;
92+
93+ bTRAvail[0] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x01);
94+ bTRAvail[1] = !! (pDqLayer->pIntraNxNAvailFlag[iMbXy] & 0x08);
95+ bTRAvail[2] = true;
96+ bTRAvail[3] = false;
97+
98+ /*************real process*********************/
99+ for (i = 0; i < 4; i++) {
100+
101+ uint8_t* pPredI8x8 = pPred + pBlockOffset[i << 2];
102+ uint8_t uiMode = pIntra8x8PredMode[g_kuiScan4[i << 2]];
103+
104+ pGetI8x8LumaPredFunc[uiMode] (pPredI8x8, iLumaStride, bTLAvail[i], bTRAvail[i]);
105+
106+ int32_t iIndex = g_kuiMbCountScan4Idx[i << 2];
107+ if (pDqLayer->pNzc[iMbXy][iIndex] || pDqLayer->pNzc[iMbXy][iIndex + 1] || pDqLayer->pNzc[iMbXy][iIndex + 4]
108+ || pDqLayer->pNzc[iMbXy][iIndex + 5]) {
109+ int16_t* pRSI8x8 = &pRS[i << 6];
110+ pIdctResAddPredFunc (pPredI8x8, iLumaStride, pRSI8x8);
111+ }
112+ }
113+
114+ return ERR_NONE;
115+}
116+
64117 int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
65118 RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
66119 RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer);
67120 return ERR_NONE;
68121 }
69122
123+
70124 int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) {
71125 /*****get local variable from outer variable********/
72126 /*prediction info*/

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