Showing the changes to codec/encoder/core/src/svc_encode_slice.cpp (1 of 15 files). Show all
Unified · Split
| @@ -827,7 +827,7 @@ int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, · 826 unmodified lines | |||
| 827 | int32_t iFirstMBInSlice = 0; | 827 | int32_t iFirstMBInSlice = 0; |
| 828 | int32_t iMbNumInSlice = 0; | 828 | int32_t iMbNumInSlice = 0; |
| 829 | 829 | ||
| 830 | for( ;iSliceIdx < kiSliceNumInFrame; iSliceIdx++ ){ | 830 | for (; iSliceIdx < kiSliceNumInFrame; iSliceIdx++) { |
| 831 | if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) { | 831 | if (SM_SINGLE_SLICE == pSliceArgument->uiSliceMode) { |
| 832 | iFirstMBInSlice = 0; | 832 | iFirstMBInSlice = 0; |
| 833 | iMbNumInSlice = kiCountNumMbInFrame; | 833 | iMbNumInSlice = kiCountNumMbInFrame; |
| @@ -836,7 +836,7 @@ int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, · 2 unmodified lines | |||
| 836 | iFirstMBInSlice = iSliceIdx * kiMBWidth; | 836 | iFirstMBInSlice = iSliceIdx * kiMBWidth; |
| 837 | iMbNumInSlice = kiMBWidth; | 837 | iMbNumInSlice = kiMBWidth; |
| 838 | } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode || | 838 | } else if (SM_RASTER_SLICE == pSliceArgument->uiSliceMode || |
| 839 | SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) { | 839 | SM_FIXEDSLCNUM_SLICE == pSliceArgument->uiSliceMode) { |
| 840 | int32_t iMbIdx = 0; | 840 | int32_t iMbIdx = 0; |
| 841 | for (int i = 0; i < iSliceIdx; i++) { | 841 | for (int i = 0; i < iSliceIdx; i++) { |
| 842 | iMbIdx += kpSlicesAssignList[i]; | 842 | iMbIdx += kpSlicesAssignList[i]; |
| @@ -864,10 +864,10 @@ int32_t InitSliceBoundaryInfo (SDqLayer* pCurLayer, · 21 unmodified lines | |||
| 864 | return ENC_RETURN_SUCCESS; | 864 | return ENC_RETURN_SUCCESS; |
| 865 | } | 865 | } |
| 866 | 866 | ||
| 867 | int32_t SetSliceBoundaryInfo(SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) { | 867 | int32_t SetSliceBoundaryInfo (SDqLayer* pCurLayer, SSlice* pSlice, const int32_t kiSliceIdx) { |
| 868 | if(NULL == pCurLayer || NULL == pSlice || | 868 | if (NULL == pCurLayer || NULL == pSlice || |
| 869 | NULL == pCurLayer->pFirstMbIdxOfSlice || | 869 | NULL == pCurLayer->pFirstMbIdxOfSlice || |
| 870 | NULL == pCurLayer->pCountMbNumInSlice) { | 870 | NULL == pCurLayer->pCountMbNumInSlice) { |
| 871 | 871 | ||
| 872 | return ENC_RETURN_UNEXPECTED; | 872 | return ENC_RETURN_UNEXPECTED; |
| 873 | } | 873 | } |
| @@ -977,15 +977,15 @@ int32_t InitAllSlicesInThread (sWelsEncCtx* pCtx) { · 103 unmodified lines | |||
| 977 | int32_t iSliceIdx = 0; | 977 | int32_t iSliceIdx = 0; |
| 978 | int32_t iSlcBuffIdx = 0; | 978 | int32_t iSlcBuffIdx = 0; |
| 979 | 979 | ||
| 980 | for( ; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) { | 980 | for (; iSliceIdx < pCurDqLayer->iMaxSliceNum; iSliceIdx++) { |
| 981 | if(NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) { | 981 | if (NULL == pCurDqLayer->ppSliceInLayer[iSliceIdx]) { |
| 982 | return ENC_RETURN_UNEXPECTED; | 982 | return ENC_RETURN_UNEXPECTED; |
| 983 | } | 983 | } |
| 984 | 984 | ||
| 985 | pCurDqLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx = -1; | 985 | pCurDqLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx = -1; |
| 986 | } | 986 | } |
| 987 | 987 | ||
| 988 | for( ; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | 988 | for (; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 989 | pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iCodedSliceNum = 0; | 989 | pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iCodedSliceNum = 0; |
| 990 | } | 990 | } |
| 991 | 991 | ||
| @@ -999,11 +999,11 @@ int32_t InitOneSliceInThread (sWelsEncCtx* pCtx, · 7 unmodified lines | |||
| 999 | const int32_t kiSliceIdx) { | 999 | const int32_t kiSliceIdx) { |
| 1000 | 1000 | ||
| 1001 | if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) { | 1001 | if (pCtx->pCurDqLayer->bThreadSlcBufferFlag) { |
| 1002 | const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum; | 1002 | const int32_t kiCodedNumInThread = pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iCodedSliceNum; |
| 1003 | assert(kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum -1 ); | 1003 | assert (kiCodedNumInThread <= pCtx->pCurDqLayer->sSliceBufferInfo[kiSlcBuffIdx].iMaxSliceNum - 1); |
| 1004 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread]; | 1004 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [kiSlcBuffIdx].pSliceBuffer[kiCodedNumInThread]; |
| 1005 | } else { | 1005 | } else { |
| 1006 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx]; | 1006 | pSlice = &pCtx->pCurDqLayer->sSliceBufferInfo [0].pSliceBuffer[kiSliceIdx]; |
| 1007 | } | 1007 | } |
| 1008 | pSlice->iSliceIdx = kiSliceIdx; | 1008 | pSlice->iSliceIdx = kiSliceIdx; |
| 1009 | pSlice->uiBufferIdx = kiSlcBuffIdx; | 1009 | pSlice->uiBufferIdx = kiSlcBuffIdx; |
| @@ -1029,7 +1029,7 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 19 unmodified lines | |||
| 1029 | assert (iThreadNum > 0); | 1029 | assert (iThreadNum > 0); |
| 1030 | 1030 | ||
| 1031 | //for fixed slice num case, no need to reallocate, so one slice buffer for all thread | 1031 | //for fixed slice num case, no need to reallocate, so one slice buffer for all thread |
| 1032 | if( pDqLayer->bThreadSlcBufferFlag) { | 1032 | if (pDqLayer->bThreadSlcBufferFlag) { |
| 1033 | iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1; | 1033 | iMaxSliceNum = pDqLayer->iMaxSliceNum / iThreadNum + 1; |
| 1034 | iSlcBufferNum = iThreadNum; | 1034 | iSlcBufferNum = iThreadNum; |
| 1035 | } else { | 1035 | } else { |
| @@ -1040,7 +1040,8 @@ int32_t InitSliceThreadInfo (sWelsEncCtx* pCtx, · 4 unmodified lines | |||
| 1040 | while (iIdx < iSlcBufferNum) { | 1040 | while (iIdx < iSlcBufferNum) { |
| 1041 | pDqLayer->sSliceBufferInfo[iIdx].iMaxSliceNum = iMaxSliceNum; | 1041 | pDqLayer->sSliceBufferInfo[iIdx].iMaxSliceNum = iMaxSliceNum; |
| 1042 | pDqLayer->sSliceBufferInfo[iIdx].iCodedSliceNum = 0; | 1042 | pDqLayer->sSliceBufferInfo[iIdx].iCodedSliceNum = 0; |
| 1043 | pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, "pSliceBuffer"); | 1043 | pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer = (SSlice*)pMa->WelsMallocz (sizeof (SSlice) * iMaxSliceNum, |
| 1044 | "pSliceBuffer"); | ||
| 1044 | if (NULL == pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer) { | 1045 | if (NULL == pDqLayer->sSliceBufferInfo[iIdx].pSliceBuffer) { |
| 1045 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, | 1046 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| 1046 | "CWelsH264SVCEncoder::InitSliceThreadInfo: pSliceThreadInfo->pSliceBuffer[iIdx] is NULL"); | 1047 | "CWelsH264SVCEncoder::InitSliceThreadInfo: pSliceThreadInfo->pSliceBuffer[iIdx] is NULL"); |
| @@ -1081,21 +1082,21 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 34 unmodified lines | |||
| 1081 | //SM_SINGLE_SLICE mode using single-thread bs writer pOut->sBsWrite | 1082 | //SM_SINGLE_SLICE mode using single-thread bs writer pOut->sBsWrite |
| 1082 | //even though multi-thread is on for other layers | 1083 | //even though multi-thread is on for other layers |
| 1083 | pDqLayer->bSliceBsBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 && | 1084 | pDqLayer->bSliceBsBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 && |
| 1084 | SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false; | 1085 | SM_SINGLE_SLICE != pSliceArgument->uiSliceMode) ? true : false; |
| 1085 | 1086 | ||
| 1086 | pDqLayer->bThreadSlcBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 && | 1087 | pDqLayer->bThreadSlcBufferFlag = (pCtx->pSvcParam->iMultipleThreadIdc > 1 && |
| 1087 | SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? true : false; | 1088 | SM_SIZELIMITED_SLICE == pSliceArgument->uiSliceMode) ? true : false; |
| 1088 | 1089 | ||
| 1089 | iRet = InitSliceThreadInfo (pCtx, | 1090 | iRet = InitSliceThreadInfo (pCtx, |
| 1090 | pDqLayer, | 1091 | pDqLayer, |
| 1091 | kiDlayerIndex, | 1092 | kiDlayerIndex, |
| 1092 | pMa); | 1093 | pMa); |
| 1093 | if (ENC_RETURN_SUCCESS != iRet) { | 1094 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1094 | return ENC_RETURN_MEMALLOCERR; | 1095 | return ENC_RETURN_MEMALLOCERR; |
| 1095 | } | 1096 | } |
| 1096 | 1097 | ||
| 1097 | pDqLayer->iMaxSliceNum = 0; | 1098 | pDqLayer->iMaxSliceNum = 0; |
| 1098 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | 1099 | for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1099 | pDqLayer->iMaxSliceNum += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | 1100 | pDqLayer->iMaxSliceNum += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1100 | } | 1101 | } |
| 1101 | 1102 | ||
| @@ -1105,15 +1106,19 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 3 unmodified lines | |||
| 1105 | return ENC_RETURN_MEMALLOCERR; | 1106 | return ENC_RETURN_MEMALLOCERR; |
| 1106 | } | 1107 | } |
| 1107 | 1108 | ||
| 1108 | pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, "pFirstMbIdxOfSlice"); | 1109 | pDqLayer->pFirstMbIdxOfSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, |
| 1110 | "pFirstMbIdxOfSlice"); | ||
| 1109 | if (NULL == pDqLayer->pFirstMbIdxOfSlice) { | 1111 | if (NULL == pDqLayer->pFirstMbIdxOfSlice) { |
| 1110 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL"); | 1112 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| 1113 | "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pFirstMbIdxOfSlice is NULL"); | ||
| 1111 | return ENC_RETURN_MEMALLOCERR; | 1114 | return ENC_RETURN_MEMALLOCERR; |
| 1112 | } | 1115 | } |
| 1113 | 1116 | ||
| 1114 | pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, "pCountMbNumInSlice"); | 1117 | pDqLayer->pCountMbNumInSlice = (int32_t*)pMa->WelsMallocz (sizeof (int32_t*) * pDqLayer->iMaxSliceNum, |
| 1118 | "pCountMbNumInSlice"); | ||
| 1115 | if (NULL == pDqLayer->pCountMbNumInSlice) { | 1119 | if (NULL == pDqLayer->pCountMbNumInSlice) { |
| 1116 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL"); | 1120 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, |
| 1121 | "CWelsH264SVCEncoder::InitSliceInLayer() pDqLayer->pCountMbNumInSlice is NULL"); | ||
| 1117 | return ENC_RETURN_MEMALLOCERR; | 1122 | return ENC_RETURN_MEMALLOCERR; |
| 1118 | } | 1123 | } |
| 1119 | 1124 | ||
| @@ -1123,9 +1128,9 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 3 unmodified lines | |||
| 1123 | } | 1128 | } |
| 1124 | 1129 | ||
| 1125 | iStartIdx = 0; | 1130 | iStartIdx = 0; |
| 1126 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | 1131 | for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1127 | for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++ ) { | 1132 | for (iSliceIdx = 0; iSliceIdx < pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { |
| 1128 | pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer+ iSliceIdx; | 1133 | pDqLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pDqLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1129 | } | 1134 | } |
| 1130 | 1135 | ||
| 1131 | iStartIdx += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | 1136 | iStartIdx += pDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| @@ -1135,7 +1140,7 @@ int32_t InitSliceInLayer (sWelsEncCtx* pCtx, · 3 unmodified lines | |||
| 1135 | } | 1140 | } |
| 1136 | 1141 | ||
| 1137 | void InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice) { | 1142 | void InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice) { |
| 1138 | if(NULL == pSlice || NULL == pBaseSlice) { | 1143 | if (NULL == pSlice || NULL == pBaseSlice) { |
| 1139 | return; | 1144 | return; |
| 1140 | } | 1145 | } |
| 1141 | 1146 | ||
| @@ -1150,7 +1155,7 @@ void InitSliceHeadWithBase (SSlice* pSlice, SSlice* pBaseSlice) { · 8 unmodified lines | |||
| 1150 | } | 1155 | } |
| 1151 | 1156 | ||
| 1152 | void InitSliceRefInfoWithBase (SSlice* pSlice, SSlice* pBaseSlice, const uint8_t kuiRefCount) { | 1157 | void InitSliceRefInfoWithBase (SSlice* pSlice, SSlice* pBaseSlice, const uint8_t kuiRefCount) { |
| 1153 | if( NULL == pSlice || NULL == pBaseSlice) { | 1158 | if (NULL == pSlice || NULL == pBaseSlice) { |
| 1154 | return; | 1159 | return; |
| 1155 | } | 1160 | } |
| 1156 | 1161 | ||
| @@ -1213,7 +1218,7 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 56 unmodified lines | |||
| 1213 | for (iSliceIdx = 0; iSliceIdx < kiMaxSliceNumOld; iSliceIdx++) { | 1218 | for (iSliceIdx = 0; iSliceIdx < kiMaxSliceNumOld; iSliceIdx++) { |
| 1214 | pSlice = pNewSliceList + iSliceIdx; | 1219 | pSlice = pNewSliceList + iSliceIdx; |
| 1215 | if (NULL == pSlice) { | 1220 | if (NULL == pSlice) { |
| 1216 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | 1221 | FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); |
| 1217 | return ENC_RETURN_MEMALLOCERR; | 1222 | return ENC_RETURN_MEMALLOCERR; |
| 1218 | } | 1223 | } |
| 1219 | 1224 | ||
| @@ -1224,14 +1229,14 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 4 unmodified lines | |||
| 1224 | 1229 | ||
| 1225 | pBaseSlice = &pSliceList[0]; | 1230 | pBaseSlice = &pSliceList[0]; |
| 1226 | if (NULL == pBaseSlice) { | 1231 | if (NULL == pBaseSlice) { |
| 1227 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()"); | 1232 | FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "ReallocateSliceList()::InitSliceBsBuffer()"); |
| 1228 | return ENC_RETURN_MEMALLOCERR; | 1233 | return ENC_RETURN_MEMALLOCERR; |
| 1229 | } | 1234 | } |
| 1230 | 1235 | ||
| 1231 | for (iSliceIdx = kiMaxSliceNumOld; iSliceIdx < kiMaxSliceNumNew; iSliceIdx++) { | 1236 | for (iSliceIdx = kiMaxSliceNumOld; iSliceIdx < kiMaxSliceNumNew; iSliceIdx++) { |
| 1232 | pSlice = pNewSliceList + iSliceIdx; | 1237 | pSlice = pNewSliceList + iSliceIdx; |
| 1233 | if (NULL == pSlice) { | 1238 | if (NULL == pSlice) { |
| 1234 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | 1239 | FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); |
| 1235 | return ENC_RETURN_MEMALLOCERR; | 1240 | return ENC_RETURN_MEMALLOCERR; |
| 1236 | } | 1241 | } |
| 1237 | 1242 | ||
| @@ -1246,13 +1251,13 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 8 unmodified lines | |||
| 1246 | iMaxSliceBufferSize, | 1251 | iMaxSliceBufferSize, |
| 1247 | pMA); | 1252 | pMA); |
| 1248 | if (ENC_RETURN_SUCCESS != iRet) { | 1253 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1249 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | 1254 | FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); |
| 1250 | return iRet; | 1255 | return iRet; |
| 1251 | } | 1256 | } |
| 1252 | 1257 | ||
| 1253 | iRet = AllocateSliceMBBuffer (pSlice, pMA); | 1258 | iRet = AllocateSliceMBBuffer (pSlice, pMA); |
| 1254 | if (ENC_RETURN_SUCCESS != iRet) { | 1259 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1255 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | 1260 | FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); |
| 1256 | return iRet; | 1261 | return iRet; |
| 1257 | } | 1262 | } |
| 1258 | 1263 | ||
| @@ -1261,7 +1266,7 @@ int32_t ReallocateSliceList (sWelsEncCtx* pCtx, · 2 unmodified lines | |||
| 1261 | 1266 | ||
| 1262 | iRet = InitSliceRC (pSlice, pCtx->iGlobalQp); | 1267 | iRet = InitSliceRC (pSlice, pCtx->iGlobalQp); |
| 1263 | if (ENC_RETURN_SUCCESS != iRet) { | 1268 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1264 | FreeSliceBuffer(pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); | 1269 | FreeSliceBuffer (pNewSliceList, kiMaxSliceNumNew, pMA, "pSliceBuffer"); |
| 1265 | return iRet; | 1270 | return iRet; |
| 1266 | } | 1271 | } |
| 1267 | } | 1272 | } |
| @@ -1276,11 +1281,11 @@ int32_t CalculateNewSliceNum (sWelsEncCtx* pCtx, · 8 unmodified lines | |||
| 1276 | SSlice* pLastCodedSlice, | 1281 | SSlice* pLastCodedSlice, |
| 1277 | const int32_t iMaxSliceNumOld, | 1282 | const int32_t iMaxSliceNumOld, |
| 1278 | int32_t& iMaxSliceNumNew) { | 1283 | int32_t& iMaxSliceNumNew) { |
| 1279 | if ( NULL == pCtx || NULL == pLastCodedSlice || 0 == iMaxSliceNumOld ) { | 1284 | if (NULL == pCtx || NULL == pLastCodedSlice || 0 == iMaxSliceNumOld) { |
| 1280 | return ENC_RETURN_INVALIDINPUT; | 1285 | return ENC_RETURN_INVALIDINPUT; |
| 1281 | } | 1286 | } |
| 1282 | 1287 | ||
| 1283 | if ( 1 == pCtx->iActiveThreadsNum ) { | 1288 | if (1 == pCtx->iActiveThreadsNum) { |
| 1284 | iMaxSliceNumNew = iMaxSliceNumOld * SLICE_NUM_EXPAND_COEF; | 1289 | iMaxSliceNumNew = iMaxSliceNumOld * SLICE_NUM_EXPAND_COEF; |
| 1285 | return ENC_RETURN_SUCCESS; | 1290 | return ENC_RETURN_SUCCESS; |
| 1286 | } | 1291 | } |
| @@ -1292,7 +1297,7 @@ int32_t CalculateNewSliceNum (sWelsEncCtx* pCtx, · 5 unmodified lines | |||
| 1292 | - pCtx->pCurDqLayer->LastCodedMbIdxOfPartition[iPartitionID] + 1; | 1297 | - pCtx->pCurDqLayer->LastCodedMbIdxOfPartition[iPartitionID] + 1; |
| 1293 | int32_t iIncreaseSlicNum = (iLeftMBNum * INT_MULTIPLY / iMBNumInPatition) * iMaxSliceNumOld; | 1298 | int32_t iIncreaseSlicNum = (iLeftMBNum * INT_MULTIPLY / iMBNumInPatition) * iMaxSliceNumOld; |
| 1294 | 1299 | ||
| 1295 | iIncreaseSlicNum = ( 0 == (iIncreaseSlicNum / INT_MULTIPLY) ) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY); | 1300 | iIncreaseSlicNum = (0 == (iIncreaseSlicNum / INT_MULTIPLY)) ? 1 : (iIncreaseSlicNum / INT_MULTIPLY); |
| 1296 | iIncreaseSlicNum = (iIncreaseSlicNum < iMaxSliceNumOld / 2) ? (iMaxSliceNumOld / 2) : iIncreaseSlicNum; | 1301 | iIncreaseSlicNum = (iIncreaseSlicNum < iMaxSliceNumOld / 2) ? (iMaxSliceNumOld / 2) : iIncreaseSlicNum; |
| 1297 | iMaxSliceNumNew = iMaxSliceNumOld + iIncreaseSlicNum; | 1302 | iMaxSliceNumNew = iMaxSliceNumOld + iIncreaseSlicNum; |
| 1298 | 1303 | ||
| @@ -1332,9 +1337,9 @@ int32_t ReallocateSliceInThread (sWelsEncCtx* pCtx, · 33 unmodified lines | |||
| 1332 | return ENC_RETURN_SUCCESS; | 1337 | return ENC_RETURN_SUCCESS; |
| 1333 | } | 1338 | } |
| 1334 | 1339 | ||
| 1335 | int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx, | 1340 | int32_t ExtendLayerBuffer (sWelsEncCtx* pCtx, |
| 1336 | const int32_t kiMaxSliceNumOld, | 1341 | const int32_t kiMaxSliceNumOld, |
| 1337 | const int32_t kiMaxSliceNumNew){ | 1342 | const int32_t kiMaxSliceNumNew) { |
| 1338 | CMemoryAlign* pMA = pCtx->pMemAlign; | 1343 | CMemoryAlign* pMA = pCtx->pMemAlign; |
| 1339 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; | 1344 | SDqLayer* pCurLayer = pCtx->pCurDqLayer; |
| 1340 | SSlice** ppSlice = NULL; | 1345 | SSlice** ppSlice = NULL; |
| @@ -1356,7 +1361,7 @@ int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx, · 15 unmodified lines | |||
| 1356 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pFirstMbIdxOfSlice is NULL"); | 1361 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pFirstMbIdxOfSlice is NULL"); |
| 1357 | return ENC_RETURN_MEMALLOCERR; | 1362 | return ENC_RETURN_MEMALLOCERR; |
| 1358 | } | 1363 | } |
| 1359 | memset (pFirstMbIdxOfSlice, 0, sizeof(int32_t) * kiMaxSliceNumNew); | 1364 | memset (pFirstMbIdxOfSlice, 0, sizeof (int32_t) * kiMaxSliceNumNew); |
| 1360 | memcpy (pFirstMbIdxOfSlice, pCurLayer->pFirstMbIdxOfSlice, sizeof (int32_t) * kiMaxSliceNumOld); | 1365 | memcpy (pFirstMbIdxOfSlice, pCurLayer->pFirstMbIdxOfSlice, sizeof (int32_t) * kiMaxSliceNumOld); |
| 1361 | pMA->WelsFree (pCurLayer->pFirstMbIdxOfSlice, "pFirstMbIdxOfSlice"); | 1366 | pMA->WelsFree (pCurLayer->pFirstMbIdxOfSlice, "pFirstMbIdxOfSlice"); |
| 1362 | pCurLayer->pFirstMbIdxOfSlice = pFirstMbIdxOfSlice; | 1367 | pCurLayer->pFirstMbIdxOfSlice = pFirstMbIdxOfSlice; |
| @@ -1367,7 +1372,7 @@ int32_t ExtendLayerBuffer(sWelsEncCtx* pCtx, · 4 unmodified lines | |||
| 1367 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pCountMbNumInSlice is NULL"); | 1372 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_ERROR, "CWelsH264SVCEncoder::ExtendLayerBuffer: pCountMbNumInSlice is NULL"); |
| 1368 | return ENC_RETURN_MEMALLOCERR; | 1373 | return ENC_RETURN_MEMALLOCERR; |
| 1369 | } | 1374 | } |
| 1370 | memset (pCountMbNumInSlice, 0, sizeof(int32_t) * kiMaxSliceNumNew); | 1375 | memset (pCountMbNumInSlice, 0, sizeof (int32_t) * kiMaxSliceNumNew); |
| 1371 | memcpy (pCountMbNumInSlice, pCurLayer->pCountMbNumInSlice, sizeof (int32_t) * kiMaxSliceNumOld); | 1376 | memcpy (pCountMbNumInSlice, pCurLayer->pCountMbNumInSlice, sizeof (int32_t) * kiMaxSliceNumOld); |
| 1372 | pMA->WelsFree (pCurLayer->pCountMbNumInSlice, "pCountMbNumInSlice"); | 1377 | pMA->WelsFree (pCurLayer->pCountMbNumInSlice, "pCountMbNumInSlice"); |
| 1373 | pCurLayer->pCountMbNumInSlice = pCountMbNumInSlice; | 1378 | pCurLayer->pCountMbNumInSlice = pCountMbNumInSlice; |
| @@ -1408,16 +1413,16 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 34 unmodified lines | |||
| 1408 | pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew; | 1413 | pCurLayer->sSliceBufferInfo[0].iMaxSliceNum = iMaxSliceNumNew; |
| 1409 | 1414 | ||
| 1410 | iMaxSliceNumNew = 0; | 1415 | iMaxSliceNumNew = 0; |
| 1411 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | 1416 | for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1412 | iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | 1417 | iMaxSliceNumNew += pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1413 | } | 1418 | } |
| 1414 | 1419 | ||
| 1415 | iRet = ExtendLayerBuffer(pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); | 1420 | iRet = ExtendLayerBuffer (pCtx, pCurLayer->iMaxSliceNum, iMaxSliceNumNew); |
| 1416 | if (ENC_RETURN_SUCCESS != iRet) { | 1421 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1417 | return iRet; | 1422 | return iRet; |
| 1418 | } | 1423 | } |
| 1419 | 1424 | ||
| 1420 | for(iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++ ) { | 1425 | for (iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1421 | for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { | 1426 | for (iSliceIdx = 0; iSliceIdx < pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; iSliceIdx++) { |
| 1422 | pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; | 1427 | pCurLayer->ppSliceInLayer[iStartIdx + iSliceIdx] = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1423 | } | 1428 | } |
| @@ -1429,14 +1434,14 @@ int32_t ReallocSliceBuffer (sWelsEncCtx* pCtx) { · 5 unmodified lines | |||
| 1429 | return ENC_RETURN_SUCCESS; | 1434 | return ENC_RETURN_SUCCESS; |
| 1430 | } | 1435 | } |
| 1431 | 1436 | ||
| 1432 | static inline int32_t CheckAllSliceBuffer(SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) { | 1437 | static inline int32_t CheckAllSliceBuffer (SDqLayer* pCurLayer, const int32_t kiCodedSliceNum) { |
| 1433 | int32_t iSliceIdx = 0; | 1438 | int32_t iSliceIdx = 0; |
| 1434 | for(; iSliceIdx <kiCodedSliceNum ; iSliceIdx ++ ) { | 1439 | for (; iSliceIdx < kiCodedSliceNum ; iSliceIdx ++) { |
| 1435 | if ( NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) { | 1440 | if (NULL == pCurLayer->ppSliceInLayer[iSliceIdx]) { |
| 1436 | return ENC_RETURN_UNEXPECTED; | 1441 | return ENC_RETURN_UNEXPECTED; |
| 1437 | } | 1442 | } |
| 1438 | 1443 | ||
| 1439 | if ( iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) { | 1444 | if (iSliceIdx != pCurLayer->ppSliceInLayer[iSliceIdx]->iSliceIdx) { |
| 1440 | return ENC_RETURN_UNEXPECTED; | 1445 | return ENC_RETURN_UNEXPECTED; |
| 1441 | } | 1446 | } |
| 1442 | } | 1447 | } |
| @@ -1464,16 +1469,16 @@ int32_t ReOrderSliceInLayer (sWelsEncCtx* pCtx, · 21 unmodified lines | |||
| 1464 | 1469 | ||
| 1465 | //for non-dynamic slice mode, iPartitionNum = 1, iPartitionOffset = 0 | 1470 | //for non-dynamic slice mode, iPartitionNum = 1, iPartitionOffset = 0 |
| 1466 | iPartitionNum = (SM_SIZELIMITED_SLICE == kuiSliceMode) ? kiThreadNum : 1; | 1471 | iPartitionNum = (SM_SIZELIMITED_SLICE == kuiSliceMode) ? kiThreadNum : 1; |
| 1467 | for(iPartitionIdx = 0; iPartitionIdx < iPartitionNum; iPartitionIdx++) { | 1472 | for (iPartitionIdx = 0; iPartitionIdx < iPartitionNum; iPartitionIdx++) { |
| 1468 | aiPartitionOffset[iPartitionIdx] = iEncodeSliceNum; | 1473 | aiPartitionOffset[iPartitionIdx] = iEncodeSliceNum; |
| 1469 | if ( SM_SIZELIMITED_SLICE == kuiSliceMode) { | 1474 | if (SM_SIZELIMITED_SLICE == kuiSliceMode) { |
| 1470 | iEncodeSliceNum += pCurLayer->NumSliceCodedOfPartition[iPartitionIdx]; | 1475 | iEncodeSliceNum += pCurLayer->NumSliceCodedOfPartition[iPartitionIdx]; |
| 1471 | } else { | 1476 | } else { |
| 1472 | iEncodeSliceNum = pCurLayer->sSliceEncCtx.iSliceNumInFrame; | 1477 | iEncodeSliceNum = pCurLayer->sSliceEncCtx.iSliceNumInFrame; |
| 1473 | } | 1478 | } |
| 1474 | } | 1479 | } |
| 1475 | 1480 | ||
| 1476 | if( iEncodeSliceNum != pCurLayer->sSliceEncCtx.iSliceNumInFrame) { | 1481 | if (iEncodeSliceNum != pCurLayer->sSliceEncCtx.iSliceNumInFrame) { |
| 1477 | return ENC_RETURN_UNEXPECTED; | 1482 | return ENC_RETURN_UNEXPECTED; |
| 1478 | } | 1483 | } |
| 1479 | 1484 | ||
| @@ -1482,42 +1487,42 @@ int32_t ReOrderSliceInLayer (sWelsEncCtx* pCtx, · 2 unmodified lines | |||
| 1482 | for (iSlcBuffIdx = 0; iSlcBuffIdx < kiThreadNum; iSlcBuffIdx++) { | 1487 | for (iSlcBuffIdx = 0; iSlcBuffIdx < kiThreadNum; iSlcBuffIdx++) { |
| 1483 | iSliceNumInThread = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | 1488 | iSliceNumInThread = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1484 | 1489 | ||
| 1485 | for(iSliceIdx =0; iSliceIdx < iSliceNumInThread; iSliceIdx++) { | 1490 | for (iSliceIdx = 0; iSliceIdx < iSliceNumInThread; iSliceIdx++) { |
| 1486 | pSliceBuffer = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; | 1491 | pSliceBuffer = pCurLayer->sSliceBufferInfo[iSlcBuffIdx].pSliceBuffer + iSliceIdx; |
| 1487 | if (NULL == pSliceBuffer) { | 1492 | if (NULL == pSliceBuffer) { |
| 1488 | return ENC_RETURN_UNEXPECTED; | 1493 | return ENC_RETURN_UNEXPECTED; |
| 1489 | } | 1494 | } |
| 1490 | 1495 | ||
| 1491 | if( -1 != pSliceBuffer->iSliceIdx) { | 1496 | if (-1 != pSliceBuffer->iSliceIdx) { |
| 1492 | iPartitionID = pSliceBuffer->iSliceIdx % iPartitionNum; | 1497 | iPartitionID = pSliceBuffer->iSliceIdx % iPartitionNum; |
| 1493 | iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceBuffer->iSliceIdx / iPartitionNum; | 1498 | iActualSliceIdx = aiPartitionOffset[iPartitionID] + pSliceBuffer->iSliceIdx / iPartitionNum; |
| 1494 | pSliceBuffer->iSliceIdx = iActualSliceIdx; | 1499 | pSliceBuffer->iSliceIdx = iActualSliceIdx; |
| 1495 | pCurLayer->ppSliceInLayer[iActualSliceIdx] = pSliceBuffer; | 1500 | pCurLayer->ppSliceInLayer[iActualSliceIdx] = pSliceBuffer; |
| 1496 | iUsedSliceNum ++; | 1501 | iUsedSliceNum ++; |
| 1497 | } else { | 1502 | } else { |
| 1498 | pCurLayer->ppSliceInLayer[iEncodeSliceNum + iNonUsedBufferNum] = pSliceBuffer; | 1503 | pCurLayer->ppSliceInLayer[iEncodeSliceNum + iNonUsedBufferNum] = pSliceBuffer; |
| 1499 | iNonUsedBufferNum ++; | 1504 | iNonUsedBufferNum ++; |
| 1500 | } | 1505 | } |
| 1501 | } | 1506 | } |
| 1502 | } | 1507 | } |
| 1503 | 1508 | ||
| 1504 | if( iUsedSliceNum != iEncodeSliceNum || | 1509 | if (iUsedSliceNum != iEncodeSliceNum || |
| 1505 | pCurLayer->iMaxSliceNum != (iNonUsedBufferNum + iUsedSliceNum)) { | 1510 | pCurLayer->iMaxSliceNum != (iNonUsedBufferNum + iUsedSliceNum)) { |
| 1506 | return ENC_RETURN_UNEXPECTED; | 1511 | return ENC_RETURN_UNEXPECTED; |
| 1507 | } | 1512 | } |
| 1508 | 1513 | ||
| 1509 | if (ENC_RETURN_SUCCESS != CheckAllSliceBuffer(pCurLayer, iEncodeSliceNum)) { | 1514 | if (ENC_RETURN_SUCCESS != CheckAllSliceBuffer (pCurLayer, iEncodeSliceNum)) { |
| 1510 | return ENC_RETURN_UNEXPECTED; | 1515 | return ENC_RETURN_UNEXPECTED; |
| 1511 | } | 1516 | } |
| 1512 | 1517 | ||
| 1513 | return ENC_RETURN_SUCCESS; | 1518 | return ENC_RETURN_SUCCESS; |
| 1514 | } | 1519 | } |
| 1515 | 1520 | ||
| 1516 | int32_t GetCurLayerNalCount(const SDqLayer* pCurDq, const int32_t kiCodedSliceNum) { | 1521 | int32_t GetCurLayerNalCount (const SDqLayer* pCurDq, const int32_t kiCodedSliceNum) { |
| 1517 | int32_t iTotalNalCount = 0; | 1522 | int32_t iTotalNalCount = 0; |
| 1518 | int32_t iSliceIdx = 0; | 1523 | int32_t iSliceIdx = 0; |
| 1519 | SWelsSliceBs* pSliceBs = NULL; | 1524 | SWelsSliceBs* pSliceBs = NULL; |
| 1520 | for ( ; iSliceIdx < kiCodedSliceNum; iSliceIdx++ ) { | 1525 | for (; iSliceIdx < kiCodedSliceNum; iSliceIdx++) { |
| 1521 | pSliceBs = &pCurDq->ppSliceInLayer[iSliceIdx]->sSliceBs; | 1526 | pSliceBs = &pCurDq->ppSliceInLayer[iSliceIdx]->sSliceBs; |
| 1522 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { | 1527 | if (pSliceBs != NULL && pSliceBs->uiBsPos > 0) { |
| 1523 | iTotalNalCount += pSliceBs->iNalIndex; | 1528 | iTotalNalCount += pSliceBs->iNalIndex; |
| @@ -1527,7 +1532,7 @@ int32_t GetCurLayerNalCount(const SDqLayer* pCurDq, const int32_t kiCodedSliceNu · 3 unmodified lines | |||
| 1527 | return iTotalNalCount; | 1532 | return iTotalNalCount; |
| 1528 | } | 1533 | } |
| 1529 | 1534 | ||
| 1530 | int32_t GetTotalCodedNalCount(SFrameBSInfo* pFbi) { | 1535 | int32_t GetTotalCodedNalCount (SFrameBSInfo* pFbi) { |
| 1531 | int32_t iTotalCodedNalCount = 0; | 1536 | int32_t iTotalCodedNalCount = 0; |
| 1532 | for (int32_t iNalIdx = 0; iNalIdx < MAX_LAYER_NUM_OF_FRAME; iNalIdx++) { | 1537 | for (int32_t iNalIdx = 0; iNalIdx < MAX_LAYER_NUM_OF_FRAME; iNalIdx++) { |
| 1533 | iTotalCodedNalCount += pFbi->sLayerInfo[iNalIdx].iNalCount; | 1538 | iTotalCodedNalCount += pFbi->sLayerInfo[iNalIdx].iNalCount; |
| @@ -1584,13 +1589,13 @@ int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, · 50 unmodified lines | |||
| 1584 | int32_t iCodedNalCount = 0; | 1589 | int32_t iCodedNalCount = 0; |
| 1585 | int32_t iRet = 0; | 1590 | int32_t iRet = 0; |
| 1586 | 1591 | ||
| 1587 | for ( int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { | 1592 | for (int32_t iSlcBuffIdx = 0; iSlcBuffIdx < pCtx->iActiveThreadsNum; iSlcBuffIdx++) { |
| 1588 | iMaxSliceNum += pCtx->pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; | 1593 | iMaxSliceNum += pCtx->pCurDqLayer->sSliceBufferInfo[iSlcBuffIdx].iMaxSliceNum; |
| 1589 | } | 1594 | } |
| 1590 | 1595 | ||
| 1591 | //reallocate ppSliceInLayer if total encoded slice num exceed max slice num | 1596 | //reallocate ppSliceInLayer if total encoded slice num exceed max slice num |
| 1592 | if (iMaxSliceNum > pCtx->pCurDqLayer->iMaxSliceNum) { | 1597 | if (iMaxSliceNum > pCtx->pCurDqLayer->iMaxSliceNum) { |
| 1593 | iRet = ExtendLayerBuffer(pCtx, pCtx->pCurDqLayer->iMaxSliceNum, iMaxSliceNum); | 1598 | iRet = ExtendLayerBuffer (pCtx, pCtx->pCurDqLayer->iMaxSliceNum, iMaxSliceNum); |
| 1594 | if (ENC_RETURN_SUCCESS != iRet) { | 1599 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1595 | return iRet; | 1600 | return iRet; |
| 1596 | } | 1601 | } |
| @@ -1607,12 +1612,12 @@ int32_t SliceLayerInfoUpdate (sWelsEncCtx* pCtx, · 10 unmodified lines | |||
| 1607 | 1612 | ||
| 1608 | //Extend NalList buffer if exceed | 1613 | //Extend NalList buffer if exceed |
| 1609 | iCodedSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer); | 1614 | iCodedSliceNum = GetCurrentSliceNum (pCtx->pCurDqLayer); |
| 1610 | pLayerBsInfo->iNalCount = GetCurLayerNalCount(pCtx->pCurDqLayer, iCodedSliceNum); | 1615 | pLayerBsInfo->iNalCount = GetCurLayerNalCount (pCtx->pCurDqLayer, iCodedSliceNum); |
| 1611 | iCodedNalCount = GetTotalCodedNalCount(pFrameBsInfo); | 1616 | iCodedNalCount = GetTotalCodedNalCount (pFrameBsInfo); |
| 1612 | 1617 | ||
| 1613 | if( iCodedNalCount > pCtx->pOut->iCountNals) { | 1618 | if (iCodedNalCount > pCtx->pOut->iCountNals) { |
| 1614 | iRet = FrameBsRealloc (pCtx, pFrameBsInfo, pLayerBsInfo, pCtx->pCurDqLayer->iMaxSliceNum); | 1619 | iRet = FrameBsRealloc (pCtx, pFrameBsInfo, pLayerBsInfo, pCtx->pCurDqLayer->iMaxSliceNum); |
| 1615 | if(ENC_RETURN_SUCCESS != iRet) { | 1620 | if (ENC_RETURN_SUCCESS != iRet) { |
| 1616 | return iRet; | 1621 | return iRet; |
| 1617 | } | 1622 | } |
| 1618 | } | 1623 | } |
| @@ -1625,8 +1630,9 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, const int32_t · 6 unmodified lines | |||
| 1625 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; | 1630 | SWelsSvcRc* pWelsSvcRc = &pEncCtx->pWelsSvcRc[pEncCtx->uiDependencyId]; |
| 1626 | SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; | 1631 | SNalUnitHeaderExt* pNalHeadExt = &pCurLayer->sLayerInfo.sNalHeaderExt; |
| 1627 | SBitStringAux* pBs = pCurSlice->pSliceBsa; | 1632 | SBitStringAux* pBs = pCurSlice->pSliceBsa; |
| 1628 | const int32_t kiDynamicSliceFlag = (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode | 1633 | const int32_t kiDynamicSliceFlag = |
| 1629 | == SM_SIZELIMITED_SLICE); | 1634 | (pEncCtx->pSvcParam->sSpatialLayers[pEncCtx->uiDependencyId].sSliceArgument.uiSliceMode |
| 1635 | == SM_SIZELIMITED_SLICE); | ||
| 1630 | if (I_SLICE == pEncCtx->eSliceType) { | 1636 | if (I_SLICE == pEncCtx->eSliceType) { |
| 1631 | pNalHeadExt->bIdrFlag = 1; | 1637 | pNalHeadExt->bIdrFlag = 1; |
| 1632 | pCurSlice->sScaleShift = 0; | 1638 | pCurSlice->sScaleShift = 0; |
| @@ -1639,7 +1645,7 @@ int32_t WelsCodeOneSlice (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, const int32_t · 6 unmodified lines | |||
| 1639 | 1645 | ||
| 1640 | //RomRC init slice by slice | 1646 | //RomRC init slice by slice |
| 1641 | if (pWelsSvcRc->bGomRC) { | 1647 | if (pWelsSvcRc->bGomRC) { |
| 1642 | GomRCInitForOneSlice(pCurSlice, pWelsSvcRc->iBitsPerMb); | 1648 | GomRCInitForOneSlice (pCurSlice, pWelsSvcRc->iBitsPerMb); |
| 1643 | } | 1649 | } |
| 1644 | 1650 | ||
| 1645 | g_pWelsWriteSliceHeader[pCurSlice->bSliceHeaderExtFlag] (pEncCtx, pBs, pCurLayer, pCurSlice, | 1651 | g_pWelsWriteSliceHeader[pCurSlice->bSliceHeaderExtFlag] (pEncCtx, pBs, pCurLayer, pCurSlice, |
| @@ -1695,7 +1701,7 @@ void AddSliceBoundary (sWelsEncCtx* pEncCtx, SSlice* pCurSlice, SSliceCtx* pSlic · 49 unmodified lines | |||
| 1695 | pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | 1701 | pCurSlice->sSliceHeaderExt.uiNumMbsInSlice = 1 + iCurMbIdx - pCurSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; |
| 1696 | 1702 | ||
| 1697 | //pNextSlice pointer/initialization | 1703 | //pNextSlice pointer/initialization |
| 1698 | if(pEncCtx->iActiveThreadsNum > 1) { | 1704 | if (pEncCtx->iActiveThreadsNum > 1) { |
| 1699 | pNextSlice = &pSliceBuffer[ iCodedSliceNum + 1 ]; | 1705 | pNextSlice = &pSliceBuffer[ iCodedSliceNum + 1 ]; |
| 1700 | } else { | 1706 | } else { |
| 1701 | pNextSlice = &pSliceBuffer[ iNextSliceIdc ]; | 1707 | pNextSlice = &pSliceBuffer[ iNextSliceIdc ]; |