bool VaapiDPBManager::execDummyPictureMarking(const PicturePtr& dummyPic, const SliceHeaderPtr& sliceHdr, int32_t frameNum) { initPictureRefLists(dummyPic); initPictureRefsPicNum(dummyPic, sliceHdr, frameNum); if (!execRefPicMarkingSlidingWindow(dummyPic)) return false; removeShortReference(dummyPic); /* add to short reference */ DPBLayer->shortRef[DPBLayer->shortRefCount++] = dummyPic.get(); return true; }
bool VaapiDPBManager::execRefPicMarkingAdaptive1(const PicturePtr& picture, H264RefPicMarking *refPicMarking, uint32_t MMCO) { uint32_t picNumX, i; int32_t longTermFrameIdx; VaapiDecPictureH264 *refPicture; int32_t foundIdx = 0; switch (MMCO) { case 1: { picNumX = getPicNumX(picture, refPicMarking); foundIdx = findShortRermReference(picNumX); if (foundIdx < 0) return false; i = (uint32_t) foundIdx; setH264PictureReference(DPBLayer->shortRef[i], 0, VAAPI_PICTURE_IS_FRAME(picture)); ARRAY_REMOVE_INDEX(DPBLayer->shortRef, i); } break; case 2: { foundIdx = findLongTermReference(refPicMarking->long_term_pic_num); if (foundIdx < 0) return false; i = (uint32_t) foundIdx; setH264PictureReference(DPBLayer->longRef[i], 0, VAAPI_PICTURE_IS_FRAME(picture)); ARRAY_REMOVE_INDEX(DPBLayer->longRef, i); } break; case 3: { for (i = 0; i < DPBLayer->longRefCount; i++) { if ((int32_t) DPBLayer->longRef[i]->m_longTermFrameIdx == refPicMarking->long_term_frame_idx) break; } if (i != DPBLayer->longRefCount) { setH264PictureReference(DPBLayer->longRef[i], 0, true); ARRAY_REMOVE_INDEX(DPBLayer->longRef, i); } picNumX = getPicNumX(picture, refPicMarking); foundIdx = findShortRermReference(picNumX); if (foundIdx < 0) return false; i = (uint32_t) foundIdx; refPicture = DPBLayer->shortRef[i]; ARRAY_REMOVE_INDEX(DPBLayer->shortRef, i); DPBLayer->longRef[DPBLayer->longRefCount++] = refPicture; refPicture->m_longTermFrameIdx = refPicMarking->long_term_frame_idx; setH264PictureReference(refPicture, VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE, VAAPI_PICTURE_IS_FRAME(picture)); } break; case 4: { longTermFrameIdx = refPicMarking->max_long_term_frame_idx_plus1 - 1; for (i = 0; i < DPBLayer->longRefCount; i++) { if (DPBLayer->longRef[i]->m_longTermFrameIdx <= longTermFrameIdx) continue; setH264PictureReference(DPBLayer->longRef[i], 0, false); ARRAY_REMOVE_INDEX(DPBLayer->longRef, i); i--; } } break; case 5: { flushDPB(); /* The picture shall be inferred to have had frame_num equal to 0 (7.4.3) */ picture->m_frameNum = 0; /* Update TopFieldOrderCnt and BottomFieldOrderCnt (8.2.1) */ if (picture->m_structure != VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD) picture->m_fieldPoc[TOP_FIELD] -= picture->m_POC; if (picture->m_structure != VAAPI_PICTURE_STRUCTURE_TOP_FIELD) picture->m_fieldPoc[BOTTOM_FIELD] -= picture->m_POC; picture->m_POC = 0; if (VAAPI_H264_PICTURE_IS_SHORT_TERM_REFERENCE(picture)) removeShortReference(picture); } break; case 6: { picture->m_longTermFrameIdx = refPicMarking->long_term_frame_idx; setH264PictureReference(picture.get(), VAAPI_PICTURE_FLAG_LONG_TERM_REFERENCE, false); } break; default: ERROR("unsupported MMCO type %d", MMCO); break; } return true; }