Showing the changes to codec/decoder (22 of 25 files). Show all
Unified · Split
| @@ -68,10 +68,12 @@ struct TagDqLayer { · 67 unmodified lines | |||
| 68 | int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; | 68 | int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; |
| 69 | int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; | 69 | int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A]; |
| 70 | int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM]; | 70 | int8_t (*pRefIndex[LIST_A])[MB_BLOCK4x4_NUM]; |
| 71 | bool* pNoSubMbPartSizeLessThan8x8Flag; | ||
| 72 | bool* pTransformSize8x8Flag; | ||
| 71 | int8_t* pLumaQp; | 73 | int8_t* pLumaQp; |
| 72 | int8_t (*pChromaQp)[2]; | 74 | int8_t (*pChromaQp)[2]; |
| 73 | int8_t* pCbp; | 75 | int8_t* pCbp; |
| 74 | uint8_t *pCbfDc; | 76 | uint16_t *pCbfDc; |
| 75 | int8_t (*pNzc)[24]; | 77 | int8_t (*pNzc)[24]; |
| 76 | int8_t (*pNzcRs)[24]; | 78 | int8_t (*pNzcRs)[24]; |
| 77 | int8_t* pResidualPredFlag; | 79 | int8_t* pResidualPredFlag; |
| @@ -81,6 +83,7 @@ struct TagDqLayer { · 3 unmodified lines | |||
| 81 | int16_t (*pScaledTCoeff)[MB_COEFF_LIST_SIZE]; | 83 | int16_t (*pScaledTCoeff)[MB_COEFF_LIST_SIZE]; |
| 82 | int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 | 84 | int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 |
| 83 | int8_t (*pIntra4x4FinalMode)[MB_BLOCK4x4_NUM]; | 85 | int8_t (*pIntra4x4FinalMode)[MB_BLOCK4x4_NUM]; |
| 86 | uint8_t *pIntraNxNAvailFlag; | ||
| 84 | int8_t* pChromaPredMode; | 87 | int8_t* pChromaPredMode; |
| 85 | //uint8_t (*motion_pred_flag[LIST_A])[MB_PARTITION_SIZE]; // 8x8 | 88 | //uint8_t (*motion_pred_flag[LIST_A])[MB_PARTITION_SIZE]; // 8x8 |
| 86 | int8_t (*pSubMbType)[MB_SUB_PARTITION_SIZE]; | 89 | int8_t (*pSubMbType)[MB_SUB_PARTITION_SIZE]; |
| @@ -132,7 +135,6 @@ typedef struct TagGpuAvcLayer { · 45 unmodified lines | |||
| 132 | int8_t* pCbp; | 135 | int8_t* pCbp; |
| 133 | int8_t (*pNzc)[24]; | 136 | int8_t (*pNzc)[24]; |
| 134 | int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 | 137 | int8_t (*pIntraPredMode)[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 |
| 135 | |||
| 136 | int32_t iMbX; | 138 | int32_t iMbX; |
| 137 | int32_t iMbY; | 139 | int32_t iMbY; |
| 138 | int32_t iMbXyIndex; | 140 | int32_t iMbXyIndex; |
| @@ -232,6 +232,18 @@ static inline int32_t BsGetTrailingBits (uint8_t* pBuf) { · 231 unmodified lines | |||
| 232 | 232 | ||
| 233 | return 0; | 233 | return 0; |
| 234 | } | 234 | } |
| 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 | |||
| 235 | //define macros to check syntax elements | 247 | //define macros to check syntax elements |
| 236 | #define WELS_CHECK_SE_BOTH_ERROR(val, lower_bound, upper_bound, syntax_name, ret_code) do {\ | 248 | #define WELS_CHECK_SE_BOTH_ERROR(val, lower_bound, upper_bound, syntax_name, ret_code) do {\ |
| 237 | if ((val < lower_bound) || (val > upper_bound)) {\ | 249 | if ((val < lower_bound) || (val > upper_bound)) {\ |
| @@ -39,6 +39,7 @@ · 38 unmodified lines | |||
| 39 | namespace WelsDec { | 39 | namespace WelsDec { |
| 40 | 40 | ||
| 41 | void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs); | 41 | 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); | ||
| 42 | 43 | ||
| 43 | #if defined(__cplusplus) | 44 | #if defined(__cplusplus) |
| 44 | extern "C" { | 45 | extern "C" { |
| @@ -91,8 +91,15 @@ typedef struct { · 90 unmodified lines | |||
| 91 | #define NEW_CTX_OFFSET_LAST 166 | 91 | #define NEW_CTX_OFFSET_LAST 166 |
| 92 | #define NEW_CTX_OFFSET_ONE 227 | 92 | #define NEW_CTX_OFFSET_ONE 227 |
| 93 | #define NEW_CTX_OFFSET_ABS 232 | 93 | #define NEW_CTX_OFFSET_ABS 232 |
| 94 | #define NEW_CTX_OFFSET_TS_8x8_FLAG 399 | ||
| 94 | #define CTX_NUM_MVD 7 | 95 | #define CTX_NUM_MVD 7 |
| 95 | #define CTX_NUM_CBP 4 | 96 | #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? | ||
| 96 | 103 | ||
| 97 | typedef struct TagDataBuffer { | 104 | typedef struct TagDataBuffer { |
| 98 | uint8_t* pHead; | 105 | uint8_t* pHead; |
| @@ -131,6 +138,8 @@ typedef void (*PIdctResAddPredFunc) (uint8_t* pPred, const int32_t kiStride, int · 32 unmodified lines | |||
| 131 | typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth, | 138 | typedef void (*PExpandPictureFunc) (uint8_t* pDst, const int32_t kiStride, const int32_t kiPicWidth, |
| 132 | const int32_t kiPicHeight); | 139 | const int32_t kiPicHeight); |
| 133 | 140 | ||
| 141 | typedef void (*PGetIntraPred8x8Func) (uint8_t* pPred, const int32_t kiLumaStride, bool bTLAvail, bool bTRAvail); | ||
| 142 | |||
| 134 | /**/ | 143 | /**/ |
| 135 | typedef struct TagRefPic { | 144 | typedef struct TagRefPic { |
| 136 | PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme | 145 | PPicture pRefList[LIST_A][MAX_REF_PIC_COUNT]; // reference picture marking plus FIFO scheme |
| @@ -262,15 +271,18 @@ typedef struct TagWelsDecoderContext { · 125 unmodified lines | |||
| 262 | int16_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */ | 271 | int16_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */ |
| 263 | int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] | 272 | int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] |
| 264 | int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM]; | 273 | int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM]; |
| 274 | bool* pNoSubMbPartSizeLessThan8x8Flag[LAYER_NUM_EXCHANGEABLE]; | ||
| 275 | bool* pTransformSize8x8Flag[LAYER_NUM_EXCHANGEABLE]; | ||
| 265 | int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/ | 276 | int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/ |
| 266 | int8_t (*pChromaQp[LAYER_NUM_EXCHANGEABLE])[2]; /*mb chroma_qp*/ | 277 | int8_t (*pChromaQp[LAYER_NUM_EXCHANGEABLE])[2]; /*mb chroma_qp*/ |
| 267 | int16_t (*pMvd[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*] | 278 | 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]; |
| 269 | int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24]; | 280 | int8_t (*pNzc[LAYER_NUM_EXCHANGEABLE])[24]; |
| 270 | int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24]; | 281 | int8_t (*pNzcRs[LAYER_NUM_EXCHANGEABLE])[24]; |
| 271 | int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/ | 282 | int16_t (*pScaledTCoeff[LAYER_NUM_EXCHANGEABLE])[MB_COEFF_LIST_SIZE]; /*need be aligned*/ |
| 272 | int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 | 283 | int8_t (*pIntraPredMode[LAYER_NUM_EXCHANGEABLE])[8]; //0~3 top4x4 ; 4~6 left 4x4; 7 intra16x16 |
| 273 | int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM]; | 284 | int8_t (*pIntra4x4FinalMode[LAYER_NUM_EXCHANGEABLE])[MB_BLOCK4x4_NUM]; |
| 285 | uint8_t* pIntraNxNAvailFlag[LAYER_NUM_EXCHANGEABLE]; | ||
| 274 | int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE]; | 286 | int8_t* pChromaPredMode[LAYER_NUM_EXCHANGEABLE]; |
| 275 | int8_t* pCbp[LAYER_NUM_EXCHANGEABLE]; | 287 | int8_t* pCbp[LAYER_NUM_EXCHANGEABLE]; |
| 276 | uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8 | 288 | uint8_t (*pMotionPredFlag[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_PARTITION_SIZE]; // 8x8 |
| @@ -284,7 +296,6 @@ typedef struct TagWelsDecoderContext { · 7 unmodified lines | |||
| 284 | uint32_t iMbHeight; | 296 | uint32_t iMbHeight; |
| 285 | } sMb; | 297 | } sMb; |
| 286 | 298 | ||
| 287 | |||
| 288 | // reconstruction picture | 299 | // reconstruction picture |
| 289 | PPicture pDec; //pointer to current picture being reconstructed | 300 | PPicture pDec; //pointer to current picture being reconstructed |
| 290 | 301 | ||
| @@ -381,6 +392,9 @@ typedef struct TagWelsDecoderContext { · 90 unmodified lines | |||
| 381 | PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t | 392 | PGetIntraPredFunc pGetIChromaPredFunc[7]; // h264_predict_8x8_t |
| 382 | PIdctResAddPredFunc pIdctResAddPredFunc; | 393 | PIdctResAddPredFunc pIdctResAddPredFunc; |
| 383 | SMcFunc sMcFunc; | 394 | SMcFunc sMcFunc; |
| 395 | //Transform8x8 | ||
| 396 | PGetIntraPred8x8Func pGetI8x8LumaPredFunc[14]; | ||
| 397 | PIdctResAddPredFunc pIdctResAddPredFunc8x8; | ||
| 384 | 398 | ||
| 385 | //For error concealment | 399 | //For error concealment |
| 386 | SCopyFunc sCopyFunc; | 400 | SCopyFunc sCopyFunc; |
| @@ -395,8 +409,8 @@ typedef struct TagWelsDecoderContext { · 8 unmodified lines | |||
| 395 | int32_t iCurSeqIntervalMaxPicWidth; | 409 | int32_t iCurSeqIntervalMaxPicWidth; |
| 396 | int32_t iCurSeqIntervalMaxPicHeight; | 410 | int32_t iCurSeqIntervalMaxPicHeight; |
| 397 | 411 | ||
| 398 | PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntra4x4Func; | 412 | PWelsFillNeighborMbInfoIntra4x4Func pFillInfoCacheIntraNxNFunc; |
| 399 | PWelsMapNeighToSample pMap4x4NeighToSampleFunc; | 413 | PWelsMapNeighToSample pMapNxNNeighToSampleFunc; |
| 400 | PWelsMap16NeighToSample pMap16x16NeighToSampleFunc; | 414 | PWelsMap16NeighToSample pMap16x16NeighToSampleFunc; |
| 401 | 415 | ||
| 402 | //feedback whether or not have VCL in current AU, and the temporal ID | 416 | //feedback whether or not have VCL in current AU, and the temporal ID |
| @@ -60,6 +60,21 @@ void WelsI4x4LumaPredVR_c (uint8_t* pPred, const int32_t kiStride); · 59 unmodified lines | |||
| 60 | void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride); | 60 | void WelsI4x4LumaPredHU_c (uint8_t* pPred, const int32_t kiStride); |
| 61 | void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride); | 61 | void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride); |
| 62 | 62 | ||
| 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 | |||
| 63 | void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride); | 78 | void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride); |
| 64 | void WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride); | 79 | void WelsIChromaPredH_c (uint8_t* pPred, const int32_t kiStride); |
| 65 | void WelsIChromaPredPlane_c (uint8_t* pPred, const int32_t kiStride); | 80 | 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 | |||
| 96 | void WelsDecoderIChromaPredDcLeft_mmx (uint8_t* pPred, const int32_t kiStride); | 111 | void WelsDecoderIChromaPredDcLeft_mmx (uint8_t* pPred, const int32_t kiStride); |
| 97 | void WelsDecoderIChromaPredDcNA_mmx (uint8_t* pPred, const int32_t kiStride); | 112 | void WelsDecoderIChromaPredDcNA_mmx (uint8_t* pPred, const int32_t kiStride); |
| 98 | 113 | ||
| 99 | |||
| 100 | |||
| 101 | void WelsDecoderI4x4LumaPredH_sse2 (uint8_t* pPred, const int32_t kiStride); | 114 | void WelsDecoderI4x4LumaPredH_sse2 (uint8_t* pPred, const int32_t kiStride); |
| 102 | void WelsDecoderI4x4LumaPredDDR_mmx (uint8_t* pPred, const int32_t kiStride); | 115 | void WelsDecoderI4x4LumaPredDDR_mmx (uint8_t* pPred, const int32_t kiStride); |
| 103 | void WelsDecoderI4x4LumaPredHD_mmx (uint8_t* pPred, const int32_t kiStride); | 116 | void WelsDecoderI4x4LumaPredHD_mmx (uint8_t* pPred, const int32_t kiStride); |
| @@ -167,12 +167,16 @@ typedef struct TagPps { · 166 unmodified lines | |||
| 167 | bool bRedundantPicCntPresentFlag; | 167 | bool bRedundantPicCntPresentFlag; |
| 168 | bool bWeightedPredFlag; | 168 | bool bWeightedPredFlag; |
| 169 | uint8_t uiWeightedBipredIdc; | 169 | uint8_t uiWeightedBipredIdc; |
| 170 | bool bTransform_8x8_mode_flag; | 170 | |
| 171 | bool bTransform8x8ModeFlag; | ||
| 171 | //Add for scalinglist support | 172 | //Add for scalinglist support |
| 172 | bool bPicScalingMatrixPresentFlag; | 173 | bool bPicScalingMatrixPresentFlag; |
| 173 | bool bPicScalingListPresentFlag[12]; | 174 | bool bPicScalingListPresentFlag[12]; |
| 174 | uint8_t iScalingList4x4[6][16]; | 175 | uint8_t iScalingList4x4[6][16]; |
| 175 | uint8_t iScalingList8x8[6][64]; | 176 | uint8_t iScalingList8x8[6][64]; |
| 177 | |||
| 178 | int32_t iSecondChromaQPIndexOffset; //second_chroma_qp_index_offset | ||
| 179 | |||
| 176 | } SPps, *PPps; | 180 | } SPps, *PPps; |
| 177 | 181 | ||
| 178 | } // namespace WelsDec | 182 | } // namespace WelsDec |
| @@ -46,6 +46,7 @@ int32_t ParseEndOfSliceCabac (PWelsDecoderContext pCtx, uint32_t& uiBinVal); · 45 unmodified lines | |||
| 46 | int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSkip); | 46 | int32_t ParseSkipFlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSkip); |
| 47 | int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal); | 47 | int32_t ParseMBTypeISliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal); |
| 48 | int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal); | 48 | int32_t ParseMBTypePSliceCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiBinVal); |
| 49 | int32_t ParseTransformSize8x8FlagCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, bool& bTransformSize8x8Flag); | ||
| 49 | int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType); | 50 | int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType); |
| 50 | int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t& iBinVal); | 51 | int32_t ParseIntraPredModeLumaCabac (PWelsDecoderContext pCtx, int32_t& iBinVal); |
| 51 | int32_t ParseIntraPredModeChromaCabac (PWelsDecoderContext pCtx, uint8_t uiNeighAvail, int32_t& iBinVal); | 52 | 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 | |||
| 66 | int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux, | 67 | int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux, |
| 67 | int32_t index, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty, int16_t* sTCoeff, uint8_t uiQp, | 68 | int32_t index, int32_t iMaxNumCoeff, const uint8_t* pScanTable, int32_t iResProperty, int16_t* sTCoeff, uint8_t uiQp, |
| 68 | PWelsDecoderContext pCtx); | 69 | 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); | ||
| 69 | int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx); | 73 | int32_t ParseIPCMInfoCabac (PWelsDecoderContext pCtx); |
| 70 | } | 74 | } |
| 71 | //#pragma pack() | 75 | //#pragma pack() |
| @@ -53,9 +53,9 @@ namespace WelsDec { · 52 unmodified lines | |||
| 53 | 53 | ||
| 54 | void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer); | 54 | void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer); |
| 55 | void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, PDqLayer pCurLayer); | 55 | 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, |
| 57 | PDqLayer pCurLayer); | 57 | PDqLayer pCurLayer); |
| 58 | void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | 58 | void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, |
| 59 | PDqLayer pCurLayer); | 59 | PDqLayer pCurLayer); |
| 60 | void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, | 60 | void WelsFillCacheInterCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, |
| 61 | int16_t iMvArray[LIST_A][30][MV_A], int16_t iMvdCache[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], PDqLayer pCurLayer); | 61 | 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 | |||
| 64 | 64 | ||
| 65 | /*! | 65 | /*! |
| 66 | * \brief check iPredMode for intra16x16 eligible or not | 66 | * \brief check iPredMode for intra16x16 eligible or not |
| 67 | * \param input : current iPredMode | 67 | * \param input : current iPredMode |
| 68 | * \param output: 0 indicating decoding correctly; -1 means error occurence | 68 | * \param output: 0 indicating decoding correctly; -1 means error occurence |
| 69 | */ | 69 | */ |
| 70 | int32_t CheckIntra16x16PredMode (uint8_t uiSampleAvail, int8_t* pMode); | 70 | int32_t CheckIntra16x16PredMode (uint8_t uiSampleAvail, int8_t* pMode); |
| 71 | 71 | ||
| 72 | /*! | 72 | /*! |
| 73 | * \brief check iPredMode for intra4x4 eligible or not | 73 | * \brief check iPredMode for intraNxN eligible or not |
| 74 | * \param input : current iPredMode | 74 | * \param input : current iPredMode |
| 75 | * \param output: 0 indicating decoding correctly; -1 means error occurence | 75 | * \param output: 0 indicating decoding correctly; -1 means error occurence |
| 76 | */ | 76 | */ |
| 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); |
| 78 | 78 | ||
| 79 | /*! | 79 | /*! |
| 80 | * \brief check iPredMode for chroma eligible or not | 80 | * \brief check iPredMode for chroma eligible or not |
| 81 | * \param input : current iPredMode | 81 | * \param input : current iPredMode |
| 82 | * \param output: 0 indicating decoding correctly; -1 means error occurence | 82 | * \param output: 0 indicating decoding correctly; -1 means error occurence |
| 83 | */ | 83 | */ |
| 84 | int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode); | 84 | int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode); |
| 85 | 85 | ||
| 86 | /*! | 86 | /*! |
| 87 | * \brief predict the mode of intra4x4 | 87 | * \brief predict the mode of intra4x4 |
| 88 | * \param input : current intra4x4 block index | 88 | * \param input : current intra4x4 block index |
| 89 | * \param output: mode index | 89 | * \param output: mode index |
| 90 | */ | 90 | */ |
| 91 | int32_t PredIntra4x4Mode (int8_t* pIntraPredMode, int32_t iIdx4); | 91 | int32_t PredIntra4x4Mode (int8_t* pIntraPredMode, int32_t iIdx4); |
| 92 | 92 | ||
| @@ -107,10 +107,25 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, · 14 unmodified lines | |||
| 107 | uint8_t uiQp, | 107 | uint8_t uiQp, |
| 108 | PWelsDecoderContext pCtx); | 108 | PWelsDecoderContext pCtx); |
| 109 | 109 | ||
| 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 | |||
| 110 | /*! | 125 | /*! |
| 111 | * \brief parsing inter info (including ref_index and pMvd) | 126 | * \brief parsing inter info (including ref_index and pMvd) |
| 112 | * \param input : decoding context, current mb, bit-stream | 127 | * \param input : decoding context, current mb, bit-stream |
| 113 | * \param output: 0 indicating decoding correctly; -1 means error | 128 | * \param output: 0 indicating decoding correctly; -1 means error |
| 114 | */ | 129 | */ |
| 115 | int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], | 130 | int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], |
| 116 | PBitStringAux pBs); | 131 | PBitStringAux pBs); |
| @@ -78,6 +78,10 @@ int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLe · 77 unmodified lines | |||
| 78 | 78 | ||
| 79 | int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); | 79 | int32_t RecI4x4Chroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); |
| 80 | 80 | ||
| 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 | |||
| 81 | int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); | 85 | int32_t RecI16x16Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); |
| 82 | 86 | ||
| 83 | int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); | 87 | int32_t RecChroma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer); |
| @@ -72,16 +72,19 @@ typedef int32_t SubMbType; · 71 unmodified lines | |||
| 72 | #define LUMA_DC_AC 3 | 72 | #define LUMA_DC_AC 3 |
| 73 | #define CHROMA_DC 4 | 73 | #define CHROMA_DC 4 |
| 74 | #define CHROMA_AC 5 | 74 | #define CHROMA_AC 5 |
| 75 | #define CHROMA_DC_U 6 | 75 | #define LUMA_DC_AC_8 6 |
| 76 | #define CHROMA_DC_V 7 | 76 | #define CHROMA_DC_U 7 |
| 77 | #define CHROMA_AC_U 8 | 77 | #define CHROMA_DC_V 8 |
| 78 | #define CHROMA_AC_V 9 | 78 | #define CHROMA_AC_U 9 |
| 79 | #define LUMA_DC_AC_INTRA 10 | 79 | #define CHROMA_AC_V 10 |
| 80 | #define LUMA_DC_AC_INTER 11 | 80 | #define LUMA_DC_AC_INTRA 11 |
| 81 | #define CHROMA_DC_U_INTER 12 | 81 | #define LUMA_DC_AC_INTER 12 |
| 82 | #define CHROMA_DC_V_INTER 13 | 82 | #define CHROMA_DC_U_INTER 13 |
| 83 | #define CHROMA_AC_U_INTER 14 | 83 | #define CHROMA_DC_V_INTER 14 |
| 84 | #define CHROMA_AC_V_INTER 15 | 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 | ||
| 85 | 88 | ||
| 86 | #define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); } | 89 | #define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); } |
| 87 | #define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; } | 90 | #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 | |||
| 93 | 7, 11, 14, 15, | 96 | 7, 11, 14, 15, |
| 94 | }; | 97 | }; |
| 95 | 98 | ||
| 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 | }; | ||
| 96 | 131 | ||
| 97 | static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProperty,bool bCavlc) | 132 | static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProperty,bool bCavlc) |
| 98 | { | 133 | { |
| @@ -142,8 +177,17 @@ static inline void GetMbResProperty(int32_t * pMBproperty,int32_t* pResidualProp · 43 unmodified lines | |||
| 142 | break; | 177 | break; |
| 143 | case CHROMA_AC_V_INTER: | 178 | case CHROMA_AC_V_INTER: |
| 144 | *pMBproperty = 5; | 179 | *pMBproperty = 5; |
| 145 | *pResidualProperty = bCavlc ?CHROMA_AC:CHROMA_AC_V; | 180 | *pResidualProperty = bCavlc ? CHROMA_AC : CHROMA_AC_V; |
| 146 | break; | 181 | 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; | ||
| 147 | } | 191 | } |
| 148 | } | 192 | } |
| 149 | 193 | ||
| @@ -124,6 +124,7 @@ uint8_t* ParseNalHeader (PWelsDecoderContext pCtx, SNalUnitHeader* pNalUnitHeade · 123 unmodified lines | |||
| 124 | uiBsZero = pSrcRbsp[iIndex]; | 124 | uiBsZero = pSrcRbsp[iIndex]; |
| 125 | if (0 == uiBsZero) { | 125 | if (0 == uiBsZero) { |
| 126 | --iNalSize; | 126 | --iNalSize; |
| 127 | ++ (*pConsumedBytes); | ||
| 127 | --iIndex; | 128 | --iIndex; |
| 128 | } else { | 129 | } else { |
| 129 | break; | 130 | break; |
| @@ -991,16 +992,10 @@ int32_t ParseSps (PWelsDecoderContext pCtx, PBitStringAux pBsAux, int32_t* pPicW · 861 unmodified lines | |||
| 991 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag | 992 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //seq_scaling_matrix_present_flag |
| 992 | pSps->bSeqScalingMatrixPresentFlag = !!uiCode; | 993 | pSps->bSeqScalingMatrixPresentFlag = !!uiCode; |
| 993 | 994 | ||
| 994 | if (pSps->bSeqScalingMatrixPresentFlag)// For high profile, it is not used in current application. FIXME | 995 | if (pSps->bSeqScalingMatrixPresentFlag) { |
| 995 | |||
| 996 | WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4, | 996 | WELS_READ_VERIFY (ParseScalingList (pSps, pBs, 0, pSps->bSeqScalingListPresentFlag, pSps->iScalingList4x4, |
| 997 | pSps->iScalingList8x8)); | 997 | pSps->iScalingList8x8)); |
| 998 | //if exist, to parse scalinglist matrix value | 998 | } |
| 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); | ||
| 1004 | } | 999 | } |
| 1005 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4 | 1000 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //log2_max_frame_num_minus4 |
| 1006 | WELS_CHECK_SE_UPPER_ERROR (uiCode, SPS_LOG2_MAX_FRAME_NUM_MINUS4_MAX, "log2_max_frame_num_minus4", | 1001 | 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 | |||
| 1379 | pPps->bConstainedIntraPredFlag = !!uiCode; | 1374 | pPps->bConstainedIntraPredFlag = !!uiCode; |
| 1380 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag | 1375 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //redundant_pic_cnt_present_flag |
| 1381 | pPps->bRedundantPicCntPresentFlag = !!uiCode; | 1376 | pPps->bRedundantPicCntPresentFlag = !!uiCode; |
| 1382 | /*TODO: to judge whether going on to parse*/ | 1377 | |
| 1383 | //going on to parse high profile syntax, need fix me | 1378 | if (CheckMoreRBSPData (pBsAux)) { |
| 1384 | if (0) { | 1379 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //transform_8x8_mode_flag |
| 1385 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); | 1380 | pPps->bTransform8x8ModeFlag = !!uiCode; |
| 1386 | pPps->bTransform_8x8_mode_flag = !!uiCode; | 1381 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); //pic_scaling_matrix_present_flag |
| 1387 | WELS_READ_VERIFY (BsGetOneBit (pBsAux, &uiCode)); | ||
| 1388 | pPps->bPicScalingMatrixPresentFlag = !!uiCode; | 1382 | pPps->bPicScalingMatrixPresentFlag = !!uiCode; |
| 1389 | if (pPps->bPicScalingMatrixPresentFlag) { | 1383 | if (pPps->bPicScalingMatrixPresentFlag) { |
| 1390 | if (pCtx->bSpsAvailFlags[pPps->iSpsId]) | 1384 | if (pCtx->bSpsAvailFlags[pPps->iSpsId]) { |
| 1391 | WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag, | 1385 | WELS_READ_VERIFY (ParseScalingList (&pCtx->sSpsBuffer[pPps->iSpsId], pBsAux, 1, pPps->bPicScalingListPresentFlag, |
| 1392 | pPps->iScalingList4x4, pPps->iScalingList8x8)); | 1386 | pPps->iScalingList4x4, pPps->iScalingList8x8)); |
| 1393 | else { | 1387 | } else { |
| 1394 | pCtx->bSpsLatePps = true; | 1388 | pCtx->bSpsLatePps = true; |
| 1395 | WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, | 1389 | WELS_READ_VERIFY (ParseScalingList (NULL, pBsAux, 1, pPps->bPicScalingListPresentFlag, pPps->iScalingList4x4, |
| 1396 | pPps->iScalingList8x8)); | 1390 | pPps->iScalingList8x8)); |
| 1397 | } | 1391 | } |
| 1398 | } | 1392 | } |
| 1399 | //add second chroma qp parsing process | 1393 | WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //second_chroma_qp_index_offset |
| 1400 | WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); //chroma_qp_index_offset,cr | 1394 | pPps->iChromaQpIndexOffset[1] = iCode; |
| 1401 | pPps->iChromaQpIndexOffset[1] = iCode; | 1395 | WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset[1], PPS_CHROMA_QP_INDEX_OFFSET_MIN, |
| 1402 | WELS_CHECK_SE_BOTH_ERROR (pPps->iChromaQpIndexOffset[1], PPS_CHROMA_QP_INDEX_OFFSET_MIN, PPS_CHROMA_QP_INDEX_OFFSET_MAX, | 1396 | PPS_CHROMA_QP_INDEX_OFFSET_MAX, "chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, |
| 1403 | "second_chroma_qp_index_offset", GENERATE_ERROR_NO (ERR_LEVEL_PARAM_SETS, ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET)); | 1397 | ERR_INFO_INVALID_CHROMA_QP_INDEX_OFFSET)); |
| 1404 | } | 1398 | } |
| 1405 | 1399 | ||
| 1406 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { | 1400 | if (pCtx->pAccessUnitList->uiAvailUnitsNum > 0) { |
| @@ -1481,6 +1475,7 @@ int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* b · 74 unmodified lines | |||
| 1481 | int iNextScale = 8; | 1475 | int iNextScale = 8; |
| 1482 | int iDeltaScale; | 1476 | int iDeltaScale; |
| 1483 | int32_t iCode; | 1477 | int32_t iCode; |
| 1478 | int32_t iIdx; | ||
| 1484 | for (int j = 0; j < iScalingListNum; j++) { | 1479 | for (int j = 0; j < iScalingListNum; j++) { |
| 1485 | if (iNextScale != 0) { | 1480 | if (iNextScale != 0) { |
| 1486 | WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); | 1481 | WELS_READ_VERIFY (BsGetSe (pBsAux, &iCode)); |
| @@ -1492,8 +1487,9 @@ int32_t SetScalingListValue (uint8_t* pScalingList, int iScalingListNum, bool* b · 5 unmodified lines | |||
| 1492 | if (*bUseDefaultScalingMatrixFlag) | 1487 | if (*bUseDefaultScalingMatrixFlag) |
| 1493 | break; | 1488 | break; |
| 1494 | } | 1489 | } |
| 1495 | pScalingList[g_kuiZigzagScan[j]] = (iNextScale == 0) ? iLastScale : iNextScale; | 1490 | iIdx = iScalingListNum == 16 ? g_kuiZigzagScan[j] : g_kuiZigzagScan8x8[j]; |
| 1496 | iLastScale = pScalingList[g_kuiZigzagScan[j]]; | 1491 | pScalingList[iIdx] = (iNextScale == 0) ? iLastScale : iNextScale; |
| 1492 | iLastScale = pScalingList[iIdx]; | ||
| 1497 | } | 1493 | } |
| 1498 | 1494 | ||
| 1499 | 1495 | ||
| @@ -74,7 +74,7 @@ int32_t InitCabacDecEngineFromBS (PWelsCabacDecEngine pDecEngine, PBitStringAux · 73 unmodified lines | |||
| 74 | uint8_t* pCurr; | 74 | uint8_t* pCurr; |
| 75 | 75 | ||
| 76 | pCurr = pBsAux->pCurBuf - iRemainingBytes; | 76 | pCurr = pBsAux->pCurBuf - iRemainingBytes; |
| 77 | if(pCurr >= (pBsAux->pEndBuf - 1)) { | 77 | if (pCurr >= (pBsAux->pEndBuf - 1)) { |
| 78 | return ERR_INFO_INVALID_ACCESS; | 78 | return ERR_INFO_INVALID_ACCESS; |
| 79 | } | 79 | } |
| 80 | pDecEngine->uiOffset = ((pCurr[0] << 16) | (pCurr[1] << 8) | pCurr[2]); | 80 | pDecEngine->uiOffset = ((pCurr[0] << 16) | (pCurr[1] << 8) | pCurr[2]); |
| @@ -136,6 +136,19 @@ static const uint8_t g_kuiTableBIdx[2][8] = { · 135 unmodified lines | |||
| 136 | }, | 136 | }, |
| 137 | }; | 137 | }; |
| 138 | 138 | ||
| 139 | static const uint8_t g_kuiTableB8x8Idx[2][16] = { | ||
| 140 | { | ||
| 141 | 0, 1, 4, 5, 8, 9, 12, 13, // 0 1 | 2 3 | ||
| 142 | 2, 3, 6, 7, 10, 11, 14, 15 // 4 5 | 6 7 | ||
| 143 | }, // ------------ | ||
| 144 | // 8 9 | 10 11 | ||
| 145 | { | ||
| 146 | // 12 13 | 14 15 | ||
| 147 | 0, 1, 4, 5, 2, 3, 6, 7, | ||
| 148 | 8, 9, 12, 13, 10, 11, 14, 15 | ||
| 149 | }, | ||
| 150 | }; | ||
| 151 | |||
| 139 | #define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \ | 152 | #define TC0_TBL_LOOKUP(tc, iIndexA, pBS, bChroma) \ |
| 140 | {\ | 153 | {\ |
| 141 | tc[0] = g_kiTc0Table(iIndexA)[pBS[0]] + bChroma;\ | 154 | 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 | |||
| 170 | nBS[0][2][3] = (pNnzTab[13] | pNnzTab[14]) << iLShiftFactor; | 183 | nBS[0][2][3] = (pNnzTab[13] | pNnzTab[14]) << iLShiftFactor; |
| 171 | nBS[0][3][3] = (pNnzTab[14] | pNnzTab[15]) << iLShiftFactor; | 184 | nBS[0][3][3] = (pNnzTab[14] | pNnzTab[15]) << iLShiftFactor; |
| 172 | * (uint32_t*)nBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor; | 185 | * (uint32_t*)nBS[1][3] = (uiNnz32b2 | uiNnz32b3) << iLShiftFactor; |
| 186 | } | ||
| 187 | |||
| 188 | void inline DeblockingBSInsideMBAvsbase8x8 (int8_t* pNnzTab, uint8_t nBS[2][4][4], int32_t iLShiftFactor) { | ||
| 189 | int8_t i8x8NnzTab[4]; | ||
| 190 | for (int32_t i = 0; i < 4; i++) { | ||
| 191 | int32_t iBlkIdx = i << 2; | ||
| 192 | i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | | ||
| 193 | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); | ||
| 194 | } | ||
| 173 | 195 | ||
| 196 | //vertical | ||
| 197 | nBS[0][2][0] = nBS[0][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[1]) << iLShiftFactor; | ||
| 198 | nBS[0][2][2] = nBS[0][2][3] = (i8x8NnzTab[2] | i8x8NnzTab[3]) << iLShiftFactor; | ||
| 199 | //horizontal | ||
| 200 | nBS[1][2][0] = nBS[1][2][1] = (i8x8NnzTab[0] | i8x8NnzTab[2]) << iLShiftFactor; | ||
| 201 | nBS[1][2][2] = nBS[1][2][3] = (i8x8NnzTab[1] | i8x8NnzTab[3]) << iLShiftFactor; | ||
| 174 | } | 202 | } |
| 175 | 203 | ||
| 176 | void static inline DeblockingBSInsideMBNormal (PDqLayer pCurDqLayer, uint8_t nBS[2][4][4], int8_t* pNnzTab, | 204 | 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 | |||
| 179 | int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy]; | 207 | int8_t* iRefIndex = pCurDqLayer->pRefIndex[LIST_0][iMbXy]; |
| 180 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); | 208 | ENFORCE_STACK_ALIGN_1D (uint8_t, uiBsx4, 4, 4); |
| 181 | 209 | ||
| 182 | uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); | 210 | int8_t i8x8NnzTab[4]; |
| 183 | uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); | ||
| 184 | uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); | ||
| 185 | uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); | ||
| 186 | 211 | ||
| 187 | for (int i = 0; i < 3; i++) | 212 | if (pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { |
| 188 | uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1]; | 213 | for (int32_t i = 0; i < 4; i++) { |
| 189 | nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0); | 214 | int32_t iBlkIdx = i << 2; |
| 190 | nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1); | 215 | i8x8NnzTab[i] = (pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 1]] | |
| 191 | nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2); | 216 | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 2]] | pNnzTab[g_kuiMbCountScan4Idx[iBlkIdx + 3]]); |
| 192 | 217 | } | |
| 193 | for (int i = 0; i < 3; i++) | 218 | //vertical |
| 194 | uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1]; | 219 | nBS[0][2][0] = nBS[0][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[1]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], |
| 195 | nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4); | 220 | g_kuiMbCountScan4Idx[1 << 2], g_kuiMbCountScan4Idx[0]); |
| 196 | nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5); | 221 | nBS[0][2][2] = nBS[0][2][3] = BS_EDGE ((i8x8NnzTab[2] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], |
| 197 | nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6); | 222 | g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[2 << 2]); |
| 198 | 223 | ||
| 199 | for (int i = 0; i < 3; i++) | 224 | //horizontal |
| 200 | uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1]; | 225 | nBS[1][2][0] = nBS[1][2][1] = BS_EDGE ((i8x8NnzTab[0] | i8x8NnzTab[2]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], |
| 201 | nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8); | 226 | g_kuiMbCountScan4Idx[2 << 2], g_kuiMbCountScan4Idx[0]); |
| 202 | nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9); | 227 | nBS[1][2][2] = nBS[1][2][3] = BS_EDGE ((i8x8NnzTab[1] | i8x8NnzTab[3]), iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], |
| 203 | nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10); | 228 | g_kuiMbCountScan4Idx[3 << 2], g_kuiMbCountScan4Idx[1 << 2]); |
| 204 | 229 | } else { | |
| 205 | for (int i = 0; i < 3; i++) | 230 | uiNnz32b0 = * (uint32_t*) (pNnzTab + 0); |
| 206 | uiBsx4[i] = pNnzTab[12 + i] | pNnzTab[12 + i + 1]; | 231 | uiNnz32b1 = * (uint32_t*) (pNnzTab + 4); |
| 207 | nBS[0][1][3] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 12); | 232 | uiNnz32b2 = * (uint32_t*) (pNnzTab + 8); |
| 208 | nBS[0][2][3] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 13); | 233 | uiNnz32b3 = * (uint32_t*) (pNnzTab + 12); |
| 209 | nBS[0][3][3] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 14); | 234 | |
| 210 | 235 | for (int i = 0; i < 3; i++) | |
| 211 | // horizontal | 236 | uiBsx4[i] = pNnzTab[i] | pNnzTab[i + 1]; |
| 212 | * (uint32_t*)uiBsx4 = (uiNnz32b0 | uiNnz32b1); | 237 | nBS[0][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 1, 0); |
| 213 | nBS[1][1][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 4, 0); | 238 | nBS[0][2][0] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 2, 1); |
| 214 | nBS[1][1][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 1); | 239 | nBS[0][3][0] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 3, 2); |
| 215 | nBS[1][1][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 2); | 240 | |
| 216 | nBS[1][1][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 3); | 241 | for (int i = 0; i < 3; i++) |
| 217 | 242 | uiBsx4[i] = pNnzTab[4 + i] | pNnzTab[4 + i + 1]; | |
| 218 | * (uint32_t*)uiBsx4 = (uiNnz32b1 | uiNnz32b2); | 243 | nBS[0][1][1] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 5, 4); |
| 219 | nBS[1][2][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 8, 4); | 244 | nBS[0][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 6, 5); |
| 220 | nBS[1][2][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 5); | 245 | nBS[0][3][1] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 7, 6); |
| 221 | nBS[1][2][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 6); | 246 | |
| 222 | nBS[1][2][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 7); | 247 | for (int i = 0; i < 3; i++) |
| 223 | 248 | uiBsx4[i] = pNnzTab[8 + i] | pNnzTab[8 + i + 1]; | |
| 224 | * (uint32_t*)uiBsx4 = (uiNnz32b2 | uiNnz32b3); | 249 | nBS[0][1][2] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 9, 8); |
| 225 | nBS[1][3][0] = BS_EDGE (uiBsx4[0], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 12, 8); | 250 | nBS[0][2][2] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 10, 9); |
| 226 | nBS[1][3][1] = BS_EDGE (uiBsx4[1], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 13, 9); | 251 | nBS[0][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 11, 10); |
| 227 | nBS[1][3][2] = BS_EDGE (uiBsx4[2], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 14, 10); | 252 | |
| 228 | nBS[1][3][3] = BS_EDGE (uiBsx4[3], iRefIndex, pCurDqLayer->pMv[LIST_0][iMbXy], 15, 11); | 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 | } | ||
| 229 | } | 278 | } |
| 230 | 279 | ||
| 231 | uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { | 280 | uint32_t DeblockingBsMarginalMBAvcbase (PDqLayer pCurDqLayer, int32_t iEdge, int32_t iNeighMb, int32_t iMbXy) { |
| 232 | int32_t i; | 281 | int32_t i, j; |
| 233 | uint32_t uiBSx4; | 282 | uint32_t uiBSx4; |
| 234 | //uint8_t* bS = static_cast<uint8_t*>(&uiBSx4); | ||
| 235 | uint8_t* pBS = (uint8_t*) (&uiBSx4); | 283 | uint8_t* pBS = (uint8_t*) (&uiBSx4); |
| 236 | const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0]; | 284 | const uint8_t* pBIdx = &g_kuiTableBIdx[iEdge][0]; |
| 237 | const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4]; | 285 | const uint8_t* pBnIdx = &g_kuiTableBIdx[iEdge][4]; |
| 238 | 286 | const uint8_t* pB8x8Idx = &g_kuiTableB8x8Idx[iEdge][0]; | |
| 239 | for (i = 0; i < 4; i++) { | 287 | const uint8_t* pBn8x8Idx = &g_kuiTableB8x8Idx[iEdge][8]; |
| 240 | if (pCurDqLayer->pNzc[iMbXy][*pBIdx] | pCurDqLayer->pNzc[iNeighMb][*pBnIdx]) { | 288 | |
| 241 | pBS[i] = 2; | 289 | if (pCurDqLayer->pTransformSize8x8Flag[iMbXy] && pCurDqLayer->pTransformSize8x8Flag[iNeighMb]) { |
| 242 | } else { | 290 | for (i = 0; i < 2; i++) { |
| 243 | pBS[i] = MB_BS_MV (pCurDqLayer->pRefIndex[LIST_0], pCurDqLayer->pMv[LIST_0], iMbXy, iNeighMb, *pBIdx, | 291 | uint8_t uiNzc = 0; |
| 244 | *pBnIdx); | 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++; | ||
| 245 | } | 349 | } |
| 246 | pBIdx++; | ||
| 247 | pBnIdx++; | ||
| 248 | } | 350 | } |
| 351 | |||
| 249 | return uiBSx4; | 352 | return uiBSx4; |
| 250 | } | 353 | } |
| 251 | int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) { | 354 | int32_t DeblockingAvailableNoInterlayer (PDqLayer pCurDqLayer, int32_t iFilterIdc) { |
| @@ -501,7 +604,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 249 unmodified lines | |||
| 501 | pFilter->iChromaQP[0] = pCurChromaQp[0]; | 604 | pFilter->iChromaQP[0] = pCurChromaQp[0]; |
| 502 | pFilter->iChromaQP[1] = pCurChromaQp[1]; | 605 | pFilter->iChromaQP[1] = pCurChromaQp[1]; |
| 503 | 606 | ||
| 504 | if (* (uint32_t*)nBS[0][1] != 0) { | 607 | if (* (uint32_t*)nBS[0][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { |
| 505 | FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]); | 608 | FilteringEdgeLumaV (pFilter, &pDestY[1 << 2], iLineSize, nBS[0][1]); |
| 506 | } | 609 | } |
| 507 | 610 | ||
| @@ -510,7 +613,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 2 unmodified lines | |||
| 510 | FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]); | 613 | FilteringEdgeChromaV (pFilter, &pDestCb[2 << 1], &pDestCr[2 << 1], iLineSizeUV, nBS[0][2]); |
| 511 | } | 614 | } |
| 512 | 615 | ||
| 513 | if (* (uint32_t*)nBS[0][3] != 0) { | 616 | if (* (uint32_t*)nBS[0][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { |
| 514 | FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]); | 617 | FilteringEdgeLumaV (pFilter, &pDestY[3 << 2], iLineSize, nBS[0][3]); |
| 515 | } | 618 | } |
| 516 | 619 | ||
| @@ -536,7 +639,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 19 unmodified lines | |||
| 536 | pFilter->iChromaQP[0] = pCurChromaQp[0]; | 639 | pFilter->iChromaQP[0] = pCurChromaQp[0]; |
| 537 | pFilter->iChromaQP[1] = pCurChromaQp[1]; | 640 | pFilter->iChromaQP[1] = pCurChromaQp[1]; |
| 538 | 641 | ||
| 539 | if (* (uint32_t*)nBS[1][1] != 0) { | 642 | if (* (uint32_t*)nBS[1][1] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { |
| 540 | FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]); | 643 | FilteringEdgeLumaH (pFilter, &pDestY[ (1 << 2)*iLineSize], iLineSize, nBS[1][1]); |
| 541 | } | 644 | } |
| 542 | 645 | ||
| @@ -546,7 +649,7 @@ void DeblockingInterMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, uint8_ · 3 unmodified lines | |||
| 546 | nBS[1][2]); | 649 | nBS[1][2]); |
| 547 | } | 650 | } |
| 548 | 651 | ||
| 549 | if (* (uint32_t*)nBS[1][3] != 0) { | 652 | if (* (uint32_t*)nBS[1][3] != 0 && !pCurDqLayer->pTransformSize8x8Flag[iMbXyIndex]) { |
| 550 | FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]); | 653 | FilteringEdgeLumaH (pFilter, &pDestY[ (3 << 2)*iLineSize], iLineSize, nBS[1][3]); |
| 551 | } | 654 | } |
| 552 | } | 655 | } |
| @@ -581,9 +684,16 @@ void FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int3 · 28 unmodified lines | |||
| 581 | iBeta); | 684 | iBeta); |
| 582 | if (iAlpha | iBeta) { | 685 | if (iAlpha | iBeta) { |
| 583 | TC0_TBL_LOOKUP (iTc, iIndexA, uiBSx4, 0); | 686 | 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 | |||
| 585 | pFilter->pLoopf->pfLumaDeblockingLT4Hor (&pDestY[2 << 2], iLineSize, iAlpha, iBeta, iTc); | 692 | 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 | } | ||
| 587 | } | 697 | } |
| 588 | 698 | ||
| 589 | // luma h | 699 | // luma h |
| @@ -594,9 +704,15 @@ void FilteringEdgeLumaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int3 · 4 unmodified lines | |||
| 594 | 704 | ||
| 595 | pFilter->iLumaQP = iCurQp; | 705 | pFilter->iLumaQP = iCurQp; |
| 596 | if (iAlpha | iBeta) { | 706 | 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 | |||
| 598 | pFilter->pLoopf->pfLumaDeblockingLT4Ver (&pDestY[ (2 << 2)*iLineSize], iLineSize, iAlpha, iBeta, iTc); | 711 | 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 | } | ||
| 600 | } | 716 | } |
| 601 | } | 717 | } |
| 602 | void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { | 718 | void FilteringEdgeChromaHV (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t iBoundryFlag) { |
| @@ -705,6 +821,7 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t · 102 unmodified lines | |||
| 705 | 821 | ||
| 706 | switch (iCurMbType) { | 822 | switch (iCurMbType) { |
| 707 | case MB_TYPE_INTRA4x4: | 823 | case MB_TYPE_INTRA4x4: |
| 824 | case MB_TYPE_INTRA8x8: | ||
| 708 | case MB_TYPE_INTRA16x16: | 825 | case MB_TYPE_INTRA16x16: |
| 709 | case MB_TYPE_INTRA_PCM: | 826 | case MB_TYPE_INTRA_PCM: |
| 710 | DeblockingIntraMb (pCurDqLayer, pFilter, iBoundryFlag); | 827 | DeblockingIntraMb (pCurDqLayer, pFilter, iBoundryFlag); |
| @@ -728,7 +845,11 @@ void WelsDeblockingMb (PDqLayer pCurDqLayer, PDeblockingFilter pFilter, int32_t · 17 unmodified lines | |||
| 728 | //SKIP MB_16x16 or others | 845 | //SKIP MB_16x16 or others |
| 729 | if (iCurMbType != MB_TYPE_SKIP) { | 846 | if (iCurMbType != MB_TYPE_SKIP) { |
| 730 | if (iCurMbType == MB_TYPE_16x16) { | 847 | 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 | } | ||
| 732 | } else { | 853 | } else { |
| 733 | DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); | 854 | DeblockingBSInsideMBNormal (pCurDqLayer, nBS, pCurDqLayer->pNzc[iMbXyIndex], iMbXyIndex); |
| 734 | } | 855 | } |
| @@ -839,8 +960,8 @@ void DeblockingInit (SDeblockingFunc* pFunc, int32_t iCpu) { · 104 unmodified lines | |||
| 839 | if (iCpu & WELS_CPU_SSSE3) { | 960 | if (iCpu & WELS_CPU_SSSE3) { |
| 840 | pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_ssse3; | 961 | pFunc->pfLumaDeblockingLT4Ver = DeblockLumaLt4V_ssse3; |
| 841 | pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_ssse3; | 962 | pFunc->pfLumaDeblockingEQ4Ver = DeblockLumaEq4V_ssse3; |
| 842 | pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_ssse3; | 963 | pFunc->pfLumaDeblockingLT4Hor = DeblockLumaLt4H_ssse3; |
| 843 | pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_ssse3; | 964 | pFunc->pfLumaDeblockingEQ4Hor = DeblockLumaEq4H_ssse3; |
| 844 | pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_ssse3; | 965 | pFunc->pfChromaDeblockingLT4Ver = DeblockChromaLt4V_ssse3; |
| 845 | pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_ssse3; | 966 | pFunc->pfChromaDeblockingEQ4Ver = DeblockChromaEq4V_ssse3; |
| 846 | pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_ssse3; | 967 | pFunc->pfChromaDeblockingLT4Hor = DeblockChromaLt4H_ssse3; |
| @@ -76,6 +76,96 @@ void IdctResAddPred_c (uint8_t* pPred, const int32_t kiStride, int16_t* pRs) { · 75 unmodified lines | |||
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 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 | |||
| 79 | void GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) { | 169 | void GetI4LumaIChromaAddrTable (int32_t* pBlockOffset, const int32_t kiYStride, const int32_t kiUVStride) { |
| 80 | int32_t* pOffset = pBlockOffset; | 170 | int32_t* pOffset = pBlockOffset; |
| 81 | int32_t i; | 171 | int32_t i; |
| @@ -144,7 +144,6 @@ int32_t WelsTargetSliceConstruction (PWelsDecoderContext pCtx) { · 143 unmodified lines | |||
| 144 | return 0;//NO_SUPPORTED_FILTER_IDX | 144 | return 0;//NO_SUPPORTED_FILTER_IDX |
| 145 | } else { | 145 | } else { |
| 146 | WelsDeblockingFilterSlice (pCtx, pDeblockMb); | 146 | WelsDeblockingFilterSlice (pCtx, pDeblockMb); |
| 147 | |||
| 148 | } | 147 | } |
| 149 | // any other filter_idc not supported here, 7/22/2010 | 148 | // any other filter_idc not supported here, 7/22/2010 |
| 150 | 149 | ||
| @@ -159,11 +158,22 @@ int32_t WelsMbInterSampleConstruction (PWelsDecoderContext pCtx, PDqLayer pCurLa · 8 unmodified lines | |||
| 159 | WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16 | 158 | WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 256); // 256 = 16*16 |
| 160 | WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4 | 159 | WelsChromaDcIdct (pCurLayer->pScaledTCoeff[iMbXy] + 320); // 320 = 16*16 + 16*4 |
| 161 | 160 | ||
| 162 | for (i = 0; i < 16; i++) { //luma | 161 | if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { |
| 163 | iIndex = g_kuiMbCountScan4Idx[i]; | 162 | for (i = 0; i < 4; i++) { |
| 164 | if (pCurLayer->pNzc[iMbXy][iIndex]) { | 163 | iIndex = g_kuiMbCountScan4Idx[i << 2]; |
| 165 | iOffset = ((iIndex >> 2) << 2) * iStrideL + ((iIndex % 4) << 2); | 164 | if (pCurLayer->pNzc[iMbXy][iIndex] || pCurLayer->pNzc[iMbXy][iIndex + 1] || pCurLayer->pNzc[iMbXy][iIndex + 4] |
| 166 | pCtx->pIdctResAddPredFunc (pDstY + iOffset, iStrideL, pCurLayer->pScaledTCoeff[iMbXy] + (i << 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 | } | ||
| 167 | } | 177 | } |
| 168 | } | 178 | } |
| 169 | 179 | ||
| @@ -258,6 +268,10 @@ int32_t WelsMbIntraPredictionConstruction (PWelsDecoderContext pCtx, PDqLayer pC · 88 unmodified lines | |||
| 258 | return 0; | 268 | return 0; |
| 259 | } | 269 | } |
| 260 | 270 | ||
| 271 | if (IS_INTRA8x8 (pCurLayer->pMbType[iMbXy])) { | ||
| 272 | RecI8x8Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); | ||
| 273 | } | ||
| 274 | |||
| 261 | if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) | 275 | if (IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) |
| 262 | RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); | 276 | RecI4x4Mb (iMbXy, pCtx, pCurLayer->pScaledTCoeff[iMbXy], pCurLayer); |
| 263 | 277 | ||
| @@ -326,7 +340,7 @@ void WelsChromaDcIdct (int16_t* pBlock) { · 62 unmodified lines | |||
| 326 | pBlk[iStride1] = (iE - iB) >> 1; | 340 | pBlk[iStride1] = (iE - iB) >> 1; |
| 327 | } | 341 | } |
| 328 | 342 | ||
| 329 | void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { | 343 | void WelsMapNxNNeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { |
| 330 | if (pNeighAvail->iLeftAvail) { //left | 344 | if (pNeighAvail->iLeftAvail) { //left |
| 331 | pSampleAvail[ 6] = | 345 | pSampleAvail[ 6] = |
| 332 | pSampleAvail[12] = | 346 | pSampleAvail[12] = |
| @@ -347,7 +361,7 @@ void WelsMap4x4NeighToSampleNormal (PWelsNeighAvail pNeighAvail, int32_t* pSampl · 14 unmodified lines | |||
| 347 | } | 361 | } |
| 348 | } | 362 | } |
| 349 | 363 | ||
| 350 | void WelsMap4x4NeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { | 364 | void WelsMapNxNNeighToSampleConstrain1 (PWelsNeighAvail pNeighAvail, int32_t* pSampleAvail) { |
| 351 | if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left | 365 | if (pNeighAvail->iLeftAvail && IS_INTRA (pNeighAvail->iLeftType)) { //left |
| 352 | pSampleAvail[ 6] = | 366 | pSampleAvail[ 6] = |
| 353 | pSampleAvail[12] = | 367 | pSampleAvail[12] = |
| @@ -401,7 +415,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 47 unmodified lines | |||
| 401 | uint8_t uiNeighAvail = 0; | 415 | uint8_t uiNeighAvail = 0; |
| 402 | uint32_t uiCode; | 416 | uint32_t uiCode; |
| 403 | int32_t iCode; | 417 | int32_t iCode; |
| 404 | pCtx->pMap4x4NeighToSampleFunc (pNeighAvail, iSampleAvail); | 418 | pCtx->pMapNxNNeighToSampleFunc (pNeighAvail, iSampleAvail); |
| 405 | uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]); | 419 | uiNeighAvail = (iSampleAvail[6] << 2) | (iSampleAvail[0] << 1) | (iSampleAvail[1]); |
| 406 | for (i = 0; i < 16; i++) { | 420 | for (i = 0; i < 16; i++) { |
| 407 | int32_t iPrevIntra4x4PredMode = 0; | 421 | int32_t iPrevIntra4x4PredMode = 0; |
| @@ -429,7 +443,7 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 21 unmodified lines | |||
| 429 | } | 443 | } |
| 430 | } | 444 | } |
| 431 | 445 | ||
| 432 | iFinalMode = CheckIntra4x4PredMode (&iSampleAvail[0], &iBestMode, i); | 446 | iFinalMode = CheckIntraNxNPredMode (&iSampleAvail[0], &iBestMode, i, false); |
| 433 | if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) { | 447 | if (iFinalMode == ERR_INVALID_INTRA4X4_MODE) { |
| 434 | return ERR_INFO_INVALID_I4x4_PRED_MODE; | 448 | return ERR_INFO_INVALID_I4x4_PRED_MODE; |
| 435 | } | 449 | } |
| @@ -469,6 +483,87 @@ int32_t ParseIntra4x4Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail · 33 unmodified lines | |||
| 469 | return ERR_NONE; | 483 | return ERR_NONE; |
| 470 | } | 484 | } |
| 471 | 485 | ||
| 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 | |||
| 472 | int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs, | 567 | int32_t ParseIntra16x16Mode (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, PBitStringAux pBs, |
| 473 | PDqLayer pCurDqLayer) { | 568 | PDqLayer pCurDqLayer) { |
| 474 | int32_t iMbXy = pCurDqLayer->iMbXyIndex; | 569 | int32_t iMbXy = pCurDqLayer->iMbXyIndex; |
| @@ -519,6 +614,9 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 44 unmodified lines | |||
| 519 | 614 | ||
| 520 | ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); | 615 | ENFORCE_STACK_ALIGN_1D (uint8_t, pNonZeroCount, 48, 16); |
| 521 | 616 | ||
| 617 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 618 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 619 | |||
| 522 | pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; | 620 | pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; |
| 523 | pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; | 621 | pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; |
| 524 | GetNeighborAvailMbType (&sNeighAvail, pCurLayer); | 622 | GetNeighborAvailMbType (&sNeighAvail, pCurLayer); |
| @@ -539,8 +637,18 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 14 unmodified lines | |||
| 539 | } else if (0 == uiMbType) { //I4x4 | 637 | } else if (0 == uiMbType) { //I4x4 |
| 540 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); | 638 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 541 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; | 639 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 542 | pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | 640 | if (pCtx->pPps->bTransform8x8ModeFlag) { |
| 543 | WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | 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 | } | ||
| 544 | //get uiCbp for I4x4 | 652 | //get uiCbp for I4x4 |
| 545 | WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp)); | 653 | WELS_READ_VERIFY (ParseCbpInfoCabac (pCtx, &sNeighAvail, uiCbp)); |
| 546 | pCurLayer->pCbp[iMbXy] = uiCbp; | 654 | pCurLayer->pCbp[iMbXy] = uiCbp; |
| @@ -549,6 +657,8 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 2 unmodified lines | |||
| 549 | uiCbpLuma = uiCbp & 15; | 657 | uiCbpLuma = uiCbp & 15; |
| 550 | } else { //I16x16; | 658 | } else { //I16x16; |
| 551 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; | 659 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 660 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 661 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 552 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; | 662 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 553 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; | 663 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 554 | uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ; | 664 | uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0 ; |
| @@ -565,7 +675,7 @@ int32_t WelsDecodeMbCabacISliceBaseMode0 (PWelsDecoderContext pCtx, uint32_t& ui · 10 unmodified lines | |||
| 565 | ST32 (&pCurLayer->pNzc[iMbXy][20], 0); | 675 | ST32 (&pCurLayer->pNzc[iMbXy][20], 0); |
| 566 | pCurLayer->pCbfDc[iMbXy] = 0; | 676 | pCurLayer->pCbfDc[iMbXy] = 0; |
| 567 | 677 | ||
| 568 | if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRA4x4 (pCurLayer->pMbType[iMbXy])) { | 678 | if (pCurLayer->pCbp[iMbXy] == 0 && IS_INTRANxN (pCurLayer->pMbType[iMbXy])) { |
| 569 | pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; | 679 | pCurLayer->pLumaQp[iMbXy] = pSlice->iLastMbQp; |
| 570 | for (i = 0; i < 2; i++) { | 680 | for (i = 0; i < 2; i++) { |
| 571 | pCurLayer->pChromaQp[iMbXy][i] = g_kuiChromaQpTable[WELS_CLIP3 ((pCurLayer->pLumaQp[iMbXy] + | 681 | 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 | |||
| 608 | ST32 (&pCurLayer->pNzc[iMbXy][12], 0); | 718 | ST32 (&pCurLayer->pNzc[iMbXy][12], 0); |
| 609 | } | 719 | } |
| 610 | } else { //non-MB_TYPE_INTRA16x16 | 720 | } else { //non-MB_TYPE_INTRA16x16 |
| 611 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | 721 | if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { |
| 612 | if (uiCbpLuma & (1 << iId8x8)) { | 722 | // Transform 8x8 support for CABAC |
| 613 | int32_t iIdx = (iId8x8 << 2); | 723 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { |
| 614 | for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | 724 | if (uiCbpLuma & (1 << iId8x8)) { |
| 615 | //Luma (DC and AC decoding together) | 725 | WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (&sNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), |
| 616 | WELS_READ_VERIFY (ParseResidualBlockCabac (&sNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, | 726 | iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, LUMA_DC_AC_INTRA_8, |
| 617 | g_kuiZigzagScan + iScanIdxStart, LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), | 727 | pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); |
| 618 | pCurLayer->pLumaQp[iMbXy], | 728 | } else { |
| 619 | pCtx)); | 729 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); |
| 620 | iIdx++; | 730 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); |
| 621 | } | 731 | } |
| 622 | } else { | ||
| 623 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); | ||
| 624 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | ||
| 625 | } | 732 | } |
| 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])); | ||
| 626 | } | 757 | } |
| 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])); | ||
| 631 | } | 758 | } |
| 632 | int32_t iMbResProperty; | 759 | int32_t iMbResProperty; |
| 633 | //chroma | 760 | //chroma |
| @@ -730,10 +857,21 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 96 unmodified lines | |||
| 730 | if (0 == uiMbType) { //Intra4x4 | 857 | if (0 == uiMbType) { //Intra4x4 |
| 731 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); | 858 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 732 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; | 859 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 733 | pCtx->pFillInfoCacheIntra4x4Func (pNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | 860 | if (pCtx->pPps->bTransform8x8ModeFlag) { |
| 734 | WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, pNeighAvail, pIntraPredMode, pBsAux, pCurLayer)); | 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 | } | ||
| 735 | } else { //Intra16x16 | 871 | } else { //Intra16x16 |
| 736 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; | 872 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 873 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 874 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 737 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; | 875 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 738 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; | 876 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 739 | uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; | 877 | uiCbpChroma = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; |
| @@ -761,6 +899,23 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 21 unmodified lines | |||
| 761 | } | 899 | } |
| 762 | 900 | ||
| 763 | if (pCurLayer->pCbp[iMbXy] || MB_TYPE_INTRA16x16 == pCurLayer->pMbType[iMbXy]) { | 901 | 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 | |||
| 764 | memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); | 919 | memset (pCurLayer->pScaledTCoeff[iMbXy], 0, 384 * sizeof (pCurLayer->pScaledTCoeff[iMbXy][0])); |
| 765 | 920 | ||
| 766 | int32_t iQpDelta, iId8x8, iId4x4; | 921 | int32_t iQpDelta, iId8x8, iId4x4; |
| @@ -798,27 +953,46 @@ int32_t WelsDecodeMbCabacPSliceBaseMode0 (PWelsDecoderContext pCtx, PWelsNeighAv · 31 unmodified lines | |||
| 798 | ST32 (&pCurLayer->pNzc[iMbXy][12], 0); | 953 | ST32 (&pCurLayer->pNzc[iMbXy][12], 0); |
| 799 | } | 954 | } |
| 800 | } else { //non-MB_TYPE_INTRA16x16 | 955 | } else { //non-MB_TYPE_INTRA16x16 |
| 801 | iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | 956 | if (pCtx->pCurDqLayer->pTransformSize8x8Flag[iMbXy]) { |
| 802 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | 957 | // Transform 8x8 support for CABAC |
| 803 | if (uiCbpLuma & (1 << iId8x8)) { | 958 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { |
| 804 | int32_t iIdx = (iId8x8 << 2); | 959 | if (uiCbpLuma & (1 << iId8x8)) { |
| 805 | for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | 960 | WELS_READ_VERIFY (ParseResidualBlockCabac8x8 (pNeighAvail, pNonZeroCount, pBsAux, (iId8x8 << 2), |
| 806 | //Luma (DC and AC decoding together) | 961 | iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, |
| 807 | WELS_READ_VERIFY (ParseResidualBlockCabac (pNeighAvail, pNonZeroCount, pBsAux, iIdx, iScanIdxEnd - iScanIdxStart + 1, | 962 | IS_INTRA (pCurLayer->pMbType[iMbXy]) ? LUMA_DC_AC_INTRA_8 : LUMA_DC_AC_INTER_8, |
| 808 | g_kuiZigzagScan + iScanIdxStart, iMbResProperty, pCurLayer->pScaledTCoeff[iMbXy] + (iIdx << 4), | 963 | pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), pCurLayer->pLumaQp[iMbXy], pCtx)); |
| 809 | pCurLayer->pLumaQp[iMbXy], | 964 | } else { |
| 810 | pCtx)); | 965 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2)]], 0); |
| 811 | iIdx++; | 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); | ||
| 812 | } | 989 | } |
| 813 | } else { | ||
| 814 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[iId8x8 << 2]], 0); | ||
| 815 | ST16 (&pNonZeroCount[g_kCacheNzcScanIdx[ (iId8x8 << 2) + 2]], 0); | ||
| 816 | } | 990 | } |
| 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])); | ||
| 817 | } | 995 | } |
| 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])); | ||
| 822 | } | 996 | } |
| 823 | 997 | ||
| 824 | //chroma | 998 | //chroma |
| @@ -886,8 +1060,12 @@ int32_t WelsDecodeMbCabacPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 61 unmodified lines | |||
| 886 | pCurLayer->pCbfDc[iMbXy] = 0; | 1060 | pCurLayer->pCbfDc[iMbXy] = 0; |
| 887 | pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC; | 1061 | pCurLayer->pChromaPredMode[iMbXy] = C_PRED_DC; |
| 888 | 1062 | ||
| 1063 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 1064 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 1065 | |||
| 889 | GetNeighborAvailMbType (&uiNeighAvail, pCurLayer); | 1066 | GetNeighborAvailMbType (&uiNeighAvail, pCurLayer); |
| 890 | WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode)); | 1067 | WELS_READ_VERIFY (ParseSkipFlagCabac (pCtx, &uiNeighAvail, uiCode)); |
| 1068 | |||
| 891 | if (uiCode) { | 1069 | if (uiCode) { |
| 892 | int16_t pMv[2] = {0}; | 1070 | int16_t pMv[2] = {0}; |
| 893 | pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP; | 1071 | pCurLayer->pMbType[iMbXy] = MB_TYPE_SKIP; |
| @@ -943,30 +1121,23 @@ int32_t WelsCalcDeqCoeffScalingList (PWelsDecoderContext pCtx) { · 49 unmodified lines | |||
| 943 | //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) { | 1121 | //if (!pCtx->pSps->bSeqScalingListPresentFlag[i]) { |
| 944 | if (!pCtx->pPps->bPicScalingListPresentFlag[i]) { | 1122 | if (!pCtx->pPps->bPicScalingListPresentFlag[i]) { |
| 945 | if (i < 6) { | 1123 | if (i < 6) { |
| 946 | |||
| 947 | |||
| 948 | if (i == 0 || i == 3) | 1124 | if (i == 0 || i == 3) |
| 949 | memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t)); | 1125 | memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pSps->iScalingList4x4[i], 16 * sizeof (uint8_t)); |
| 950 | else | 1126 | else |
| 951 | memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t)); | 1127 | memcpy (pCtx->pPps->iScalingList4x4[i], pCtx->pPps->iScalingList4x4[i - 1], 16 * sizeof (uint8_t)); |
| 952 | } else { | 1128 | } else { |
| 953 | |||
| 954 | if (i == 6 || i == 7) | 1129 | if (i == 6 || i == 7) |
| 955 | memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t)); | 1130 | memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pSps->iScalingList8x8[ i - 6 ], 64 * sizeof (uint8_t)); |
| 956 | else | 1131 | else |
| 957 | memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pPps->iScalingList8x8[i - 8], 64 * sizeof (uint8_t)); | 1132 | memcpy (pCtx->pPps->iScalingList8x8[ i - 6 ], pCtx->pPps->iScalingList8x8[i - 8], 64 * sizeof (uint8_t)); |
| 958 | |||
| 959 | |||
| 960 | } | 1133 | } |
| 961 | |||
| 962 | } | 1134 | } |
| 963 | } | 1135 | } |
| 964 | |||
| 965 | |||
| 966 | } | 1136 | } |
| 967 | //Init dequant coeff value for different QP | 1137 | //Init dequant coeff value for different QP |
| 968 | for (i = 0; i < 6; i++) { | 1138 | for (i = 0; i < 6; i++) { |
| 969 | pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i]; | 1139 | pCtx->pDequant_coeff4x4[i] = pCtx->pDequant_coeff_buffer4x4[i]; |
| 1140 | pCtx->pDequant_coeff8x8[i] = pCtx->pDequant_coeff_buffer8x8[i]; | ||
| 970 | for (q = 0; q < 51; q++) { | 1141 | for (q = 0; q < 51; q++) { |
| 971 | for (x = 0; x < 16; x++) { | 1142 | for (x = 0; x < 16; x++) { |
| 972 | pCtx->pDequant_coeff4x4[i][q][x] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList4x4[i][x] * | 1143 | 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 | |||
| 974 | } | 1145 | } |
| 975 | for (y = 0; y < 64; y++) { | 1146 | for (y = 0; y < 64; y++) { |
| 976 | pCtx->pDequant_coeff8x8[i][q][y] = pCtx->pPps->bPicScalingMatrixPresentFlag ? pCtx->pPps->iScalingList8x8[i][y] * | 1147 | 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 & | 1148 | g_kuiMatrixV[q % 6][y / 8][y % 8] : pCtx->pSps->iScalingList8x8[i][y] * g_kuiMatrixV[q % 6][y / 8][y % 8]; |
| 978 | 0x07];//pseudo-code ,holding for 8x8transform into | ||
| 979 | } | 1149 | } |
| 980 | } | 1150 | } |
| 981 | } | 1151 | } |
| 982 | |||
| 983 | |||
| 984 | pCtx->bDequantCoeff4x4Init = true; | 1152 | pCtx->bDequantCoeff4x4Init = true; |
| 985 | pCtx->iDequantCoeffPpsid = pCtx->pPps->iPpsId; | 1153 | pCtx->iDequantCoeffPpsid = pCtx->pPps->iPpsId; |
| 986 | } | 1154 | } |
| @@ -1027,12 +1195,12 @@ int32_t WelsDecodeSlice (PWelsDecoderContext pCtx, bool bFirstSliceInLayer, PNal · 40 unmodified lines | |||
| 1027 | } | 1195 | } |
| 1028 | 1196 | ||
| 1029 | if (pSliceHeader->pPps->bConstainedIntraPredFlag) { | 1197 | if (pSliceHeader->pPps->bConstainedIntraPredFlag) { |
| 1030 | pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain1Intra4x4; | 1198 | pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain1IntraNxN; |
| 1031 | pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleConstrain1; | 1199 | pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleConstrain1; |
| 1032 | pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1; | 1200 | pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleConstrain1; |
| 1033 | } else { | 1201 | } else { |
| 1034 | pCtx->pFillInfoCacheIntra4x4Func = WelsFillCacheConstrain0Intra4x4; | 1202 | pCtx->pFillInfoCacheIntraNxNFunc = WelsFillCacheConstrain0IntraNxN; |
| 1035 | pCtx->pMap4x4NeighToSampleFunc = WelsMap4x4NeighToSampleNormal; | 1203 | pCtx->pMapNxNNeighToSampleFunc = WelsMapNxNNeighToSampleNormal; |
| 1036 | pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal; | 1204 | pCtx->pMap16x16NeighToSampleFunc = WelsMap16x16NeighToSampleNormal; |
| 1037 | } | 1205 | } |
| 1038 | 1206 | ||
| @@ -1117,6 +1285,9 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 78 unmodified lines | |||
| 1117 | pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; | 1285 | pCurLayer->pInterPredictionDoneFlag[iMbXy] = 0; |
| 1118 | pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; | 1286 | pCurLayer->pResidualPredFlag[iMbXy] = pSlice->sSliceHeaderExt.bDefaultResidualPredFlag; |
| 1119 | 1287 | ||
| 1288 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 1289 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 1290 | |||
| 1120 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType | 1291 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //uiMbType |
| 1121 | uiMbType = uiCode; | 1292 | uiMbType = uiCode; |
| 1122 | if (uiMbType > 25) | 1293 | if (uiMbType > 25) |
| @@ -1178,8 +1349,20 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 55 unmodified lines | |||
| 1178 | } else if (0 == uiMbType) { //reference to JM | 1349 | } else if (0 == uiMbType) { //reference to JM |
| 1179 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); | 1350 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 1180 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; | 1351 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 1181 | pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | 1352 | if (pCtx->pPps->bTransform8x8ModeFlag) { |
| 1182 | WELS_READ_VERIFY (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)); | 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 | } | ||
| 1183 | 1366 | ||
| 1184 | //uiCbp | 1367 | //uiCbp |
| 1185 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern | 1368 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //coded_block_pattern |
| @@ -1199,6 +1382,8 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 13 unmodified lines | |||
| 1199 | uiCbpL = uiCbp & 15; | 1382 | uiCbpL = uiCbp & 15; |
| 1200 | } else { //I_PCM exclude, we can ignore it | 1383 | } else { //I_PCM exclude, we can ignore it |
| 1201 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; | 1384 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 1385 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 1386 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 1202 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; | 1387 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 1203 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; | 1388 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 1204 | uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; | 1389 | uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; |
| @@ -1266,27 +1451,51 @@ int32_t WelsActualDecodeMbCavlcISlice (PWelsDecoderContext pCtx) { · 61 unmodified lines | |||
| 1266 | ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | 1451 | ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); |
| 1267 | } | 1452 | } |
| 1268 | } else { //non-MB_TYPE_INTRA16x16 | 1453 | } else { //non-MB_TYPE_INTRA16x16 |
| 1269 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | 1454 | if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { |
| 1270 | if (uiCbpL & (1 << iId8x8)) { | 1455 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { |
| 1271 | int32_t iIndex = (iId8x8 << 2); | 1456 | iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; |
| 1272 | for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | 1457 | if (uiCbpL & (1 << iId8x8)) { |
| 1273 | //Luma (DC and AC decoding together) | 1458 | int32_t iIndex = (iId8x8 << 2); |
| 1274 | if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, | 1459 | for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { |
| 1275 | iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, | 1460 | if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, |
| 1276 | LUMA_DC_AC_INTRA, pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) { | 1461 | iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, |
| 1277 | return -1;//abnormal | 1462 | pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) { |
| 1463 | return -1; | ||
| 1464 | } | ||
| 1465 | iIndex++; | ||
| 1278 | } | 1466 | } |
| 1279 | iIndex++; | 1467 | } else { |
| 1468 | ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0); | ||
| 1469 | ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | ||
| 1280 | } | 1470 | } |
| 1281 | } else { | ||
| 1282 | ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2)]], 0); | ||
| 1283 | ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | ||
| 1284 | } | 1471 | } |
| 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])); | ||
| 1285 | } | 1498 | } |
| 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])); | ||
| 1290 | } | 1499 | } |
| 1291 | 1500 | ||
| 1292 | //chroma | 1501 | //chroma |
| @@ -1399,6 +1608,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 106 unmodified lines | |||
| 1399 | int8_t iRefIndex[LIST_A][30]; | 1608 | int8_t iRefIndex[LIST_A][30]; |
| 1400 | pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType; | 1609 | pCurLayer->pMbType[iMbXy] = g_ksInterMbTypeInfo[uiMbType].iType; |
| 1401 | WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer); | 1610 | WelsFillCacheInter (&sNeighAvail, pNonZeroCount, iMotionVector, iRefIndex, pCurLayer); |
| 1611 | |||
| 1402 | if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) { | 1612 | if (ParseInterInfo (pCtx, iMotionVector, iRefIndex, pBs)) { |
| 1403 | return -1;//abnormal | 1613 | return -1;//abnormal |
| 1404 | } | 1614 | } |
| @@ -1484,12 +1694,24 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 79 unmodified lines | |||
| 1484 | if (0 == uiMbType) { | 1694 | if (0 == uiMbType) { |
| 1485 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); | 1695 | ENFORCE_STACK_ALIGN_1D (int8_t, pIntraPredMode, 48, 16); |
| 1486 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; | 1696 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA4x4; |
| 1487 | pCtx->pFillInfoCacheIntra4x4Func (&sNeighAvail, pNonZeroCount, pIntraPredMode, pCurLayer); | 1697 | if (pCtx->pPps->bTransform8x8ModeFlag) { |
| 1488 | if (ParseIntra4x4Mode (pCtx, &sNeighAvail, pIntraPredMode, pBs, pCurLayer)) { | 1698 | WELS_READ_VERIFY (BsGetOneBit (pBs, &uiCode)); //transform_size_8x8_flag |
| 1489 | return -1; | 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)); | ||
| 1490 | } | 1710 | } |
| 1491 | } else { //I_PCM exclude, we can ignore it | 1711 | } else { //I_PCM exclude, we can ignore it |
| 1492 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; | 1712 | pCurLayer->pMbType[iMbXy] = MB_TYPE_INTRA16x16; |
| 1713 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 1714 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 1493 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; | 1715 | pCurLayer->pIntraPredMode[iMbXy][7] = (uiMbType - 1) & 3; |
| 1494 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; | 1716 | pCurLayer->pCbp[iMbXy] = g_kuiI16CbpTable[ (uiMbType - 1) >> 2]; |
| 1495 | uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; | 1717 | uiCbpC = pCtx->pSps->uiChromaFormatIdc ? pCurLayer->pCbp[iMbXy] >> 4 : 0; |
| @@ -1510,7 +1732,7 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 14 unmodified lines | |||
| 1510 | return ERR_INFO_INVALID_CBP; | 1732 | return ERR_INFO_INVALID_CBP; |
| 1511 | if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15)) | 1733 | if (!pCtx->pSps->uiChromaFormatIdc && (uiCbp > 15)) |
| 1512 | return ERR_INFO_INVALID_CBP; | 1734 | 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]) { |
| 1514 | 1736 | ||
| 1515 | uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp]; | 1737 | uiCbp = pCtx->pSps->uiChromaFormatIdc ? g_kuiIntra4x4CbpTable[uiCbp] : g_kuiIntra4x4CbpTable400[uiCbp]; |
| 1516 | } else //inter | 1738 | } else //inter |
| @@ -1520,6 +1742,20 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 3 unmodified lines | |||
| 1520 | pCurLayer->pCbp[iMbXy] = uiCbp; | 1742 | pCurLayer->pCbp[iMbXy] = uiCbp; |
| 1521 | uiCbpC = pCurLayer->pCbp[iMbXy] >> 4; | 1743 | uiCbpC = pCurLayer->pCbp[iMbXy] >> 4; |
| 1522 | uiCbpL = pCurLayer->pCbp[iMbXy] & 15; | 1744 | 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 | } | ||
| 1523 | } | 1759 | } |
| 1524 | 1760 | ||
| 1525 | ST32A4 (&pNzc[0], 0); | 1761 | ST32A4 (&pNzc[0], 0); |
| @@ -1577,28 +1813,52 @@ int32_t WelsActualDecodeMbCavlcPSlice (PWelsDecoderContext pCtx) { · 51 unmodified lines | |||
| 1577 | ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); | 1813 | ST32A4 (&pNzc[12], LD32 (&pNonZeroCount[1 + 8 * 4])); |
| 1578 | } | 1814 | } |
| 1579 | } else { //non-MB_TYPE_INTRA16x16 | 1815 | } else { //non-MB_TYPE_INTRA16x16 |
| 1580 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { | 1816 | if (pCurLayer->pTransformSize8x8Flag[iMbXy]) { |
| 1581 | iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; | 1817 | for (iId8x8 = 0; iId8x8 < 4; iId8x8++) { |
| 1582 | if (uiCbpL & (1 << iId8x8)) { | 1818 | iMbResProperty = (IS_INTRA (pCurLayer->pMbType[iMbXy])) ? LUMA_DC_AC_INTRA : LUMA_DC_AC_INTER; |
| 1583 | int32_t iIndex = (iId8x8 << 2); | 1819 | if (uiCbpL & (1 << iId8x8)) { |
| 1584 | for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { | 1820 | int32_t iIndex = (iId8x8 << 2); |
| 1585 | //Luma (DC and AC decoding together) | 1821 | for (iId4x4 = 0; iId4x4 < 4; iId4x4++) { |
| 1586 | if (WelsResidualBlockCavlc (pVlcTable, pNonZeroCount, pBs, iIndex, | 1822 | if (WelsResidualBlockCavlc8x8 (pVlcTable, pNonZeroCount, pBs, iIndex, |
| 1587 | iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan + iScanIdxStart, iMbResProperty, | 1823 | iScanIdxEnd - iScanIdxStart + 1, g_kuiZigzagScan8x8 + iScanIdxStart, iMbResProperty, |
| 1588 | pCurLayer->pScaledTCoeff[iMbXy] + (iIndex << 4), pCurLayer->pLumaQp[iMbXy], pCtx)) { | 1824 | pCurLayer->pScaledTCoeff[iMbXy] + (iId8x8 << 6), iId4x4, pCurLayer->pLumaQp[iMbXy], pCtx)) { |
| 1589 | return -1;//abnormal | 1825 | return -1; |
| 1826 | } | ||
| 1827 | iIndex++; | ||
| 1590 | } | 1828 | } |
| 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); | ||
| 1592 | } | 1855 | } |
| 1593 | } else { | ||
| 1594 | ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[iId8x8 << 2]], 0); | ||
| 1595 | ST16 (&pNonZeroCount[g_kuiCache48CountScan4Idx[ (iId8x8 << 2) + 2]], 0); | ||
| 1596 | } | 1856 | } |
| 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])); | ||
| 1597 | } | 1861 | } |
| 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])); | ||
| 1602 | } | 1862 | } |
| 1603 | 1863 | ||
| 1604 | 1864 | ||
| @@ -1661,6 +1921,9 @@ int32_t WelsDecodeMbCavlcPSlice (PWelsDecoderContext pCtx, PNalUnit pNalCur, uin · 56 unmodified lines | |||
| 1661 | int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15 | 1921 | int32_t iRet = 0; //should have the return value to indicate decoding error or not, It's NECESSARY--2010.4.15 |
| 1662 | uint32_t uiCode; | 1922 | uint32_t uiCode; |
| 1663 | 1923 | ||
| 1924 | pCurLayer->pNoSubMbPartSizeLessThan8x8Flag[iMbXy] = true; | ||
| 1925 | pCurLayer->pTransformSize8x8Flag[iMbXy] = false; | ||
| 1926 | |||
| 1664 | if (-1 == pSlice->iMbSkipRun) { | 1927 | if (-1 == pSlice->iMbSkipRun) { |
| 1665 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run | 1928 | WELS_READ_VERIFY (BsGetUe (pBs, &uiCode)); //mb_skip_run |
| 1666 | pSlice->iMbSkipRun = uiCode; | 1929 | pSlice->iMbSkipRun = uiCode; |
| @@ -862,6 +862,21 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 861 unmodified lines | |||
| 862 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_c; | 862 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HU ] = WelsI4x4LumaPredHU_c; |
| 863 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_c; | 863 | pCtx->pGetI4x4LumaPredFunc[I4_PRED_HD ] = WelsI4x4LumaPredHD_c; |
| 864 | 864 | ||
| 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 | |||
| 865 | pCtx->pGetIChromaPredFunc[C_PRED_DC ] = WelsIChromaPredDc_c; | 880 | pCtx->pGetIChromaPredFunc[C_PRED_DC ] = WelsIChromaPredDc_c; |
| 866 | pCtx->pGetIChromaPredFunc[C_PRED_H ] = WelsIChromaPredH_c; | 881 | pCtx->pGetIChromaPredFunc[C_PRED_H ] = WelsIChromaPredH_c; |
| 867 | pCtx->pGetIChromaPredFunc[C_PRED_V ] = WelsIChromaPredV_c; | 882 | pCtx->pGetIChromaPredFunc[C_PRED_V ] = WelsIChromaPredV_c; |
| @@ -872,6 +887,8 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 4 unmodified lines | |||
| 872 | 887 | ||
| 873 | pCtx->pIdctResAddPredFunc = IdctResAddPred_c; | 888 | pCtx->pIdctResAddPredFunc = IdctResAddPred_c; |
| 874 | 889 | ||
| 890 | pCtx->pIdctResAddPredFunc8x8 = IdctResAddPred8x8_c; | ||
| 891 | |||
| 875 | #if defined(HAVE_NEON) | 892 | #if defined(HAVE_NEON) |
| 876 | if (pCtx->uiCpuFlag & WELS_CPU_NEON) { | 893 | if (pCtx->uiCpuFlag & WELS_CPU_NEON) { |
| 877 | pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; | 894 | pCtx->pIdctResAddPredFunc = IdctResAddPred_neon; |
| @@ -931,7 +948,7 @@ void AssignFuncPointerForRec (PWelsDecoderContext pCtx) { · 53 unmodified lines | |||
| 931 | if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { | 948 | if (pCtx->uiCpuFlag & WELS_CPU_MMXEXT) { |
| 932 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; | 949 | pCtx->pIdctResAddPredFunc = IdctResAddPred_mmx; |
| 933 | 950 | ||
| 934 | /////////mmx code opt--- | 951 | ///////mmx code opt--- |
| 935 | pCtx->pGetIChromaPredFunc[C_PRED_H] = WelsDecoderIChromaPredH_mmx; | 952 | pCtx->pGetIChromaPredFunc[C_PRED_H] = WelsDecoderIChromaPredH_mmx; |
| 936 | pCtx->pGetIChromaPredFunc[C_PRED_V] = WelsDecoderIChromaPredV_mmx; | 953 | pCtx->pGetIChromaPredFunc[C_PRED_V] = WelsDecoderIChromaPredV_mmx; |
| 937 | pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsDecoderIChromaPredDcLeft_mmx; | 954 | pCtx->pGetIChromaPredFunc[C_PRED_DC_L ] = WelsDecoderIChromaPredDcLeft_mmx; |
| @@ -1238,11 +1238,16 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 1237 unmodified lines | |||
| 1238 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); | 1238 | int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pRefIndex[][]"); |
| 1239 | pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1239 | pCtx->sMb.pLumaQp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1240 | "pCtx->sMb.pLumaQp[]"); | 1240 | "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[]"); | ||
| 1241 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2, | 1246 | pCtx->sMb.pChromaQp[i] = (int8_t (*)[2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 2, |
| 1242 | "pCtx->sMb.pChromaQp[]"); | 1247 | "pCtx->sMb.pChromaQp[]"); |
| 1243 | pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( | 1248 | pCtx->sMb.pMvd[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof ( |
| 1244 | int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMvd[][]"); | 1249 | 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), |
| 1246 | "pCtx->sMb.pCbfDc[]"); | 1251 | "pCtx->sMb.pCbfDc[]"); |
| 1247 | pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, | 1252 | pCtx->sMb.pNzc[i] = (int8_t (*)[24])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t) * 24, |
| 1248 | "pCtx->sMb.pNzc[]"); | 1253 | "pCtx->sMb.pNzc[]"); |
| @@ -1255,6 +1260,8 @@ int32_t InitialDqLayersContext (PWelsDecoderContext pCtx, const int32_t kiMaxWid · 6 unmodified lines | |||
| 1255 | "pCtx->sMb.pIntraPredMode[]"); | 1260 | "pCtx->sMb.pIntraPredMode[]"); |
| 1256 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * | 1261 | pCtx->sMb.pIntra4x4FinalMode[i] = (int8_t (*)[MB_BLOCK4x4_NUM])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * |
| 1257 | sizeof (int8_t) * MB_BLOCK4x4_NUM, "pCtx->sMb.pIntra4x4FinalMode[]"); | 1262 | 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"); | ||
| 1258 | pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1265 | pCtx->sMb.pChromaPredMode[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), |
| 1259 | "pCtx->sMb.pChromaPredMode[]"); | 1266 | "pCtx->sMb.pChromaPredMode[]"); |
| 1260 | pCtx->sMb.pCbp[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t), | 1267 | 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 | |||
| 1341 | pCtx->sMb.pRefIndex[i][0] = NULL; | 1348 | pCtx->sMb.pRefIndex[i][0] = NULL; |
| 1342 | } | 1349 | } |
| 1343 | 1350 | ||
| 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 | |||
| 1344 | if (pCtx->sMb.pLumaQp[i]) { | 1363 | if (pCtx->sMb.pLumaQp[i]) { |
| 1345 | WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]"); | 1364 | WelsFree (pCtx->sMb.pLumaQp[i], "pCtx->sMb.pLumaQp[]"); |
| 1346 | 1365 | ||
| @@ -1393,6 +1412,12 @@ void UninitialDqLayersContext (PWelsDecoderContext pCtx) { · 46 unmodified lines | |||
| 1393 | pCtx->sMb.pIntra4x4FinalMode[i] = NULL; | 1412 | pCtx->sMb.pIntra4x4FinalMode[i] = NULL; |
| 1394 | } | 1413 | } |
| 1395 | 1414 | ||
| 1415 | if (pCtx->sMb.pIntraNxNAvailFlag[i]) { | ||
| 1416 | WelsFree (pCtx->sMb.pIntraNxNAvailFlag[i], "pCtx->sMb.pIntraNxNAvailFlag"); | ||
| 1417 | |||
| 1418 | pCtx->sMb.pIntraNxNAvailFlag[i] = NULL; | ||
| 1419 | } | ||
| 1420 | |||
| 1396 | if (pCtx->sMb.pChromaPredMode[i]) { | 1421 | if (pCtx->sMb.pChromaPredMode[i]) { |
| 1397 | WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]"); | 1422 | WelsFree (pCtx->sMb.pChromaPredMode[i], "pCtx->sMb.pChromaPredMode[]"); |
| 1398 | 1423 | ||
| @@ -1989,7 +2014,7 @@ static inline void InitDqLayerInfo (PDqLayer pDqLayer, PLayerInfo pLayerInfo, PN · 590 unmodified lines | |||
| 1989 | if (kuiQualityId == BASE_QUALITY_ID) { | 2014 | if (kuiQualityId == BASE_QUALITY_ID) { |
| 1990 | pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering; | 2015 | pDqLayer->pRefPicListReordering = &pSh->pRefPicListReordering; |
| 1991 | pDqLayer->pRefPicMarking = &pSh->sRefMarking; | 2016 | pDqLayer->pRefPicMarking = &pSh->sRefMarking; |
| 1992 | 2017 | ||
| 1993 | if (pSh->pPps->bWeightedPredFlag) { | 2018 | if (pSh->pPps->bWeightedPredFlag) { |
| 1994 | pDqLayer->bUseWeightPredictionFlag = true; | 2019 | pDqLayer->bUseWeightPredictionFlag = true; |
| 1995 | pDqLayer->pPredWeightTable = &pSh->sPredWeightTable; | 2020 | pDqLayer->pPredWeightTable = &pSh->sPredWeightTable; |
| @@ -2029,6 +2054,8 @@ void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { · 33 unmodified lines | |||
| 2029 | pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0]; | 2054 | pCurDq->pSliceIdc = pCtx->sMb.pSliceIdc[0]; |
| 2030 | pCurDq->pMv[0] = pCtx->sMb.pMv[0][0]; | 2055 | pCurDq->pMv[0] = pCtx->sMb.pMv[0][0]; |
| 2031 | pCurDq->pRefIndex[0] = pCtx->sMb.pRefIndex[0][0]; | 2056 | pCurDq->pRefIndex[0] = pCtx->sMb.pRefIndex[0][0]; |
| 2057 | pCurDq->pNoSubMbPartSizeLessThan8x8Flag = pCtx->sMb.pNoSubMbPartSizeLessThan8x8Flag[0]; | ||
| 2058 | pCurDq->pTransformSize8x8Flag = pCtx->sMb.pTransformSize8x8Flag[0]; | ||
| 2032 | pCurDq->pLumaQp = pCtx->sMb.pLumaQp[0]; | 2059 | pCurDq->pLumaQp = pCtx->sMb.pLumaQp[0]; |
| 2033 | pCurDq->pChromaQp = pCtx->sMb.pChromaQp[0]; | 2060 | pCurDq->pChromaQp = pCtx->sMb.pChromaQp[0]; |
| 2034 | pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0]; | 2061 | pCurDq->pMvd[0] = pCtx->sMb.pMvd[0][0]; |
| @@ -2038,6 +2065,7 @@ void InitCurDqLayerData (PWelsDecoderContext pCtx, PDqLayer pCurDq) { · 3 unmodified lines | |||
| 2038 | pCurDq->pScaledTCoeff = pCtx->sMb.pScaledTCoeff[0]; | 2065 | pCurDq->pScaledTCoeff = pCtx->sMb.pScaledTCoeff[0]; |
| 2039 | pCurDq->pIntraPredMode = pCtx->sMb.pIntraPredMode[0]; | 2066 | pCurDq->pIntraPredMode = pCtx->sMb.pIntraPredMode[0]; |
| 2040 | pCurDq->pIntra4x4FinalMode = pCtx->sMb.pIntra4x4FinalMode[0]; | 2067 | pCurDq->pIntra4x4FinalMode = pCtx->sMb.pIntra4x4FinalMode[0]; |
| 2068 | pCurDq->pIntraNxNAvailFlag = pCtx->sMb.pIntraNxNAvailFlag[0]; | ||
| 2041 | pCurDq->pChromaPredMode = pCtx->sMb.pChromaPredMode[0]; | 2069 | pCurDq->pChromaPredMode = pCtx->sMb.pChromaPredMode[0]; |
| 2042 | pCurDq->pCbp = pCtx->sMb.pCbp[0]; | 2070 | pCurDq->pCbp = pCtx->sMb.pCbp[0]; |
| 2043 | pCurDq->pSubMbType = pCtx->sMb.pSubMbType[0]; | 2071 | pCurDq->pSubMbType = pCtx->sMb.pSubMbType[0]; |
| @@ -380,6 +380,507 @@ void WelsI4x4LumaPredHD_c (uint8_t* pPred, const int32_t kiStride) { · 379 unmodified lines | |||
| 380 | ST32A4 (pPred + kiStride3, LD32 (kuiList)); | 380 | ST32A4 (pPred + kiStride3, LD32 (kuiList)); |
| 381 | } | 381 | } |
| 382 | 382 | ||
| 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 | |||
| 383 | void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) { | 884 | void WelsIChromaPredV_c (uint8_t* pPred, const int32_t kiStride) { |
| 384 | const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]); | 885 | const uint64_t kuiVal64 = LD64A8 (&pPred[-kiStride]); |
| 385 | const int32_t kiStride2 = kiStride << 1; | 886 | const int32_t kiStride2 = kiStride << 1; |
| @@ -127,7 +127,7 @@ int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) { · 126 unmodified lines | |||
| 127 | || (ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->eErrorConMethod) | 127 | || (ERROR_CON_SLICE_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->eErrorConMethod) |
| 128 | || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR == pCtx->eErrorConMethod) | 128 | || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR == pCtx->eErrorConMethod) |
| 129 | || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->eErrorConMethod)) | 129 | || (ERROR_CON_SLICE_MV_COPY_CROSS_IDR_FREEZE_RES_CHANGE == pCtx->eErrorConMethod)) |
| 130 | && (NULL != pCtx->pPreviousDecodedPictureInDpb); | 130 | && (NULL != pCtx->pPreviousDecodedPictureInDpb); |
| 131 | bCopyPrevious = bCopyPrevious && (pRef->iWidthInPixel == pCtx->pPreviousDecodedPictureInDpb->iWidthInPixel) | 131 | bCopyPrevious = bCopyPrevious && (pRef->iWidthInPixel == pCtx->pPreviousDecodedPictureInDpb->iWidthInPixel) |
| 132 | && (pRef->iHeightInPixel == pCtx->pPreviousDecodedPictureInDpb->iHeightInPixel); | 132 | && (pRef->iHeightInPixel == pCtx->pPreviousDecodedPictureInDpb->iHeightInPixel); |
| 133 | 133 | ||
| @@ -35,13 +35,14 @@ · 34 unmodified lines | |||
| 35 | #include "error_code.h" | 35 | #include "error_code.h" |
| 36 | namespace WelsDec { | 36 | namespace WelsDec { |
| 37 | #define IDX_UNUSED -1 | 37 | #define IDX_UNUSED -1 |
| 38 | static const int16_t g_kMaxPos [] = {IDX_UNUSED, 15, 14, 15, 3, 14, 3, 3, 14, 14}; | 38 | |
| 39 | static const int16_t g_kMaxC2 [] = {IDX_UNUSED, 4, 4, 4, 3, 4, 3, 3, 4, 4}; | 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_kBlockCat2CtxOffsetCBF[] = {IDX_UNUSED, 0, 4, 8, 12, 16, 12, 12, 16, 16}; | 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_kBlockCat2CtxOffsetMap [] = {IDX_UNUSED, 0, 15, 29, 44, 47, 44, 44, 47, 47}; | 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_kBlockCat2CtxOffsetLast[] = {IDX_UNUSED, 0, 15, 29, 44, 47, 44, 44, 47, 47}; | 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_kBlockCat2CtxOffsetOne [] = {IDX_UNUSED, 0 , 10, 20, 30, 39, 30, 30, 39, 39}; | 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_kBlockCat2CtxOffsetAbs [] = {IDX_UNUSED, 0 , 10, 20, 30, 39, 30, 30, 39, 39}; | 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}; | ||
| 45 | 46 | ||
| 46 | const uint8_t g_kTopBlkInsideMb[24] = { //for index with z-order 0~23 | 47 | const uint8_t g_kTopBlkInsideMb[24] = { //for index with z-order 0~23 |
| 47 | // 0 1 | 4 5 luma 8*8 block pNonZeroCount[16+8] | 48 | // 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 | |||
| 275 | } | 276 | } |
| 276 | return ERR_NONE; | 277 | return ERR_NONE; |
| 277 | } | 278 | } |
| 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 | |||
| 278 | int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType) { | 297 | int32_t ParseSubMBTypeCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNeighAvail, uint32_t& uiSubMbType) { |
| 279 | uint32_t uiCode; | 298 | uint32_t uiCode; |
| 280 | PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine; | 299 | PWelsCabacDecEngine pCabacDecEngine = pCtx->pCabacDecEngine; |
| @@ -471,6 +490,9 @@ int32_t ParseInterMotionInfoCabac (PWelsDecoderContext pCtx, PWelsNeighAvail pNe · 190 unmodified lines | |||
| 471 | pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType; | 490 | pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType; |
| 472 | pSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount; | 491 | pSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount; |
| 473 | pPartW[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartWidth; | 492 | 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); | ||
| 474 | } | 496 | } |
| 475 | 497 | ||
| 476 | for (i = 0; i < 4; i++) { | 498 | for (i = 0; i < 4; i++) { |
| @@ -721,7 +743,7 @@ int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int3 · 244 unmodified lines | |||
| 721 | int32_t iCurrBlkXy = pCtx->pCurDqLayer->iMbXyIndex; | 743 | int32_t iCurrBlkXy = pCtx->pCurDqLayer->iMbXyIndex; |
| 722 | int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring | 744 | int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring |
| 723 | int32_t iLeftBlkXy = iCurrBlkXy - 1; //default value: MB neighboring | 745 | int32_t iLeftBlkXy = iCurrBlkXy - 1; //default value: MB neighboring |
| 724 | uint8_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc; | 746 | uint16_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc; |
| 725 | int16_t* pMbType = pCtx->pCurDqLayer->pMbType; | 747 | int16_t* pMbType = pCtx->pCurDqLayer->pMbType; |
| 726 | int32_t iCtxInc; | 748 | int32_t iCtxInc; |
| 727 | uiCbfBit = 0; | 749 | uiCbfBit = 0; |
| @@ -760,22 +782,30 @@ int32_t ParseCbfInfoCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNzcCache, int3 · 32 unmodified lines | |||
| 760 | int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty, PWelsDecoderContext pCtx, | 782 | int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty, PWelsDecoderContext pCtx, |
| 761 | uint32_t& uiCoeffNum) { | 783 | uint32_t& uiCoeffNum) { |
| 762 | uint32_t uiCode; | 784 | uint32_t uiCode; |
| 763 | PWelsCabacCtx pMapCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_MAP + g_kBlockCat2CtxOffsetMap [iResProperty]; | 785 | |
| 764 | PWelsCabacCtx pLastCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_LAST + g_kBlockCat2CtxOffsetLast[iResProperty]; | 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 | |||
| 765 | 791 | ||
| 766 | int32_t i; | 792 | int32_t i; |
| 767 | uiCoeffNum = 0; | 793 | uiCoeffNum = 0; |
| 768 | int32_t i0 = 0; | 794 | int32_t i0 = 0; |
| 769 | int32_t i1 = g_kMaxPos[iResProperty]; | 795 | int32_t i1 = g_kMaxPos[iResProperty]; |
| 770 | 796 | ||
| 797 | int32_t iCtx; | ||
| 798 | |||
| 771 | for (i = i0; i < i1; ++i) { | 799 | for (i = i0; i < i1; ++i) { |
| 800 | iCtx = (iResProperty == LUMA_DC_AC_8 ? g_kuiIdx2CtxSignificantCoeffFlag8x8[i] : i); | ||
| 772 | //read significant | 801 | //read significant |
| 773 | WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pMapCtx + i, uiCode)); | 802 | WELS_READ_VERIFY (DecodeBinCabac (pCtx->pCabacDecEngine, pMapCtx + iCtx, uiCode)); |
| 774 | if (uiCode) { | 803 | if (uiCode) { |
| 775 | * (pSignificantMap++) = 1; | 804 | * (pSignificantMap++) = 1; |
| 776 | ++ uiCoeffNum; | 805 | ++ uiCoeffNum; |
| 777 | //read last significant | 806 | //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)); | ||
| 779 | if (uiCode) { | 809 | if (uiCode) { |
| 780 | memset (pSignificantMap, 0, (i1 - i) * sizeof (int32_t)); | 810 | memset (pSignificantMap, 0, (i1 - i) * sizeof (int32_t)); |
| 781 | return ERR_NONE; | 811 | return ERR_NONE; |
| @@ -796,8 +826,11 @@ int32_t ParseSignificantMapCabac (int32_t* pSignificantMap, int32_t iResProperty · 14 unmodified lines | |||
| 796 | 826 | ||
| 797 | int32_t ParseSignificantCoeffCabac (int32_t* pSignificant, int32_t iResProperty, PWelsDecoderContext pCtx) { | 827 | int32_t ParseSignificantCoeffCabac (int32_t* pSignificant, int32_t iResProperty, PWelsDecoderContext pCtx) { |
| 798 | uint32_t uiCode; | 828 | uint32_t uiCode; |
| 799 | PWelsCabacCtx pOneCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_ONE + g_kBlockCat2CtxOffsetOne[iResProperty]; | 829 | PWelsCabacCtx pOneCtx = pCtx->pCabacCtx + (iResProperty == LUMA_DC_AC_8 ? NEW_CTX_OFFSET_ONE_8x8 : NEW_CTX_OFFSET_ONE) + |
| 800 | PWelsCabacCtx pAbsCtx = pCtx->pCabacCtx + NEW_CTX_OFFSET_ABS + g_kBlockCat2CtxOffsetAbs[iResProperty]; | 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 | |||
| 801 | const int16_t iMaxType = g_kMaxC2[iResProperty]; | 834 | const int16_t iMaxType = g_kMaxC2[iResProperty]; |
| 802 | int32_t i = g_kMaxPos[iResProperty]; | 835 | int32_t i = g_kMaxPos[iResProperty]; |
| 803 | int32_t* pCoff = pSignificant + i; | 836 | int32_t* pCoff = pSignificant + i; |
| @@ -826,6 +859,46 @@ int32_t ParseSignificantCoeffCabac (int32_t* pSignificant, int32_t iResProperty, · 22 unmodified lines | |||
| 826 | return ERR_NONE; | 859 | return ERR_NONE; |
| 827 | } | 860 | } |
| 828 | 861 | ||
| 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 | |||
| 829 | int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux, | 902 | int32_t ParseResidualBlockCabac (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCountCache, SBitStringAux* pBsAux, |
| 830 | int32_t iIndex, int32_t iMaxNumCoeff, | 903 | int32_t iIndex, int32_t iMaxNumCoeff, |
| 831 | const uint8_t* pScanTable, int32_t iResProperty, short* sTCoeff, /*int mb_mode*/ uint8_t uiQp, | 904 | const uint8_t* pScanTable, int32_t iResProperty, short* sTCoeff, /*int mb_mode*/ uint8_t uiQp, |
| @@ -151,7 +151,7 @@ void WelsFillCacheNonZeroCount (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCo · 150 unmodified lines | |||
| 151 | pNonZeroCount[5 + 8 * 5] = -1;//unavailable | 151 | pNonZeroCount[5 + 8 * 5] = -1;//unavailable |
| 152 | } | 152 | } |
| 153 | } | 153 | } |
| 154 | void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | 154 | void WelsFillCacheConstrain1IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, |
| 155 | PDqLayer pCurLayer) { //no matter slice type | 155 | PDqLayer pCurLayer) { //no matter slice type |
| 156 | int32_t iCurXy = pCurLayer->iMbXyIndex; | 156 | int32_t iCurXy = pCurLayer->iMbXyIndex; |
| 157 | int32_t iTopXy = 0; | 157 | int32_t iTopXy = 0; |
| @@ -197,7 +197,7 @@ void WelsFillCacheConstrain1Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 39 unmodified lines | |||
| 197 | } | 197 | } |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, | 200 | void WelsFillCacheConstrain0IntraNxN (PWelsNeighAvail pNeighAvail, uint8_t* pNonZeroCount, int8_t* pIntraPredMode, |
| 201 | PDqLayer pCurLayer) { //no matter slice type | 201 | PDqLayer pCurLayer) { //no matter slice type |
| 202 | int32_t iCurXy = pCurLayer->iMbXyIndex; | 202 | int32_t iCurXy = pCurLayer->iMbXyIndex; |
| 203 | int32_t iTopXy = 0; | 203 | int32_t iTopXy = 0; |
| @@ -214,7 +214,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 10 unmodified lines | |||
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | //intra4x4_pred_mode | 216 | //intra4x4_pred_mode |
| 217 | if (pNeighAvail->iTopAvail && IS_INTRA4x4 (pNeighAvail->iTopType)) { //top | 217 | if (pNeighAvail->iTopAvail && IS_INTRANxN (pNeighAvail->iTopType)) { //top |
| 218 | ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0])); | 218 | ST32 (pIntraPredMode + 1, LD32 (&pCurLayer->pIntraPredMode[iTopXy][0])); |
| 219 | } else { | 219 | } else { |
| 220 | int32_t iPred; | 220 | int32_t iPred; |
| @@ -225,7 +225,7 @@ void WelsFillCacheConstrain0Intra4x4 (PWelsNeighAvail pNeighAvail, uint8_t* pNon · 4 unmodified lines | |||
| 225 | ST32 (pIntraPredMode + 1, iPred); | 225 | ST32 (pIntraPredMode + 1, iPred); |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | if (pNeighAvail->iLeftAvail && IS_INTRA4x4 (pNeighAvail->iLeftType)) { //left | 228 | if (pNeighAvail->iLeftAvail && IS_INTRANxN (pNeighAvail->iLeftType)) { //left |
| 229 | pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4]; | 229 | pIntraPredMode[ 0 + 8 * 1] = pCurLayer->pIntraPredMode[iLeftXy][4]; |
| 230 | pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5]; | 230 | pIntraPredMode[ 0 + 8 * 2] = pCurLayer->pIntraPredMode[iLeftXy][5]; |
| 231 | pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6]; | 231 | pIntraPredMode[ 0 + 8 * 3] = pCurLayer->pIntraPredMode[iLeftXy][6]; |
| @@ -565,12 +565,13 @@ int32_t CheckIntraChromaPredMode (uint8_t uiSampleAvail, int8_t* pMode) { · 333 unmodified lines | |||
| 565 | return 0; | 565 | return 0; |
| 566 | } | 566 | } |
| 567 | 567 | ||
| 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) { |
| 569 | int8_t iIdx = g_kuiCache30ScanIdx[iIndex]; | 569 | int8_t iIdx = g_kuiCache30ScanIdx[iIndex]; |
| 570 | |||
| 570 | int32_t iLeftAvail = pSampleAvail[iIdx - 1]; | 571 | int32_t iLeftAvail = pSampleAvail[iIdx - 1]; |
| 571 | int32_t iTopAvail = pSampleAvail[iIdx - 6]; | 572 | int32_t iTopAvail = pSampleAvail[iIdx - 6]; |
| 572 | int32_t bLeftTopAvail = pSampleAvail[iIdx - 7]; | 573 | 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 |
| 574 | 575 | ||
| 575 | int8_t iFinalMode; | 576 | int8_t iFinalMode; |
| 576 | 577 | ||
| @@ -900,6 +901,93 @@ int32_t WelsResidualBlockCavlc (SVlcTable* pVlcTable, uint8_t* pNonZeroCountCach · 323 unmodified lines | |||
| 900 | return 0; | 901 | return 0; |
| 901 | } | 902 | } |
| 902 | 903 | ||
| 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 | |||
| 903 | int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], | 991 | int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][MV_A], int8_t iRefIdxArray[LIST_A][30], |
| 904 | PBitStringAux pBs) { | 992 | PBitStringAux pBs) { |
| 905 | PSlice pSlice = &pCtx->pCurDqLayer->sLayerInfo.sSliceInLayer; | 993 | 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 | |||
| 941 | return ERR_INFO_INVALID_REF_INDEX; | 1029 | return ERR_INFO_INVALID_REF_INDEX; |
| 942 | } | 1030 | } |
| 943 | } | 1031 | } |
| 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); | ||
| 945 | } else { | 1034 | } else { |
| 946 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); | 1035 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); |
| 947 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); | 1036 | 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 | |||
| 981 | return ERR_INFO_INVALID_REF_INDEX; | 1070 | return ERR_INFO_INVALID_REF_INDEX; |
| 982 | } | 1071 | } |
| 983 | } | 1072 | } |
| 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); | ||
| 985 | } | 1075 | } |
| 986 | for (i = 0; i < 2; i++) { | 1076 | for (i = 0; i < 2; i++) { |
| 987 | PredInter16x8Mv (iMvArray, iRefIdxArray, i << 3, iRefIdx[i], iMv); | 1077 | 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 | |||
| 1017 | return ERR_INFO_INVALID_REF_INDEX; | 1107 | return ERR_INFO_INVALID_REF_INDEX; |
| 1018 | } | 1108 | } |
| 1019 | } | 1109 | } |
| 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); | ||
| 1021 | } else { | 1112 | } else { |
| 1022 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); | 1113 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_WARNING, "inter parse: iMotionPredFlag = 1 not supported. "); |
| 1023 | return GENERATE_ERROR_NO (ERR_LEVEL_MB_DATA, ERR_INFO_UNSUPPORTED_ILP); | 1114 | 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 | |||
| 1056 | pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType; | 1147 | pCurDqLayer->pSubMbType[iMbXy][i] = g_ksInterSubMbTypeInfo[uiSubMbType].iType; |
| 1057 | iSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount; | 1148 | iSubPartCount[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartCount; |
| 1058 | iPartWidth[i] = g_ksInterSubMbTypeInfo[uiSubMbType].iPartWidth; | 1149 | 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); | ||
| 1059 | } | 1153 | } |
| 1060 | 1154 | ||
| 1061 | if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) { | 1155 | if (pSlice->sSliceHeaderExt.bAdaptiveMotionPredFlag) { |
| @@ -1085,7 +1179,8 @@ int32_t ParseInterInfo (PWelsDecoderContext pCtx, int16_t iMvArray[LIST_A][30][M · 23 unmodified lines | |||
| 1085 | return ERR_INFO_INVALID_REF_INDEX; | 1179 | return ERR_INFO_INVALID_REF_INDEX; |
| 1086 | } | 1180 | } |
| 1087 | } | 1181 | } |
| 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); | ||
| 1089 | 1184 | ||
| 1090 | pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] = | 1185 | pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx ] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 1] = |
| 1091 | pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i]; | 1186 | pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 4] = pCurDqLayer->pRefIndex[0][iMbXy][uiScan4Idx + 5] = iRefIdx[i]; |
| @@ -61,12 +61,66 @@ void WelsFillRecNeededMbInfo (PWelsDecoderContext pCtx, bool bOutput, PDqLayer p · 60 unmodified lines | |||
| 61 | } | 61 | } |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 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 | |||
| 64 | int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) { | 117 | int32_t RecI4x4Mb (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) { |
| 65 | RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer); | 118 | RecI4x4Luma (iMBXY, pCtx, pScoeffLevel, pDqLayer); |
| 66 | RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer); | 119 | RecI4x4Chroma (iMBXY, pCtx, pScoeffLevel, pDqLayer); |
| 67 | return ERR_NONE; | 120 | return ERR_NONE; |
| 68 | } | 121 | } |
| 69 | 122 | ||
| 123 | |||
| 70 | int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) { | 124 | int32_t RecI4x4Luma (int32_t iMBXY, PWelsDecoderContext pCtx, int16_t* pScoeffLevel, PDqLayer pDqLayer) { |
| 71 | /*****get local variable from outer variable********/ | 125 | /*****get local variable from outer variable********/ |
| 72 | /*prediction info*/ | 126 | /*prediction info*/ |