expand the mb_idx range so as to support frame size > 32767
This commit is contained in:
parent
a39c46601d
commit
c02d9b0865
@ -204,7 +204,7 @@ typedef struct TagWelsEncCtx {
|
||||
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
|
||||
|
||||
/*
|
||||
|
@ -50,9 +50,9 @@ typedef struct TagMB {
|
||||
/*************************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;
|
||||
|
@ -78,10 +78,10 @@ typedef struct SlicepEncCtx_s {
|
||||
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 @@ void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa);
|
||||
*
|
||||
* \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 @@ int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kiSliceIdc);
|
||||
*
|
||||
* \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 @@ int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY);
|
||||
*
|
||||
* \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)
|
||||
|
@ -702,7 +702,7 @@ static void InitMbInfo (sWelsEncCtx* pEnc, SMB* pList, SDqLayer* pLayer, con
|
||||
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 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx,
|
||||
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;
|
||||
|
||||
|
@ -75,7 +75,7 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
|
||||
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 @@ int32_t AssignMbMapMultipleSlices (SSliceCtx* pSliceSeg, const SSliceConfig* kpM
|
||||
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 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
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 @@ int32_t InitSliceSegment (SSliceCtx* pSliceSeg,
|
||||
|
||||
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 @@ void UninitSlicePEncCtx (SSliceCtx* pSliceCtx, CMemoryAlign* pMa) {
|
||||
*
|
||||
* \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 @@ int32_t WelsGetFirstMbOfSlice (SSliceCtx* pSliceCtx, const int32_t kuiSliceIdc)
|
||||
*
|
||||
* \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 @@ int32_t WelsGetNextMbOfSlice (SSliceCtx* pSliceCtx, const int16_t kiMbXY) {
|
||||
*
|
||||
* \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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user