shithub: openh264

Download patch

ref: 573b02797b8d7d334e6647106d992cebbefa5ef5
parent: a31f2b3265ce7a5cc522af0865ea1ecd9180dcee
parent: 5303eaaeb9366b83b4ee8f913996bb71ade1ebf5
author: Licai Guo <licaguo@cisco.com>
date: Thu Feb 27 07:39:23 EST 2014

Merge pull request #363 from huili2/remove_store_base

remove unused codes in reference picture management

--- a/codec/decoder/core/inc/manage_dec_ref.h
+++ b/codec/decoder/core/inc/manage_dec_ref.h
@@ -47,16 +47,10 @@
 
 namespace WelsDec {
 
-typedef enum TagRemoveFlag {
-REMOVE_TARGET = 0,
-REMOVE_BASE = 1,
-REMOVE_BASE_FIRST = 2
-} ERemoveFlag;
-
 void  WelsResetRefPic (PWelsDecoderContext pCtx);
 int32_t WelsInitRefList (PWelsDecoderContext pCtx, int32_t iPoc);
 int32_t WelsReorderRefList (PWelsDecoderContext pCtx);
-int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag);
+int32_t WelsMarkAsRef (PWelsDecoderContext pCtx);
 
 } // namespace WelsDec
 
--- a/codec/decoder/core/inc/picture.h
+++ b/codec/decoder/core/inc/picture.h
@@ -67,7 +67,6 @@
 uint8_t		uiTemporalId;
 uint8_t		uiSpatialId;
 uint8_t		uiQualityId;
-bool		bRefBaseFlag;
 
 int32_t		iFrameNum;		// frame number			//for ref pic management
 int32_t		iLongTermFrameIdx;					//id for long term ref pic
--- a/codec/decoder/core/src/decoder_core.cpp
+++ b/codec/decoder/core/src/decoder_core.cpp
@@ -101,10 +101,8 @@
   return 0;
 }
 
-inline bool    CheckSliceNeedReconstruct (int16_t iCurDid, int16_t iCurQid, bool bStoreRefBasePicFlag,
-    uint8_t uiDidMax, uint8_t uiLayerDqId, uint8_t uiTargetDqId) {
-  return ((iCurDid == uiDidMax) && (iCurQid == BASE_QUALITY_ID) && (bStoreRefBasePicFlag))   // store base
-         || (uiLayerDqId == uiTargetDqId); // target layer
+inline bool    CheckSliceNeedReconstruct (uint8_t uiLayerDqId, uint8_t uiTargetDqId) {
+  return (uiLayerDqId == uiTargetDqId); // target layer
 }
 
 inline uint8_t GetTargetDqId (uint8_t uiTargetDqId,  SDecodingParam* psParam) {
@@ -1863,8 +1861,7 @@
       pSh		= &pNalCur->sNalData.sVclNal.sSliceHeaderExt.sSliceHeader;
       pShExt	= &pNalCur->sNalData.sVclNal.sSliceHeaderExt;
 
-      bReconstructSlice = CheckSliceNeedReconstruct (iCurrIdD, iCurrIdQ, pShExt->bStoreRefBasePicFlag,
-                          kuiDependencyIdMax, pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId);
+      bReconstructSlice = CheckSliceNeedReconstruct (pNalCur->sNalHeaderExt.uiLayerDqId, kuiTargetLayerDqId);
 
       memcpy (&pLayerInfo.sNalHeaderExt, &pNalCur->sNalHeaderExt, sizeof (SNalUnitHeaderExt)); //confirmed_safe_unsafe_usage
 
@@ -1995,25 +1992,15 @@
 #endif
 
       }
-      if ((uiNalRefIdc > 0) && (iCurrIdQ || (!dq_cur->bStoreRefBasePicFlag))) {
-        WelsMarkAsRef (pCtx, false);
-        ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture,
-                                  pCtx->sExpandPicFunc.pExpandChromaPicture);
-        pCtx->pDec = NULL;
-      }
-    }
-
-    if ((iCurrIdD == kuiDependencyIdMax) && (iCurrIdQ == BASE_QUALITY_ID) && (dq_cur->bStoreRefBasePicFlag)) {
-      pStoreBasePic = pCtx->pDec;
-
       if (uiNalRefIdc > 0) {
-        WelsMarkAsRef (pCtx, true);
+        WelsMarkAsRef (pCtx);
         ExpandReferencingPicture (pCtx->pDec, pCtx->sExpandPicFunc.pExpandLumaPicture,
                                   pCtx->sExpandPicFunc.pExpandChromaPicture);
         pCtx->pDec = NULL;
       }
     }
