Showing the changes to codec/encoder/core/src/encoder_ext.cpp (1 of 5 files). Show all
Unified · Split
| @@ -79,8 +79,8 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 78 unmodified lines | ||
| 79 | 79 | |
| 80 | 80 | assert (pCfg != NULL); |
| 81 | 81 | |
| 82 | − if((pCfg->iUsageType != CAMERA_VIDEO_REAL_TIME)&&(pCfg->iUsageType != SCREEN_CONTENT_REAL_TIME)){ | |
| 83 | − WelsLog (NULL, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d",pCfg->iUsageType); | |
| 82 | + if ((pCfg->iUsageType != CAMERA_VIDEO_REAL_TIME) && (pCfg->iUsageType != SCREEN_CONTENT_REAL_TIME)) { | |
| 83 | + WelsLog (NULL, WELS_LOG_ERROR, "ParamValidation(),Invalid usage type = %d", pCfg->iUsageType); | |
| 84 | 84 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 85 | 85 | } |
| 86 | 86 | for (i = 0; i < pCfg->iSpatialLayerNum; ++ i) { |
| @@ -88,12 +88,13 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 1 unmodified line | ||
| 88 | 88 | if (fDlp->fOutputFrameRate > fDlp->fInputFrameRate || (fDlp->fInputFrameRate >= -fEpsn |
| 89 | 89 | && fDlp->fInputFrameRate <= fEpsn) |
| 90 | 90 | || (fDlp->fOutputFrameRate >= -fEpsn && fDlp->fOutputFrameRate <= fEpsn)) { |
| 91 | − WelsLog (NULL, WELS_LOG_ERROR,"Invalid settings in input frame rate(%.6f) or output frame rate(%.6f) of layer #%d config file..\n", | |
| 91 | + WelsLog (NULL, WELS_LOG_ERROR, | |
| 92 | + "Invalid settings in input frame rate(%.6f) or output frame rate(%.6f) of layer #%d config file..\n", | |
| 92 | 93 | fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i); |
| 93 | 94 | return ENC_RETURN_INVALIDINPUT; |
| 94 | 95 | } |
| 95 | 96 | if (UINT_MAX == GetLogFactor (fDlp->fOutputFrameRate, fDlp->fInputFrameRate)) { |
| 96 | − WelsLog (NULL,WELS_LOG_ERROR, | |
| 97 | + WelsLog (NULL, WELS_LOG_ERROR, | |
| 97 | 98 | "Invalid settings in input frame rate(%.6f) and output frame rate(%.6f) of layer #%d config file: iResult of output frame rate divided by input frame rate should be power of 2(i.e,in/pOut=2^n)..\n", |
| 98 | 99 | fDlp->fInputFrameRate, fDlp->fOutputFrameRate, i); |
| 99 | 100 | return ENC_RETURN_INVALIDINPUT; |
| @@ -115,7 +116,7 @@ int32_t ParamValidation (SWelsSvcCodingParam* pCfg) { · 15 unmodified lines | ||
| 115 | 116 | } |
| 116 | 117 | |
| 117 | 118 | |
| 118 | −int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) { | |
| 119 | +int32_t ParamValidationExt (sWelsEncCtx* pCtx, SWelsSvcCodingParam* pCodingParam) { | |
| 119 | 120 | int8_t i = 0; |
| 120 | 121 | int32_t iIdx = 0; |
| 121 | 122 | |
| @@ -123,8 +124,8 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 1 unmodified line | ||
| 123 | 124 | if (NULL == pCodingParam) |
| 124 | 125 | return ENC_RETURN_INVALIDINPUT; |
| 125 | 126 | |
| 126 | − if((pCodingParam->iUsageType != CAMERA_VIDEO_REAL_TIME)&&(pCodingParam->iUsageType != SCREEN_CONTENT_REAL_TIME)){ | |
| 127 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(),Invalid usage type = %d",pCodingParam->iUsageType); | |
| 127 | + if ((pCodingParam->iUsageType != CAMERA_VIDEO_REAL_TIME) && (pCodingParam->iUsageType != SCREEN_CONTENT_REAL_TIME)) { | |
| 128 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(),Invalid usage type = %d", pCodingParam->iUsageType); | |
| 128 | 129 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 129 | 130 | } |
| 130 | 131 | if (pCodingParam->iSpatialLayerNum < 1 || pCodingParam->iSpatialLayerNum > MAX_DEPENDENCY_LAYER) { |
| @@ -140,7 +141,8 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 9 unmodified lines | ||
| 140 | 141 | } |
| 141 | 142 | |
| 142 | 143 | if (pCodingParam->uiGopSize < 1 || pCodingParam->uiGopSize > MAX_GOP_SIZE) { |
| 143 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), monitor invalid pCodingParam->uiGopSize: %d!\n", pCodingParam->uiGopSize); | |
| 144 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), monitor invalid pCodingParam->uiGopSize: %d!\n", | |
| 145 | + pCodingParam->uiGopSize); | |
| 144 | 146 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 145 | 147 | } |
| 146 | 148 | |
| @@ -153,7 +155,8 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 6 unmodified lines | ||
| 153 | 155 | } |
| 154 | 156 | |
| 155 | 157 | if (pCodingParam->uiIntraPeriod && (pCodingParam->uiIntraPeriod & (pCodingParam->uiGopSize - 1)) != 0) { |
| 156 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), uiIntraPeriod(%d) should be multiple of uiGopSize(%d) or -1 specified!\n", | |
| 158 | + WelsLog (pCtx, WELS_LOG_ERROR, | |
| 159 | + "ParamValidationExt(), uiIntraPeriod(%d) should be multiple of uiGopSize(%d) or -1 specified!\n", | |
| 157 | 160 | pCodingParam->uiIntraPeriod, pCodingParam->uiGopSize); |
| 158 | 161 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 159 | 162 | } |
| @@ -180,7 +183,8 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 20 unmodified lines | ||
| 180 | 183 | int32_t iMbNumInFrame = 0; |
| 181 | 184 | uint32_t iMaxSliceNum = MAX_SLICES_NUM; |
| 182 | 185 | if (kiPicWidth <= 0 || kiPicHeight <= 0) { |
| 183 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid %d x %d in dependency layer settings!\n", kiPicWidth, kiPicHeight); | |
| 186 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid %d x %d in dependency layer settings!\n", kiPicWidth, | |
| 187 | + kiPicHeight); | |
| 184 | 188 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 185 | 189 | } |
| 186 | 190 | if ((kiPicWidth & 0x0F) != 0 || (kiPicHeight & 0x0F) != 0) { |
| @@ -191,11 +195,13 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 4 unmodified lines | ||
| 191 | 195 | } |
| 192 | 196 | |
| 193 | 197 | if (fDlp->sSliceCfg.uiSliceMode >= SM_RESERVED) { |
| 194 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n", fDlp->sSliceCfg.uiSliceMode); | |
| 198 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMode (%d) settings!\n", | |
| 199 | + fDlp->sSliceCfg.uiSliceMode); | |
| 195 | 200 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 196 | 201 | } |
| 197 | − if((pCodingParam->uiMaxNalSize != 0) && (fDlp->sSliceCfg.uiSliceMode != SM_DYN_SLICE)){ | |
| 198 | − WelsLog (pCtx, WELS_LOG_ERROR,"ParamValidationExt(), invalid uiSliceMode (%d) settings!,MaxNalSize = %d\n", fDlp->sSliceCfg.uiSliceMode,pCodingParam->uiMaxNalSize); | |
| 202 | + if ((pCodingParam->uiMaxNalSize != 0) && (fDlp->sSliceCfg.uiSliceMode != SM_DYN_SLICE)) { | |
| 203 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMode (%d) settings!,MaxNalSize = %d\n", | |
| 204 | + fDlp->sSliceCfg.uiSliceMode, pCodingParam->uiMaxNalSize); | |
| 199 | 205 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 200 | 206 | } |
| 201 | 207 | //check pSlice settings under multi-pSlice |
| @@ -212,7 +218,7 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 10 unmodified lines | ||
| 212 | 218 | fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[iIdx] = 0; |
| 213 | 219 | } |
| 214 | 220 | break; |
| 215 | − case SM_FIXEDSLCNUM_SLICE:{ | |
| 221 | + case SM_FIXEDSLCNUM_SLICE: { | |
| 216 | 222 | fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0; |
| 217 | 223 | |
| 218 | 224 | iMbWidth = (kiPicWidth + 15) >> 4; |
| @@ -220,8 +226,9 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 1 unmodified line | ||
| 220 | 226 | iMbNumInFrame = iMbWidth * iMbHeight; |
| 221 | 227 | iMaxSliceNum = MAX_SLICES_NUM; |
| 222 | 228 | if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0 |
| 223 | − || fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { | |
| 224 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sSliceCfg.sSliceArgument.uiSliceNum); | |
| 229 | + || fDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceNum) { | |
| 230 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", | |
| 231 | + fDlp->sSliceCfg.sSliceArgument.uiSliceNum); | |
| 225 | 232 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 226 | 233 | } |
| 227 | 234 | if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) { |
| @@ -240,7 +247,7 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 12 unmodified lines | ||
| 240 | 247 | } else if (!CheckFixedSliceNumMultiSliceSetting (iMbNumInFrame, |
| 241 | 248 | &fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings |
| 242 | 249 | //check uiSliceMbNum with current uiSliceNum |
| 243 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n", | |
| 250 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceMbNum (%d) settings!\n", | |
| 244 | 251 | fDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); |
| 245 | 252 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 246 | 253 | } |
| @@ -252,7 +259,7 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 5 unmodified lines | ||
| 252 | 259 | } |
| 253 | 260 | } |
| 254 | 261 | break; |
| 255 | − case SM_AUTO_SLICE:{ | |
| 262 | + case SM_AUTO_SLICE: { | |
| 256 | 263 | fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = 0; |
| 257 | 264 | } |
| 258 | 265 | break; |
| @@ -281,11 +288,12 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 22 unmodified lines | ||
| 281 | 288 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 282 | 289 | } |
| 283 | 290 | if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) { |
| 284 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!\n"); | |
| 291 | + WelsLog (pCtx, WELS_LOG_ERROR, | |
| 292 | + "ParamValidationExt(), pSlice setting for SM_RASTER_SLICE now turn to SM_SINGLE_SLICE!\n"); | |
| 285 | 293 | fDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; |
| 286 | 294 | break; |
| 287 | 295 | } |
| 288 | − if ((pCodingParam->iRCMode!=RC_OFF_MODE) && fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1) { | |
| 296 | + if ((pCodingParam->iRCMode != RC_OFF_MODE) && fDlp->sSliceCfg.sSliceArgument.uiSliceNum > 1) { | |
| 289 | 297 | WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), WARNING: GOM based RC do not support SM_RASTER_SLICE!\n"); |
| 290 | 298 | } |
| 291 | 299 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| @@ -309,7 +317,8 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 17 unmodified lines | ||
| 309 | 317 | fDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMbHeight; |
| 310 | 318 | |
| 311 | 319 | if (fDlp->sSliceCfg.sSliceArgument.uiSliceNum <= 0) { |
| 312 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", fDlp->sSliceCfg.sSliceArgument.uiSliceNum); | |
| 320 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiSliceNum (%d) settings!\n", | |
| 321 | + fDlp->sSliceCfg.sSliceArgument.uiSliceNum); | |
| 313 | 322 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 314 | 323 | } |
| 315 | 324 | if (!CheckRowMbMultiSliceSetting (iMbWidth, &fDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings |
| @@ -328,15 +337,16 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 12 unmodified lines | ||
| 328 | 337 | return ENC_RETURN_UNSUPPORTED_PARA; |
| 329 | 338 | } |
| 330 | 339 | |
| 331 | − if( pCodingParam->uiMaxNalSize <= NAL_HEADER_ADD_0X30BYTES) { | |
| 332 | − WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiMaxNalSize (%d) settings!\n", | |
| 333 | − pCodingParam->uiMaxNalSize); | |
| 334 | − return ENC_RETURN_UNSUPPORTED_PARA; | |
| 340 | + if (pCodingParam->uiMaxNalSize <= NAL_HEADER_ADD_0X30BYTES) { | |
| 341 | + WelsLog (pCtx, WELS_LOG_ERROR, "ParamValidationExt(), invalid uiMaxNalSize (%d) settings!\n", | |
| 342 | + pCodingParam->uiMaxNalSize); | |
| 343 | + return ENC_RETURN_UNSUPPORTED_PARA; | |
| 335 | 344 | } |
| 336 | 345 | |
| 337 | − if( fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint > (pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES)){ | |
| 338 | − WelsLog (pCtx, WELS_LOG_WARNING, "ParamValidationExt(), slice mode = SM_DYN_SLICE, uiSliceSizeConstraint = %d ,uiMaxNalsize = %d!\n", | |
| 339 | − fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint,pCodingParam->uiMaxNalSize); | |
| 346 | + if (fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint > (pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES)) { | |
| 347 | + WelsLog (pCtx, WELS_LOG_WARNING, | |
| 348 | + "ParamValidationExt(), slice mode = SM_DYN_SLICE, uiSliceSizeConstraint = %d ,uiMaxNalsize = %d!\n", | |
| 349 | + fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint, pCodingParam->uiMaxNalSize); | |
| 340 | 350 | fDlp->sSliceCfg.sSliceArgument.uiSliceSizeConstraint = pCodingParam->uiMaxNalSize - NAL_HEADER_ADD_0X30BYTES; |
| 341 | 351 | } |
| 342 | 352 | |
| @@ -362,8 +372,7 @@ int32_t ParamValidationExt (sWelsEncCtx*pCtx,SWelsSvcCodingParam* pCodingParam) · 19 unmodified lines | ||
| 362 | 372 | } |
| 363 | 373 | |
| 364 | 374 | |
| 365 | −void WelsEncoderApplyFrameRate(SWelsSvcCodingParam* pParam) | |
| 366 | −{ | |
| 375 | +void WelsEncoderApplyFrameRate (SWelsSvcCodingParam* pParam) { | |
| 367 | 376 | SDLayerParam* pLayerParam; |
| 368 | 377 | const float kfEpsn = 0.000001f; |
| 369 | 378 | const int32_t kiNumLayer = pParam->iSpatialLayerNum; |
| @@ -373,50 +382,51 @@ void WelsEncoderApplyFrameRate(SWelsSvcCodingParam* pParam) · 3 unmodified lines | ||
| 373 | 382 | float fTargetOutputFrameRate; |
| 374 | 383 | |
| 375 | 384 | //set input frame rate to each layer |
| 376 | − for (i=0;i<kiNumLayer;i++) { | |
| 377 | − pLayerParam = &(pParam->sDependencyLayers[i]); | |
| 385 | + for (i = 0; i < kiNumLayer; i++) { | |
| 386 | + pLayerParam = & (pParam->sDependencyLayers[i]); | |
| 378 | 387 | |
| 379 | 388 | fRatio = pLayerParam->fOutputFrameRate / pLayerParam->fInputFrameRate; |
| 380 | − if ( (kfMaxFrameRate - pLayerParam->fInputFrameRate) > kfEpsn | |
| 381 | − || (kfMaxFrameRate - pLayerParam->fInputFrameRate) < -kfEpsn ) { | |
| 389 | + if ((kfMaxFrameRate - pLayerParam->fInputFrameRate) > kfEpsn | |
| 390 | + || (kfMaxFrameRate - pLayerParam->fInputFrameRate) < -kfEpsn) { | |
| 382 | 391 | pLayerParam->fInputFrameRate = kfMaxFrameRate; |
| 383 | − fTargetOutputFrameRate = kfMaxFrameRate*fRatio; | |
| 384 | − pLayerParam->fOutputFrameRate = (fTargetOutputFrameRate>=6)?fTargetOutputFrameRate:(pLayerParam->fInputFrameRate); | |
| 392 | + fTargetOutputFrameRate = kfMaxFrameRate * fRatio; | |
| 393 | + pLayerParam->fOutputFrameRate = (fTargetOutputFrameRate >= 6) ? fTargetOutputFrameRate : (pLayerParam->fInputFrameRate); | |
| 385 | 394 | //TODO:{Sijia} from design, there is no sense to have temporal layer when under 6fps even with such setting? |
| 386 | 395 | } |
| 387 | 396 | } |
| 388 | 397 | } |
| 389 | 398 | |
| 390 | 399 | |
| 391 | −void WelsEncoderApplyBitRate(SWelsSvcCodingParam* pParam,int iLayer) | |
| 392 | −{ | |
| 400 | +void WelsEncoderApplyBitRate (SWelsSvcCodingParam* pParam, int iLayer) { | |
| 393 | 401 | //TODO (Sijia): this is a temporary solution which keep the ratio between layers |
| 394 | 402 | //but it is also possible to fulfill the bitrate of lower layer first |
| 395 | 403 | |
| 396 | 404 | SDLayerParam* pLayerParam; |
| 397 | 405 | const int32_t iNumLayers = pParam->iSpatialLayerNum; |
| 398 | − int32_t i, iOrigTotalBitrate=0; | |
| 399 | − if(iLayer == SPATIAL_LAYER_ALL){ | |
| 400 | − if(pParam->iMaxBitrate <pParam->iTargetBitrate){ | |
| 401 | − WelsLog (NULL, WELS_LOG_WARNING,"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,overall settting,TargetBitrate = %d,iMaxBitrate = %d\n", | |
| 402 | − pParam->iTargetBitrate,pParam->iMaxBitrate); | |
| 406 | + int32_t i, iOrigTotalBitrate = 0; | |
| 407 | + if (iLayer == SPATIAL_LAYER_ALL) { | |
| 408 | + if (pParam->iMaxBitrate < pParam->iTargetBitrate) { | |
| 409 | + WelsLog (NULL, WELS_LOG_WARNING, | |
| 410 | + "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,overall settting,TargetBitrate = %d,iMaxBitrate = %d\n", | |
| 411 | + pParam->iTargetBitrate, pParam->iMaxBitrate); | |
| 403 | 412 | pParam->iMaxBitrate = pParam->iTargetBitrate; |
| 404 | 413 | } |
| 405 | 414 | //read old BR |
| 406 | − for (i=0;i<iNumLayers;i++) { | |
| 407 | − iOrigTotalBitrate += pParam->sDependencyLayers[i].iSpatialBitrate; | |
| 415 | + for (i = 0; i < iNumLayers; i++) { | |
| 416 | + iOrigTotalBitrate += pParam->sDependencyLayers[i].iSpatialBitrate; | |
| 408 | 417 | } |
| 409 | 418 | //write new BR |
| 410 | 419 | float fRatio = 0.0; |
| 411 | − for (i=0;i<iNumLayers;i++) { | |
| 412 | − pLayerParam = &(pParam->sDependencyLayers[i]); | |
| 413 | − fRatio = pLayerParam->iSpatialBitrate/(static_cast<float>(iOrigTotalBitrate)); | |
| 414 | − pLayerParam->iSpatialBitrate = static_cast<int32_t>(pParam->iTargetBitrate*fRatio); | |
| 415 | − } | |
| 416 | − }else{ | |
| 417 | − if(pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate <pParam->sSpatialLayers[iLayer].iSpatialBitrate){ | |
| 418 | − WelsLog (NULL, WELS_LOG_WARNING,"CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iLayer = %d,iTargetBitrate = %d,iMaxBitrate = %d\n", | |
| 419 | − iLayer,pParam->sSpatialLayers[iLayer].iSpatialBitrate,pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate); | |
| 420 | + for (i = 0; i < iNumLayers; i++) { | |
| 421 | + pLayerParam = & (pParam->sDependencyLayers[i]); | |
| 422 | + fRatio = pLayerParam->iSpatialBitrate / (static_cast<float> (iOrigTotalBitrate)); | |
| 423 | + pLayerParam->iSpatialBitrate = static_cast<int32_t> (pParam->iTargetBitrate * fRatio); | |
| 424 | + } | |
| 425 | + } else { | |
| 426 | + if (pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate < pParam->sSpatialLayers[iLayer].iSpatialBitrate) { | |
| 427 | + WelsLog (NULL, WELS_LOG_WARNING, | |
| 428 | + "CWelsH264SVCEncoder::SetOption():ENCODER_OPTION_BITRATE,iLayer = %d,iTargetBitrate = %d,iMaxBitrate = %d\n", | |
| 429 | + iLayer, pParam->sSpatialLayers[iLayer].iSpatialBitrate, pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate); | |
| 420 | 430 | pParam->sSpatialLayers[iLayer].iMaxSpatialBitrate = pParam->sSpatialLayers[iLayer].iSpatialBitrate; |
| 421 | 431 | } |
| 422 | 432 | |
| @@ -479,8 +489,8 @@ static inline int32_t AcquireLayersNals (sWelsEncCtx** ppCtx, SWelsSvcCodingPara · 56 unmodified lines | ||
| 479 | 489 | |
| 480 | 490 | if (iCountNumNals - iOrgNumNals > MAX_NAL_UNITS_IN_LAYER) { |
| 481 | 491 | WelsLog (*ppCtx, WELS_LOG_ERROR, |
| 482 | − "AcquireLayersNals(), num_of_nals(%d) > MAX_NAL_UNITS_IN_LAYER(%d) per (iDid= %d, qid= %d) settings!\n", | |
| 483 | − (iCountNumNals - iOrgNumNals), MAX_NAL_UNITS_IN_LAYER, iDIndex, 0); | |
| 492 | + "AcquireLayersNals(), num_of_nals(%d) > MAX_NAL_UNITS_IN_LAYER(%d) per (iDid= %d, qid= %d) settings!\n", | |
| 493 | + (iCountNumNals - iOrgNumNals), MAX_NAL_UNITS_IN_LAYER, iDIndex, 0); | |
| 484 | 494 | return 1; |
| 485 | 495 | } |
| 486 | 496 | |
| @@ -862,7 +872,7 @@ static inline int32_t InitDqLayers (sWelsEncCtx** ppCtx) { · 375 unmodified lines | ||
| 862 | 872 | } |
| 863 | 873 | } else { |
| 864 | 874 | WelsInitSubsetSps (pSubsetSps, pDlayerParam, pParam->uiIntraPeriod, pParam->iNumRefFrame, iSpsId, |
| 865 | − pParam->bEnableFrameCroppingFlag, pParam->iRCMode!=RC_OFF_MODE); | |
| 875 | + pParam->bEnableFrameCroppingFlag, pParam->iRCMode != RC_OFF_MODE); | |
| 866 | 876 | } |
| 867 | 877 | |
| 868 | 878 | // initialize pPps |
| @@ -1154,7 +1164,31 @@ int32_t AllocStrideTables (sWelsEncCtx** ppCtx, const int32_t kiNumSpatialLayers · 285 unmodified lines | ||
| 1154 | 1164 | |
| 1155 | 1165 | return 0; |
| 1156 | 1166 | } |
| 1167 | +int32_t RequestMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const int32_t iNumRef, | |
| 1168 | + const int32_t iCountMax8x8BNum) { | |
| 1169 | + SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pVaa); | |
| 1157 | 1170 | |
| 1171 | + pVaaExt->pVaaBlockStaticIdc[0] = (static_cast<uint8_t*> (pMa->WelsMallocz (iNumRef * iCountMax8x8BNum * sizeof ( | |
| 1172 | + uint8_t), "pVaa->pVaaBlockStaticIdc[0]"))); | |
| 1173 | + if (NULL == pVaaExt->pVaaBlockStaticIdc[0]) { | |
| 1174 | + return 1; | |
| 1175 | + } | |
| 1176 | + | |
| 1177 | + for (int32_t idx = 1; idx < iNumRef; idx++) { | |
| 1178 | + pVaaExt->pVaaBlockStaticIdc[idx] = pVaaExt->pVaaBlockStaticIdc[idx - 1] + iCountMax8x8BNum; | |
| 1179 | + } | |
| 1180 | + return 0; | |
| 1181 | +} | |
| 1182 | +void ReleaseMemoryVaaScreen (SVAAFrameInfo* pVaa, CMemoryAlign* pMa, const int32_t iNumRef) { | |
| 1183 | + SVAAFrameInfoExt* pVaaExt = static_cast<SVAAFrameInfoExt*> (pVaa); | |
| 1184 | + if (pVaaExt && pMa && pVaaExt->pVaaBlockStaticIdc[0]) { | |
| 1185 | + pMa->WelsFree (pVaaExt->pVaaBlockStaticIdc[0], "pVaa->pVaaBlockStaticIdc"); | |
| 1186 | + | |
| 1187 | + for (int32_t idx = 0; idx < iNumRef; idx++) { | |
| 1188 | + pVaaExt->pVaaBlockStaticIdc[idx] = NULL; | |
| 1189 | + } | |
| 1190 | + } | |
| 1191 | +} | |
| 1158 | 1192 | /*! |
| 1159 | 1193 | * \brief request specific memory for SVC |
| 1160 | 1194 | * \pParam pEncCtx sWelsEncCtx* |
| @@ -1174,8 +1208,9 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 13 unmodified lines | ||
| 1174 | 1208 | int32_t iResult = 0; |
| 1175 | 1209 | float fCompressRatioThr = .5f; |
| 1176 | 1210 | const int32_t kiNumDependencyLayers = pParam->iSpatialLayerNum; |
| 1177 | − (*ppCtx)->iMvRange = pParam->iUsageType?EXPANDED_MV_RANGE:CAMERA_STARTMV_RANGE; | |
| 1178 | − const int32_t kiMvdRange = (pParam->iUsageType?EXPANDED_MVD_RANGE:((kiNumDependencyLayers == 1)?CAMERA_MVD_RANGE:CAMERA_HIGHLAYER_MVD_RANGE)); | |
| 1211 | + (*ppCtx)->iMvRange = pParam->iUsageType ? EXPANDED_MV_RANGE : CAMERA_STARTMV_RANGE; | |
| 1212 | + const int32_t kiMvdRange = (pParam->iUsageType ? EXPANDED_MVD_RANGE : ((kiNumDependencyLayers == 1) ? CAMERA_MVD_RANGE : | |
| 1213 | + CAMERA_HIGHLAYER_MVD_RANGE)); | |
| 1179 | 1214 | const uint32_t kuiMvdInterTableSize = 1 + (kiMvdRange << 3);//intepel*4=qpel; qpel_mv_range*2=(+/-); |
| 1180 | 1215 | const uint32_t kuiMvdCacheAlignedSize = kuiMvdInterTableSize * sizeof (uint16_t); |
| 1181 | 1216 | int32_t iVclLayersBsSizeCount = 0; |
| @@ -1245,8 +1280,7 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 63 unmodified lines | ||
| 1245 | 1280 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iTotalLength, "pFrameBs"); |
| 1246 | 1281 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| 1247 | 1282 | (*ppCtx)->iFrameBsSize = iTotalLength; |
| 1248 | − } else | |
| 1249 | − { | |
| 1283 | + } else { | |
| 1250 | 1284 | (*ppCtx)->pFrameBs = (uint8_t*)pMa->WelsMalloc (iCountBsLen, "pFrameBs"); |
| 1251 | 1285 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pFrameBs), FreeMemorySvc (ppCtx)) |
| 1252 | 1286 | (*ppCtx)->iFrameBsSize = iCountBsLen; |
| @@ -1313,13 +1347,19 @@ int32_t RequestMemorySvc (sWelsEncCtx** ppCtx) { · 60 unmodified lines | ||
| 1313 | 1347 | WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pWelsSvcRc), FreeMemorySvc (ppCtx)) |
| 1314 | 1348 | //End of Rate control module memory allocation |
| 1315 | 1349 | |
| 1316 | − //pVaa memory allocation | |
| 1317 | − if(pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) | |
| 1318 | − (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); | |
| 1319 | − else | |
| 1320 | − (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa"); | |
| 1321 | − | |
| 1322 | − WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) | |
| 1350 | + //pVaa memory allocation | |
| 1351 | + if (pParam->iUsageType == SCREEN_CONTENT_REAL_TIME) { | |
| 1352 | + (*ppCtx)->pVaa = (SVAAFrameInfoExt*)pMa->WelsMallocz (sizeof (SVAAFrameInfoExt), "pVaa"); | |
| 1353 | + WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) | |
| 1354 | + if(RequestMemoryVaaScreen ((*ppCtx)->pVaa, pMa, (*ppCtx)->pSvcParam->iNumRefFrame, iCountMaxMbNum << 2)){ | |
| 1355 | + WelsLog (*ppCtx, WELS_LOG_WARNING, "RequestMemorySvc(), RequestMemoryVaaScreen failed!"); | |
| 1356 | + FreeMemorySvc (ppCtx); | |
| 1357 | + return 1; | |
| 1358 | + } | |
| 1359 | + } else { | |
| 1360 | + (*ppCtx)->pVaa = (SVAAFrameInfo*)pMa->WelsMallocz (sizeof (SVAAFrameInfo), "pVaa"); | |
| 1361 | + WELS_VERIFY_RETURN_PROC_IF (1, (NULL == (*ppCtx)->pVaa), FreeMemorySvc (ppCtx)) | |
| 1362 | + } | |
| 1323 | 1363 | |
| 1324 | 1364 | if ((*ppCtx)->pSvcParam->bEnableAdaptiveQuant) { //malloc mem |
| 1325 | 1365 | (*ppCtx)->pVaa->sAdaptiveQuantParam.pMotionTextureUnit = static_cast<SMotionTextureUnit*> |
| @@ -1601,7 +1641,8 @@ void FreeMemorySvc (sWelsEncCtx** ppCtx) { · 275 unmodified lines | ||
| 1601 | 1641 | pMa->WelsFree (pCtx->pVaa->sVaaCalcInfo.pMad8x8, "pVaa->sVaaCalcInfo.pMad8x8"); |
| 1602 | 1642 | pCtx->pVaa->sVaaCalcInfo.pMad8x8 = NULL; |
| 1603 | 1643 | } |
| 1604 | − | |
| 1644 | + if(pCtx->pSvcParam->iUsageType == SCREEN_CONTENT_REAL_TIME) | |
| 1645 | + ReleaseMemoryVaaScreen(pCtx->pVaa, pMa,pCtx->pSvcParam->iNumRefFrame); | |
| 1605 | 1646 | pMa->WelsFree (pCtx->pVaa, "pVaa"); |
| 1606 | 1647 | pCtx->pVaa = NULL; |
| 1607 | 1648 | } |
| @@ -1660,7 +1701,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 52 unmodified lines | ||
| 1660 | 1701 | const int32_t kiMbWidth = (pDlp->iFrameWidth + 15) >> 4; |
| 1661 | 1702 | const int32_t kiMbHeight = (pDlp->iFrameHeight + 15) >> 4; |
| 1662 | 1703 | const int32_t kiMbNumInFrame = kiMbWidth * kiMbHeight; |
| 1663 | − int32_t iSliceNum = (SM_AUTO_SLICE == pMso->uiSliceMode)? kiCpuCores :pSlcArg->uiSliceNum; | |
| 1704 | + int32_t iSliceNum = (SM_AUTO_SLICE == pMso->uiSliceMode) ? kiCpuCores : pSlcArg->uiSliceNum; | |
| 1664 | 1705 | // NOTE: Per design, in case MT/DYNAMIC_SLICE_ASSIGN enabled, for SM_FIXEDSLCNUM_SLICE mode, |
| 1665 | 1706 | // uiSliceNum of current spatial layer settings equals to uiCpuCores number; SM_DYN_SLICE mode, |
| 1666 | 1707 | // uiSliceNum intials as uiCpuCores also, stay tuned dynamically slicing in future |
| @@ -1674,7 +1715,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 7 unmodified lines | ||
| 1674 | 1715 | if (iSliceNum > iMaxSliceCount) |
| 1675 | 1716 | iMaxSliceCount = iSliceNum; |
| 1676 | 1717 | // need perform check due uiSliceNum might change, although has been initialized somewhere outside |
| 1677 | − if (pCodingParam->iRCMode!=RC_OFF_MODE) { | |
| 1718 | + if (pCodingParam->iRCMode != RC_OFF_MODE) { | |
| 1678 | 1719 | GomValidCheckSliceMbNum (kiMbWidth, kiMbHeight, pSlcArg); |
| 1679 | 1720 | } else { |
| 1680 | 1721 | CheckFixedSliceNumMultiSliceSetting (kiMbNumInFrame, pSlcArg); |
| @@ -1695,7 +1736,7 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 14 unmodified lines | ||
| 1695 | 1736 | case SM_AUTO_SLICE: |
| 1696 | 1737 | iMaxSliceCount = MAX_SLICES_NUM; |
| 1697 | 1738 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = kiCpuCores; |
| 1698 | − if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceCount){ | |
| 1739 | + if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum > iMaxSliceCount) { | |
| 1699 | 1740 | pDlp->sSliceCfg.sSliceArgument.uiSliceNum = iMaxSliceCount; |
| 1700 | 1741 | } |
| 1701 | 1742 | if (pDlp->sSliceCfg.sSliceArgument.uiSliceNum == 1) { |
| @@ -1714,10 +1755,11 @@ int32_t InitSliceSettings (SWelsSvcCodingParam* pCodingParam, const int32_t kiCp · 12 unmodified lines | ||
| 1714 | 1755 | } else if (!CheckFixedSliceNumMultiSliceSetting (kiMbNumInFrame, |
| 1715 | 1756 | &pDlp->sSliceCfg.sSliceArgument)) { // verify interleave mode settings |
| 1716 | 1757 | //check uiSliceMbNum with current uiSliceNum |
| 1717 | − WelsLog (NULL, WELS_LOG_ERROR, "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type\n", | |
| 1758 | + WelsLog (NULL, WELS_LOG_ERROR, | |
| 1759 | + "InitSliceSettings(), invalid uiSliceMbNum (%d) settings!,now turn to SM_SINGLE_SLICE type\n", | |
| 1718 | 1760 | pDlp->sSliceCfg.sSliceArgument.uiSliceMbNum[0]); |
| 1719 | − pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | |
| 1720 | − pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; | |
| 1761 | + pDlp->sSliceCfg.uiSliceMode = SM_SINGLE_SLICE; | |
| 1762 | + pDlp->sSliceCfg.sSliceArgument.uiSliceNum = 1; | |
| 1721 | 1763 | } |
| 1722 | 1764 | // considering the coding efficient and performance, iCountMbNum constraint by MIN_NUM_MB_PER_SLICE condition of multi-pSlice mode settting |
| 1723 | 1765 | if (kiMbNumInFrame <= MIN_NUM_MB_PER_SLICE) { |
| @@ -1819,7 +1861,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 95 unmodified lines | ||
| 1819 | 1861 | return 1; |
| 1820 | 1862 | } |
| 1821 | 1863 | |
| 1822 | − iRet = ParamValidationExt (*ppCtx,pCodingParam); | |
| 1864 | + iRet = ParamValidationExt (*ppCtx, pCodingParam); | |
| 1823 | 1865 | if (iRet != 0) { |
| 1824 | 1866 | WelsLog (NULL, WELS_LOG_ERROR, "WelsInitEncoderExt(), ParamValidationExt failed return %d.\n", iRet); |
| 1825 | 1867 | return iRet; |
| @@ -1922,7 +1964,7 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 96 unmodified lines | ||
| 1922 | 1964 | if (pCodingParam->iMultipleThreadIdc > 1) |
| 1923 | 1965 | iRet = CreateSliceThreads (pCtx); |
| 1924 | 1966 | |
| 1925 | − WelsRcInitModule (pCtx, pCtx->pSvcParam->iRCMode!=RC_OFF_MODE ? WELS_RC_GOM : WELS_RC_DISABLE); | |
| 1967 | + WelsRcInitModule (pCtx, pCtx->pSvcParam->iRCMode != RC_OFF_MODE ? WELS_RC_GOM : WELS_RC_DISABLE); | |
| 1926 | 1968 | |
| 1927 | 1969 | pCtx->pVpp = new CWelsPreProcess (pCtx); |
| 1928 | 1970 | if (pCtx->pVpp == NULL) { |
| @@ -1931,9 +1973,9 @@ int32_t WelsInitEncoderExt (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pCodingPar · 2 unmodified lines | ||
| 1931 | 1973 | FreeMemorySvc (&pCtx); |
| 1932 | 1974 | return iRet; |
| 1933 | 1975 | } |
| 1934 | − if( (iRet = pCtx->pVpp->AllocSpatialPictures(pCtx, pCtx->pSvcParam)) != 0 ){ | |
| 1935 | − WelsLog( pCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pVPP alloc spatial pictures failed\n"); | |
| 1936 | − FreeMemorySvc(&pCtx); | |
| 1976 | + if ((iRet = pCtx->pVpp->AllocSpatialPictures (pCtx, pCtx->pSvcParam)) != 0) { | |
| 1977 | + WelsLog (pCtx, WELS_LOG_ERROR, "WelsInitEncoderExt(), pVPP alloc spatial pictures failed\n"); | |
| 1978 | + FreeMemorySvc (&pCtx); | |
| 1937 | 1979 | return iRet; |
| 1938 | 1980 | } |
| 1939 | 1981 | |
| @@ -2067,7 +2109,7 @@ void WelsUninitEncoderExt (sWelsEncCtx** ppCtx) { · 127 unmodified lines | ||
| 2067 | 2109 | } |
| 2068 | 2110 | |
| 2069 | 2111 | if ((*ppCtx)->pVpp) { |
| 2070 | − (*ppCtx)->pVpp->FreeSpatialPictures(*ppCtx); | |
| 2112 | + (*ppCtx)->pVpp->FreeSpatialPictures (*ppCtx); | |
| 2071 | 2113 | delete (*ppCtx)->pVpp; |
| 2072 | 2114 | (*ppCtx)->pVpp = NULL; |
| 2073 | 2115 | } |
| @@ -2333,15 +2375,13 @@ void WelsInitCurrentLayer (sWelsEncCtx* pCtx, · 259 unmodified lines | ||
| 2333 | 2375 | } |
| 2334 | 2376 | } |
| 2335 | 2377 | |
| 2336 | −static inline void SetFastCodingFunc(SWelsFuncPtrList* pFuncList) | |
| 2337 | −{ | |
| 2378 | +static inline void SetFastCodingFunc (SWelsFuncPtrList* pFuncList) { | |
| 2338 | 2379 | pFuncList->pfIntraFineMd = WelsMdIntraFinePartitionVaa; |
| 2339 | 2380 | pFuncList->sSampleDealingFuncs.pfMdCost = pFuncList->sSampleDealingFuncs.pfSampleSad; |
| 2340 | 2381 | pFuncList->sSampleDealingFuncs.pfIntra16x16Combined3 = pFuncList->sSampleDealingFuncs.pfIntra16x16Combined3Sad; |
| 2341 | 2382 | pFuncList->sSampleDealingFuncs.pfIntra8x8Combined3 = pFuncList->sSampleDealingFuncs.pfIntra8x8Combined3Sad; |
| 2342 | 2383 | } |
| 2343 | −static inline void SetNormalCodingFunc(SWelsFuncPtrList* pFuncList) | |
| 2344 | −{ | |
| 2384 | +static inline void SetNormalCodingFunc (SWelsFuncPtrList* pFuncList) { | |
| 2345 | 2385 | pFuncList->pfIntraFineMd = WelsMdIntraFinePartition; |
| 2346 | 2386 | pFuncList->sSampleDealingFuncs.pfMdCost = pFuncList->sSampleDealingFuncs.pfSampleSatd; |
| 2347 | 2387 | pFuncList->sSampleDealingFuncs.pfIntra16x16Combined3 = |
| @@ -2362,18 +2402,18 @@ void PreprocessSliceCoding (sWelsEncCtx* pCtx) { · 14 unmodified lines | ||
| 2362 | 2402 | |
| 2363 | 2403 | /* function pointers conditional assignment under sWelsEncCtx, layer_mb_enc_rec (in stack) is exclusive */ |
| 2364 | 2404 | if (kbHighestSpatialLayer) { |
| 2365 | − SetFastCodingFunc(pFuncList); | |
| 2405 | + SetFastCodingFunc (pFuncList); | |
| 2366 | 2406 | } else { |
| 2367 | − SetNormalCodingFunc(pFuncList); | |
| 2407 | + SetNormalCodingFunc (pFuncList); | |
| 2368 | 2408 | } |
| 2369 | 2409 | |
| 2370 | 2410 | if (P_SLICE == pCtx->eSliceType) { |
| 2371 | 2411 | pFuncList->pfMotionSearch[0] = WelsMotionEstimateSearch; |
| 2372 | 2412 | pFuncList->pfSearchMethod[BLOCK_16x16] = |
| 2373 | 2413 | pFuncList->pfSearchMethod[BLOCK_16x8] = |
| 2374 | − pFuncList->pfSearchMethod[BLOCK_8x16] = | |
| 2375 | − pFuncList->pfSearchMethod[BLOCK_8x8] = | |
| 2376 | − pFuncList->pfSearchMethod[BLOCK_4x4] = WelsDiamondSearch; | |
| 2414 | + pFuncList->pfSearchMethod[BLOCK_8x16] = | |
| 2415 | + pFuncList->pfSearchMethod[BLOCK_8x8] = | |
| 2416 | + pFuncList->pfSearchMethod[BLOCK_4x4] = WelsDiamondSearch; | |
| 2377 | 2417 | pFuncList->pfFirstIntraMode = WelsMdFirstIntraMode; |
| 2378 | 2418 | pFuncList->sSampleDealingFuncs.pfMeCost = pCtx->pFuncList->sSampleDealingFuncs.pfSampleSatd; |
| 2379 | 2419 | if (kbHighestSpatialLayer) { |
| @@ -2539,11 +2579,11 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 159 unmodified lines | ||
| 2539 | 2579 | } |
| 2540 | 2580 | |
| 2541 | 2581 | iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL, |
| 2542 | − pCtx->iFrameBsSize - pCtx->iPosBsBuffer,//available buffer to be written, so need to substract the used length | |
| 2543 | − pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2544 | − &iNalLength); | |
| 2545 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 2546 | − pNalLen[iCountNal] =iNalLength; | |
| 2582 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer,//available buffer to be written, so need to substract the used length | |
| 2583 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2584 | + &iNalLength); | |
| 2585 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 2586 | + pNalLen[iCountNal] = iNalLength; | |
| 2547 | 2587 | |
| 2548 | 2588 | pCtx->iPosBsBuffer += iNalLength; |
| 2549 | 2589 | iSize += iNalLength; |
| @@ -2568,10 +2608,10 @@ int32_t WelsWriteParameterSets (sWelsEncCtx* pCtx, int32_t* pNalLen, int32_t* pN · 18 unmodified lines | ||
| 2568 | 2608 | WelsUnloadNal (pCtx->pOut); |
| 2569 | 2609 | |
| 2570 | 2610 | iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL, |
| 2571 | − pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 2572 | − pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2573 | − &iNalLength); | |
| 2574 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 2611 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 2612 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2613 | + &iNalLength); | |
| 2614 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 2575 | 2615 | pNalLen[iCountNal] = iNalLength; |
| 2576 | 2616 | pCtx->iPosBsBuffer += iNalLength; |
| 2577 | 2617 | iSize += iNalLength; |
| @@ -2603,11 +2643,11 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, · 25 unmodified lines | ||
| 2603 | 2643 | WelsUnloadNal (pCtx->pOut); |
| 2604 | 2644 | |
| 2605 | 2645 | iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], |
| 2606 | − &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 2607 | − pCtx->iFrameBsSize-pCtx->iPosBsBuffer, | |
| 2608 | − pCtx->pFrameBs+pCtx->iPosBsBuffer, | |
| 2609 | − &pNalLen[*pNalIdxInLayer]); | |
| 2610 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 2646 | + &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 2647 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 2648 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2649 | + &pNalLen[*pNalIdxInLayer]); | |
| 2650 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 2611 | 2651 | iPayloadSize = pNalLen[*pNalIdxInLayer]; |
| 2612 | 2652 | |
| 2613 | 2653 | pCtx->iPosBsBuffer += iPayloadSize; |
| @@ -2620,11 +2660,11 @@ static inline int32_t AddPrefixNal (sWelsEncCtx* pCtx, · 6 unmodified lines | ||
| 2620 | 2660 | WelsUnloadNal (pCtx->pOut); |
| 2621 | 2661 | |
| 2622 | 2662 | iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], |
| 2623 | − &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 2624 | − pCtx->iFrameBsSize-pCtx->iPosBsBuffer, | |
| 2625 | − pCtx->pFrameBs+pCtx->iPosBsBuffer, | |
| 2626 | − &pNalLen[*pNalIdxInLayer]); | |
| 2627 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 2663 | + &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 2664 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 2665 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2666 | + &pNalLen[*pNalIdxInLayer]); | |
| 2667 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 2628 | 2668 | iPayloadSize = pNalLen[*pNalIdxInLayer]; |
| 2629 | 2669 | |
| 2630 | 2670 | pCtx->iPosBsBuffer += iPayloadSize; |
| @@ -2667,10 +2707,10 @@ int32_t WritePadding (sWelsEncCtx* pCtx, int32_t iLen, int32_t& iSize) { · 36 unmodified lines | ||
| 2667 | 2707 | |
| 2668 | 2708 | WelsUnloadNal (pCtx->pOut); |
| 2669 | 2709 | int32_t iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[iNal], NULL, |
| 2670 | − pCtx->iFrameBsSize-pCtx->iPosBsBuffer, | |
| 2671 | − pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2672 | − &iNalLen); | |
| 2673 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 2710 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 2711 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2712 | + &iNalLen); | |
| 2713 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 2674 | 2714 | |
| 2675 | 2715 | pCtx->iPosBsBuffer += iNalLen; |
| 2676 | 2716 | iSize += iNalLen; |
| @@ -2701,7 +2741,7 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) { · 24 unmodified lines | ||
| 2701 | 2741 | InitBits (&pCtx->pOut->sBsWrite, pCtx->pOut->pBsBuffer, pCtx->pOut->uiSize); |
| 2702 | 2742 | |
| 2703 | 2743 | int32_t iReturn = WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal); |
| 2704 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 2744 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 2705 | 2745 | |
| 2706 | 2746 | pLayerBsInfo->uiPriorityId = 0; |
| 2707 | 2747 | pLayerBsInfo->uiSpatialId = 0; |
| @@ -2729,7 +2769,7 @@ int32_t WelsEncoderEncodeParameterSets (sWelsEncCtx* pCtx, void* pDst) { · 21 unmodified lines | ||
| 2729 | 2769 | * \pParam pSrcPic Source Picture |
| 2730 | 2770 | * \return EFrameType (videoFrameTypeIDR/videoFrameTypeI/videoFrameTypeP) |
| 2731 | 2771 | */ |
| 2732 | −int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSourcePicture* pSrcPic) { | |
| 2772 | +int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo* pFbi, const SSourcePicture* pSrcPic) { | |
| 2733 | 2773 | SLayerBSInfo* pLayerBsInfo = &pFbi->sLayerInfo[0]; |
| 2734 | 2774 | SWelsSvcCodingParam* pSvcParam = pCtx->pSvcParam; |
| 2735 | 2775 | SSpatialPicIndex* pSpatialIndexMap = &pCtx->sSpatialIndexMap[0]; |
| @@ -2793,7 +2833,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 57 unmodified lines | ||
| 2793 | 2833 | |
| 2794 | 2834 | // write parameter sets bitstream here |
| 2795 | 2835 | pCtx->iEncoderError = WelsWriteParameterSets (pCtx, &iNalLen[0], &iCountNal); |
| 2796 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2836 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2797 | 2837 | |
| 2798 | 2838 | pLayerBsInfo->uiPriorityId = 0; |
| 2799 | 2839 | pLayerBsInfo->uiSpatialId = 0; |
| @@ -2833,7 +2873,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 33 unmodified lines | ||
| 2833 | 2873 | |
| 2834 | 2874 | switch (param_d->sSliceCfg.uiSliceMode) { |
| 2835 | 2875 | case SM_FIXEDSLCNUM_SLICE: |
| 2836 | − case SM_AUTO_SLICE:{ | |
| 2876 | + case SM_AUTO_SLICE: { | |
| 2837 | 2877 | if ((iCurDid > 0) && (pSvcParam->iMultipleThreadIdc > 1) && |
| 2838 | 2878 | (pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE |
| 2839 | 2879 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[iCurDid].sSliceCfg.sSliceArgument.uiSliceNum) |
| @@ -2893,11 +2933,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 53 unmodified lines | ||
| 2893 | 2933 | |
| 2894 | 2934 | WelsInitCurrentLayer (pCtx, iCurWidth, iCurHeight); |
| 2895 | 2935 | |
| 2896 | − pCtx->pFuncList->pMarkPic(pCtx); | |
| 2897 | − if (!pCtx->pFuncList->pBuildRefList (pCtx, pCtx->iPOC,0)) { | |
| 2936 | + pCtx->pFuncList->pMarkPic (pCtx); | |
| 2937 | + if (!pCtx->pFuncList->pBuildRefList (pCtx, pCtx->iPOC, 0)) { | |
| 2898 | 2938 | // Force coding IDR as followed |
| 2899 | 2939 | ForceCodingIDR (pCtx); |
| 2900 | − WelsLog (pCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!\n", | |
| 2940 | + WelsLog (pCtx, WELS_LOG_WARNING, | |
| 2941 | + "WelsEncoderEncodeExt(), WelsBuildRefList failed for P frames, pCtx->iNumRef0= %d. ForceCodingIDR!\n", | |
| 2901 | 2942 | pCtx->iNumRef0); |
| 2902 | 2943 | pFbi->eOutputFrameType = videoFrameTypeIDR; |
| 2903 | 2944 | pCtx->iEncoderError = ENC_RETURN_CORRECTED; |
| @@ -2921,24 +2962,25 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 17 unmodified lines | ||
| 2921 | 2962 | int32_t iPayloadSize = 0; |
| 2922 | 2963 | |
| 2923 | 2964 | if (pCtx->bNeedPrefixNalFlag) { |
| 2924 | − pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc, iPayloadSize); | |
| 2925 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2965 | + pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc, | |
| 2966 | + iPayloadSize); | |
| 2967 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2926 | 2968 | iLayerSize += iPayloadSize; |
| 2927 | 2969 | } |
| 2928 | 2970 | |
| 2929 | 2971 | WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc); |
| 2930 | 2972 | |
| 2931 | 2973 | pCtx->iEncoderError = WelsCodeOneSlice (pCtx, 0, eNalType); |
| 2932 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2974 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2933 | 2975 | |
| 2934 | 2976 | WelsUnloadNal (pCtx->pOut); |
| 2935 | 2977 | |
| 2936 | 2978 | pCtx->iEncoderError = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], |
| 2937 | − &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 2938 | − pCtx->iFrameBsSize-pCtx->iPosBsBuffer, | |
| 2939 | − pCtx->pFrameBs+pCtx->iPosBsBuffer, | |
| 2940 | − &iNalLen[iNalIdxInLayer]); | |
| 2941 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2979 | + &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 2980 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 2981 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 2982 | + &iNalLen[iNalIdxInLayer]); | |
| 2983 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2942 | 2984 | iSliceSize = iNalLen[iNalIdxInLayer]; |
| 2943 | 2985 | |
| 2944 | 2986 | iLayerSize += iSliceSize; |
| @@ -2952,11 +2994,10 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 7 unmodified lines | ||
| 2952 | 2994 | pLayerBsInfo->iNalCount = ++ iNalIdxInLayer; |
| 2953 | 2995 | } |
| 2954 | 2996 | // for dynamic slicing single threading.. |
| 2955 | − else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) | |
| 2956 | − { | |
| 2997 | + else if ((SM_DYN_SLICE == param_d->sSliceCfg.uiSliceMode) && (pSvcParam->iMultipleThreadIdc <= 1)) { | |
| 2957 | 2998 | const int32_t kiLastMbInFrame = pCtx->pCurDqLayer->pSliceEncCtx->iMbNumInFrame; |
| 2958 | 2999 | pCtx->iEncoderError = WelsCodeOnePicPartition (pCtx, pLayerBsInfo, &iNalIdxInLayer, &iLayerSize, 0, kiLastMbInFrame, 0); |
| 2959 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3000 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 2960 | 3001 | } else { |
| 2961 | 3002 | //other multi-slice uiSliceMode |
| 2962 | 3003 | int err = 0; |
| @@ -2993,11 +3034,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 30 unmodified lines | ||
| 2993 | 3034 | return ENC_RETURN_UNEXPECTED; |
| 2994 | 3035 | } |
| 2995 | 3036 | |
| 2996 | − WelsMultipleEventsWaitAllBlocking (iSliceCount, &pCtx->pSliceThreading->pSliceCodedEvent[0], &pCtx->pSliceThreading->pSliceCodedMasterEvent); | |
| 3037 | + WelsMultipleEventsWaitAllBlocking (iSliceCount, &pCtx->pSliceThreading->pSliceCodedEvent[0], | |
| 3038 | + &pCtx->pSliceThreading->pSliceCodedMasterEvent); | |
| 2997 | 3039 | |
| 2998 | 3040 | |
| 2999 | 3041 | // all slices are finished coding here |
| 3000 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3042 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3001 | 3043 | |
| 3002 | 3044 | // append exclusive slice 0 bs to pFrameBs |
| 3003 | 3045 | #if defined(MT_DEBUG) |
| @@ -3077,12 +3119,12 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 73 unmodified lines | ||
| 3077 | 3119 | return ENC_RETURN_UNEXPECTED; |
| 3078 | 3120 | } |
| 3079 | 3121 | |
| 3080 | − WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0], &pCtx->pSliceThreading->pSliceCodedMasterEvent); | |
| 3081 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3122 | + WelsMultipleEventsWaitAllBlocking (kiPartitionCnt, &pCtx->pSliceThreading->pSliceCodedEvent[0], | |
| 3123 | + &pCtx->pSliceThreading->pSliceCodedMasterEvent); | |
| 3124 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3082 | 3125 | |
| 3083 | 3126 | iLayerSize = AppendSliceToFrameBs (pCtx, pLayerBsInfo, kiPartitionCnt); |
| 3084 | − } else // for non-dynamic-slicing mode single threading branch.. | |
| 3085 | − { | |
| 3127 | + } else { // for non-dynamic-slicing mode single threading branch.. | |
| 3086 | 3128 | const bool bNeedPrefix = pCtx->bNeedPrefixNalFlag; |
| 3087 | 3129 | int32_t iSliceIdx = 0; |
| 3088 | 3130 | |
| @@ -3091,22 +3133,23 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 2 unmodified lines | ||
| 3091 | 3133 | int32_t iSliceSize = 0; |
| 3092 | 3134 | int32_t iPayloadSize = 0; |
| 3093 | 3135 | if (bNeedPrefix) { |
| 3094 | − pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc, iPayloadSize); | |
| 3095 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3136 | + pCtx->iEncoderError = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, eNalType, eNalRefIdc, | |
| 3137 | + iPayloadSize); | |
| 3138 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3096 | 3139 | iLayerSize += iPayloadSize; |
| 3097 | 3140 | } |
| 3098 | 3141 | |
| 3099 | 3142 | WelsLoadNal (pCtx->pOut, eNalType, eNalRefIdc); |
| 3100 | 3143 | pCtx->iEncoderError = WelsCodeOneSlice (pCtx, iSliceIdx, eNalType); |
| 3101 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3144 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3102 | 3145 | |
| 3103 | 3146 | WelsUnloadNal (pCtx->pOut); |
| 3104 | 3147 | |
| 3105 | 3148 | pCtx->iEncoderError = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], |
| 3106 | − &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 3107 | − pCtx->iFrameBsSize-pCtx->iPosBsBuffer, | |
| 3108 | − pCtx->pFrameBs+pCtx->iPosBsBuffer, &iNalLen[iNalIdxInLayer]); | |
| 3109 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3149 | + &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 3150 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 3151 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, &iNalLen[iNalIdxInLayer]); | |
| 3152 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3110 | 3153 | iSliceSize = iNalLen[iNalIdxInLayer]; |
| 3111 | 3154 | |
| 3112 | 3155 | pCtx->iPosBsBuffer += iSliceSize; |
| @@ -3251,7 +3294,7 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 138 unmodified lines | ||
| 3251 | 3294 | if (pSvcParam->iPaddingFlag && pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize > 0) { |
| 3252 | 3295 | int32_t iPaddingNalSize = 0; |
| 3253 | 3296 | pCtx->iEncoderError = WritePadding (pCtx, pCtx->pWelsSvcRc[pCtx->uiDependencyId].iPaddingSize, iPaddingNalSize); |
| 3254 | − WELS_VERIFY_RETURN_IFNEQ(pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3297 | + WELS_VERIFY_RETURN_IFNEQ (pCtx->iEncoderError, ENC_RETURN_SUCCESS) | |
| 3255 | 3298 | |
| 3256 | 3299 | #if GOM_TRACE_FLAG |
| 3257 | 3300 | WelsLog (pCtx, WELS_LOG_INFO, "[RC] encoding_qp%d Padding: %d\n", pCtx->uiDependencyId, |
| @@ -3276,7 +3319,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 18 unmodified lines | ||
| 3276 | 3319 | ++ iLayerNum; |
| 3277 | 3320 | } |
| 3278 | 3321 | |
| 3279 | − if ((param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE||param_d->sSliceCfg.uiSliceMode == SM_AUTO_SLICE) && pSvcParam->iMultipleThreadIdc > 1 && | |
| 3322 | + if ((param_d->sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE || param_d->sSliceCfg.uiSliceMode == SM_AUTO_SLICE) | |
| 3323 | + && pSvcParam->iMultipleThreadIdc > 1 && | |
| 3280 | 3324 | pSvcParam->iMultipleThreadIdc >= param_d->sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3281 | 3325 | CalcSliceComplexRatio (pCtx->pSliceThreading->pSliceComplexRatio[iCurDid], pCtx->pCurDqLayer->pSliceEncCtx, |
| 3282 | 3326 | pCtx->pSliceThreading->pSliceConsumeTime[iCurDid]); |
| @@ -3296,8 +3340,8 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 13 unmodified lines | ||
| 3296 | 3340 | pCtx->bLongTermRefFlag[d_idx][0] = true; |
| 3297 | 3341 | } |
| 3298 | 3342 | |
| 3299 | − if( pCtx->pVpp->UpdateSpatialPictures(pCtx, pSvcParam, iCurTid, d_idx) != 0 ){ | |
| 3300 | − ForceCodingIDR(pCtx); | |
| 3343 | + if (pCtx->pVpp->UpdateSpatialPictures (pCtx, pSvcParam, iCurTid, d_idx) != 0) { | |
| 3344 | + ForceCodingIDR (pCtx); | |
| 3301 | 3345 | WelsLog (pCtx, WELS_LOG_WARNING, "WelsEncoderEncodeExt(), Logic Error Found in temporal level. ForceCodingIDR!\n"); |
| 3302 | 3346 | //the above is to set the next frame IDR |
| 3303 | 3347 | pFbi->eOutputFrameType = eFrameType; |
| @@ -3315,9 +3359,11 @@ int32_t WelsEncoderEncodeExt (sWelsEncCtx* pCtx, SFrameBSInfo * pFbi, const SSou · 11 unmodified lines | ||
| 3315 | 3359 | #endif//MT_DEBUG |
| 3316 | 3360 | |
| 3317 | 3361 | if (pSvcParam->iMultipleThreadIdc > 1 && did_list[0] == BASE_DEPENDENCY_ID |
| 3318 | − && ((pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) | |
| 3362 | + && ((pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE) | |
| 3363 | + || (pSvcParam->sDependencyLayers[0].sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) | |
| 3319 | 3364 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[0].sSliceCfg.sSliceArgument.uiSliceNum |
| 3320 | − && ((pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE)||(pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) | |
| 3365 | + && ((pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_FIXEDSLCNUM_SLICE) | |
| 3366 | + || (pSvcParam->sDependencyLayers[did_list[iSpatialNum - 1]].sSliceCfg.uiSliceMode == SM_AUTO_SLICE)) | |
| 3321 | 3367 | && pSvcParam->iMultipleThreadIdc >= pSvcParam->sDependencyLayers[did_list[iSpatialNum - |
| 3322 | 3368 | 1]].sSliceCfg.sSliceArgument.uiSliceNum) { |
| 3323 | 3369 | AdjustBaseLayer (pCtx); |
| @@ -3351,7 +3397,7 @@ int32_t WelsEncoderParamAdjust (sWelsEncCtx** ppCtx, SWelsSvcCodingParam* pNewPa · 27 unmodified lines | ||
| 3351 | 3397 | if (NULL == ppCtx || NULL == *ppCtx || NULL == pNewParam) return 1; |
| 3352 | 3398 | |
| 3353 | 3399 | /* Check validation in new parameters */ |
| 3354 | − iReturn = ParamValidationExt (*ppCtx,pNewParam); | |
| 3400 | + iReturn = ParamValidationExt (*ppCtx, pNewParam); | |
| 3355 | 3401 | if (iReturn != ENC_RETURN_SUCCESS) return iReturn; |
| 3356 | 3402 | |
| 3357 | 3403 | pOldParam = (*ppCtx)->pSvcParam; |
| @@ -3555,21 +3601,21 @@ int32_t WelsCodeOnePicPartition (sWelsEncCtx* pCtx, · 197 unmodified lines | ||
| 3555 | 3601 | |
| 3556 | 3602 | if (kbNeedPrefix) { |
| 3557 | 3603 | iReturn = AddPrefixNal (pCtx, pLayerBsInfo, &iNalLen[0], &iNalIdxInLayer, keNalType, keNalRefIdc, iPayloadSize); |
| 3558 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 3604 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 3559 | 3605 | iPartitionBsSize += iPayloadSize; |
| 3560 | 3606 | } |
| 3561 | 3607 | |
| 3562 | 3608 | WelsLoadNal (pCtx->pOut, keNalType, keNalRefIdc); |
| 3563 | − iReturn=WelsCodeOneSlice (pCtx, iSliceIdx, keNalType); | |
| 3564 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 3609 | + iReturn = WelsCodeOneSlice (pCtx, iSliceIdx, keNalType); | |
| 3610 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 3565 | 3611 | WelsUnloadNal (pCtx->pOut); |
| 3566 | 3612 | |
| 3567 | 3613 | iReturn = WelsEncodeNal (&pCtx->pOut->sNalList[pCtx->pOut->iNalIndex - 1], |
| 3568 | − &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 3569 | − pCtx->iFrameBsSize-pCtx->iPosBsBuffer, | |
| 3570 | − pCtx->pFrameBs+pCtx->iPosBsBuffer, | |
| 3571 | − &iNalLen[iNalIdxInLayer]); | |
| 3572 | − WELS_VERIFY_RETURN_IFNEQ(iReturn, ENC_RETURN_SUCCESS) | |
| 3614 | + &pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt, | |
| 3615 | + pCtx->iFrameBsSize - pCtx->iPosBsBuffer, | |
| 3616 | + pCtx->pFrameBs + pCtx->iPosBsBuffer, | |
| 3617 | + &iNalLen[iNalIdxInLayer]); | |
| 3618 | + WELS_VERIFY_RETURN_IFNEQ (iReturn, ENC_RETURN_SUCCESS) | |
| 3573 | 3619 | iSliceSize = iNalLen[iNalIdxInLayer]; |
| 3574 | 3620 | |
| 3575 | 3621 | pCtx->iPosBsBuffer += iSliceSize; |