aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vaapi_encode_av1.c
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2024-08-21 23:27:15 +0800
committerLynne <dev@lynne.ee>2024-09-09 07:05:24 +0200
commit9db68ed042a9043362d57c79945f6a8d936f9dba (patch)
tree887988d3bf3186cbf552be7a233880fd5c96840a /libavcodec/vaapi_encode_av1.c
parentfdf8025eb64c99567eadbebfd488a8e04c028a10 (diff)
downloadffmpeg-9db68ed042a9043362d57c79945f6a8d936f9dba.tar.gz
hw_base_encode: refactor picture allocation/freeing
This commit cleans up and refactors the mess of private state upon private state that used to be. Now, FFHWBaseEncodePicture is fully initialized upon call-time, and, most importantly, this lets APIs which require initialization data for frames (VkImageViews) to initialize this for both the input image, and the reconstruction (DPB) image. Signed-off-by: Tong Wu <wutong1208@outlook.com>
Diffstat (limited to 'libavcodec/vaapi_encode_av1.c')
-rw-r--r--libavcodec/vaapi_encode_av1.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/libavcodec/vaapi_encode_av1.c b/libavcodec/vaapi_encode_av1.c
index dfdb424185..6d1be9fc07 100644
--- a/libavcodec/vaapi_encode_av1.c
+++ b/libavcodec/vaapi_encode_av1.c
@@ -466,12 +466,12 @@ end:
}
static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
- VAAPIEncodePicture *vaapi_pic)
+ FFHWBaseEncodePicture *pic)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeAV1Context *priv = avctx->priv_data;
- const FFHWBaseEncodePicture *pic = &vaapi_pic->base;
- VAAPIEncodeAV1Picture *hpic = pic->priv_data;
+ VAAPIEncodePicture *vaapi_pic = pic->priv;
+ VAAPIEncodeAV1Picture *hpic = pic->codec_priv;
AV1RawOBU *fh_obu = &priv->fh;
AV1RawFrameHeader *fh = &fh_obu->obu.frame.header;
VAEncPictureParameterBufferAV1 *vpic = vaapi_pic->codec_picture_params;
@@ -503,7 +503,7 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
fh->frame_type = AV1_FRAME_INTER;
fh->base_q_idx = priv->q_idx_p;
ref = pic->refs[0][pic->nb_refs[0] - 1];
- href = ref->priv_data;
+ href = ref->codec_priv;
hpic->slot = !href->slot;
hpic->last_idr_frame = href->last_idr_frame;
fh->refresh_frame_flags = 1 << hpic->slot;
@@ -519,7 +519,7 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
/** set the 2nd nearest frame in L0 as Golden frame. */
if (pic->nb_refs[0] > 1) {
ref = pic->refs[0][pic->nb_refs[0] - 2];
- href = ref->priv_data;
+ href = ref->codec_priv;
fh->ref_frame_idx[3] = href->slot;
fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
vpic->ref_frame_ctrl_l0.fields.search_idx1 = AV1_REF_FRAME_GOLDEN;
@@ -540,7 +540,7 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
vpic->ref_frame_ctrl_l1.fields.search_idx0 = AV1_REF_FRAME_BWDREF;
ref = pic->refs[0][pic->nb_refs[0] - 1];
- href = ref->priv_data;
+ href = ref->codec_priv;
hpic->last_idr_frame = href->last_idr_frame;
fh->primary_ref_frame = href->slot;
fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
@@ -549,7 +549,7 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
}
ref = pic->refs[1][pic->nb_refs[1] - 1];
- href = ref->priv_data;
+ href = ref->codec_priv;
fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
for (i = AV1_REF_FRAME_GOLDEN; i < AV1_REFS_PER_FRAME; i++) {
fh->ref_frame_idx[i] = href->slot;
@@ -634,7 +634,7 @@ static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx,
for (int j = 0; j < pic->nb_refs[i]; j++) {
FFHWBaseEncodePicture *ref_pic = pic->refs[i][j];
- slot = ((VAAPIEncodeAV1Picture*)ref_pic->priv_data)->slot;
+ slot = ((VAAPIEncodeAV1Picture*)ref_pic->codec_priv)->slot;
av_assert0(vpic->reference_frames[slot] == VA_INVALID_SURFACE);
vpic->reference_frames[slot] = ((VAAPIEncodePicture *)ref_pic)->recon_surface;
@@ -732,7 +732,7 @@ end:
}
static int vaapi_encode_av1_init_slice_params(AVCodecContext *avctx,
- VAAPIEncodePicture *pic,
+ FFHWBaseEncodePicture *base,
VAAPIEncodeSlice *slice)
{
VAAPIEncodeAV1Context *priv = avctx->priv_data;
@@ -754,7 +754,7 @@ static int vaapi_encode_av1_init_slice_params(AVCodecContext *avctx,
}
static int vaapi_encode_av1_write_picture_header(AVCodecContext *avctx,
- VAAPIEncodePicture *vaapi_pic,
+ FFHWBaseEncodePicture *pic,
char *data, size_t *data_len)
{
VAAPIEncodeAV1Context *priv = avctx->priv_data;
@@ -762,7 +762,7 @@ static int vaapi_encode_av1_write_picture_header(AVCodecContext *avctx,
CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data;
AV1RawOBU *fh_obu = &priv->fh;
AV1RawFrameHeader *rep_fh = &fh_obu->obu.frame_header;
- const FFHWBaseEncodePicture *pic = &vaapi_pic->base;
+ VAAPIEncodePicture *vaapi_pic = pic->priv;
VAAPIEncodeAV1Picture *href;
int ret = 0;
@@ -770,7 +770,7 @@ static int vaapi_encode_av1_write_picture_header(AVCodecContext *avctx,
/** Pack repeat frame header. */
if (pic->display_order > pic->encode_order) {
memset(fh_obu, 0, sizeof(*fh_obu));
- href = pic->refs[0][pic->nb_refs[0] - 1]->priv_data;
+ href = pic->refs[0][pic->nb_refs[0] - 1]->codec_priv;
fh_obu->header.obu_type = AV1_OBU_FRAME_HEADER;
fh_obu->header.obu_has_size_field = 1;
@@ -804,7 +804,7 @@ end:
}
static int vaapi_encode_av1_write_extra_header(AVCodecContext *avctx,
- VAAPIEncodePicture *pic,
+ FFHWBaseEncodePicture *base_pic,
int index, int *type,
char *data, size_t *data_len)
{