Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 2 files). Show all
Unified · Split
| @@ -166,9 +166,9 @@ void CheckReferenceNumSetting (SLogContext* pLogCtx, SWelsSvcCodingParam* pParam · 165 unmodified lines | ||
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | −int32_t SliceArgumentValidationFixedSliceMode(SLogContext* pLogCtx, | |
| 170 | − SSliceArgument* pSliceArgument, const RC_MODES kiRCMode, | |
| 171 | − const int32_t kiPicWidth, const int32_t kiPicHeight) { | |
| 169 | +int32_t SliceArgumentValidationFixedSliceMode (SLogContext* pLogCtx, | |
| 170 | + SSliceArgument* pSliceArgument, const RC_MODES kiRCMode, | |
| 171 | + const int32_t kiPicWidth, const int32_t kiPicHeight) { | |
| 172 | 172 | int32_t iCpuCores = 0; |
| 173 | 173 | int32_t iIdx = 0; |
| 174 | 174 | const int32_t iMbWidth = (kiPicWidth + 15) >> 4; |
| @@ -180,7 +180,7 @@ int32_t SliceArgumentValidationFixedSliceMode(SLogContext* pLogCtx, · 5 unmodified lines | ||
| 180 | 180 | |
| 181 | 181 | if (pSliceArgument->uiSliceNum == 0) { |
| 182 | 182 | WelsCPUFeatureDetect (&iCpuCores); |
| 183 | − if (0 == iCpuCores ) { | |
| 183 | + if (0 == iCpuCores) { | |
| 184 | 184 | // cpuid not supported or doesn't expose the number of cores, |
| 185 | 185 | // use high level system API as followed to detect number of pysical/logic processor |
| 186 | 186 | iCpuCores = DynamicDetectCpuCores(); |
| @@ -189,15 +189,17 @@ int32_t SliceArgumentValidationFixedSliceMode(SLogContext* pLogCtx, · 2 unmodified lines | ||
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | if (pSliceArgument->uiSliceNum <= 1) { |
| 192 | − WelsLog (pLogCtx, WELS_LOG_INFO, "SliceArgumentValidationFixedSliceMode(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!", | |
| 193 | − pSliceArgument->uiSliceNum); | |
| 192 | + WelsLog (pLogCtx, WELS_LOG_INFO, | |
| 193 | + "SliceArgumentValidationFixedSliceMode(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type!", | |
| 194 | + pSliceArgument->uiSliceNum); | |
| 194 | 195 | bSingleMode = true; |
| 195 | 196 | } |
| 196 | 197 | |
| 197 | 198 | // considering the coding efficient and performance, |
| 198 | 199 | // iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 199 | 200 | if (iMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| 200 | − WelsLog (pLogCtx, WELS_LOG_INFO, "SliceArgumentValidationFixedSliceMode(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type as CountMbNum less than MIN_NUM_MB_PER_SLICE!", | |
| 201 | + WelsLog (pLogCtx, WELS_LOG_INFO, | |
| 202 | + "SliceArgumentValidationFixedSliceMode(), uiSliceNum(%d) you set for SM_FIXEDSLCNUM_SLICE, now turn to SM_SINGLE_SLICE type as CountMbNum less than MIN_NUM_MB_PER_SLICE!", | |
| 201 | 203 | pSliceArgument->uiSliceNum); |
| 202 | 204 | bSingleMode = true; |
| 203 | 205 | } |
| @@ -213,15 +215,17 @@ int32_t SliceArgumentValidationFixedSliceMode(SLogContext* pLogCtx, · 9 unmodified lines | ||
| 213 | 215 | |
| 214 | 216 | if (pSliceArgument->uiSliceNum > MAX_SLICES_NUM) { |
| 215 | 217 | pSliceArgument->uiSliceNum = MAX_SLICES_NUM; |
| 216 | − WelsLog (pLogCtx, WELS_LOG_WARNING, "SliceArgumentValidationFixedSliceMode(), uiSliceNum exceed MAX_SLICES_NUM! So setting slice num eqaul to MAX_SLICES_NUM(%d)!", | |
| 218 | + WelsLog (pLogCtx, WELS_LOG_WARNING, | |
| 219 | + "SliceArgumentValidationFixedSliceMode(), uiSliceNum exceed MAX_SLICES_NUM! So setting slice num eqaul to MAX_SLICES_NUM(%d)!", | |
| 217 | 220 | pSliceArgument->uiSliceNum); |
| 218 | 221 | } |
| 219 | 222 | |
| 220 | 223 | if (kiRCMode != RC_OFF_MODE) { // multiple slices verify with gom |
| 221 | 224 | //check uiSliceNum and set uiSliceMbNum with current uiSliceNum |
| 222 | 225 | if (!GomValidCheckSliceNum (iMbWidth, iMbHeight, &pSliceArgument->uiSliceNum)) { |
| 223 | − WelsLog (pLogCtx, WELS_LOG_WARNING, "SliceArgumentValidationFixedSliceMode(), unsupported setting with Resolution and uiSliceNum combination under RC on! So uiSliceNum is changed to %d!", | |
| 224 | − pSliceArgument->uiSliceNum); | |
| 226 | + WelsLog (pLogCtx, WELS_LOG_WARNING, | |
| 227 | + "SliceArgumentValidationFixedSliceMode(), unsupported setting with Resolution and uiSliceNum combination under RC on! So uiSliceNum is changed to %d!", | |
| 228 | + pSliceArgument->uiSliceNum); | |
| 225 | 229 | } |
| 226 | 230 | |
| 227 | 231 | if (pSliceArgument->uiSliceNum <= 1 || |
| @@ -235,7 +239,7 @@ int32_t SliceArgumentValidationFixedSliceMode(SLogContext* pLogCtx, · 7 unmodified lines | ||
| 235 | 239 | //check uiSliceMbNum with current uiSliceNum |
| 236 | 240 | WelsLog (pLogCtx, WELS_LOG_ERROR, |
| 237 | 241 | "SliceArgumentValidationFixedSliceMode(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type", |
| 238 | − pSliceArgument->uiSliceMbNum[0]); | |
| 242 | + pSliceArgument->uiSliceMbNum[0]); | |
| 239 | 243 | pSliceArgument->uiSliceMode = SM_SINGLE_SLICE; |
| 240 | 244 | pSliceArgument->uiSliceNum = 1; |
| 241 | 245 | for (iIdx = 0; iIdx < MAX_SLICES_NUM; iIdx++) { |
| @@ -500,7 +504,8 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 258 unmodified lines | ||
| 500 | 504 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 501 | 505 | } |
| 502 | 506 | if ((pCodingParam->uiMaxNalSize != 0) && (pSpatialLayer->sSliceArgument.uiSliceMode != SM_SIZELIMITED_SLICE)) { |
| 503 | − WelsLog (pLogCtx, WELS_LOG_WARNING, "ParamValidationExt(), current layer %d uiSliceMode (%d) settings may not fulfill MaxNalSize = %d", i, | |
| 507 | + WelsLog (pLogCtx, WELS_LOG_WARNING, | |
| 508 | + "ParamValidationExt(), current layer %d uiSliceMode (%d) settings may not fulfill MaxNalSize = %d", i, | |
| 504 | 509 | pSpatialLayer->sSliceArgument.uiSliceMode, pCodingParam->uiMaxNalSize); |
| 505 | 510 | } |
| 506 | 511 | CheckProfileSetting (pLogCtx, pCodingParam, i, pSpatialLayer->uiProfileIdc); |
| @@ -519,9 +524,9 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 12 unmodified lines | ||
| 519 | 524 | } |
| 520 | 525 | break; |
| 521 | 526 | case SM_FIXEDSLCNUM_SLICE: { |
| 522 | − iReturn = SliceArgumentValidationFixedSliceMode(pLogCtx, &pSpatialLayer->sSliceArgument, pCodingParam->iRCMode, | |
| 523 | − kiPicWidth, kiPicHeight); | |
| 524 | − if(iReturn) | |
| 527 | + iReturn = SliceArgumentValidationFixedSliceMode (pLogCtx, &pSpatialLayer->sSliceArgument, pCodingParam->iRCMode, | |
| 528 | + kiPicWidth, kiPicHeight); | |
| 529 | + if (iReturn) | |
| 525 | 530 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 526 | 531 | } |
| 527 | 532 | break; |
| @@ -539,7 +544,7 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 11 unmodified lines | ||
| 539 | 544 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 540 | 545 | } |
| 541 | 546 | pSpatialLayer->sSliceArgument.uiSliceNum = iMbHeight; |
| 542 | − for (uint32_t j=0; j<iMbHeight; j++) { | |
| 547 | + for (uint32_t j = 0; j < iMbHeight; j++) { | |
| 543 | 548 | pSpatialLayer->sSliceArgument.uiSliceMbNum[j] = iMbWidth; |
| 544 | 549 | } |
| 545 | 550 | if (!CheckRowMbMultiSliceSetting (iMbWidth, |
| @@ -598,10 +603,10 @@ int32_t ParamValidationExt (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingPa · 52 unmodified lines | ||
| 598 | 603 | } |
| 599 | 604 | |
| 600 | 605 | if (pSpatialLayer->sSliceArgument.uiSliceSizeConstraint > (pCodingParam->uiMaxNalSize - |
| 601 | − NAL_HEADER_ADD_0X30BYTES)) { | |
| 606 | + NAL_HEADER_ADD_0X30BYTES)) { | |
| 602 | 607 | WelsLog (pLogCtx, WELS_LOG_WARNING, |
| 603 | − "ParamValidationExt(), slice mode = SM_SIZELIMITED_SLICE, uiSliceSizeConstraint = %d ,uiMaxNalsize = %d, will take uiMaxNalsize!", | |
| 604 | − pSpatialLayer->sSliceArgument.uiSliceSizeConstraint, pCodingParam->uiMaxNalSize); | |
| 608 | + "ParamValidationExt(), slice mode = SM_SIZELIMITED_SLICE, uiSliceSizeConstraint = %d ,uiMaxNalsize = %d, will take uiMaxNalsize!", | |
| 609 | + pSpatialLayer->sSliceArgument.uiSliceSizeConstraint, pCodingParam->uiMaxNalSize); | |
| 605 | 610 | pSpatialLayer->sSliceArgument.uiSliceSizeConstraint = pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES; |
| 606 | 611 | } |
| 607 | 612 | } |
| @@ -905,7 +910,7 @@ int32_t AllocMbCacheAligned (SMbCache* pMbCache, CMemoryAlign* pMa) { · 297 unmodified lines | ||
| 905 | 910 | "pMbCache->pPrevIntra4x4PredModeFlag"); |
| 906 | 911 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pPrevIntra4x4PredModeFlag)); |
| 907 | 912 | pMbCache->pRemIntra4x4PredModeFlag = (int8_t*)pMa->WelsMalloc (16 * sizeof (int8_t), |
| 908 | − "pMbCache->pRemIntra4x4PredModeFlag"); | |
| 913 | + "pMbCache->pRemIntra4x4PredModeFlag"); | |
| 909 | 914 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pRemIntra4x4PredModeFlag)); |
| 910 | 915 | pMbCache->pDct = (SDCTCoeff*)pMa->WelsMalloc (sizeof (SDCTCoeff), "pMbCache->pDct"); |
| 911 | 916 | WELS_VERIFY_RETURN_IF (1, (NULL == pMbCache->pDct)); |
| @@ -1095,7 +1100,7 @@ int32_t FindExistingPps (SWelsSPS* pSps, SSubsetSps* pSubsetSps, const bool kbUs · 183 unmodified lines | ||
| 1095 | 1100 | } |
| 1096 | 1101 | |
| 1097 | 1102 | static inline int32_t InitpSliceInLayer (sWelsEncCtx** ppCtx, SDqLayer* pDqLayer, CMemoryAlign* pMa, |
| 1098 | − const int32_t iMaxSliceNum, const int32_t kiDlayerIndex) { | |
| 1103 | + const int32_t iMaxSliceNum, const int32_t kiDlayerIndex) { | |
| 1099 | 1104 | int32_t iMaxSliceBufferSize = (*ppCtx)->iSliceBufferSize[kiDlayerIndex]; |
| 1100 | 1105 | int32_t iSliceIdx = 0; |
| 1101 | 1106 | SliceModeEnum uiSliceMode = (*ppCtx)->pSvcParam->sSpatialLayers[kiDlayerIndex].sSliceArgument.uiSliceMode; |
| @@ -1105,7 +1110,7 @@ static inline int32_t InitpSliceInLayer (sWelsEncCtx** ppCtx, SDqLayer* pDqLayer · 3 unmodified lines | ||
| 1105 | 1110 | bool bIndependenceBsBuffer = ((*ppCtx)->pSvcParam->iMultipleThreadIdc > 1 && |
| 1106 | 1111 | SM_SINGLE_SLICE != uiSliceMode) ? true : false; |
| 1107 | 1112 | |
| 1108 | − if ( iMaxSliceBufferSize <= 0) { | |
| 1113 | + if (iMaxSliceBufferSize <= 0) { | |
| 1109 | 1114 | return ENC_RETURN_UNEXPECTED; |
| 1110 | 1115 | } |
| 1111 | 1116 | |
| @@ -1115,10 +1120,10 @@ static inline int32_t InitpSliceInLayer (sWelsEncCtx** ppCtx, SDqLayer* pDqLayer · 3 unmodified lines | ||
| 1115 | 1120 | pSlice->uiSliceIdx = iSliceIdx; |
| 1116 | 1121 | pSlice->sSliceBs.uiSize = iMaxSliceBufferSize; |
| 1117 | 1122 | pSlice->sSliceBs.uiBsPos = 0; |
| 1118 | − if (bIndependenceBsBuffer){ | |
| 1123 | + if (bIndependenceBsBuffer) { | |
| 1119 | 1124 | pSlice->pSliceBsa = &pSlice->sSliceBs.sBsWrite; |
| 1120 | 1125 | pSlice->sSliceBs.pBs = (uint8_t*)pMa->WelsMalloc (iMaxSliceBufferSize, "SliceBs"); |
| 1121 | − if ( NULL == pSlice->sSliceBs.pBs) { | |
| 1126 | + if (NULL == pSlice->sSliceBs.pBs) { | |
| 1122 | 1127 | return ENC_RETURN_MEMALLOCERR; |
| 1123 | 1128 | } |
| 1124 | 1129 | } else { |
| @@ -1176,7 +1181,8 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx, SExistingParasetList* p · 51 unmodified lines | ||
| 1176 | 1181 | int32_t iPicWidth = WELS_ALIGN (kiWidth, MB_WIDTH_LUMA) + (PADDING_LENGTH << 1); // with iWidth of horizon |
| 1177 | 1182 | int32_t iPicChromaWidth = iPicWidth >> 1; |
| 1178 | 1183 | |
| 1179 | − iPicWidth = WELS_ALIGN (iPicWidth, 32); // 32(or 16 for chroma below) to match original imp. here instead of iCacheLineSize | |
| 1184 | + iPicWidth = WELS_ALIGN (iPicWidth, | |
| 1185 | + 32); // 32(or 16 for chroma below) to match original imp. here instead of iCacheLineSize | |
| 1180 | 1186 | iPicChromaWidth = WELS_ALIGN (iPicChromaWidth, 16); |
| 1181 | 1187 | |
| 1182 | 1188 | WelsGetEncBlockStrideOffset ((*ppCtx)->pStrideTab->pStrideEncBlockOffset[iDlayerIndex], iPicWidth, iPicChromaWidth); |
| @@ -1826,12 +1832,13 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 643 unmodified lines | ||
| 1826 | 1832 | uiMaxSliceNumEstimation = WELS_MIN (AVERSLICENUM_CONSTRAINT, |
| 1827 | 1833 | (iLayerBsSize / pSliceArgument->uiSliceSizeConstraint) + 1); |
| 1828 | 1834 | (*ppCtx)->iMaxSliceCount = WELS_MAX ((*ppCtx)->iMaxSliceCount, (int) uiMaxSliceNumEstimation); |
| 1829 | − iSliceBufferSize = (WELS_MAX(pSliceArgument->uiSliceSizeConstraint, iLayerBsSize/uiMaxSliceNumEstimation)<<1) + MAX_MACROBLOCK_SIZE_IN_BYTE_x2; | |
| 1835 | + iSliceBufferSize = (WELS_MAX (pSliceArgument->uiSliceSizeConstraint, | |
| 1836 | + iLayerBsSize / uiMaxSliceNumEstimation) << 1) + MAX_MACROBLOCK_SIZE_IN_BYTE_x2; | |
| 1830 | 1837 | } else { |
| 1831 | 1838 | (*ppCtx)->iMaxSliceCount = WELS_MAX ((*ppCtx)->iMaxSliceCount, (int) pSliceArgument->uiSliceNum); |
| 1832 | − iSliceBufferSize = ((iLayerBsSize / pSliceArgument->uiSliceNum)<<1) + MAX_MACROBLOCK_SIZE_IN_BYTE_x2; | |
| 1839 | + iSliceBufferSize = ((iLayerBsSize / pSliceArgument->uiSliceNum) << 1) + MAX_MACROBLOCK_SIZE_IN_BYTE_x2; | |
| 1833 | 1840 | } |
| 1834 | − iMaxSliceBufferSize = WELS_MAX(iMaxSliceBufferSize, iSliceBufferSize); | |
| 1841 | + iMaxSliceBufferSize = WELS_MAX (iMaxSliceBufferSize, iSliceBufferSize); | |
| 1835 | 1842 | (*ppCtx)->iSliceBufferSize[iIndex] = iSliceBufferSize; |
| 1836 | 1843 | ++ iIndex; |
| 1837 | 1844 | } |
| @@ -1842,8 +1849,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 4 unmodified lines | ||
| 1842 | 1849 | iTotalLength = iCountBsLen; |
| 1843 | 1850 | |
| 1844 | 1851 | pParam->iNumRefFrame = WELS_CLIP3 (pParam->iNumRefFrame, MIN_REF_PIC_COUNT, |
| 1845 | − (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : | |
| 1846 | − MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | |
| 1852 | + (pParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : | |
| 1853 | + MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | |
| 1847 | 1854 | |
| 1848 | 1855 | // Output |
| 1849 | 1856 | (*ppCtx)->pOut = (SWelsEncoderOutput*)pMa->WelsMalloc (sizeof (SWelsEncoderOutput), "SWelsEncoderOutput"); |
| @@ -1866,7 +1873,8 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 16 unmodified lines | ||
| 1866 | 1873 | (*ppCtx)->iPosBsBuffer = 0; |
| 1867 | 1874 | |
| 1868 | 1875 | // for pSlice bs buffers |
| 1869 | − if (pParam->iMultipleThreadIdc > 1 && RequestMtResource (ppCtx, pParam, iCountBsLen, iMaxSliceBufferSize, bDynamicSlice)) { | |
| 1876 | + if (pParam->iMultipleThreadIdc > 1 | |
| 1877 | + && RequestMtResource (ppCtx, pParam, iCountBsLen, iMaxSliceBufferSize, bDynamicSlice)) { | |
| 1870 | 1878 | WelsLog (& (*ppCtx)->sLogCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMtResource failed!"); |
| 1871 | 1879 | FreeMemorySvc (ppCtx); |
| 1872 | 1880 | return 1; |
| @@ -1889,7 +1897,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx, SExistingParasetList* pExistingPa · 16 unmodified lines | ||
| 1889 | 1897 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pRefIndexBlock4x4), FreeMemorySvc (ppCtx)) |
| 1890 | 1898 | |
| 1891 | 1899 | (*ppCtx)->pSadCostMb = static_cast<int32_t*> |
| 1892 | − (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); | |
| 1900 | + (pMa->WelsMallocz (iCountMaxMbNum * sizeof (int32_t), "pSadCostMb")); | |
| 1893 | 1901 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pSadCostMb), FreeMemorySvc (ppCtx)) |
| 1894 | 1902 | |
| 1895 | 1903 | (*ppCtx)->bEncCurFrmAsIdrFlag = true; // make sure first frame is IDR |
| @@ -2148,8 +2156,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 252 unmodified lines | ||
| 2148 | 2156 | FreeMbCache (&pSlice->sMbCacheInfo, pMa); |
| 2149 | 2157 | |
| 2150 | 2158 | //slice bs buffer |
| 2151 | − if(NULL != pSlice->sSliceBs.pBs) { | |
| 2152 | − pMa->WelsFree(pSlice->sSliceBs.pBs,"sSliceBs.pBs"); | |
| 2159 | + if (NULL != pSlice->sSliceBs.pBs) { | |
| 2160 | + pMa->WelsFree (pSlice->sSliceBs.pBs, "sSliceBs.pBs"); | |
| 2153 | 2161 | pSlice->sSliceBs.pBs = NULL; |
| 2154 | 2162 | } |
| 2155 | 2163 | ++ iSliceIdx; |
| @@ -2292,16 +2300,16 @@ int32_t InitSliceSettings (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodin · 136 unmodified lines | ||
| 2292 | 2300 | iMaxSliceCount = AVERSLICENUM_CONSTRAINT; |
| 2293 | 2301 | break; // go through for SM_SIZELIMITED_SLICE? |
| 2294 | 2302 | case SM_FIXEDSLCNUM_SLICE: { |
| 2295 | − iReturn = SliceArgumentValidationFixedSliceMode(pLogCtx, &pDlp->sSliceArgument, pCodingParam->iRCMode, | |
| 2296 | − pDlp->iVideoWidth, pDlp->iVideoHeight); | |
| 2297 | − if(iReturn) | |
| 2303 | + iReturn = SliceArgumentValidationFixedSliceMode (pLogCtx, &pDlp->sSliceArgument, pCodingParam->iRCMode, | |
| 2304 | + pDlp->iVideoWidth, pDlp->iVideoHeight); | |
| 2305 | + if (iReturn) | |
| 2298 | 2306 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 2299 | 2307 | |
| 2300 | 2308 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) { |
| 2301 | 2309 | iMaxSliceCount = pSliceArgument->uiSliceNum; |
| 2302 | 2310 | } |
| 2303 | 2311 | } |
| 2304 | − break; | |
| 2312 | + break; | |
| 2305 | 2313 | case SM_SINGLE_SLICE: |
| 2306 | 2314 | if (pSliceArgument->uiSliceNum > iMaxSliceCount) |
| 2307 | 2315 | iMaxSliceCount = pSliceArgument->uiSliceNum; |
| @@ -2380,7 +2388,8 @@ void OutputCpuFeaturesLog (SLogContext* pLogCtx, uint32_t uiCpuFeatureFlags, uin · 72 unmodified lines | ||
| 2380 | 2388 | int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCodingParam, int16_t& iSliceNum, |
| 2381 | 2389 | int32_t& iCacheLineSize, uint32_t& uiCpuFeatureFlags) { |
| 2382 | 2390 | // for cpu features detection, Only detect once?? |
| 2383 | − int32_t uiCpuCores = 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported | |
| 2391 | + int32_t uiCpuCores = | |
| 2392 | + 0; // number of logic processors on physical processor package, zero logic processors means HTT not supported | |
| 2384 | 2393 | uiCpuFeatureFlags = WelsCPUFeatureDetect (&uiCpuCores); // detect cpu capacity features |
| 2385 | 2394 | |
| 2386 | 2395 | #ifdef X86_ASM |
| @@ -2403,8 +2412,8 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding · 16 unmodified lines | ||
| 2403 | 2412 | uiCpuCores = DynamicDetectCpuCores(); |
| 2404 | 2413 | } |
| 2405 | 2414 | |
| 2406 | − if(0 == pCodingParam->iMultipleThreadIdc) | |
| 2407 | − pCodingParam->iMultipleThreadIdc = (uiCpuCores > 0) ? uiCpuCores : 1; | |
| 2415 | + if (0 == pCodingParam->iMultipleThreadIdc) | |
| 2416 | + pCodingParam->iMultipleThreadIdc = (uiCpuCores > 0) ? uiCpuCores : 1; | |
| 2408 | 2417 | |
| 2409 | 2418 | // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, |
| 2410 | 2419 | // for client application here it is constrained by maximal to MAX_THREADS_NUM |
| @@ -2673,7 +2682,7 @@ void DynslcUpdateMbNeighbourInfoListForAllSlices (SDqLayer* pCurDq, SMB* pMbList · 262 unmodified lines | ||
| 2673 | 2682 | |
| 2674 | 2683 | do { |
| 2675 | 2684 | SMB* pMb = &pMbList[iIdx]; |
| 2676 | − UpdateMbNeighbor(pCurDq, pMb, kiMbWidth, WelsMbToSliceIdc (pCurDq, pMb->iMbXY)); | |
| 2685 | + UpdateMbNeighbor (pCurDq, pMb, kiMbWidth, WelsMbToSliceIdc (pCurDq, pMb->iMbXY)); | |
| 2677 | 2686 | ++ iIdx; |
| 2678 | 2687 | } while (iIdx <= kiEndMbInSlice); |
| 2679 | 2688 | } |
| @@ -2881,7 +2890,7 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 201 unmodified lines | ||
| 2881 | 2890 | } |
| 2882 | 2891 | |
| 2883 | 2892 | if (pCtx->pTaskManage) { |
| 2884 | − pCtx->pTaskManage->InitFrame(kiCurDid); | |
| 2893 | + pCtx->pTaskManage->InitFrame (kiCurDid); | |
| 2885 | 2894 | } |
| 2886 | 2895 | } |
| 2887 | 2896 | |
| @@ -3045,7 +3054,7 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 157 unmodified lines | ||
| 3045 | 3054 | const int32_t kiCurTid = pCtx->uiTemporalId; |
| 3046 | 3055 | if (pCurLayer->bDeblockingParallelFlag && (pCurLayer->iLoopFilterDisableIdc != 1) |
| 3047 | 3056 | #if !defined(ENABLE_FRAME_DUMP) |
| 3048 | − && ( NRI_PRI_LOWEST != pCtx->eNalPriority ) | |
| 3057 | + && (NRI_PRI_LOWEST != pCtx->eNalPriority) | |
| 3049 | 3058 | && (pCtx->pSvcParam->sDependencyLayers[kiCurDid].iHighestTemporalId == 0 |
| 3050 | 3059 | || kiCurTid < pCtx->pSvcParam->sDependencyLayers[kiCurDid].iHighestTemporalId) |
| 3051 | 3060 | #endif// !ENABLE_FRAME_DUMP |
| @@ -3658,7 +3667,7 @@ void StackBackEncoderStatus (sWelsEncCtx* pEncCtx, · 606 unmodified lines | ||
| 3658 | 3667 | pEncCtx->iPOC = (1 << pEncCtx->pSps->iLog2MaxPocLsb) - 2; |
| 3659 | 3668 | } |
| 3660 | 3669 | |
| 3661 | − LoadBackFrameNum(pEncCtx); | |
| 3670 | + LoadBackFrameNum (pEncCtx); | |
| 3662 | 3671 | pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; |
| 3663 | 3672 | pEncCtx->eSliceType = P_SLICE; |
| 3664 | 3673 | //pEncCtx->eNalPriority = pEncCtx->eLastNalPriority; //not need this since eNalPriority will be updated at the beginning of coding a frame |
| @@ -3709,7 +3718,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 44 unmodified lines | ||
| 3709 | 3718 | int32_t iDidList[MAX_DEPENDENCY_LAYER] = {0}; |
| 3710 | 3719 | int32_t iLayerNum = 0; |
| 3711 | 3720 | int32_t iLayerSize = 0; |
| 3712 | − int32_t iSpatialNum = 0; // available count number of spatial layers due to frame size changed in this given frame | |
| 3721 | + int32_t iSpatialNum = | |
| 3722 | + 0; // available count number of spatial layers due to frame size changed in this given frame | |
| 3713 | 3723 | int32_t iSpatialIdx = 0; // iIndex of spatial layers due to frame size changed in this given frame |
| 3714 | 3724 | int32_t iFrameSize = 0; |
| 3715 | 3725 | int32_t iNalIdxInLayer = 0; |
| @@ -3851,8 +3861,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 135 unmodified lines | ||
| 3851 | 3861 | iNalIdxInLayer = 0; |
| 3852 | 3862 | bAvcBased = ((pSvcParam->bSimulcastAVC) || (iCurDid == BASE_DEPENDENCY_ID)); |
| 3853 | 3863 | pCtx->bNeedPrefixNalFlag = ((!pSvcParam->bSimulcastAVC) && (bAvcBased && |
| 3854 | − (pSvcParam->bPrefixNalAddingCtrl || | |
| 3855 | − (pSvcParam->iSpatialLayerNum > 1)))); | |
| 3864 | + (pSvcParam->bPrefixNalAddingCtrl || | |
| 3865 | + (pSvcParam->iSpatialLayerNum > 1)))); | |
| 3856 | 3866 | |
| 3857 | 3867 | if (eFrameType == videoFrameTypeP) { |
| 3858 | 3868 | eNalType = bAvcBased ? NAL_UNIT_CODED_SLICE : NAL_UNIT_CODED_SLICE_EXT; |
| @@ -4009,7 +4019,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 150 unmodified lines | ||
| 4009 | 4019 | #else |
| 4010 | 4020 | int32_t iEndMbIdx = pCtx->pCurDqLayer->sSliceEncCtx.iMbNumInFrame; |
| 4011 | 4021 | for (int32_t iIdx = kiPartitionCnt - 1; iIdx >= 0; --iIdx) { |
| 4012 | − const int32_t iFirstMbIdx = pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | |
| 4022 | + const int32_t iFirstMbIdx = | |
| 4023 | + pCtx->pCurDqLayer->sLayerInfo.pSliceInLayer[iIdx].sSliceHeaderExt.sSliceHeader.iFirstMbInSlice; | |
| 4013 | 4024 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].iStartMbIndex = iFirstMbIdx; |
| 4014 | 4025 | pCtx->pSliceThreading->pThreadPEncCtx[iIdx].iEndMbIndex = iEndMbIdx; |
| 4015 | 4026 | iEndMbIdx = iFirstMbIdx; |
| @@ -4109,7 +4120,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSour · 93 unmodified lines | ||
| 4109 | 4120 | pCtx->pFuncList->pfRc.pfWelsUpdateBufferWhenSkip (pCtx, iSpatialNum); |
| 4110 | 4121 | } |
| 4111 | 4122 | |
| 4112 | − WelsRcPostFrameSkippedUpdate(pCtx, iCurDid); | |
| 4123 | + WelsRcPostFrameSkippedUpdate (pCtx, iCurDid); | |
| 4113 | 4124 | WelsLog (& (pCtx->sLogCtx), WELS_LOG_INFO, |
| 4114 | 4125 | "[Rc] Frame timestamp = %lld, skip one frame due to post skip, continual skipped %d frames", |
| 4115 | 4126 | pSrcPic->uiTimeStamp, pCtx->iContinualSkipFrames); |
| @@ -4432,18 +4443,18 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 316 unmodified lines | ||
| 4432 | 4443 | /* Decide whether need reset for IDR frame based on adjusting prarameters changed */ |
| 4433 | 4444 | /* Temporal levels, spatial settings and/ or quality settings changed need update parameter sets related. */ |
| 4434 | 4445 | bNeedReset = (pOldParam == NULL) || |
| 4435 | − (pOldParam->bSimulcastAVC != pNewParam->bSimulcastAVC) || | |
| 4436 | − (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) || | |
| 4437 | − (pOldParam->iPicWidth != pNewParam->iPicWidth | |
| 4438 | − || pOldParam->iPicHeight != pNewParam->iPicHeight) || | |
| 4439 | − (pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth | |
| 4440 | − || pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) || | |
| 4441 | − (pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) || | |
| 4442 | − (pOldParam->iLTRRefNum != pNewParam->iLTRRefNum) || | |
| 4443 | − (pOldParam->iMultipleThreadIdc != pNewParam->iMultipleThreadIdc) || | |
| 4444 | − (pOldParam->bEnableBackgroundDetection != pNewParam->bEnableBackgroundDetection) || | |
| 4445 | − (pOldParam->bEnableAdaptiveQuant != pNewParam->bEnableAdaptiveQuant) || | |
| 4446 | − (pOldParam->eSpsPpsIdStrategy != pNewParam->eSpsPpsIdStrategy); | |
| 4446 | + (pOldParam->bSimulcastAVC != pNewParam->bSimulcastAVC) || | |
| 4447 | + (pOldParam->iSpatialLayerNum != pNewParam->iSpatialLayerNum) || | |
| 4448 | + (pOldParam->iPicWidth != pNewParam->iPicWidth | |
| 4449 | + || pOldParam->iPicHeight != pNewParam->iPicHeight) || | |
| 4450 | + (pOldParam->SUsedPicRect.iWidth != pNewParam->SUsedPicRect.iWidth | |
| 4451 | + || pOldParam->SUsedPicRect.iHeight != pNewParam->SUsedPicRect.iHeight) || | |
| 4452 | + (pOldParam->bEnableLongTermReference != pNewParam->bEnableLongTermReference) || | |
| 4453 | + (pOldParam->iLTRRefNum != pNewParam->iLTRRefNum) || | |
| 4454 | + (pOldParam->iMultipleThreadIdc != pNewParam->iMultipleThreadIdc) || | |
| 4455 | + (pOldParam->bEnableBackgroundDetection != pNewParam->bEnableBackgroundDetection) || | |
| 4456 | + (pOldParam->bEnableAdaptiveQuant != pNewParam->bEnableAdaptiveQuant) || | |
| 4457 | + (pOldParam->eSpsPpsIdStrategy != pNewParam->eSpsPpsIdStrategy); | |
| 4447 | 4458 | if (pNewParam->iMaxNumRefFrame > pOldParam->iMaxNumRefFrame) { |
| 4448 | 4459 | bNeedReset = true; |
| 4449 | 4460 | } |
| @@ -4466,7 +4477,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 16 unmodified lines | ||
| 4466 | 4477 | break; |
| 4467 | 4478 | } |
| 4468 | 4479 | |
| 4469 | − if (pOldParam->sSpatialLayers[iIndexD].sSliceArgument.uiSliceMode != pNewParam->sSpatialLayers[iIndexD].sSliceArgument.uiSliceMode | |
| 4480 | + if (pOldParam->sSpatialLayers[iIndexD].sSliceArgument.uiSliceMode != | |
| 4481 | + pNewParam->sSpatialLayers[iIndexD].sSliceArgument.uiSliceMode | |
| 4470 | 4482 | || |
| 4471 | 4483 | pOldParam->sSpatialLayers[iIndexD].sSliceArgument.uiSliceNum != |
| 4472 | 4484 | pNewParam->sSpatialLayers[iIndexD].sSliceArgument.uiSliceNum) { |
| @@ -4571,8 +4583,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 98 unmodified lines | ||
| 4571 | 4583 | } else { |
| 4572 | 4584 | /* maybe adjustment introduced in bitrate or little settings adjustment and so on.. */ |
| 4573 | 4585 | pNewParam->iNumRefFrame = WELS_CLIP3 (pNewParam->iNumRefFrame, MIN_REF_PIC_COUNT, |
| 4574 | − (pNewParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : | |
| 4575 | − MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | |
| 4586 | + (pNewParam->iUsageType == CAMERA_VIDEO_REAL_TIME ? MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA : | |
| 4587 | + MAX_REFERENCE_PICTURE_COUNT_NUM_SCREEN)); | |
| 4576 | 4588 | pNewParam->iLoopFilterDisableIdc = WELS_CLIP3 (pNewParam->iLoopFilterDisableIdc, 0, 6); |
| 4577 | 4589 | pNewParam->iLoopFilterAlphaC0Offset = WELS_CLIP3 (pNewParam->iLoopFilterAlphaC0Offset, -6, 6); |
| 4578 | 4590 | pNewParam->iLoopFilterBetaOffset = WELS_CLIP3 (pNewParam->iLoopFilterBetaOffset, -6, 6); |
| @@ -4612,13 +4624,16 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 33 unmodified lines | ||
| 4612 | 4624 | /* Motion search */ |
| 4613 | 4625 | |
| 4614 | 4626 | /* Deblocking loop filter */ |
| 4615 | − pOldParam->iLoopFilterDisableIdc = pNewParam->iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries | |
| 4627 | + pOldParam->iLoopFilterDisableIdc = | |
| 4628 | + pNewParam->iLoopFilterDisableIdc; // 0: on, 1: off, 2: on except for slice boundaries | |
| 4616 | 4629 | pOldParam->iLoopFilterAlphaC0Offset = pNewParam->iLoopFilterAlphaC0Offset;// AlphaOffset: valid range [-6, 6], default 0 |
| 4617 | − pOldParam->iLoopFilterBetaOffset = pNewParam->iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 | |
| 4630 | + pOldParam->iLoopFilterBetaOffset = | |
| 4631 | + pNewParam->iLoopFilterBetaOffset; // BetaOffset: valid range [-6, 6], default 0 | |
| 4618 | 4632 | |
| 4619 | 4633 | /* Rate Control */ |
| 4620 | 4634 | pOldParam->iRCMode = pNewParam->iRCMode; |
| 4621 | − pOldParam->iTargetBitrate = pNewParam->iTargetBitrate; // overall target bitrate introduced in RC module | |
| 4635 | + pOldParam->iTargetBitrate = | |
| 4636 | + pNewParam->iTargetBitrate; // overall target bitrate introduced in RC module | |
| 4622 | 4637 | pOldParam->iPaddingFlag = pNewParam->iPaddingFlag; |
| 4623 | 4638 | |
| 4624 | 4639 | /* Layer definition */ |
| @@ -4637,7 +4652,8 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 12 unmodified lines | ||
| 4637 | 4652 | pOldDlpInternal->fOutputFrameRate = pNewDlpInternal->fOutputFrameRate; // output frame rate |
| 4638 | 4653 | pOldDlp->iSpatialBitrate = pNewDlp->iSpatialBitrate; |
| 4639 | 4654 | |
| 4640 | − pOldDlp->uiProfileIdc = pNewDlp->uiProfileIdc; // value of profile IDC (0 for auto-detection) | |
| 4655 | + pOldDlp->uiProfileIdc = | |
| 4656 | + pNewDlp->uiProfileIdc; // value of profile IDC (0 for auto-detection) | |
| 4641 | 4657 | pOldDlp->iDLayerQp = pNewDlp->iDLayerQp; |
| 4642 | 4658 | |
| 4643 | 4659 | /* Derived variants below */ |
| @@ -4679,7 +4695,7 @@ int32_t WelsEncoderApplyLTR (SLogContext* pLogCtx, sWelsEncCtx** ppCtx, SLTRConf · 35 unmodified lines | ||
| 4679 | 4695 | sConfig.iLTRRefNum = 0; |
| 4680 | 4696 | } |
| 4681 | 4697 | iNumRefFrame = ((uiGopSize >> 1) > 1) ? ((uiGopSize >> 1) + sConfig.iLTRRefNum) : (MIN_REF_PIC_COUNT + |
| 4682 | − sConfig.iLTRRefNum); | |
| 4698 | + sConfig.iLTRRefNum); | |
| 4683 | 4699 | iNumRefFrame = WELS_CLIP3 (iNumRefFrame, MIN_REF_PIC_COUNT, MAX_REFERENCE_PICTURE_COUNT_NUM_CAMERA); |
| 4684 | 4700 | |
| 4685 | 4701 | } |
| @@ -4794,13 +4810,14 @@ int32_t DynSliceRealloc (sWelsEncCtx* pCtx, · 108 unmodified lines | ||
| 4794 | 4810 | uiSliceIdx = iMaxSliceNumOld; |
| 4795 | 4811 | SRCSlicing* pSORC = &pSlcingOverRc[uiSliceIdx]; |
| 4796 | 4812 | const int32_t kiBitsPerMb = WELS_DIV_ROUND (pCtx->pWelsSvcRc[kiCurDid].iTargetBits * INT_MULTIPLY, |
| 4797 | − pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); | |
| 4813 | + pCtx->pWelsSvcRc[kiCurDid].iNumberMbFrame); | |
| 4798 | 4814 | while (uiSliceIdx < iMaxSliceNum) { |
| 4799 | 4815 | pSORC->iComplexityIndexSlice = 0; |
| 4800 | 4816 | pSORC->iCalculatedQpSlice = pCtx->iGlobalQp; |
| 4801 | 4817 | pSORC->iTotalQpSlice = 0; |
| 4802 | 4818 | pSORC->iTotalMbSlice = 0; |
| 4803 | − pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx].iCountMbNumInSlice, | |
| 4819 | + pSORC->iTargetBitsSlice = WELS_DIV_ROUND (kiBitsPerMb * | |
| 4820 | + pCurLayer->sLayerInfo.pSliceInLayer[uiSliceIdx].iCountMbNumInSlice, | |
| 4804 | 4821 | INT_MULTIPLY); |
| 4805 | 4822 | pSORC->iFrameBitsSlice = 0; |
| 4806 | 4823 | pSORC->iGomBitsSlice = 0; |
| @@ -4845,7 +4862,8 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 38 unmodified lines | ||
| 4845 | 4862 | //init |
| 4846 | 4863 | { |
| 4847 | 4864 | pStartSlice->sSliceHeaderExt.sSliceHeader.iFirstMbInSlice = iFirstMbInPartition; |
| 4848 | − pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = 1; // one slice per partition intialized, dynamic slicing inside | |
| 4865 | + pCurLayer->pNumSliceCodedOfPartition[kiPartitionId] = | |
| 4866 | + 1; // one slice per partition intialized, dynamic slicing inside | |
| 4849 | 4867 | pCurLayer->pLastMbIdxOfPartition[kiPartitionId] = iEndMbInPartition - 1; |
| 4850 | 4868 | } |
| 4851 | 4869 | pCurLayer->pLastCodedMbIdxOfPartition[kiPartitionId] = 0; |