[FFmpeg-cvslog] lavfi/vaapi: Add function to get surface ID from AVFrame

Fei Wang git at videolan.org
Sun Jun 25 07:30:21 EEST 2023


ffmpeg | branch: master | Fei Wang <fei.w.wang-at-intel.com at ffmpeg.org> | Fri Jun 16 08:58:08 2023 +0800| [f565da83463715b5dc0ea6272d51e3dc2c6d076b] | committer: Haihao Xiang

lavfi/vaapi: Add function to get surface ID from AVFrame

Signed-off-by: Fei Wang <fei.w.wang at intel.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f565da83463715b5dc0ea6272d51e3dc2c6d076b
---

 libavfilter/vaapi_vpp.c | 10 ++--------
 libavfilter/vaapi_vpp.h |  5 +++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
index a323dab8b8..10d31977c6 100644
--- a/libavfilter/vaapi_vpp.c
+++ b/libavfilter/vaapi_vpp.c
@@ -518,7 +518,6 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
                              AVFrame *output_frame)
 {
     VAAPIVPPContext *ctx = avctx->priv;
-    VASurfaceID input_surface;
     int err;
 
     ctx->input_region = (VARectangle) {
@@ -534,10 +533,8 @@ int ff_vaapi_vpp_init_params(AVFilterContext *avctx,
     output_frame->crop_left   = 0;
     output_frame->crop_right  = 0;
 
-    input_surface = (VASurfaceID)(uintptr_t)input_frame->data[3],
-
     *params = (VAProcPipelineParameterBuffer) {
-        .surface                 = input_surface,
+        .surface                 = ff_vaapi_vpp_get_surface_id(input_frame),
         .surface_region          = &ctx->input_region,
         .output_region           = NULL,
         .output_background_color = VAAPI_VPP_BACKGROUND_BLACK,
@@ -623,7 +620,6 @@ int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx,
                                  AVFrame *output_frame)
 {
     VAAPIVPPContext *ctx = avctx->priv;
-    VASurfaceID output_surface;
     VABufferID *params_ids;
     VAStatus vas;
     int err;
@@ -635,10 +631,8 @@ int ff_vaapi_vpp_render_pictures(AVFilterContext *avctx,
     for (int i = 0; i < cout; i++)
         params_ids[i] = VA_INVALID_ID;
 
-    output_surface = (VASurfaceID)(uintptr_t)output_frame->data[3];
-
     vas = vaBeginPicture(ctx->hwctx->display,
-                         ctx->va_context, output_surface);
+                         ctx->va_context, ff_vaapi_vpp_get_surface_id(output_frame));
     if (vas != VA_STATUS_SUCCESS) {
         av_log(avctx, AV_LOG_ERROR, "Failed to attach new picture: "
                "%d (%s).\n", vas, vaErrorStr(vas));
diff --git a/libavfilter/vaapi_vpp.h b/libavfilter/vaapi_vpp.h
index ead07036dc..cc845b854c 100644
--- a/libavfilter/vaapi_vpp.h
+++ b/libavfilter/vaapi_vpp.h
@@ -27,6 +27,11 @@
 
 #include "avfilter.h"
 
+static inline VASurfaceID ff_vaapi_vpp_get_surface_id(const AVFrame *frame)
+{
+    return (uintptr_t)frame->data[3];
+}
+
 // ARGB black, for VAProcPipelineParameterBuffer.output_background_color.
 #define VAAPI_VPP_BACKGROUND_BLACK 0xff000000
 



More information about the ffmpeg-cvslog mailing list