Lines Matching refs:dpb
24 AVCDecPicBuffer *dpb = video->decPicBuf;
35 dpb->fs[num_fs] = NULL;
49 if (dpb->decoded_picture_buffer)
51 avcHandle->CBAVC_Free(userData, (int)dpb->decoded_picture_buffer);
52 dpb->decoded_picture_buffer = NULL;
55 /* need to allocate one extra frame for current frame, DPB only defines for reference frames */
57 dpb->num_fs = (uint32)(MaxDPBX2[mapLev2Idx[level]] << 2) / (3 * FrameHeightInMbs * PicWidthInMbs) + 1;
58 if (dpb->num_fs > MAX_FS)
60 dpb->num_fs = MAX_FS;
63 if (video->currSeqParams->num_ref_frames + 1 > (uint32)dpb->num_fs)
65 dpb->num_fs = video->currSeqParams->num_ref_frames + 1;
68 dpb->dpb_size = dpb->num_fs * (framesize + video->padded_size);
69 // dpb->dpb_size = (uint32)MaxDPBX2[mapLev2Idx[level]]*512 + framesize;
72 dpb->decoded_picture_buffer = (uint8*) avcHandle->CBAVC_Malloc(userData, dpb->dpb_size, 100/*DPB_MEM_ATTR*/);
74 if (dpb->decoded_picture_buffer == NULL || dpb->decoded_picture_buffer&0x3) // not word aligned
77 dpb->used_size = 0;
80 while (num_fs < dpb->num_fs)
83 dpb->fs[num_fs] = (AVCFrameStore*) avcHandle->CBAVC_Malloc(userData, sizeof(AVCFrameStore), 101/*DEFAULT_ATTR*/);
84 if (dpb->fs[num_fs] == NULL)
90 dpb->fs[num_fs]->base_dpb = dpb->decoded_picture_buffer + dpb->used_size;
92 dpb->fs[num_fs]->IsReference = 0;
93 dpb->fs[num_fs]->IsLongTerm = 0;
94 dpb->fs[num_fs]->IsOutputted = 3;
95 dpb->fs[num_fs]->frame.RefIdx = refIdx++; /* this value will remain unchanged through out the encoding session */
96 dpb->fs[num_fs]->frame.picType = AVC_FRAME;
97 dpb->fs[num_fs]->frame.isLongTerm = 0;
98 dpb->fs[num_fs]->frame.isReference = 0;
99 video->RefPicList0[num_fs] = &(dpb->fs[num_fs]->frame);
100 dpb->fs[num_fs]->frame.padded = 0;
101 dpb->used_size += (framesize + video->padded_size);
111 AVCDecPicBuffer *dpb = video->decPicBuf;
124 for (ii = 0; ii < dpb->num_fs; ii++)
126 dpb->fs[ii]->IsReference = 0;
127 dpb->fs[ii]->IsOutputted |= 0x02;
207 AVCDecPicBuffer *dpb = video->decPicBuf;
213 if (dpb->fs[ii] != NULL)
215 avcHandle->CBAVC_Free(userData, dpb->fs[ii]);
216 dpb->fs[ii] = NULL;
220 if (dpb->decoded_picture_buffer)
222 avcHandle->CBAVC_Free(userData, dpb->decoded_picture_buffer);
223 dpb->decoded_picture_buffer = NULL;
226 dpb->used_size = 0;
227 dpb->dpb_size = 0;
234 AVCDecPicBuffer *dpb = video->decPicBuf;
238 /* look for next unused dpb->fs, or complementary field pair */
243 for (ii = 0; ii < dpb->num_fs; ii++)
246 if (dpb->fs[ii]->IsReference == 0 && dpb->fs[ii]->IsOutputted == 3)
248 video->currFS = dpb->fs[ii];
259 if (ii == dpb->num_fs)
318 AVCDecPicBuffer *dpb = video->decPicBuf;
326 ii = dpb->num_fs;
329 if (dpb->fs[ii] == video->currFS)
344 AVCDecPicBuffer *dpb = video->decPicBuf;
354 for (ii = 0; ii < dpb->num_fs; ii++)
356 if (dpb->fs[ii] != video->currFS) /* not current frame */
358 dpb->fs[ii]->IsReference = 0; /* mark as unused for reference */
359 dpb->fs[ii]->IsLongTerm = 0; /* but still used until output */
360 dpb->fs[ii]->IsOutputted |= 0x02;
362 if (dpb->fs[ii]->IsOutputted == 3)
388 for (ii = 0; ii < dpb->num_fs; ii++)
390 if (dpb->fs[ii] != video->currFS) /* not current frame */
392 dpb->fs[ii]->IsOutputted = 3;
407 status = sliding_window_process(avcHandle, video, dpb); /* we may have to do this after adaptive_memory_marking */
411 status = adaptive_memory_marking(avcHandle, video, dpb, sliceHdr);
441 for (ii = 0; ii < dpb->num_fs; ii++)
443 if (dpb->fs[ii]->IsReference)
458 AVCStatus sliding_window_process(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb)
467 for (ii = 0; ii < dpb->num_fs; ii++)
469 if (dpb->fs[ii] != video->currFS) /* do not count the current frame */
471 if (dpb->fs[ii]->IsLongTerm)
475 else if (dpb->fs[ii]->IsReference)
489 for (ii = 0; ii < dpb->num_fs; ii++)
491 if (dpb->fs[ii]->IsReference && !dpb->fs[ii]->IsLongTerm)
493 if (dpb->fs[ii]->FrameNumWrap < MinFrameNumWrap)
495 MinFrameNumWrap = dpb->fs[ii]->FrameNumWrap;
506 dpb->fs[MinIdx]->IsReference = 0;
507 dpb->fs[MinIdx]->IsLongTerm = 0;
508 dpb->fs[MinIdx]->frame.isReference = FALSE;
509 dpb->fs[MinIdx]->frame.isLongTerm = FALSE;
510 dpb->fs[MinIdx]->IsOutputted |= 0x02;
512 if (dpb->fs[MinIdx]->IsOutputted == 3)
523 AVCStatus adaptive_memory_marking(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, AVCSliceHeader *sliceHdr)
533 MemMgrCtrlOp1(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[ii]);
534 // update_ref_list(dpb);
537 MemMgrCtrlOp2(avcHandle, dpb, sliceHdr->long_term_pic_num[ii]);
540 MemMgrCtrlOp3(avcHandle, video, dpb, sliceHdr->difference_of_pic_nums_minus1[ii], sliceHdr->long_term_frame_idx[ii]);
543 MemMgrCtrlOp4(avcHandle, video, dpb, sliceHdr->max_long_term_frame_idx_plus1[ii]);
546 MemMgrCtrlOp5(avcHandle, video, dpb);
551 MemMgrCtrlOp6(avcHandle, video, dpb, sliceHdr->long_term_frame_idx[ii]);
567 void MemMgrCtrlOp1(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, int difference_of_pic_nums_minus1)
573 for (ii = 0; ii < dpb->num_fs; ii++)
575 if (dpb->fs[ii]->IsReference == 3 && dpb->fs[ii]->IsLongTerm == 0)
577 if (dpb->fs[ii]->frame.PicNum == picNumX)
579 unmark_for_reference(avcHandle, dpb, ii);
589 void MemMgrCtrlOp2(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, int long_term_pic_num)
593 for (ii = 0; ii < dpb->num_fs; ii++)
595 if (dpb->fs[ii]->IsLongTerm == 3)
597 if (dpb->fs[ii]->frame.LongTermPicNum == long_term_pic_num)
599 unmark_for_reference(avcHandle, dpb, ii);
606 void MemMgrCtrlOp3(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint difference_of_pic_nums_minus1,
615 unmark_long_term_frame_for_reference_by_frame_idx(avcHandle, dpb, long_term_frame_idx);
620 for (ii = 0; ii < dpb->num_fs; ii++)
622 if (dpb->fs[ii]->IsReference == 3)
624 if ((dpb->fs[ii]->frame.isLongTerm == FALSE) && (dpb->fs[ii]->frame.PicNum == picNumX))
626 dpb->fs[ii]->LongTermFrameIdx = long_term_frame_idx;
627 dpb->fs[ii]->frame.LongTermPicNum = long_term_frame_idx;
629 dpb->fs[ii]->frame.isLongTerm = TRUE;
631 dpb->fs[ii]->IsLongTerm = 3;
640 void MemMgrCtrlOp4(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint max_long_term_frame_idx_plus1)
647 for (ii = 0; ii < dpb->num_fs; ii++)
649 if (dpb->fs[ii]->IsLongTerm && dpb->fs[ii] != video->currFS)
651 if (dpb->fs[ii]->LongTermFrameIdx > video->MaxLongTermFrameIdx)
653 unmark_for_reference(avcHandle, dpb, ii);
661 void MemMgrCtrlOp5(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb)
666 for (ii = 0; ii < dpb->num_fs; ii++) /* including the current frame ??????*/
668 if (dpb->fs[ii] != video->currFS) // MC_FIX
670 unmark_for_reference(avcHandle, dpb, ii);
678 void MemMgrCtrlOp6(AVCHandle *avcHandle, AVCCommonObj *video, AVCDecPicBuffer *dpb, uint long_term_frame_idx)
681 unmark_long_term_frame_for_reference_by_frame_idx(avcHandle, dpb, long_term_frame_idx);
691 void unmark_for_reference(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint idx)
694 AVCFrameStore *fs = dpb->fs[idx];
710 void unmark_long_term_frame_for_reference_by_frame_idx(AVCHandle *avcHandle, AVCDecPicBuffer *dpb, uint long_term_frame_idx)
713 for (ii = 0; ii < dpb->num_fs; ii++)
716 if (dpb->fs[ii]->IsLongTerm && (dpb->fs[ii]->LongTermFrameIdx == (int)long_term_frame_idx))
718 unmark_for_reference(avcHandle, dpb, ii);