Showing the changes to codec/encoder/core/src/encoder.cpp (1 of 5 files). Show all
Unified · Split
| @@ -226,6 +226,41 @@ int32_t InitFunctionPointers (sWelsEncCtx* pEncCtx, SWelsSvcCodingParam* pParam, · 225 unmodified lines | ||
| 226 | 226 | return iReturn; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | +void UpdateFrameNum(sWelsEncCtx* pEncCtx) { | |
| 230 | + bool bNeedFrameNumIncreasing = false; | |
| 231 | + for (int32_t i=0; i<MAX_DEPENDENCY_LAYER; i++) { | |
| 232 | + if (NRI_PRI_LOWEST != pEncCtx->eLastNalPriority[i]) { | |
| 233 | + bNeedFrameNumIncreasing = true; | |
| 234 | + } | |
| 235 | + } | |
| 236 | + if (bNeedFrameNumIncreasing) { | |
| 237 | + if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1) | |
| 238 | + ++ pEncCtx->iFrameNum; | |
| 239 | + else | |
| 240 | + pEncCtx->iFrameNum = 0; // if iFrameNum overflow | |
| 241 | + } | |
| 242 | + for (int32_t i=0; i<MAX_DEPENDENCY_LAYER; i++) { | |
| 243 | + pEncCtx->eLastNalPriority[i] = NRI_PRI_LOWEST; | |
| 244 | + } | |
| 245 | +} | |
| 246 | + | |
| 247 | + | |
| 248 | +void LoadBackFrameNum(sWelsEncCtx* pEncCtx) { | |
| 249 | + bool bNeedFrameNumIncreasing = false; | |
| 250 | + for (int32_t i=0; i<MAX_DEPENDENCY_LAYER; i++) { | |
| 251 | + if (NRI_PRI_LOWEST != pEncCtx->eLastNalPriority[i]) { | |
| 252 | + bNeedFrameNumIncreasing = true; | |
| 253 | + } | |
| 254 | + } | |
| 255 | + if (bNeedFrameNumIncreasing) { | |
| 256 | + if (pEncCtx->iFrameNum != 0) { | |
| 257 | + pEncCtx->iFrameNum --; | |
| 258 | + } else { | |
| 259 | + pEncCtx->iFrameNum = (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1; | |
| 260 | + } | |
| 261 | + } | |
| 262 | +} | |
| 263 | + | |
| 229 | 264 | /*! |
| 230 | 265 | * \brief initialize frame coding |
| 231 | 266 | */ |
| @@ -245,12 +280,8 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { · 13 unmodified lines | ||
| 245 | 280 | else |
| 246 | 281 | pEncCtx->iPOC = 0; |
| 247 | 282 | |
| 248 | − if (pEncCtx->eLastNalPriority != 0) { | |
| 249 | − if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1) | |
| 250 | − ++ pEncCtx->iFrameNum; | |
| 251 | − else | |
| 252 | − pEncCtx->iFrameNum = 0; // if iFrameNum overflow | |
| 253 | − } | |
| 283 | + UpdateFrameNum(pEncCtx); | |
| 284 | + | |
| 254 | 285 | pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; |
| 255 | 286 | pEncCtx->eSliceType = P_SLICE; |
| 256 | 287 | pEncCtx->eNalPriority = NRI_PRI_HIGH; |
| @@ -275,12 +306,7 @@ void InitFrameCoding (sWelsEncCtx* pEncCtx, const EVideoFrameType keFrameType) { · 18 unmodified lines | ||
| 275 | 306 | else |
| 276 | 307 | pEncCtx->iPOC = 0; |
| 277 | 308 | |
| 278 | − if (pEncCtx->eLastNalPriority != 0) { | |
| 279 | − if (pEncCtx->iFrameNum < (1 << pEncCtx->pSps->uiLog2MaxFrameNum) - 1) | |
| 280 | − ++ pEncCtx->iFrameNum; | |
| 281 | − else | |
| 282 | − pEncCtx->iFrameNum = 0; // if iFrameNum overflow | |
| 283 | − } | |
| 309 | + UpdateFrameNum(pEncCtx); | |
| 284 | 310 | |
| 285 | 311 | pEncCtx->eNalType = NAL_UNIT_CODED_SLICE; |
| 286 | 312 | pEncCtx->eSliceType = I_SLICE; |