📄 umc_h264_dec_decode_pic.cpp
字号:
bool bIsFieldSlice, Ipp32s /*NumL0RefActive*/, H264DecoderFrame **pRefPicList // pointer to start of list 0){ Ipp32s i, j, k; Ipp32s NumFramesInList; H264DecoderFrame *pHead = m_H264DecoderFramesList.head(); H264DecoderFrame *pFrm; Ipp32s PicNum; bool bError = false; VM_ASSERT(pRefPicList); for (i=0; i<MAX_NUM_REF_FRAMES; i++) { pRefPicList[i] = NULL; } NumFramesInList = 0; if (!bIsFieldSlice) { // Frame. Ref pic list ordering: Short term largest pic num to // smallest, followed by long term, largest long term pic num to // smallest. Note that ref pic list has one extra slot to assist // with re-ordering. for (pFrm = pHead; pFrm; pFrm = pFrm->future()) { if (pFrm->isShortTermRef()==3) { // add to ordered list PicNum = pFrm->PicNum(0); // find insertion point j=0; while (j<NumFramesInList && pRefPicList[j]->isShortTermRef() && pRefPicList[j]->PicNum(0) > PicNum) j++; // make room if needed if (pRefPicList[j]) { for (k=NumFramesInList; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } pRefPicList[k] = pRefPicList[k-1]; } } // add the short-term reference pRefPicList[j] = pFrm; NumFramesInList++; } else if (pFrm->isLongTermRef()==3) { // add to ordered list PicNum = pFrm->LongTermPicNum(0,3); // find insertion point j=0; // Skip past short-term refs and long term refs with smaller // long term pic num while (j<NumFramesInList && (pRefPicList[j]->isShortTermRef() || (pRefPicList[j]->isLongTermRef() && pRefPicList[j]->LongTermPicNum(0,2) < PicNum))) j++; // make room if needed if (pRefPicList[j]) { for (k=NumFramesInList; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } pRefPicList[k] = pRefPicList[k-1]; } } // add the long-term reference pRefPicList[j] = pFrm; NumFramesInList++; } if (bError) break; } } else { // TBD: field for (pFrm = pHead; pFrm; pFrm = pFrm->future()) { if (pFrm->isShortTermRef()) { // add to ordered list PicNum = pFrm->FrameNumWrap(); // find insertion point j=0; while (j<NumFramesInList && pRefPicList[j]->isShortTermRef() && pRefPicList[j]->FrameNumWrap() > PicNum) j++; // make room if needed if (pRefPicList[j]) { for (k=NumFramesInList; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } pRefPicList[k] = pRefPicList[k-1]; } } // add the short-term reference pRefPicList[j] = pFrm; NumFramesInList++; } else if (pFrm->isLongTermRef()) { // long term reference PicNum = pFrm->LongTermPicNum(0,2); // find insertion point j=0; // Skip past short-term refs and long term refs with smaller // long term pic num while (j<NumFramesInList && (pRefPicList[j]->isShortTermRef() || (pRefPicList[j]->isLongTermRef() && pRefPicList[j]->LongTermPicNum(0,2) < PicNum))) j++; // make room if needed if (pRefPicList[j]) { for (k=NumFramesInList; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } pRefPicList[k] = pRefPicList[k-1]; } } // add the long-term reference pRefPicList[j] = pFrm; NumFramesInList++; } if (bError) break; } } // If the number of reference pictures on the L0 list is greater than the // number of active references, discard the "extras". //I realy don't know why... /*if (NumFramesInList > NumL0RefActive) { for (i=NumFramesInList-1; i>=NumL0RefActive; i--) pRefPicList[i] = NULL; }*/} // InitPSliceRefPicList//////////////////////////////////////////////////////////////////////////////// InitBSliceRefPicLists//////////////////////////////////////////////////////////////////////////////void H264VideoDecoder::InitBSliceRefPicLists( bool bIsFieldSlice, Ipp32s /*NumL0RefActive*/, Ipp32s /*NumL1RefActive*/, H264DecoderFrame **pRefPicList0, // pointer to start of list 0 H264DecoderFrame **pRefPicList1 // pointer to start of list 1){ Ipp32s i, j, k; Ipp32s NumFramesInL0List; Ipp32s NumFramesInL1List; Ipp32s NumFramesInLTList; H264DecoderFrame *pHead = m_H264DecoderFramesList.head(); H264DecoderFrame *pFrm; Ipp32s FrmPicOrderCnt; H264DecoderFrame *LTRefPicList[MAX_NUM_REF_FRAMES]; // temp storage for long-term ordered list Ipp32s LongTermPicNum; bool bError = false; for (i=0; i<MAX_NUM_REF_FRAMES; i++) { pRefPicList0[i] = NULL; pRefPicList1[i] = NULL; LTRefPicList[i] = NULL; } NumFramesInL0List = 0; NumFramesInL1List = 0; NumFramesInLTList = 0; if (!bIsFieldSlice) { Ipp32s CurrPicOrderCnt = m_pCurrentFrame->PicOrderCnt(0); // Short term references: // Need L0 and L1 lists. Both contain 2 sets of reference frames ordered // by PicOrderCnt. The "previous" set contains the reference frames with // a PicOrderCnt < current frame. The "future" set contains the reference // frames with a PicOrderCnt > current frame. In both cases the ordering // is from closest to current frame to farthest. L0 has the previous set // followed by the future set; L1 has the future set followed by the previous set. // Accomplish this by one pass through the decoded frames list creating // the ordered previous list in the L0 array and the ordered future list // in the L1 array. Then copy from both to the other for the second set. // Long term references: // The ordered list is the same for L0 and L1, is ordered by ascending // LongTermPicNum. The ordered list is created using local temp then // appended to the L0 and L1 lists after the short term references. for (pFrm = pHead; pFrm; pFrm = pFrm->future()) { if (pFrm->isShortTermRef()==3) { // add to ordered list FrmPicOrderCnt = pFrm->PicOrderCnt(0,3); if (FrmPicOrderCnt < CurrPicOrderCnt) { // Previous reference to L0, order large to small j=0; while (j<NumFramesInL0List && (pRefPicList0[j]->PicOrderCnt(0,3) > FrmPicOrderCnt)) j++; // make room if needed if (pRefPicList0[j]) { for (k=NumFramesInL0List; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } pRefPicList0[k] = pRefPicList0[k-1]; } } // add the short-term reference pRefPicList0[j] = pFrm; NumFramesInL0List++; } else { // Future reference to L1, order small to large j=0; while (j<NumFramesInL1List && pRefPicList1[j]->PicOrderCnt(0,3) < FrmPicOrderCnt) j++; // make room if needed if (pRefPicList1[j]) { for (k=NumFramesInL1List; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } pRefPicList1[k] = pRefPicList1[k-1]; } } // add the short-term reference pRefPicList1[j] = pFrm; NumFramesInL1List++; } } // short-term B else if (pFrm->isLongTermRef()==3) { // long term reference LongTermPicNum = pFrm->LongTermPicNum(0,3); // order smallest to largest j=0; while (j<NumFramesInLTList && LTRefPicList[j]->LongTermPicNum(0) < LongTermPicNum) j++; // make room if needed if (LTRefPicList[j]) { for (k=NumFramesInLTList; k>j; k--) { // Avoid writing beyond end of list if (k > MAX_NUM_REF_FRAMES-1) { VM_ASSERT(0); bError = true; break; } LTRefPicList[k] = LTRefPicList[k-1]; } } // add the long-term reference LTRefPicList[j] = pFrm; NumFramesInLTList++; } // long term reference if (bError) break; } // for pFrm if ((NumFramesInL0List+NumFramesInL1List+NumFramesInLTList) < MAX_NUM_REF_FRAMES) { // Complete L0 and L1 lists // Add future short term references to L0 list, after previous for (i=0; i<NumFramesInL1List; i++) pRefPicList0[NumFramesInL0List+i] = pRefPicList1[i]; // Add previous short term references to L1 list, after future for (i=0; i<NumFramesInL0List; i++) pRefPicList1[NumFramesInL1List+i] = pRefPicList0[i]; // Add long term list to both L0 and L1 for (i=0; i<NumFramesInLTList; i++) { pRefPicList0[NumFramesInL0List+NumFramesInL1List+i] = LTRefPicList[i]; pRefPicList1[NumFramesInL0List+NumFramesInL1List+i] = LTRefPicList[i]; } // Special rule: When L1 has more than one entry and L0 == L1, all entries, // swap the first two entries of L1. // They can be equal only if there are no future or no previous short term
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -