Showing the changes to codec/decoder/core/src/manage_dec_ref.cpp (1 of 4 files). Show all
Unified · Split
| @@ -44,20 +44,18 @@ · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | namespace WelsDec { |
| 46 | 46 | |
| 47 | −static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag); | |
| 48 | −static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag); | |
| 49 | −static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag); | |
| 50 | −static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag); | |
| 47 | +static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum); | |
| 48 | +static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx); | |
| 49 | +static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum); | |
| 50 | +static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx); | |
| 51 | 51 | |
| 52 | −static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking); | |
| 53 | 52 | static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking); |
| 54 | −static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic, | |
| 53 | +static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, | |
| 55 | 54 | int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx); |
| 56 | 55 | static int32_t SlidingWindow (PWelsDecoderContext pCtx); |
| 57 | 56 | |
| 58 | 57 | static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic); |
| 59 | 58 | static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx); |
| 60 | −static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx); | |
| 61 | 59 | static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx); |
| 62 | 60 | |
| 63 | 61 | static void SetUnRef (PPicture pRef) { |
| @@ -67,7 +65,6 @@ static void SetUnRef (PPicture pRef) { · 3 unmodified lines | ||
| 67 | 65 | pRef->iFrameNum = -1; |
| 68 | 66 | pRef->iFramePoc = 0; |
| 69 | 67 | pRef->iLongTermFrameIdx = -1; |
| 70 | − pRef->bRefBaseFlag = 0; | |
| 71 | 68 | pRef->uiQualityId = -1; |
| 72 | 69 | pRef->uiTemporalId = -1; |
| 73 | 70 | pRef->uiSpatialId = -1; |
| @@ -114,37 +111,13 @@ int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc) { · 40 unmodified lines | ||
| 114 | 111 | memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture)); |
| 115 | 112 | //short |
| 116 | 113 | for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) { |
| 117 | − if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) { | |
| 118 | − pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i]; | |
| 119 | − } else { | |
| 120 | − for (j = 0; j < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++j) { | |
| 121 | − if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum | |
| 122 | − && ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) { | |
| 123 | − break; | |
| 124 | − } | |
| 125 | − } | |
| 126 | − if (j == pCtx->sRefPic.uiShortRefCount[LIST_0]) { | |
| 127 | − pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i]; | |
| 128 | − } | |
| 129 | − } | |
| 114 | + pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i]; | |
| 130 | 115 | } |
| 131 | 116 | |
| 132 | 117 | //long |
| 133 | 118 | j = 0; |
| 134 | 119 | for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) { |
| 135 | − if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) { | |
| 136 | − pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i]; | |
| 137 | − } else { | |
| 138 | − for (j = 0; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) { | |
| 139 | − if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx | |
| 140 | − && ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) { | |
| 141 | − break; | |
| 142 | − } | |
| 143 | − } | |
| 144 | − if (j == pCtx->sRefPic.uiLongRefCount[LIST_0]) { | |
| 145 | − pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i]; | |
| 146 | − } | |
| 147 | − } | |
| 120 | + pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppLongRefList[i]; | |
| 148 | 121 | } |
| 149 | 122 | pCtx->sRefPic.uiRefCount[LIST_0] = iCount; |
| 150 | 123 | |
| @@ -231,7 +204,7 @@ int32_t WelsReorderRefList (PWelsDecoderContext pCtx) { · 80 unmodified lines | ||
| 231 | 204 | return ERR_NONE; |
| 232 | 205 | } |
| 233 | 206 | |
| 234 | −int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag) { | |
| 207 | +int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) { | |
| 235 | 208 | PRefPic pRefPic = &pCtx->sRefPic; |
| 236 | 209 | PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking; |
| 237 | 210 | PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking; |
| @@ -240,14 +213,10 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 2 unmodified lines | ||
| 240 | 213 | uint32_t j; |
| 241 | 214 | |
| 242 | 215 | int32_t iRet = ERR_NONE; |
| 243 | − if (pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames < 2)) { | |
| 244 | − return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH; | |
| 245 | − } | |
| 246 | 216 | |
| 247 | 217 | pCtx->pDec->bUsedAsRef = true; |
| 248 | 218 | pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId; |
| 249 | 219 | pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId; |
| 250 | − pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag; | |
| 251 | 220 | |
| 252 | 221 | for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) { |
| 253 | 222 | if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR |
| @@ -264,14 +233,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 10 unmodified lines | ||
| 264 | 233 | pCtx->sRefPic.iMaxLongTermFrameIdx = -1; |
| 265 | 234 | } |
| 266 | 235 | } else { |
| 267 | − if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag) { | |
| 268 | − iRet = MMCOBase (pCtx, pRefPicBaseMarking); | |
| 269 | − } | |
| 270 | − | |
| 271 | − if (iRet != ERR_NONE) { | |
| 272 | − return iRet; | |
| 273 | − } | |
| 274 | − | |
| 275 | 236 | if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) { |
| 276 | 237 | iRet = MMCO (pCtx, pRefPicMarking); |
| 277 | 238 | if (pCtx->bLastHasMmco5) { |
| @@ -293,29 +254,6 @@ int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag · 15 unmodified lines | ||
| 293 | 254 | return iRet; |
| 294 | 255 | } |
| 295 | 256 | |
| 296 | −static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking) { | |
| 297 | − PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps; | |
| 298 | − int32_t i = 0; | |
| 299 | − int32_t iRet = ERR_NONE; | |
| 300 | − | |
| 301 | − for (i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++) { | |
| 302 | − uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType; | |
| 303 | − int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) & (( | |
| 304 | − 1 << pSps->uiLog2MaxFrameNum) - 1); | |
| 305 | − uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum; | |
| 306 | − if (uiMmcoType > MMCO_LONG2UNUSED) { | |
| 307 | − return ERR_INFO_INVALID_MMCO_OPCODE_BASE; | |
| 308 | − } | |
| 309 | − iRet = MMCOProcess (pCtx, uiMmcoType, true, iShortFrameNum, uiLongTermPicNum, 0, 0); | |
| 310 | − | |
| 311 | − if (iRet != ERR_NONE) { | |
| 312 | − return iRet; | |
| 313 | − } | |
| 314 | − } | |
| 315 | − | |
| 316 | − return ERR_NONE; | |
| 317 | −} | |
| 318 | − | |
| 319 | 257 | static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { |
| 320 | 258 | PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps; |
| 321 | 259 | int32_t i = 0; |
| @@ -330,7 +268,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { · 8 unmodified lines | ||
| 330 | 268 | if (uiMmcoType > MMCO_LONG) { |
| 331 | 269 | return ERR_INFO_INVALID_MMCO_OPCODE_BASE; |
| 332 | 270 | } |
| 333 | − iRet = MMCOProcess (pCtx, uiMmcoType, false, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx); | |
| 271 | + iRet = MMCOProcess (pCtx, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx); | |
| 334 | 272 | if (iRet != ERR_NONE) { |
| 335 | 273 | return iRet; |
| 336 | 274 | } |
| @@ -338,7 +276,7 @@ static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) { · 1 unmodified line | ||
| 338 | 276 | |
| 339 | 277 | return ERR_NONE; |
| 340 | 278 | } |
| 341 | −static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic, | |
| 279 | +static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, | |
| 342 | 280 | int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) { |
| 343 | 281 | PRefPic pRefPic = &pCtx->sRefPic; |
| 344 | 282 | PPicture pPic = NULL; |
| @@ -347,20 +285,17 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 2 unmodified lines | ||
| 347 | 285 | |
| 348 | 286 | switch (uiMmcoType) { |
| 349 | 287 | case MMCO_SHORT2UNUSED: |
| 350 | − pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic); | |
| 288 | + pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum); | |
| 351 | 289 | break; |
| 352 | 290 | case MMCO_LONG2UNUSED: |
| 353 | − pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum, (ERemoveFlag) bRefBasePic); | |
| 291 | + pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum); | |
| 354 | 292 | break; |
| 355 | 293 | case MMCO_SHORT2LONG: |
| 356 | 294 | if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) { |
| 357 | 295 | return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX; |
| 358 | 296 | } |
| 359 | − pPic = WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_TARGET); | |
| 360 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); | |
| 361 | − | |
| 362 | − WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_BASE); | |
| 363 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); | |
| 297 | + pPic = WelsDelShortFromList (pRefPic, iShortFrameNum); | |
| 298 | + WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx); | |
| 364 | 299 | #ifdef LONG_TERM_REF |
| 365 | 300 | pCtx->bCurAuContainLtrMarkSeFlag = true; |
| 366 | 301 | pCtx->iFrameNumOfAuMarkedLtr = iShortFrameNum; |
| @@ -374,7 +309,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 7 unmodified lines | ||
| 374 | 309 | pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx; |
| 375 | 310 | for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) { |
| 376 | 311 | if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) { |
| 377 | − WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx, REMOVE_BASE_FIRST); | |
| 312 | + WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx); | |
| 378 | 313 | } |
| 379 | 314 | } |
| 380 | 315 | break; |
| @@ -391,8 +326,7 @@ static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool · 10 unmodified lines | ||
| 391 | 326 | pCtx->iFrameNumOfAuMarkedLtr = pCtx->iFrameNum; |
| 392 | 327 | WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum); |
| 393 | 328 | #endif |
| 394 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); | |
| 395 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); | |
| 329 | + WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx); | |
| 396 | 330 | iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx); |
| 397 | 331 | break; |
| 398 | 332 | default : |
| @@ -409,7 +343,7 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { · 10 unmodified lines | ||
| 409 | 343 | |
| 410 | 344 | if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) { |
| 411 | 345 | for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) { |
| 412 | − pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum, REMOVE_BASE_FIRST); | |
| 346 | + pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum); | |
| 413 | 347 | if (pPic) { |
| 414 | 348 | SetUnRef (pPic); |
| 415 | 349 | break; |
| @@ -421,68 +355,61 @@ static int32_t SlidingWindow (PWelsDecoderContext pCtx) { · 5 unmodified lines | ||
| 421 | 355 | return ERR_NONE; |
| 422 | 356 | } |
| 423 | 357 | |
| 424 | −static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) { | |
| 358 | +static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) { | |
| 425 | 359 | int32_t i = 0; |
| 426 | 360 | int32_t iMoveSize = 0; |
| 427 | 361 | PPicture pPic = NULL; |
| 428 | 362 | |
| 429 | 363 | for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) { |
| 430 | 364 | if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) { |
| 431 | − if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag) | |
| 432 | − || (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag) | |
| 433 | − || (eRemoveFlag == REMOVE_BASE_FIRST)) { | |
| 434 | − iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1; | |
| 435 | − pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false; | |
| 436 | − pPic = pRefPic->pShortRefList[LIST_0][i]; | |
| 437 | − pRefPic->pShortRefList[LIST_0][i] = NULL; | |
| 438 | − if (iMoveSize > 0) { | |
| 439 | − memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1], | |
| 440 | − iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage | |
| 441 | − } | |
| 442 | − pRefPic->uiShortRefCount[LIST_0]--; | |
| 443 | − pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL; | |
| 444 | − break; | |
| 365 | + iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1; | |
| 366 | + pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false; | |
| 367 | + pPic = pRefPic->pShortRefList[LIST_0][i]; | |
| 368 | + pRefPic->pShortRefList[LIST_0][i] = NULL; | |
| 369 | + if (iMoveSize > 0) { | |
| 370 | + memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1], | |
| 371 | + iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage | |
| 445 | 372 | } |
| 373 | + pRefPic->uiShortRefCount[LIST_0]--; | |
| 374 | + pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL; | |
| 375 | + break; | |
| 446 | 376 | } |
| 447 | 377 | } |
| 448 | 378 | |
| 449 | 379 | return pPic; |
| 450 | 380 | } |
| 451 | 381 | |
| 452 | −static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) { | |
| 453 | − PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag); | |
| 382 | +static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) { | |
| 383 | + PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum); | |
| 454 | 384 | if (pPic) { |
| 455 | 385 | SetUnRef (pPic); |
| 456 | 386 | } |
| 457 | 387 | return pPic; |
| 458 | 388 | } |
| 459 | 389 | |
| 460 | −static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) { | |
| 390 | +static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) { | |
| 461 | 391 | PPicture pPic = NULL; |
| 462 | 392 | int32_t i = 0; |
| 463 | 393 | for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) { |
| 464 | 394 | pPic = pRefPic->pLongRefList[LIST_0][i]; |
| 465 | 395 | if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) { |
| 466 | − if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE) | |
| 467 | − && pPic->bRefBaseFlag)) { | |
| 468 | − int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1; | |
| 469 | − pPic->bUsedAsRef = false; | |
| 470 | − pPic->bIsLongRef = false; | |
| 471 | − if (iMoveSize > 0) { | |
| 472 | − memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1], | |
| 473 | − iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage | |
| 474 | − } | |
| 475 | − pRefPic->uiLongRefCount[LIST_0]--; | |
| 476 | − pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL; | |
| 477 | − return pPic; | |
| 396 | + int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1; | |
| 397 | + pPic->bUsedAsRef = false; | |
| 398 | + pPic->bIsLongRef = false; | |
| 399 | + if (iMoveSize > 0) { | |
| 400 | + memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1], | |
| 401 | + iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage | |
| 478 | 402 | } |
| 403 | + pRefPic->uiLongRefCount[LIST_0]--; | |
| 404 | + pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL; | |
| 405 | + return pPic; | |
| 479 | 406 | } |
| 480 | 407 | } |
| 481 | 408 | return NULL; |
| 482 | 409 | } |
| 483 | 410 | |
| 484 | −static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) { | |
| 485 | − PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag); | |
| 411 | +static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) { | |
| 412 | + PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx); | |
| 486 | 413 | if (pPic) { |
| 487 | 414 | SetUnRef (pPic); |
| 488 | 415 | } |
| @@ -528,34 +455,11 @@ static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongT · 39 unmodified lines | ||
| 528 | 455 | return ERR_NONE; |
| 529 | 456 | } |
| 530 | 457 | |
| 531 | −static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) { | |
| 532 | − PPicture pPic = NULL; | |
| 533 | − int32_t iRet = ERR_NONE; | |
| 534 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); | |
| 535 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); | |
| 536 | − | |
| 537 | − pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_TARGET); | |
| 538 | − if (pPic) { | |
| 539 | − iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx); | |
| 540 | − } else { | |
| 541 | − return ERR_INFO_INVALID_REF_MARKING; | |
| 542 | − } | |
| 543 | − | |
| 544 | − pPic = NULL; | |
| 545 | − pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_BASE); | |
| 546 | − if (pPic) { | |
| 547 | − iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx); | |
| 548 | − } | |
| 549 | − | |
| 550 | − return iRet; | |
| 551 | −} | |
| 552 | − | |
| 553 | 458 | static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) { |
| 554 | 459 | PPicture pPic = NULL; |
| 555 | 460 | int32_t i = 0; |
| 556 | 461 | int32_t iRet = ERR_NONE; |
| 557 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET); | |
| 558 | − WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE); | |
| 462 | + WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx); | |
| 559 | 463 | |
| 560 | 464 | for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++) { |
| 561 | 465 | pPic = pRefPic->pRefList[LIST_0][i]; |