-    // need update frame_num due current frame is well decoded
+
+   // need update frame_num due current frame is well decoded
     pCtx->iPrevFrameNum	= pSh->iFrameNum;
     if (pCtx->bLastHasMmco5)
       pCtx->iPrevFrameNum = 0;
--- a/codec/decoder/core/src/manage_dec_ref.cpp
+++ b/codec/decoder/core/src/manage_dec_ref.cpp
@@ -44,20 +44,18 @@
 
 namespace WelsDec {
 
-static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum,          ERemoveFlag eRemoveFlag);
-static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
-static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum,          ERemoveFlag eRemoveFlag);
-static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag);
+static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum);
+static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
+static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum);
+static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx);
 
-static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking);
 static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking);
-static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic,
+static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
                             int32_t iShortFrameNum, uint32_t uiLongTermPicNum, int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx);
 static int32_t SlidingWindow (PWelsDecoderContext pCtx);
 
 static int32_t AddShortTermToList (PRefPic pRefPic, PPicture pPic);
 static int32_t AddLongTermToList (PRefPic pRefPic, PPicture pPic, int32_t iLongTermFrameIdx);
-static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
 static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx);
 
 static void SetUnRef (PPicture pRef) {
@@ -67,7 +65,6 @@
     pRef->iFrameNum = -1;
     pRef->iFramePoc = 0;
     pRef->iLongTermFrameIdx = -1;
-    pRef->bRefBaseFlag = 0;
     pRef->uiQualityId = -1;
     pRef->uiTemporalId = -1;
     pRef->uiSpatialId = -1;
@@ -114,37 +111,13 @@
   memset (pCtx->sRefPic.pRefList[LIST_0], 0, MAX_REF_PIC_COUNT * sizeof (PPicture));
   //short
   for (i = 0; i < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++i) {
-    if (kbUseRefBasePicFlag == ppShoreRefList[i]->bRefBaseFlag) {
-      pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
-    } else {
-      for (j = 0; j < pCtx->sRefPic.uiShortRefCount[LIST_0]; ++j) {
-        if (ppShoreRefList[j]->iFrameNum == ppShoreRefList[i]->iFrameNum
-            && ppShoreRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
-          break;
-        }
-      }
-      if (j == pCtx->sRefPic.uiShortRefCount[LIST_0]) {
-        pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppShoreRefList[i];
-      }
-    }
+    pCtx->sRefPic.pRefList[LIST_0][iCount++ ] = ppShoreRefList[i];
   }
 
   //long
   j = 0;
   for (i = 0; i < pCtx->sRefPic.uiLongRefCount[LIST_0] ; ++i) {
-    if (kbUseRefBasePicFlag == ppLongRefList[i]->bRefBaseFlag) {
-      pCtx->sRefPic.pRefList[LIST_0][iCount++  ] = ppLongRefList[i];
-    } else {
-      for (j = 0; j < pCtx->sRefPic.uiLongRefCount[LIST_0]; ++j) {
-        if (ppLongRefList[j]->iLongTermFrameIdx == ppLongRefList[i]->iLongTermFrameIdx
-            && ppLongRefList[j]->bRefBaseFlag == kbUseRefBasePicFlag) {
-          break;
-        }
-      }
-      if (j == pCtx->sRefPic.uiLongRefCount[LIST_0]) {
-        pCtx->sRefPic.pRefList[LIST_0][iCount++] = ppLongRefList[i];
-      }
-    }
+    pCtx->sRefPic.pRefList[LIST_0][iCount++  ] = ppLongRefList[i];
   }
   pCtx->sRefPic.uiRefCount[LIST_0] = iCount;
 
@@ -231,7 +204,7 @@
   return ERR_NONE;
 }
 
-int32_t WelsMarkAsRef (PWelsDecoderContext pCtx, const bool kbRefBaseMarkingFlag) {
+int32_t WelsMarkAsRef (PWelsDecoderContext pCtx) {
   PRefPic pRefPic = &pCtx->sRefPic;
   PRefPicMarking pRefPicMarking = pCtx->pCurDqLayer->pRefPicMarking;
   PRefBasePicMarking pRefPicBaseMarking = pCtx->pCurDqLayer->pRefPicBaseMarking;
@@ -240,14 +213,10 @@
   uint32_t j;
 
   int32_t iRet = ERR_NONE;
-  if (pCtx->pCurDqLayer->bStoreRefBasePicFlag && (pCtx->pSps->iNumRefFrames < 2)) {
-    return ERR_INFO_INVALID_MMCO_REF_NUM_NOT_ENOUGH;
-  }
 
   pCtx->pDec->bUsedAsRef = true;
   pCtx->pDec->uiQualityId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiQualityId;
   pCtx->pDec->uiTemporalId = pCtx->pCurDqLayer->sLayerInfo.sNalHeaderExt.uiTemporalId;
-  pCtx->pDec->bRefBaseFlag = kbRefBaseMarkingFlag;
 
   for (j = pCurAU->uiStartPos; j <= pCurAU->uiEndPos; j++) {
     if (pCurAU->pNalUnitsList[j]->sNalHeaderExt.sNalUnitHeader.eNalUnitType == NAL_UNIT_CODED_SLICE_IDR
@@ -264,14 +233,6 @@
       pCtx->sRefPic.iMaxLongTermFrameIdx = -1;
     }
   } else {
-    if (pRefPicBaseMarking->bAdaptiveRefBasePicMarkingModeFlag) {
-      iRet = MMCOBase (pCtx, pRefPicBaseMarking);
-    }
-
-    if (iRet != ERR_NONE) {
-      return iRet;
-    }
-
     if (pRefPicMarking->bAdaptiveRefPicMarkingModeFlag) {
       iRet = MMCO (pCtx, pRefPicMarking);
       if (pCtx->bLastHasMmco5) {
@@ -293,29 +254,6 @@
   return iRet;
 }
 
-static int32_t MMCOBase (PWelsDecoderContext pCtx, PRefBasePicMarking pRefPicBaseMarking) {
-  PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
-  int32_t i = 0;
-  int32_t iRet = ERR_NONE;
-
-  for (i = 0 ; pRefPicBaseMarking->mmco_base[i].uiMmcoType != MMCO_END; i++) {
-    uint32_t uiMmcoType = pRefPicBaseMarking->mmco_base[i].uiMmcoType;
-    int32_t iShortFrameNum = (pCtx->iFrameNum - pRefPicBaseMarking->mmco_base[i].uiDiffOfPicNums) & ((
-                               1 << pSps->uiLog2MaxFrameNum) - 1);
-    uint32_t uiLongTermPicNum = pRefPicBaseMarking->mmco_base[i].uiLongTermPicNum;
-    if (uiMmcoType > MMCO_LONG2UNUSED)	{
-      return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
-    }
-    iRet = MMCOProcess (pCtx, uiMmcoType, true, iShortFrameNum, uiLongTermPicNum, 0, 0);
-
-    if (iRet != ERR_NONE) {
-      return iRet;
-    }
-  }
-
-  return ERR_NONE;
-}
-
 static int32_t MMCO (PWelsDecoderContext pCtx, PRefPicMarking pRefPicMarking) {
   PSps pSps = pCtx->pCurDqLayer->sLayerInfo.pSps;
   int32_t i = 0;
@@ -330,7 +268,7 @@
     if (uiMmcoType > MMCO_LONG)	{
       return ERR_INFO_INVALID_MMCO_OPCODE_BASE;
     }
-    iRet = MMCOProcess (pCtx, uiMmcoType, false, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);
+    iRet = MMCOProcess (pCtx, uiMmcoType, iShortFrameNum, uiLongTermPicNum, iLongTermFrameIdx, iMaxLongTermFrameIdx);
     if (iRet != ERR_NONE) {
       return iRet;
     }
@@ -338,7 +276,7 @@
 
   return ERR_NONE;
 }
-static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType, bool bRefBasePic,
+static int32_t MMCOProcess (PWelsDecoderContext pCtx, uint32_t uiMmcoType,
                             int32_t iShortFrameNum, uint32_t uiLongTermPicNum , int32_t iLongTermFrameIdx, int32_t iMaxLongTermFrameIdx) {
   PRefPic pRefPic = &pCtx->sRefPic;
   PPicture pPic = NULL;
@@ -347,20 +285,17 @@
 
   switch (uiMmcoType) {
   case MMCO_SHORT2UNUSED:
-    pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum, (ERemoveFlag) bRefBasePic);
+    pPic = WelsDelShortFromListSetUnref (pRefPic, iShortFrameNum);
     break;
   case MMCO_LONG2UNUSED:
-    pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum, (ERemoveFlag) bRefBasePic);
+    pPic = WelsDelLongFromListSetUnref (pRefPic, uiLongTermPicNum);
     break;
   case MMCO_SHORT2LONG:
     if (iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
       return ERR_INFO_INVALID_MMCO_LONG_TERM_IDX_EXCEED_MAX;
     }
-    pPic = WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_TARGET);
-    WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
-
-    WelsDelShortFromList (pRefPic, iShortFrameNum, REMOVE_BASE);
-    WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
+    pPic = WelsDelShortFromList (pRefPic, iShortFrameNum);
+    WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
 #ifdef LONG_TERM_REF
     pCtx->bCurAuContainLtrMarkSeFlag = true;
     pCtx->iFrameNumOfAuMarkedLtr      = iShortFrameNum;
@@ -374,7 +309,7 @@
     pRefPic->iMaxLongTermFrameIdx = iMaxLongTermFrameIdx;
     for (i = 0 ; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
       if (pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx > pRefPic->iMaxLongTermFrameIdx) {
-        WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx, REMOVE_BASE_FIRST);
+        WelsDelLongFromListSetUnref (pRefPic, pRefPic->pLongRefList[LIST_0][i]->iLongTermFrameIdx);
       }
     }
     break;
@@ -391,8 +326,7 @@
     pCtx->iFrameNumOfAuMarkedLtr      = pCtx->iFrameNum;
     WelsLog (pCtx, WELS_LOG_INFO, "ex_mark_avc():::MMCO_LONG:::LTR marking....iFrameNum: %d\n", pCtx->iFrameNum);
 #endif
-    WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
-    WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
+    WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
     iRet = AddLongTermToList (pRefPic, pCtx->pDec, iLongTermFrameIdx);
     break;
   default :
@@ -409,7 +343,7 @@
 
   if (pCtx->sRefPic.uiShortRefCount[LIST_0] + pCtx->sRefPic.uiLongRefCount[LIST_0] >= pCtx->pSps->iNumRefFrames) {
     for (i = pRefPic->uiShortRefCount[LIST_0] - 1; i >= 0; i--) {
-      pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum, REMOVE_BASE_FIRST);
+      pPic = WelsDelShortFromList (pRefPic, pRefPic->pShortRefList[LIST_0][i]->iFrameNum);
       if (pPic) {
         SetUnRef (pPic);
         break;
@@ -421,7 +355,7 @@
   return ERR_NONE;
 }
 
-static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
+static PPicture WelsDelShortFromList (PRefPic pRefPic, int32_t iFrameNum) {
   int32_t i = 0;
   int32_t iMoveSize = 0;
   PPicture pPic = NULL;
@@ -428,21 +362,17 @@
 
   for (i = 0; i < pRefPic->uiShortRefCount[LIST_0]; i++) {
     if (pRefPic->pShortRefList[LIST_0][i]->iFrameNum == iFrameNum) {
-      if ((eRemoveFlag == REMOVE_TARGET && !pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
-          || (eRemoveFlag == REMOVE_BASE && pRefPic->pShortRefList[LIST_0][i]->bRefBaseFlag)
-          || (eRemoveFlag == REMOVE_BASE_FIRST)) {
-        iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
-        pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
-        pPic = pRefPic->pShortRefList[LIST_0][i];
-        pRefPic->pShortRefList[LIST_0][i] = NULL;
-        if (iMoveSize > 0) {
-          memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
-                   iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
-        }
-        pRefPic->uiShortRefCount[LIST_0]--;
-        pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
-        break;
+      iMoveSize = pRefPic->uiShortRefCount[LIST_0] - i - 1;
+      pRefPic->pShortRefList[LIST_0][i]->bUsedAsRef = false;
+      pPic = pRefPic->pShortRefList[LIST_0][i];
+      pRefPic->pShortRefList[LIST_0][i] = NULL;
+      if (iMoveSize > 0) {
+        memmove (&pRefPic->pShortRefList[LIST_0][i], &pRefPic->pShortRefList[LIST_0][i + 1],
+                 iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
       }
+      pRefPic->uiShortRefCount[LIST_0]--;
+      pRefPic->pShortRefList[LIST_0][pRefPic->uiShortRefCount[0]] = NULL;
+      break;
     }
   }
 
@@ -449,8 +379,8 @@
   return pPic;
 }
 
-static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum, ERemoveFlag eRemoveFlag) {
-  PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum, eRemoveFlag);
+static PPicture WelsDelShortFromListSetUnref (PRefPic pRefPic, int32_t iFrameNum) {
+  PPicture pPic = WelsDelShortFromList (pRefPic, iFrameNum);
   if (pPic) {
     SetUnRef (pPic);
   }
@@ -457,32 +387,29 @@
   return pPic;
 }
 
-static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
+static PPicture WelsDelLongFromList (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
   PPicture pPic = NULL;
   int32_t i = 0;
   for (i = 0; i < pRefPic->uiLongRefCount[LIST_0]; i++) {
     pPic = pRefPic->pLongRefList[LIST_0][i];
     if (pPic->iLongTermFrameIdx == (int32_t)uiLongTermFrameIdx) {
-      if (((eRemoveFlag == REMOVE_TARGET) && ! (pPic->bRefBaseFlag)) || ((eRemoveFlag == REMOVE_BASE)
-          && pPic->bRefBaseFlag)) {
-        int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
-        pPic->bUsedAsRef = false;
-        pPic->bIsLongRef = false;
-        if (iMoveSize > 0) {
-          memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
-                   iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
-        }
-        pRefPic->uiLongRefCount[LIST_0]--;
-        pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
-        return pPic;
+      int32_t iMoveSize = pRefPic->uiLongRefCount[LIST_0] - i - 1;
+      pPic->bUsedAsRef = false;
+      pPic->bIsLongRef = false;
+      if (iMoveSize > 0) {
+        memmove (&pRefPic->pLongRefList[LIST_0][i], &pRefPic->pLongRefList[LIST_0][i + 1],
+                 iMoveSize * sizeof (PPicture)); //confirmed_safe_unsafe_usage
       }
+      pRefPic->uiLongRefCount[LIST_0]--;
+      pRefPic->pLongRefList[LIST_0][pRefPic->uiLongRefCount[LIST_0]] = NULL;
+      return pPic;
     }
   }
   return NULL;
 }
 
-static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx, ERemoveFlag eRemoveFlag) {
-  PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx, eRemoveFlag);
+static PPicture WelsDelLongFromListSetUnref (PRefPic pRefPic, uint32_t uiLongTermFrameIdx) {
+  PPicture pPic = WelsDelLongFromList (pRefPic, uiLongTermFrameIdx);
   if (pPic) {
     SetUnRef (pPic);
   }
@@ -528,34 +455,11 @@
   return ERR_NONE;
 }
 
-static int32_t AssignLongTermIdx (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
-  PPicture pPic = NULL;
-  int32_t iRet = ERR_NONE;
-  WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
-  WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
-
-  pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_TARGET);
-  if (pPic) {
-    iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
-  } else {
-    return ERR_INFO_INVALID_REF_MARKING;
-  }
-
-  pPic = NULL;
-  pPic = WelsDelShortFromList (pRefPic, iFrameNum, REMOVE_BASE);
-  if (pPic) {
-    iRet = AddLongTermToList (pRefPic, pPic, iLongTermFrameIdx);
-  }
-
-  return iRet;
-}
-
 static int32_t MarkAsLongTerm (PRefPic pRefPic, int32_t iFrameNum, int32_t iLongTermFrameIdx) {
   PPicture pPic = NULL;
   int32_t i = 0;
   int32_t iRet = ERR_NONE;
-  WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_TARGET);
-  WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx, REMOVE_BASE);
+  WelsDelLongFromListSetUnref (pRefPic, iLongTermFrameIdx);
 
   for (i = 0; i < pRefPic->uiRefCount[LIST_0]; i++)	{
     pPic = pRefPic->pRefList[LIST_0][i];