diff mbox series

[FFmpeg-devel,6/6] lavfi/qsvvpp: use the right picture struct for vpp initilaization

Message ID 20230612081448.936570-6-haihao.xiang@intel.com
State Accepted
Commit 88b3841149b9f41d6c5ec7930dcd5c6caf28b198
Headers show
Series [FFmpeg-devel,1/6] lavfi/qsvvpp: track the runtime version in vpp context | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Xiang, Haihao June 12, 2023, 8:14 a.m. UTC
From: Haihao Xiang <haihao.xiang@intel.com>

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
 libavfilter/qsvvpp.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index f2e8e5fd73..a03de05d9c 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -536,6 +536,20 @@  static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink, const AVFr
     out_frame->frame->height = outlink->h;
     out_frame->surface.Info = s->vpp_param.vpp.Out;
 
+    for (int i = 0; i < s->vpp_param.NumExtParam; i++) {
+        mfxExtBuffer *extbuf = s->vpp_param.ExtParam[i];
+
+        if (extbuf->BufferId == MFX_EXTBUFF_VPP_DEINTERLACING) {
+            out_frame->frame->interlaced_frame = 0;
+            break;
+        }
+    }
+
+    out_frame->surface.Info.PicStruct =
+        !out_frame->frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE :
+        (out_frame->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF :
+         MFX_PICSTRUCT_FIELD_BFF);
+
     return out_frame;
 }
 
@@ -851,13 +865,16 @@  failed:
     return ret;
 }
 
-static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s)
+static int qsvvpp_init_vpp_session(AVFilterContext *avctx, QSVVPPContext *s, const QSVFrame *in, QSVFrame *out)
 {
     int ret;
 
     if (s->vpp_initted)
         return 0;
 
+    s->vpp_param.vpp.In.PicStruct = in->surface.Info.PicStruct;
+    s->vpp_param.vpp.Out.PicStruct = out->surface.Info.PicStruct;
+
     /* Query VPP params again, including params for frame */
     ret = MFXVideoVPP_Query(s->session, &s->vpp_param, &s->vpp_param);
     if (ret < 0)
@@ -940,7 +957,7 @@  int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picr
             return AVERROR(ENOMEM);
         }
 
-        ret = qsvvpp_init_vpp_session(ctx, s);
+        ret = qsvvpp_init_vpp_session(ctx, s, in_frame, out_frame);
         if (ret)
             return ret;