1
0
Fork 0

avcodec/hevcdec: Move collocated_ref to HEVCContext

Only the collocated_ref of the current frame (i.e. HEVCContext.ref)
is ever used*, so move it to HEVCContext directly after ref.

*: This goes so far that collocated_ref was not even synced across
threads in case of frame-threading.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2022-08-22 20:33:32 +02:00
parent 2b300eb533
commit ba6a5e7a3d
4 changed files with 7 additions and 8 deletions

View File

@ -227,7 +227,7 @@ static int temporal_luma_motion_vector(const HEVCContext *s, int x0, int y0,
int availableFlagLXCol = 0;
int colPic;
const HEVCFrame *ref = s->ref->collocated_ref;
const HEVCFrame *ref = s->collocated_ref;
if (!ref) {
memset(mvLXCol, 0, sizeof(*mvLXCol));

View File

@ -51,8 +51,6 @@ void ff_hevc_unref_frame(HEVCFrame *frame, int flags)
frame->rpl_tab = NULL;
frame->refPicList = NULL;
frame->collocated_ref = NULL;
ff_refstruct_unref(&frame->hwaccel_picture_private);
}
}
@ -156,6 +154,7 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, int poc)
*frame = ref->frame;
s->ref = ref;
s->collocated_ref = NULL;
if (s->sh.pic_output_flag)
ref->flags = HEVC_FRAME_FLAG_OUTPUT | HEVC_FRAME_FLAG_SHORT_REF;
@ -387,7 +386,7 @@ int ff_hevc_slice_rpl(HEVCContext *s)
if (sh->collocated_list == list_idx &&
sh->collocated_ref_idx < rpl->nb_refs)
s->ref->collocated_ref = rpl->ref[sh->collocated_ref_idx];
s->collocated_ref = rpl->ref[sh->collocated_ref_idx];
}
return 0;

View File

@ -2920,7 +2920,7 @@ static int hevc_frame_start(HEVCContext *s)
fail:
if (s->ref)
ff_hevc_unref_frame(s->ref, ~0);
s->ref = NULL;
s->ref = s->collocated_ref = NULL;
return ret;
}
@ -3136,7 +3136,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
int i, ret = 0;
int eos_at_start = 1;
s->ref = NULL;
s->ref = s->collocated_ref = NULL;
s->last_eos = s->eos;
s->eos = 0;
s->overlap = 0;
@ -3351,7 +3351,7 @@ static int hevc_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
old, s->dovi_ctx.dv_profile);
}
s->ref = NULL;
s->ref = s->collocated_ref = NULL;
ret = decode_nal_units(s, avpkt->data, avpkt->size);
if (ret < 0)
return ret;

View File

@ -413,7 +413,6 @@ typedef struct HEVCFrame {
RefPicListTab **rpl_tab;
int ctb_count;
int poc;
struct HEVCFrame *collocated_ref;
AVBufferRef *tab_mvf_buf;
AVBufferRef *rpl_tab_buf;
@ -529,6 +528,7 @@ typedef struct HEVCContext {
enum HEVCNALUnitType nal_unit_type;
int temporal_id; ///< temporal_id_plus1 - 1
HEVCFrame *ref;
HEVCFrame *collocated_ref;
HEVCFrame DPB[32];
int poc;
int pocTid0;