ref: a384df3246a1741ecd9d1eeff8e060567c21fb1f
parent: da8646f5b2da5ecec8098b89c472c6842efa21c1
parent: 403cc57dc6422467f2a12b4ea6a0d811ab1816fa
author: huili2 <[email protected]>
date: Tue Mar 24 05:18:43 EDT 2015
Merge pull request #1868 from huili2/wels_common_basis merge common part of wels_common_basis
--- a/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj
+++ b/codec/build/iOS/enc/welsenc/welsenc.xcodeproj/project.pbxproj
@@ -81,7 +81,6 @@
4CE4432518B6FFA00017DF25 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
4CE446AA18BC605C0017DF25 /* as264_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = as264_common.h; sourceTree = "<group>"; };
4CE446AB18BC605C0017DF25 /* au_set.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = au_set.h; sourceTree = "<group>"; };
- 4CE446AC18BC605C0017DF25 /* bit_stream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bit_stream.h; sourceTree = "<group>"; };
4CE446AE18BC605C0017DF25 /* deblocking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = deblocking.h; sourceTree = "<group>"; };
4CE446AF18BC605C0017DF25 /* decode_mb_aux.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = decode_mb_aux.h; sourceTree = "<group>"; };
4CE446B018BC605C0017DF25 /* dq_map.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dq_map.h; sourceTree = "<group>"; };
@@ -262,7 +261,6 @@
4CDBFB9D18E5068D0025A767 /* wels_transpose_matrix.h */,
4CE446AA18BC605C0017DF25 /* as264_common.h */,
4CE446AB18BC605C0017DF25 /* au_set.h */,
- 4CE446AC18BC605C0017DF25 /* bit_stream.h */,
4CE446AE18BC605C0017DF25 /* deblocking.h */,
4CE446AF18BC605C0017DF25 /* decode_mb_aux.h */,
4CE446B018BC605C0017DF25 /* dq_map.h */,
--- a/codec/common/inc/wels_common_defs.h
+++ b/codec/common/inc/wels_common_defs.h
@@ -226,6 +226,42 @@
// need pointer to next byte start position in case 0 bit left then 8 instead
} SBitStringAux, *PBitStringAux;
+/* AVC MB types*/
+#define MB_TYPE_INTRA4x4 0x00000001
+#define MB_TYPE_INTRA16x16 0x00000002
+#define MB_TYPE_INTRA8x8 0x00000004
+#define MB_TYPE_16x16 0x00000008
+#define MB_TYPE_16x8 0x00000010
+#define MB_TYPE_8x16 0x00000020
+#define MB_TYPE_8x8 0x00000040
+#define MB_TYPE_8x8_REF0 0x00000080
+#define MB_TYPE_SKIP 0x00000100
+#define MB_TYPE_INTRA_PCM 0x00000200
+#define MB_TYPE_INTRA_BL 0x00000400
+
+#define MB_TYPE_DIRECT2 0x00004000
+
+#define SUB_MB_TYPE_8x8 0x00000001
+#define SUB_MB_TYPE_8x4 0x00000002
+#define SUB_MB_TYPE_4x8 0x00000004
+#define SUB_MB_TYPE_4x4 0x00000008
+
+#define MB_TYPE_INTRA (MB_TYPE_INTRA4x4 | MB_TYPE_INTRA16x16 | MB_TYPE_INTRA8x8 | MB_TYPE_INTRA_PCM)
+#define MB_TYPE_INTER (MB_TYPE_16x16 | MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_8x8_REF0 | MB_TYPE_SKIP)
+#define IS_INTRA4x4(type) ( MB_TYPE_INTRA4x4 == (type) )
+#define IS_INTRA16x16(type) ( MB_TYPE_INTRA16x16 == (type) )
+#define IS_INTRA(type) ( (type)&MB_TYPE_INTRA )
+#define IS_INTER(type) ( (type)&MB_TYPE_INTER )
+
+#define IS_SKIP(type) ( (type) == MB_TYPE_SKIP )
+#define IS_SVC_INTER(type) IS_INTER(type)
+#define IS_I_BL(type) ( (type) == MB_TYPE_INTRA_BL )
+#define IS_SVC_INTRA(type) ( IS_I_BL(type) || IS_INTRA(type) )
+#define IS_Inter_8x8(type) ( (type) == MB_TYPE_8x8)
+
+#define REF_NOT_AVAIL -2
+#define REF_NOT_IN_LIST -1 //intra
+
/////////intra16x16 Luma
#define I16_PRED_INVALID -1
#define I16_PRED_V 0
--- a/codec/decoder/core/inc/dec_frame.h
+++ b/codec/decoder/core/inc/dec_frame.h
@@ -63,7 +63,7 @@
PBitStringAux pBitStringAux; // pointer to SBitStringAux
PFmo pFmo; // Current fmo context pointer used
- int8_t* pMbType;
+ int16_t* pMbType;
int32_t* pSliceIdc; // using int32_t for slice_idc
int16_t (*pMv[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
int16_t (*pMvd[LIST_A])[MB_BLOCK4x4_NUM][MV_A];
@@ -126,7 +126,7 @@
SLayerInfo sLayerInfo;
PBitStringAux pBitStringAux; // pointer to SBitStringAux
- int8_t* pMbType;
+ int16_t* pMbType;
int32_t* pSliceIdc; // using int32_t for slice_idc
int8_t* pLumaQp;
int8_t* pCbp;
--- a/codec/decoder/core/inc/decoder_context.h
+++ b/codec/decoder/core/inc/decoder_context.h
@@ -259,7 +259,7 @@
iDecBlockOffsetArray[24]; // address talbe for sub 4x4 block in intra4x4_mb, so no need to caculta the address every time.
struct {
- int8_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
+ int16_t* pMbType[LAYER_NUM_EXCHANGEABLE]; /* mb type */
int16_t (*pMv[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM][MV_A]; //[LAYER_NUM_EXCHANGEABLE MB_BLOCK4x4_NUM*]
int8_t (*pRefIndex[LAYER_NUM_EXCHANGEABLE][LIST_A])[MB_BLOCK4x4_NUM];
int8_t* pLumaQp[LAYER_NUM_EXCHANGEABLE]; /*mb luma_qp*/
--- a/codec/decoder/core/inc/wels_common_basis.h
+++ b/codec/decoder/core/inc/wels_common_basis.h
@@ -54,27 +54,7 @@
extern const uint8_t g_kNonZeroScanIdxC[4];
/* Profile IDC */
typedef uint8_t ProfileIdc;
-enum {
-PRO_BASELINE = 66,
-PRO_MAIN = 77,
-PRO_EXTENDED = 88,
-PRO_HIGH = 100,
-PRO_HIGH10 = 110,
-PRO_HIGH422 = 122,
-PRO_HIGH444 = 144,
-PRO_CAVLC444 = 244,
-PRO_SCALABLE_BASELINE = 83,
-PRO_SCALABLE_HIGH = 86
-};
-
-/* Picture Size */
-typedef struct TagPictureSize {
-int32_t iWidth;
-int32_t iHeight;
-} SPictureSize;
-
-
/* Position Offset structure */
typedef struct TagPosOffset {
int32_t iLeftOffset;
@@ -83,46 +63,10 @@
int32_t iBottomOffset;
} SPosOffset;
-enum EMbPosition { //
-MB_LEFT = 0x01, // A
-MB_TOP = 0x02, // B
-MB_TOPRIGHT = 0x04, // C
-MB_TOPLEFT = 0x08, // D,
-MB_PRIVATE = 0x10
-};
/* MB Type & Sub-MB Type */
typedef int32_t MbType;
typedef int32_t SubMbType;
-#define MB_TYPE_INTRA4x4 0x01
-#define MB_TYPE_INTRA16x16 0x02
-#define MB_TYPE_INTRA8x8 0x03
-#define MB_TYPE_INTRA_PCM 0x04
-
-#define MB_TYPE_INTRA_BL 0x05// I_BL new MB type
-
-#define MB_TYPE_16x16 0x06
-#define MB_TYPE_16x8 0x07
-#define MB_TYPE_8x16 0x08
-#define MB_TYPE_8x8 0x09
-#define MB_TYPE_8x8_REF0 0x0a
-
-#define SUB_MB_TYPE_8x8 0x0b
-#define SUB_MB_TYPE_8x4 0x0c
-#define SUB_MB_TYPE_4x8 0x0d
-#define SUB_MB_TYPE_4x4 0x0e
-#define MB_TYPE_SKIP 0x0f
-#define MB_TYPE_DIRECT2 0x10
-#define not_available 0x20
-
-#define IS_INTRA4x4(type) ( MB_TYPE_INTRA4x4 == (type) )
-#define IS_INTRA16x16(type) ( MB_TYPE_INTRA16x16 == (type) )
-#define IS_INTRA(type) ( (type) > 0 && (type) < 5 )
-#define IS_INTER(type) ( (type) > 5 && (type) < 16 )
-
-#define IS_I_BL(type) ( (type) == MB_TYPE_INTRA_BL )
-#define IS_SUB8x8(type) (MB_TYPE_8x8 == (type) || MB_TYPE_8x8_REF0 == (type))
-
#define I16_LUMA_DC 1
#define I16_LUMA_AC 2
#define LUMA_DC_AC 3
@@ -138,12 +82,6 @@
#define CHROMA_DC_V_INTER 13
#define CHROMA_AC_U_INTER 14
#define CHROMA_AC_V_INTER 15
-
-typedef struct TagReadBitsCache {
- uint32_t uiCache32Bit;
- uint8_t uiRemainBits;
- uint8_t* pBuf;
-} SReadBitsCache;
#define SHIFT_BUFFER(pBitsCache) { pBitsCache->pBuf+=2; pBitsCache->uiRemainBits += 16; pBitsCache->uiCache32Bit |= (((pBitsCache->pBuf[2] << 8) | pBitsCache->pBuf[3]) << (32 - pBitsCache->uiRemainBits)); }
#define POP_BUFFER(pBitsCache, iCount) { pBitsCache->uiCache32Bit <<= iCount; pBitsCache->uiRemainBits -= iCount; }
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -1230,7 +1230,7 @@
memset (pDq, 0, sizeof (SDqLayer));
- pCtx->sMb.pMbType[i] = (int8_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int8_t),
+ pCtx->sMb.pMbType[i] = (int16_t*)WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (int16_t),
"pCtx->sMb.pMbType[]");
pCtx->sMb.pMv[i][0] = (int16_t (*)[16][2])WelsMallocz (pCtx->sMb.iMbWidth * pCtx->sMb.iMbHeight * sizeof (
int16_t) * MV_A * MB_BLOCK4x4_NUM, "pCtx->sMb.pMv[][]");
--- a/codec/decoder/core/src/parse_mb_syn_cabac.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cabac.cpp
@@ -315,7 +315,7 @@
uint32_t uiCode;
int32_t iIdxA, iIdxB, iCtxInc;
int8_t* pChromaPredMode = pCtx->pCurDqLayer->pChromaPredMode;
- int8_t* pMbType = pCtx->pCurDqLayer->pMbType;
+ int16_t* pMbType = pCtx->pCurDqLayer->pMbType;
int32_t iLeftAvail = uiNeighAvail & 0x04;
int32_t iTopAvail = uiNeighAvail & 0x01;
@@ -722,10 +722,10 @@
int32_t iTopBlkXy = iCurrBlkXy - pCtx->pCurDqLayer->iMbWidth; //default value: MB neighboring
int32_t iLeftBlkXy = iCurrBlkXy - 1; //default value: MB neighboring
uint8_t* pCbfDc = pCtx->pCurDqLayer->pCbfDc;
- int8_t* pMbType = pCtx->pCurDqLayer->pMbType;
+ int16_t* pMbType = pCtx->pCurDqLayer->pMbType;
int32_t iCtxInc;
uiCbfBit = 0;
- nA = nB = IS_INTRA (pMbType[iCurrBlkXy]);
+ nA = nB = (int8_t)!!IS_INTRA (pMbType[iCurrBlkXy]);
if (iResProperty == I16_LUMA_DC || iResProperty == CHROMA_DC_U || iResProperty == CHROMA_DC_V) { //DC
if (pNeighAvail->iTopAvail)
--- a/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
+++ b/codec/decoder/core/src/parse_mb_syn_cavlc.cpp
@@ -45,6 +45,13 @@
namespace WelsDec {
#define MAX_LEVEL_PREFIX 15
+
+typedef struct TagReadBitsCache {
+ uint32_t uiCache32Bit;
+ uint8_t uiRemainBits;
+ uint8_t* pBuf;
+} SReadBitsCache;
+
void GetNeighborAvailMbType (PWelsNeighAvail pNeighAvail, PDqLayer pCurLayer) {
int32_t iCurSliceIdc, iTopSliceIdc, iLeftTopSliceIdc, iRightTopSliceIdc, iLeftSliceIdc;
int32_t iCurXy, iTopXy = 0, iLeftXy = 0, iLeftTopXy = 0, iRightTopXy = 0;
--- a/codec/encoder/core/inc/wels_common_basis.h
+++ b/codec/encoder/core/inc/wels_common_basis.h
@@ -129,7 +129,6 @@
BOTTOMLEFT_MB_POS = 0x80, //
MB_POS_A = 0x100
};
-#define MB_ON_PIC_BOUNDRY (RIGHT_MB_POS|BOTTOM_MB_POS|LEFT_MB_POS|TOP_MB_POS)
/* MB Type & Sub-MB Type */
typedef uint32_t Mb_Type;
@@ -143,55 +142,7 @@
#define MB_BTMRIGHT_BIT 6
#define MB_BTMLEFT_BIT 7
-
-/* AVC types*/
-#define MB_TYPE_INTRA4x4 0x00000001
-#define MB_TYPE_INTRA16x16 0x00000002
-#define MB_TYPE_INTRA_PCM 0x00000004
-#define MB_TYPE_16x16 0x00000008
-#define MB_TYPE_16x8 0x00000010
-#define MB_TYPE_8x16 0x00000020
-#define MB_TYPE_8x8 0x00000040
-#define MB_TYPE_8x8_REF0 0x00000080
-
-#define MB_TYPE_SKIP 0x00000100
-#define MB_TYPE_P0L0 0x00000200
-#define MB_TYPE_P1L0 0x00000400
-#define MB_TYPE_P0L1 0x00000800
-#define MB_TYPE_P1L1 0x00001000
-#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
-#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
-#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
-#define MB_TYPE_QUANT 0x00002000
-#define MB_TYPE_CBP 0x00004000
-/* SVC extension types */
-#define MB_TYPE_INTRA_BL 0x00008000// I_BL new MB type derived H.264 SVC specific
-
#define MB_TYPE_BACKGROUND 0x00010000 // conditional BG skip_mb
-
-
-#define MB_TYPE_INTRA (MB_TYPE_INTRA4x4 | MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
-#define MB_TYPE_INTER (MB_TYPE_16x16 | MB_TYPE_16x8 | MB_TYPE_8x16 | MB_TYPE_8x8 | MB_TYPE_8x8_REF0)
-#define SUB_TYPE_8x8 (MB_TYPE_8x8 | MB_TYPE_8x8_REF0)
-
-#define MB_TYPE_UNAVAILABLE 0xFF000000
-#define REF_NOT_AVAIL -2
-#define REF_NOT_IN_LIST -1 //intra
-#define REF_PIC_REORDER_DEFAULT true
-
-#define IS_INTRA4x4(type) ( MB_TYPE_INTRA4x4 == (type) )
-#define IS_INTRA16x16(type) ( MB_TYPE_INTRA16x16 == (type) )
-#define IS_INTRA(type) ((type)&MB_TYPE_INTRA)
-#define IS_INTER(type) ((type)&MB_TYPE_INTER)
-
-#define IS_SKIP(type) ( (type) == MB_TYPE_SKIP )
-#define IS_SVC_INTER(type) ( IS_INTER(type) || IS_SKIP(type) )
-#define IS_I_BL(type) ( (type) == MB_TYPE_INTRA_BL )
-#define IS_SVC_INTRA(type) ( IS_I_BL(type) || IS_INTRA(type) )
-#define IS_SUB8x8(type) ((type)&SUB_TYPE_8x8)
-#define IS_Inter_8x8(type) ( (type) == MB_TYPE_8x8)
-
-
enum {
Intra4x4 = 0,
--- a/codec/encoder/core/src/svc_encode_slice.cpp
+++ b/codec/encoder/core/src/svc_encode_slice.cpp
@@ -292,7 +292,8 @@
BsWriteUE (pBs, 2);
break;
default:
- WelsLog(&pCtx->sLogCtx, WELS_LOG_ERROR, "Invalid uiDisableDeblockingFilterIdc %d", pSliceHeader->uiDisableDeblockingFilterIdc);
+ WelsLog (&pCtx->sLogCtx, WELS_LOG_ERROR, "Invalid uiDisableDeblockingFilterIdc %d",
+ pSliceHeader->uiDisableDeblockingFilterIdc);
break;
}
if (1 != pSliceHeader->uiDisableDeblockingFilterIdc) {
@@ -455,7 +456,8 @@
}
void OutputPMbWithoutConstructCsRsNoCopy (sWelsEncCtx* pCtx, SDqLayer* pDq, SSlice* pSlice, SMB* pMb) {
- if (IS_INTER (pMb->uiMbType) || IS_I_BL (pMb->uiMbType)) { //intra have been reconstructed, NO COPY from CS to pDecPic--
+ if ((IS_INTER (pMb->uiMbType) && !IS_SKIP (pMb->uiMbType))
+ || IS_I_BL (pMb->uiMbType)) { //intra have been reconstructed, NO COPY from CS to pDecPic--
SMbCache* pMbCache = &pSlice->sMbCacheInfo;
uint8_t* pDecY = pMbCache->SPicData.pDecMb[0];
uint8_t* pDecU = pMbCache->SPicData.pDecMb[1];
@@ -843,7 +845,7 @@
pSliceCtx->pFirstMbInSlice[iNextSliceIdc] = iFirstMbIdxOfNextSlice;
WelsSetMemMultiplebytes_c (pSliceCtx->pOverallMbMap + iFirstMbIdxOfNextSlice, iNextSliceIdc,
- (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof(uint16_t));
+ (kiLastMbIdxInPartition - iFirstMbIdxOfNextSlice + 1), sizeof (uint16_t));
//DYNAMIC_SLICING_ONE_THREAD: update pMbList slice_neighbor_info
UpdateMbNeighbourInfoForNextSlice (pSliceCtx, pMbList, iFirstMbIdxOfNextSlice, kiLastMbIdxInPartition);
--- a/test/decoder/DecUT_DeblockCommon.cpp
+++ b/test/decoder/DecUT_DeblockCommon.cpp
@@ -898,10 +898,10 @@
sDqLayer.pLumaQp = iLumaQP;
sDqLayer.pChromaQp = iChromaQP;
- int8_t iMbType[2];
+ int16_t iMbType[2];
sDqLayer.pMbType = iMbType;
- sDqLayer.pMbType[0] = 0x01;
- sDqLayer.pMbType[1] = 0x01;
+ sDqLayer.pMbType[0] = MB_TYPE_INTRA4x4;
+ sDqLayer.pMbType[1] = MB_TYPE_INTRA4x4;
sFilter.iSliceAlphaC0Offset = 0;
sFilter.iSliceBetaOffset = 0;
@@ -922,31 +922,31 @@
EXPECT_TRUE(iCb[2<<1]==iChromaV1 && iCr[2<<1]==iChromaV1)<<iQP<<" "<<sDqLayer.pMbType[1]; \
EXPECT_TRUE(iCb[(2<<1)*sFilter.iCsStride[1]]==iChromaV2 && iCr[(2<<1)*sFilter.iCsStride[1]]==iChromaV2)<<iQP<<" "<<sDqLayer.pMbType[1];
- // QP>16, LEFT & TOP, Intra mode 0x01
+ // QP>16, LEFT & TOP, Intra mode MB_TYPE_INTRA4x4
iQP = 16 + rand() % 35;
- sDqLayer.pMbType[1] = 0x01;
+ sDqLayer.pMbType[1] = MB_TYPE_INTRA4x4;
UT_DB_MACROBLOCK_TEST (0x03, iQP, 2, 1, 1, 2, 1, 1)
- // QP>16, LEFT & TOP, Intra mode 0x02
+ // QP>16, LEFT & TOP, Intra mode MB_TYPE_INTRA16x16
iQP = 16 + rand() % 35;
- sDqLayer.pMbType[1] = 0x02;
+ sDqLayer.pMbType[1] = MB_TYPE_INTRA16x16;
UT_DB_MACROBLOCK_TEST (0x03, iQP, 2, 1, 1, 2, 1, 1)
// MbType==0x03, Intra8x8 has not been supported now.
- // QP>16, LEFT & TOP, Intra mode 0x04
+ // QP>16, LEFT & TOP, Intra mode MB_TYPE_INTRA_PCM
iQP = 16 + rand() % 35;
- sDqLayer.pMbType[1] = 0x04;
+ sDqLayer.pMbType[1] = MB_TYPE_INTRA_PCM;
UT_DB_MACROBLOCK_TEST (0x03, iQP, 2, 1, 1, 2, 1, 1)
// QP>16, LEFT & TOP, neighbor is Intra
iQP = 16 + rand() % 35;
- sDqLayer.pMbType[0] = 0x02;
- sDqLayer.pMbType[1] = 0x0f; // Internal SKIP, Bs==0
+ sDqLayer.pMbType[0] = MB_TYPE_INTRA16x16;
+ sDqLayer.pMbType[1] = MB_TYPE_SKIP; // Internal SKIP, Bs==0
UT_DB_MACROBLOCK_TEST (0x03, iQP, 2, 0, 0, 2, 0, 0)
// QP<15, no output
iQP = rand() % 16;
- sDqLayer.pMbType[1] = 0x04;
+ sDqLayer.pMbType[1] = MB_TYPE_INTRA_PCM;
UT_DB_MACROBLOCK_TEST (0x03, iQP, 0, 0, 0, 0, 0, 0)
}
--- a/test/decoder/DecUT_PredMv.cpp
+++ b/test/decoder/DecUT_PredMv.cpp
@@ -419,7 +419,7 @@
if (pDqLayer->pSliceIdc == NULL)
return 1;
- pDqLayer->pMbType = (int8_t*) WelsMallocz (pDqLayer->iMbWidth * pDqLayer->iMbHeight * sizeof (int8_t),
+ pDqLayer->pMbType = (int16_t*) WelsMallocz (pDqLayer->iMbWidth * pDqLayer->iMbHeight * sizeof (int16_t),
"pDqLayer->pMbType");
if (pDqLayer->pMbType == NULL)
return 1;
@@ -476,7 +476,7 @@
void InitRandomLayerMbType (PDqLayer pDqLayer) {
for (int32_t i = 0; i < pDqLayer->iMbWidth * pDqLayer->iMbHeight; ++i) {
- pDqLayer->pMbType[i] = (rand() & 0x0f) + 1; //1 ~ 16
+ pDqLayer->pMbType[i] = 1 << (rand() % 11); //2^(1 ~ 10)
}
}
@@ -515,6 +515,7 @@
bool bOK = true;
SDqLayer sDqLayer;
int16_t iAncMvp[2], iWelsMvp[2];
+ int i;
memset (&sDqLayer, 0, sizeof (SDqLayer));
//Assume the input data as 352x288 size
@@ -537,6 +538,7 @@
#define RIGHT_TOP_MB_IDX (sDqLayer.iMbXyIndex - sDqLayer.iMbWidth + 1)
#define RIGHT_TOP_MB_BLK 12
+ int32_t iTotalMbNum = sDqLayer.iMbHeight * sDqLayer.iMbWidth;
//CASE 1: test MB [0,0], expect mvp = (0,0)
sDqLayer.iMbX = 0;
sDqLayer.iMbY = 0;
@@ -560,11 +562,13 @@
sDqLayer.iMbY = rand() % (sDqLayer.iMbHeight - 1) + 1; //not equal to 0
sDqLayer.iMbXyIndex = sDqLayer.iMbY * sDqLayer.iMbWidth + sDqLayer.iMbX;
//CASE 4.1.1: same slice_idc, assume = 0
- memset (sDqLayer.pSliceIdc, 0, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int32_t));
+ memset (sDqLayer.pSliceIdc, 0, iTotalMbNum * sizeof (int32_t));
//CASE 4.1.1.1: ALL P modes
- memset (sDqLayer.pMbType, MB_TYPE_16x16, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int8_t));
+ for (i = 0; i < iTotalMbNum; ++i) {
+ sDqLayer.pMbType[i] = MB_TYPE_16x16;
+ }
//CASE 4.1.1.1.1: ref_idx = 0, left MV = 0, top MV != 0, expect mvp = (0,0)
- memset (sDqLayer.pRefIndex[0], 0, sDqLayer.iMbWidth * sDqLayer.iMbHeight * MB_BLOCK4x4_NUM * sizeof (int8_t));
+ memset (sDqLayer.pRefIndex[0], 0, iTotalMbNum * MB_BLOCK4x4_NUM * sizeof (int8_t));
InitRandomLayerMvData (&sDqLayer); //reset Mv data
sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][0] = sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][1] = 0; //left_mv = 0
sDqLayer.pMv[0][ TOP_MB_IDX][ TOP_MB_BLK][0] = sDqLayer.pMv[0][ TOP_MB_IDX][ TOP_MB_BLK][1] = 1; //top_mv != 0
@@ -571,7 +575,7 @@
iAncMvp[0] = iAncMvp[1] = 0; //expect anchor result to 0
TEST_SKIP_MV_PRED;
//CASE 4.1.1.1.2: ref_idx = 0, left MV != 0, top MV = 0, expect mvp = (0,0)
- memset (sDqLayer.pRefIndex[0], 0, sDqLayer.iMbWidth * sDqLayer.iMbHeight * MB_BLOCK4x4_NUM * sizeof (int8_t));
+ memset (sDqLayer.pRefIndex[0], 0, iTotalMbNum * MB_BLOCK4x4_NUM * sizeof (int8_t));
InitRandomLayerMvData (&sDqLayer); //reset Mv data
sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][0] = sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][1] = 1; //left_mv != 0
sDqLayer.pMv[0][ TOP_MB_IDX][ TOP_MB_BLK][0] = sDqLayer.pMv[0][ TOP_MB_IDX][ TOP_MB_BLK][1] = 0; //top_mv = 0
@@ -593,7 +597,9 @@
iAncMvp[1] = sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][1];
TEST_SKIP_MV_PRED;
//CASE 4.1.1.2: All I
- memset (sDqLayer.pMbType, MB_TYPE_INTRA16x16, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int8_t));
+ for (i = 0; i < iTotalMbNum; ++i) {
+ sDqLayer.pMbType[i] = MB_TYPE_INTRA16x16;
+ }
//CASE 4.1.1.2.1: left P, expect mvp = left mv
sDqLayer.pMbType[LEFT_MB_IDX] = MB_TYPE_16x16; //left P
iAncMvp[0] = sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][0];
@@ -600,9 +606,10 @@
iAncMvp[1] = sDqLayer.pMv[0][LEFT_MB_IDX][LEFT_MB_BLK][1];
TEST_SKIP_MV_PRED;
//CASE 4.1.1.3: only top P, top ref_idx = 0, expect mvp = top mv
- memset (sDqLayer.pMbType, MB_TYPE_INTRA16x16, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int8_t)); // All I MB
- memset (sDqLayer.pRefIndex[0], 1, sDqLayer.iMbWidth * sDqLayer.iMbHeight * MB_BLOCK4x4_NUM * sizeof (
- int8_t)); // All ref_idx = 1
+ for (i = 0; i < iTotalMbNum; ++i) { // All I MB
+ sDqLayer.pMbType[i] = MB_TYPE_INTRA16x16;
+ }
+ memset (sDqLayer.pRefIndex[0], 1, iTotalMbNum * MB_BLOCK4x4_NUM * sizeof (int8_t)); // All ref_idx = 1
sDqLayer.pMbType[TOP_MB_IDX] = MB_TYPE_16x16; //top P
sDqLayer.pRefIndex[0][TOP_MB_IDX][TOP_MB_BLK] = 0; //top ref_idx = 0
iAncMvp[0] = sDqLayer.pMv[0][TOP_MB_IDX][TOP_MB_BLK][0];
@@ -612,9 +619,10 @@
sDqLayer.iMbX = (rand() % (sDqLayer.iMbWidth - 2)) + 1; //1 ~ (mb_width - 2)
sDqLayer.iMbY = (rand() % (sDqLayer.iMbHeight - 2)) + 1; //1 ~ (mb_height - 2)
sDqLayer.iMbXyIndex = sDqLayer.iMbY * sDqLayer.iMbWidth + sDqLayer.iMbX;
- memset (sDqLayer.pMbType, MB_TYPE_INTRA16x16, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int8_t)); // All I MB
- memset (sDqLayer.pRefIndex[0], 1, sDqLayer.iMbWidth * sDqLayer.iMbHeight * MB_BLOCK4x4_NUM * sizeof (
- int8_t)); // All ref_idx = 1
+ for (i = 0; i < iTotalMbNum; ++i) { // All I MB
+ sDqLayer.pMbType[i] = MB_TYPE_INTRA16x16;
+ }
+ memset (sDqLayer.pRefIndex[0], 1, iTotalMbNum * MB_BLOCK4x4_NUM * sizeof (int8_t)); // All ref_idx = 1
sDqLayer.pMbType[LEFT_TOP_MB_IDX] = MB_TYPE_16x16; //top P
sDqLayer.pRefIndex[0][LEFT_TOP_MB_IDX][LEFT_TOP_MB_BLK] = 0; //top ref_idx = 0
iAncMvp[0] = iAncMvp[1] = 0; //expect anchor result to 0
@@ -623,9 +631,10 @@
sDqLayer.iMbX = (rand() % (sDqLayer.iMbWidth - 2)) + 1; //1 ~ (mb_width - 2)
sDqLayer.iMbY = (rand() % (sDqLayer.iMbHeight - 2)) + 1; //1 ~ (mb_height - 2)
sDqLayer.iMbXyIndex = sDqLayer.iMbY * sDqLayer.iMbWidth + sDqLayer.iMbX;
- memset (sDqLayer.pMbType, MB_TYPE_INTRA16x16, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int8_t)); // All I MB
- memset (sDqLayer.pRefIndex[0], 1, sDqLayer.iMbWidth * sDqLayer.iMbHeight * MB_BLOCK4x4_NUM * sizeof (
- int8_t)); // All ref_idx = 1
+ for (i = 0; i < iTotalMbNum; ++i) { // All I MB
+ sDqLayer.pMbType[i] = MB_TYPE_INTRA16x16;
+ }
+ memset (sDqLayer.pRefIndex[0], 1, iTotalMbNum * MB_BLOCK4x4_NUM * sizeof (int8_t)); // All ref_idx = 1
sDqLayer.pMbType[RIGHT_TOP_MB_IDX] = MB_TYPE_16x16; //top P
sDqLayer.pRefIndex[0][RIGHT_TOP_MB_IDX][RIGHT_TOP_MB_BLK] = 0; //top ref_idx = 0
iAncMvp[0] = sDqLayer.pMv[0][RIGHT_TOP_MB_IDX][RIGHT_TOP_MB_BLK][0];
@@ -632,9 +641,10 @@
iAncMvp[1] = sDqLayer.pMv[0][RIGHT_TOP_MB_IDX][RIGHT_TOP_MB_BLK][1];
TEST_SKIP_MV_PRED;
//CASE 4.1.2: different neighbor slice idc for all P and ref_idx = 0, expect mvp = 0
- memset (sDqLayer.pMbType, MB_TYPE_16x16, sDqLayer.iMbWidth * sDqLayer.iMbHeight * sizeof (int8_t)); // All I MB
- memset (sDqLayer.pRefIndex[0], 0, sDqLayer.iMbWidth * sDqLayer.iMbHeight * MB_BLOCK4x4_NUM * sizeof (
- int8_t)); // All ref_idx = 1
+ for (i = 0; i < iTotalMbNum; ++i) { // All P MB
+ sDqLayer.pMbType[i] = MB_TYPE_16x16;
+ }
+ memset (sDqLayer.pRefIndex[0], 0, iTotalMbNum * MB_BLOCK4x4_NUM * sizeof (int8_t)); // All ref_idx = 1
sDqLayer.iMbX = (rand() % (sDqLayer.iMbWidth - 2)) + 1; //1 ~ (mb_width - 2)
sDqLayer.iMbY = (rand() % (sDqLayer.iMbHeight - 2)) + 1; //1 ~ (mb_height - 2)
sDqLayer.iMbXyIndex = sDqLayer.iMbY * sDqLayer.iMbWidth + sDqLayer.iMbX;
@@ -649,7 +659,7 @@
//add new specific tests here
//normal tests
- int32_t i = 0;
+ i = 0;
while (i++ < kiRandTime) {
InitRandomLayerData (&sDqLayer); //init MV data, as it would not affect the following logic test
AnchorPredPSkipMvFromNeighbor (&sDqLayer, iAncMvp);