aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTong Wu <tong1.wu@intel.com>2024-01-02 11:08:46 +0800
committerLynne <dev@lynne.ee>2024-07-02 14:15:12 +0200
commitf303c2629252bcdfe12336c0d921f08658c4a765 (patch)
tree30f934509f9f894adab328057affef2fadf0327b
parentdea5204b4136d08ac08115e4efb3f65e3c101fc7 (diff)
downloadffmpeg-f303c2629252bcdfe12336c0d921f08658c4a765.tar.gz
avcodec/vaapi_encode: move pic->input_surface initialization to encode_alloc
When allocating the VAAPIEncodePicture, pic->input_surface can be initialized right in the place. This movement simplifies the send_frame logic and is the preparation for moving vaapi_encode_send_frame to the base layer. Signed-off-by: Tong Wu <tong1.wu@intel.com>
-rw-r--r--libavcodec/vaapi_encode.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 54bdd73902..194422b36d 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -878,7 +878,8 @@ static int vaapi_encode_discard(AVCodecContext *avctx,
return 0;
}
-static VAAPIEncodePicture *vaapi_encode_alloc(AVCodecContext *avctx)
+static VAAPIEncodePicture *vaapi_encode_alloc(AVCodecContext *avctx,
+ const AVFrame *frame)
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodePicture *pic;
@@ -895,7 +896,7 @@ static VAAPIEncodePicture *vaapi_encode_alloc(AVCodecContext *avctx)
}
}
- pic->input_surface = VA_INVALID_ID;
+ pic->input_surface = (VASurfaceID)(uintptr_t)frame->data[3];
pic->recon_surface = VA_INVALID_ID;
pic->output_buffer = VA_INVALID_ID;
@@ -1332,7 +1333,7 @@ static int vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
if (err < 0)
return err;
- pic = vaapi_encode_alloc(avctx);
+ pic = vaapi_encode_alloc(avctx, frame);
if (!pic)
return AVERROR(ENOMEM);
@@ -1345,7 +1346,6 @@ static int vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
if (ctx->input_order == 0 || frame->pict_type == AV_PICTURE_TYPE_I)
pic->force_idr = 1;
- pic->input_surface = (VASurfaceID)(uintptr_t)frame->data[3];
pic->pts = frame->pts;
pic->duration = frame->duration;