ref: c02d9b0865e7c8eacefe55bb6a4142a0f12af2ba
parent: a39c46601d1348c5958d97e20852a34c50553f08
author: Sijia Chen <[email protected]>
date: Wed Jan 14 12:59:16 EST 2015
expand the mb_idx range so as to support frame size > 32767
--- a/codec/encoder/core/inc/encoder_context.h
+++ b/codec/encoder/core/inc/encoder_context.h
@@ -204,7 +204,7 @@
bool bRefOfCurTidIsLtr[MAX_DEPENDENCY_LAYER][MAX_TEMPORAL_LEVEL];
uint16_t uiIdrPicId; // IDR picture id: [0, 65535], this one is used for LTR
- int16_t iMaxSliceCount;// maximal count number of slices for all layers observation
+ int32_t iMaxSliceCount;// maximal count number of slices for all layers observation
int16_t iActiveThreadsNum; // number of threads active so far
/*
--- a/codec/encoder/core/inc/svc_enc_macroblock.h
+++ b/codec/encoder/core/inc/svc_enc_macroblock.h
@@ -50,9 +50,9 @@
/*************************mb_layer() syntax and generated********************************/
/*mb_layer():*/
Mb_Type uiMbType; // including MB detailed partition type, number and type of reference list
-int16_t iMbXY; // offset position of MB top left point based
-int16_t iMbX; // position of MB in horizontal axis
-int16_t iMbY; // position of MB in vertical axis
+int32_t iMbXY; // offset position of MB top left point based
+int16_t iMbX; // position of MB in horizontal axis [0..32767]
+int16_t iMbY; // position of MB in vertical axis [0..32767]
uint8_t uiNeighborAvail; // avail && same_slice: LEFT_MB_POS:0x01, TOP_MB_POS:0x02, TOPRIGHT_MB_POS = 0x04 ,TOPLEFT_MB_POS = 0x08;
uint8_t uiCbp;
--- a/codec/encoder/core/inc/svc_enc_slice_segment.h
+++ b/codec/encoder/core/inc/svc_enc_slice_segment.h
@@ -78,10 +78,10 @@
SliceModeEnum uiSliceMode; /* 0: single slice in frame; 1: multiple slices in frame; */
int16_t iMbWidth; /* width of picture size in mb */
int16_t iMbHeight; /* height of picture size in mb */
-int16_t iSliceNumInFrame; /* count number of slices in frame; */
+int32_t iSliceNumInFrame; /* count number of slices in frame; */
int32_t iMbNumInFrame; /* count number of MBs in frame */
uint16_t* pOverallMbMap; /* overall MB map in frame, store virtual slice idc; */
-int16_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
+int32_t* pFirstMbInSlice; /* first MB address top-left based in every slice respectively; */
int32_t* pCountMbNumInSlice; /* count number of MBs in every slice respectively; */
uint32_t uiSliceSizeConstraint;/*in byte*/
int32_t iMaxSliceNumConstraint;/*maximal number of slices constraint*/
@@ -140,7 +140,7 @@
*
* \return uiSliceIdc - successful; (uint8_t)(-1) - failed;
*/
-uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
+uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
/*!
* \brief Get first mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
@@ -160,7 +160,7 @@
*
* \return next_mb - successful; -1 - failed;
*/
-int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
+int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
/*!
* \brief Get previous mb to be processed in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
@@ -170,7 +170,7 @@
*
* \return prev_mb - successful; -1 - failed;
*/
-int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
+int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY);
/*!
* \brief Get number of mb in slice/slice_group: uiSliceIdc (apply in Single/multiple slices and FMO)
--- a/codec/encoder/core/src/encoder_ext.cpp
+++ b/codec/encoder/core/src/encoder_ext.cpp
@@ -702,7 +702,7 @@
bool bLeftTop;
bool bRightTop;
int32_t iLeftXY, iTopXY, iLeftTopXY, iRightTopXY;
- uint16_t uiSliceIdc;
+ uint16_t uiSliceIdc; //[0..65535] > 36864 of LEVEL5.2
pList[iIdx].iMbX = pEnc->pStrideTab->pMbIndexX[kiDlayerId][iIdx];
pList[iIdx].iMbY = pEnc->pStrideTab->pMbIndexY[kiDlayerId][iIdx];
@@ -4118,13 +4118,13 @@
pMA->WelsFree (pCurLayer->sLayerInfo.pSliceInLayer, "Slice");
pCurLayer->sLayerInfo.pSliceInLayer = pSlice;
- int16_t* pFirstMbInSlice = (int16_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int16_t), "pSliceSeg->pFirstMbInSlice");
+ int32_t* pFirstMbInSlice = (int32_t*)pMA->WelsMalloc (iMaxSliceNum * sizeof (int32_t), "pSliceSeg->pFirstMbInSlice");
if (NULL == pFirstMbInSlice) {
WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::DynSliceRealloc: pFirstMbInSlice is NULL");
return ENC_RETURN_MEMALLOCERR;
}
- memset (pFirstMbInSlice, 0, sizeof (int16_t) * iMaxSliceNum);
- memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int16_t) * iMaxSliceNumOld);
+ memset (pFirstMbInSlice, 0, sizeof (int32_t) * iMaxSliceNum);
+ memcpy (pFirstMbInSlice, pCurLayer->pSliceEncCtx->pFirstMbInSlice, sizeof (int32_t) * iMaxSliceNumOld);
pMA->WelsFree (pCurLayer->pSliceEncCtx->pFirstMbInSlice, "pSliceSeg->pFirstMbInSlice");
pCurLayer->pSliceEncCtx->pFirstMbInSlice = pFirstMbInSlice;
--- a/codec/encoder/core/src/svc_enc_slice_segment.cpp
+++ b/codec/encoder/core/src/svc_enc_slice_segment.cpp
@@ -75,7 +75,7 @@
int32_t iSliceNum = pSliceSeg->iSliceNumInFrame, uiSliceIdx = 0;
while (uiSliceIdx < iSliceNum) {
- const int16_t kiFirstMb = uiSliceIdx * kiMbWidth;
+ const int32_t kiFirstMb = uiSliceIdx * kiMbWidth;
pSliceSeg->pCountMbNumInSlice[uiSliceIdx] = kiMbWidth;
pSliceSeg->pFirstMbInSlice[uiSliceIdx] = kiFirstMb;
WelsSetMemMultiplebytes_c(pSliceSeg->pOverallMbMap + kiFirstMb, uiSliceIdx,
@@ -91,7 +91,7 @@
const int32_t kiCountNumMbInFrame = pSliceSeg->iMbNumInFrame;
const int32_t kiCountSliceNumInFrame = pSliceSeg->iSliceNumInFrame;
uint16_t iSliceIdx = 0;
- int16_t iMbIdx = 0;
+ int32_t iMbIdx = 0;
do {
const int32_t kiCurRunLength = kpSlicesAssignList[iSliceIdx];
@@ -398,7 +398,7 @@
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pOverallMbMap)
pSliceSeg->iSliceNumInFrame = 1;
- pSliceSeg->pFirstMbInSlice = (int16_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int16_t),
+ pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
"pSliceSeg->pFirstMbInSlice");
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice)
@@ -437,7 +437,7 @@
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pCountMbNumInSlice)
- pSliceSeg->pFirstMbInSlice = (int16_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int16_t),
+ pSliceSeg->pFirstMbInSlice = (int32_t*)pMa->WelsMalloc (pSliceSeg->iSliceNumInFrame * sizeof (int32_t),
"pSliceSeg->pFirstMbInSlice");
WELS_VERIFY_RETURN_IF (1, NULL == pSliceSeg->pFirstMbInSlice)
@@ -552,7 +552,7 @@
*
* \return uiSliceIdc - successful; -1 - failed;
*/
-uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int16_t kiMbXY) {
+uint16_t WelsMbToSliceIdc (SSliceCtx* pSliceCtx, const int32_t kiMbXY) {
if (NULL != pSliceCtx && kiMbXY < pSliceCtx->iMbNumInFrame && kiMbXY >= 0)
return pSliceCtx->pOverallMbMap[ kiMbXY ];
return (uint16_t) (-1);
@@ -578,7 +578,7 @@
*
* \return next_mb - successful; -1 - failed;
*/
-int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY) {
+int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY) {
if (NULL != pSliceCtx) {
SSliceCtx* pSliceSeg = pSliceCtx;
if (NULL == pSliceSeg || kiMbXY < 0 || kiMbXY >= pSliceSeg->iMbNumInFrame)
@@ -612,7 +612,7 @@
*
* \return prev_mb - successful; -1 - failed;
*/
-int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY) {
+int32_t WelsGetPrevMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiMbXY) {
if (NULL != pSliceCtx) {
SSliceCtx* pSliceSeg = pSliceCtx;
if (NULL == pSliceSeg || kiMbXY < 0 || kiMbXY >= pSliceSeg->iMbNumInFrame)