return 0;
}
-static HEVCFrame *find_ref_idx(HEVCContext *s, int poc)
+static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb)
{
int i;
- int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
- for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
- HEVCFrame *ref = &s->DPB[i];
- if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) {
- if ((ref->poc & LtMask) == poc)
- return ref;
+ if (use_msb) {
+ for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
+ HEVCFrame *ref = &s->DPB[i];
+ if (ref->frame->buf[0] && (ref->sequence == s->seq_decode)) {
+ if (ref->poc == poc)
+ return ref;
+ }
}
- }
-
- for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
- HEVCFrame *ref = &s->DPB[i];
- if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
- if (ref->poc == poc || (ref->poc & LtMask) == poc)
- return ref;
+ } else {
+ int LtMask = (1 << s->ps.sps->log2_max_poc_lsb) - 1;
+ for (i = 0; i < FF_ARRAY_ELEMS(s->DPB); i++) {
+ HEVCFrame *ref = &s->DPB[i];
+ if (ref->frame->buf[0] && ref->sequence == s->seq_decode) {
+ if ((ref->poc & LtMask) == poc)
+ return ref;
+ }
}
}
/* add a reference with the given poc to the list and mark it as used in DPB */
static int add_candidate_ref(HEVCContext *s, RefPicList *list,
- int poc, int ref_flag)
+ int poc, int ref_flag, uint8_t use_msb)
{
- HEVCFrame *ref = find_ref_idx(s, poc);
+ HEVCFrame *ref = find_ref_idx(s, poc, use_msb);
if (ref == s->ref || list->nb_refs >= HEVC_MAX_REFS)
return AVERROR_INVALIDDATA;
else
list = ST_CURR_AFT;
- ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF);
+ ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF, 1);
if (ret < 0)
goto fail;
}
int poc = long_rps->poc[i];
int list = long_rps->used[i] ? LT_CURR : LT_FOLL;
- ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF);
+ ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF, long_rps->poc_msb_present[i]);
if (ret < 0)
goto fail;
}