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