From patchwork Thu Jul 29 05:25:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 29101 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp5500857ios; Wed, 28 Jul 2021 22:27:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTGly6cJUYw7AHVpmrZVTdsvtGyJFN82TYlX9ZHXJCMcodgYjIdwk89KTXCH7mzgCXgCVl X-Received: by 2002:a17:907:20f2:: with SMTP id rh18mr2981765ejb.136.1627536461807; Wed, 28 Jul 2021 22:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627536461; cv=none; d=google.com; s=arc-20160816; b=GpEuR8hXa/pgV8Tcf3hN7U36AX6ZmoWYMuaLr1LkcWwpRh37Hw7c5hAVejFtzI7d/D 5HPyZ4zjqJxkGFhZaLonkuISaGoBoqzm0masmB6Ew9wibSt56N1WVfZOMTUuhBrRbcRs ziUZxQp1wjy7asUxnUFgs0WDUFYfHdvs3i4ofZYSyapTKrX+g+95abtWBiqsAtZH7AGl 6SNMS9hBo15ee5gM/xak8PDvQ5r3sTZQL37AjaCECYYgySXM/C/4Hwor95KOPHtpZMTx AQUIS8XUx51ti4JcnMkIxgQB6CFyAlGvTUPwlLBcoSb7cXecaLO7j7Tl1uJvLxvWsdy0 uleg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=QE3s47J1sTmG0FTxMiokldJ9Way6fwohS4vVz7WY7hM=; b=rDztKJfECtddgnX586kI/CwXteftEPMSpT4HIgaV99tfNtOlQKRb9m/p2n+6UjdPu+ 3Y/uc9fmEySFPYKnn+kK1DFUDSKqcZmGy4VSQcwHsDAa0K89TQdFBiql0e2UkZ3DqVtw lyqZ3WNTdDF4LjjIKAbrj0a8ZsWJIKTi3upAI3+sN6j2IA0sGnkj+NQ52aZa6V1o/4jG lKXy7UjJvW7KgxxsuHd9KWe7LvEzq2SCHPybf+OS82ZF+A83ZZh2h2v7h05rU/nStAyd SEbTASZRZcF1qQM2Ea9Evv9u4QMZbpbhCKFkd0itaP8qlD1U6GEaQbjpPj7DhEoMett7 /TbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d2si1588449ejr.606.2021.07.28.22.27.41; Wed, 28 Jul 2021 22:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FEB468A3BF; Thu, 29 Jul 2021 08:26:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9469968A196 for ; Thu, 29 Jul 2021 08:26:14 +0300 (EEST) X-IronPort-AV: E=McAfee;i="6200,9189,10059"; a="210922210" X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="210922210" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 22:26:05 -0700 X-IronPort-AV: E=Sophos;i="5.84,278,1620716400"; d="scan'208";a="456730175" Received: from xhh-dg164.sh.intel.com ([10.239.159.167]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jul 2021 22:26:04 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Jul 2021 13:25:05 +0800 Message-Id: <20210729052509.30992-18-haihao.xiang@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210729052509.30992-1-haihao.xiang@intel.com> References: <20210729052509.30992-1-haihao.xiang@intel.com> Subject: [FFmpeg-devel] [PATCH v4 17/21] lavfi/deinterlace_qsv: simplify deinterlace_qsv filter X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Haihao Xiang MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: zl8M/DKmPjn9 Like what we did for scale_qsv filter, we use QSVVPPContext as a base context to manage MFX session for deinterlace_qsv filter --- libavfilter/vf_deinterlace_qsv.c | 492 ++----------------------------- 1 file changed, 30 insertions(+), 462 deletions(-) diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c index 3c2d87c7c8..50ff553e6a 100644 --- a/libavfilter/vf_deinterlace_qsv.c +++ b/libavfilter/vf_deinterlace_qsv.c @@ -42,34 +42,10 @@ #include "internal.h" #include "video.h" -enum { - QSVDEINT_MORE_OUTPUT = 1, - QSVDEINT_MORE_INPUT, -}; - typedef struct QSVDeintContext { - const AVClass *class; - - AVBufferRef *hw_frames_ctx; - /* a clone of the main session, used internally for deinterlacing */ - mfxSession session; - - mfxMemId *mem_ids; - int nb_mem_ids; - - mfxFrameSurface1 **surface_ptrs; - int nb_surface_ptrs; + QSVVPPContext qsv; - mfxExtOpaqueSurfaceAlloc opaque_alloc; - mfxExtVPPDeinterlacing deint_conf; - mfxExtBuffer *ext_buffers[2]; - int num_ext_buffers; - - QSVFrame *work_frames; - - int64_t last_pts; - - int eof; + mfxExtVPPDeinterlacing deint_conf; /* option for Deinterlacing algorithm to be used */ int mode; @@ -77,28 +53,7 @@ typedef struct QSVDeintContext { static av_cold void qsvdeint_uninit(AVFilterContext *ctx) { - QSVDeintContext *s = ctx->priv; - QSVFrame *cur; - - if (s->session) { - MFXClose(s->session); - s->session = NULL; - } - av_buffer_unref(&s->hw_frames_ctx); - - cur = s->work_frames; - while (cur) { - s->work_frames = cur->next; - av_frame_free(&cur->frame); - av_freep(&cur); - cur = s->work_frames; - } - - av_freep(&s->mem_ids); - s->nb_mem_ids = 0; - - av_freep(&s->surface_ptrs); - s->nb_surface_ptrs = 0; + ff_qsvvpp_close(ctx); } static int qsvdeint_query_formats(AVFilterContext *ctx) @@ -115,441 +70,54 @@ static int qsvdeint_query_formats(AVFilterContext *ctx) return 0; } -static mfxStatus frame_alloc(mfxHDL pthis, mfxFrameAllocRequest *req, - mfxFrameAllocResponse *resp) -{ - AVFilterContext *ctx = pthis; - QSVDeintContext *s = ctx->priv; - - if (!(req->Type & MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET) || - !(req->Type & (MFX_MEMTYPE_FROM_VPPIN | MFX_MEMTYPE_FROM_VPPOUT)) || - !(req->Type & MFX_MEMTYPE_EXTERNAL_FRAME)) - return MFX_ERR_UNSUPPORTED; - - resp->mids = s->mem_ids; - resp->NumFrameActual = s->nb_mem_ids; - - return MFX_ERR_NONE; -} - -static mfxStatus frame_free(mfxHDL pthis, mfxFrameAllocResponse *resp) -{ - return MFX_ERR_NONE; -} - -static mfxStatus frame_lock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr) -{ - return MFX_ERR_UNSUPPORTED; -} - -static mfxStatus frame_unlock(mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr) -{ - return MFX_ERR_UNSUPPORTED; -} - -static mfxStatus frame_get_hdl(mfxHDL pthis, mfxMemId mid, mfxHDL *hdl) -{ - *hdl = mid; - return MFX_ERR_NONE; -} - -static const mfxHandleType handle_types[] = { - MFX_HANDLE_VA_DISPLAY, - MFX_HANDLE_D3D9_DEVICE_MANAGER, - MFX_HANDLE_D3D11_DEVICE, -}; - -static int init_out_session(AVFilterContext *ctx) -{ - - QSVDeintContext *s = ctx->priv; - AVHWFramesContext *hw_frames_ctx = (AVHWFramesContext*)s->hw_frames_ctx->data; - AVQSVFramesContext *hw_frames_hwctx = hw_frames_ctx->hwctx; - AVQSVDeviceContext *device_hwctx = hw_frames_ctx->device_ctx->hwctx; - - int opaque = !!(hw_frames_hwctx->frame_type & MFX_MEMTYPE_OPAQUE_FRAME); - - mfxHDL handle = NULL; - mfxHandleType handle_type; - mfxVersion ver; - mfxIMPL impl; - mfxVideoParam par; - mfxStatus err; - int i; - - /* extract the properties of the "master" session given to us */ - err = MFXQueryIMPL(device_hwctx->session, &impl); - if (err == MFX_ERR_NONE) - err = MFXQueryVersion(device_hwctx->session, &ver); - if (err != MFX_ERR_NONE) { - av_log(ctx, AV_LOG_ERROR, "Error querying the session attributes\n"); - return AVERROR_UNKNOWN; - } - - for (i = 0; i < FF_ARRAY_ELEMS(handle_types); i++) { - err = MFXVideoCORE_GetHandle(device_hwctx->session, handle_types[i], &handle); - if (err == MFX_ERR_NONE) { - handle_type = handle_types[i]; - break; - } - } - - if (err < 0) - return ff_qsvvpp_print_error(ctx, err, "Error getting the session handle"); - else if (err > 0) { - ff_qsvvpp_print_warning(ctx, err, "Warning in getting the session handle"); - return AVERROR_UNKNOWN; - } - - /* create a "slave" session with those same properties, to be used for - * actual deinterlacing */ - err = MFXInit(impl, &ver, &s->session); - if (err < 0) - return ff_qsvvpp_print_error(ctx, err, "Error initializing a session for deinterlacing"); - else if (err > 0) { - ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization"); - return AVERROR_UNKNOWN; - } - - if (handle) { - err = MFXVideoCORE_SetHandle(s->session, handle_type, handle); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; - } - - if (QSV_RUNTIME_VERSION_ATLEAST(ver, 1, 25)) { - err = MFXJoinSession(device_hwctx->session, s->session); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; - } - - memset(&par, 0, sizeof(par)); - - s->deint_conf.Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING; - s->deint_conf.Header.BufferSz = sizeof(s->deint_conf); - s->deint_conf.Mode = s->mode; - - s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->deint_conf; - - if (opaque) { - s->surface_ptrs = av_mallocz_array(hw_frames_hwctx->nb_surfaces, - sizeof(*s->surface_ptrs)); - if (!s->surface_ptrs) - return AVERROR(ENOMEM); - for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++) - s->surface_ptrs[i] = hw_frames_hwctx->surfaces + i; - s->nb_surface_ptrs = hw_frames_hwctx->nb_surfaces; - - s->opaque_alloc.In.Surfaces = s->surface_ptrs; - s->opaque_alloc.In.NumSurface = s->nb_surface_ptrs; - s->opaque_alloc.In.Type = hw_frames_hwctx->frame_type; - - s->opaque_alloc.Out = s->opaque_alloc.In; - - s->opaque_alloc.Header.BufferId = MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION; - s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc); - - s->ext_buffers[s->num_ext_buffers++] = (mfxExtBuffer *)&s->opaque_alloc; - - par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | MFX_IOPATTERN_OUT_OPAQUE_MEMORY; - } else { - mfxFrameAllocator frame_allocator = { - .pthis = ctx, - .Alloc = frame_alloc, - .Lock = frame_lock, - .Unlock = frame_unlock, - .GetHDL = frame_get_hdl, - .Free = frame_free, - }; - - s->mem_ids = av_mallocz_array(hw_frames_hwctx->nb_surfaces, - sizeof(*s->mem_ids)); - if (!s->mem_ids) - return AVERROR(ENOMEM); - for (i = 0; i < hw_frames_hwctx->nb_surfaces; i++) - s->mem_ids[i] = hw_frames_hwctx->surfaces[i].Data.MemId; - s->nb_mem_ids = hw_frames_hwctx->nb_surfaces; - - err = MFXVideoCORE_SetFrameAllocator(s->session, &frame_allocator); - if (err != MFX_ERR_NONE) - return AVERROR_UNKNOWN; - - par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | MFX_IOPATTERN_OUT_VIDEO_MEMORY; - } - - par.ExtParam = s->ext_buffers; - par.NumExtParam = s->num_ext_buffers; - - par.AsyncDepth = 1; // TODO async - - par.vpp.In = hw_frames_hwctx->surfaces[0].Info; - - par.vpp.In.CropW = ctx->inputs[0]->w; - par.vpp.In.CropH = ctx->inputs[0]->h; - - if (ctx->inputs[0]->frame_rate.num) { - par.vpp.In.FrameRateExtN = ctx->inputs[0]->frame_rate.num; - par.vpp.In.FrameRateExtD = ctx->inputs[0]->frame_rate.den; - } else { - par.vpp.In.FrameRateExtN = ctx->inputs[0]->time_base.num; - par.vpp.In.FrameRateExtD = ctx->inputs[0]->time_base.den; - } - - par.vpp.Out = par.vpp.In; - - if (ctx->outputs[0]->frame_rate.num) { - par.vpp.Out.FrameRateExtN = ctx->outputs[0]->frame_rate.num; - par.vpp.Out.FrameRateExtD = ctx->outputs[0]->frame_rate.den; - } else { - par.vpp.Out.FrameRateExtN = ctx->outputs[0]->time_base.num; - par.vpp.Out.FrameRateExtD = ctx->outputs[0]->time_base.den; - } - - /* Print input memory mode */ - ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0x0F, "VPP"); - /* Print output memory mode */ - ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0xF0, "VPP"); - err = MFXVideoVPP_Init(s->session, &par); - if (err < 0) - return ff_qsvvpp_print_error(ctx, err, - "Error opening the VPP for deinterlacing"); - else if (err > 0) { - ff_qsvvpp_print_warning(ctx, err, - "Warning in VPP initialization"); - return AVERROR_UNKNOWN; - } - - return 0; -} - static int qsvdeint_config_props(AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; AVFilterLink *inlink = ctx->inputs[0]; - QSVDeintContext *s = ctx->priv; - int ret; + QSVDeintContext *s = ctx->priv; + QSVVPPParam param = { NULL }; + mfxExtBuffer *ext_buf[1]; + enum AVPixelFormat in_format; qsvdeint_uninit(ctx); - s->last_pts = AV_NOPTS_VALUE; + outlink->w = inlink->w; + outlink->h = inlink->h; outlink->frame_rate = av_mul_q(inlink->frame_rate, (AVRational){ 2, 1 }); outlink->time_base = av_mul_q(inlink->time_base, (AVRational){ 1, 2 }); - /* check that we have a hw context */ - if (!inlink->hw_frames_ctx) { - av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n"); - return AVERROR(EINVAL); - } - - s->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx); - if (!s->hw_frames_ctx) - return AVERROR(ENOMEM); - - av_buffer_unref(&outlink->hw_frames_ctx); - outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx); - if (!outlink->hw_frames_ctx) { - qsvdeint_uninit(ctx); - return AVERROR(ENOMEM); - } - - ret = init_out_session(ctx); - if (ret < 0) - return ret; - - - return 0; -} - -static void clear_unused_frames(QSVDeintContext *s) -{ - QSVFrame *cur = s->work_frames; - while (cur) { - if (!cur->surface.Data.Locked) { - av_frame_free(&cur->frame); - cur->queued = 0; - } - cur = cur->next; - } -} - -static int get_free_frame(QSVDeintContext *s, QSVFrame **f) -{ - QSVFrame *frame, **last; - - clear_unused_frames(s); + if (inlink->format == AV_PIX_FMT_QSV) { + if (!inlink->hw_frames_ctx || !inlink->hw_frames_ctx->data) + return AVERROR(EINVAL); + else + in_format = ((AVHWFramesContext*)inlink->hw_frames_ctx->data)->sw_format; + } else + in_format = inlink->format; - frame = s->work_frames; - last = &s->work_frames; - while (frame) { - if (!frame->queued) { - *f = frame; - return 0; - } + param.out_sw_format = in_format; + param.ext_buf = ext_buf; - last = &frame->next; - frame = frame->next; - } + memset(&s->deint_conf, 0, sizeof(mfxExtVPPDeinterlacing)); + s->deint_conf.Header.BufferId = MFX_EXTBUFF_VPP_DEINTERLACING; + s->deint_conf.Header.BufferSz = sizeof(s->deint_conf); + s->deint_conf.Mode = s->mode; + param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)&s->deint_conf; - frame = av_mallocz(sizeof(*frame)); - if (!frame) - return AVERROR(ENOMEM); - *last = frame; - *f = frame; - - return 0; -} - -static int submit_frame(AVFilterContext *ctx, AVFrame *frame, - mfxFrameSurface1 **surface) -{ - QSVDeintContext *s = ctx->priv; - QSVFrame *qf; - int ret; - - ret = get_free_frame(s, &qf); - if (ret < 0) - return ret; - - qf->frame = frame; - - qf->surface = *(mfxFrameSurface1*)qf->frame->data[3]; - - qf->surface.Data.Locked = 0; - qf->surface.Info.CropW = qf->frame->width; - qf->surface.Info.CropH = qf->frame->height; - - qf->surface.Info.PicStruct = !qf->frame->interlaced_frame ? MFX_PICSTRUCT_PROGRESSIVE : - (qf->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF : - MFX_PICSTRUCT_FIELD_BFF); - if (qf->frame->repeat_pict == 1) { - qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FIELD_REPEATED; - qf->surface.Info.PicStruct |= qf->frame->top_field_first ? MFX_PICSTRUCT_FIELD_TFF : - MFX_PICSTRUCT_FIELD_BFF; - } else if (qf->frame->repeat_pict == 2) - qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_DOUBLING; - else if (qf->frame->repeat_pict == 4) - qf->surface.Info.PicStruct |= MFX_PICSTRUCT_FRAME_TRIPLING; - - if (ctx->inputs[0]->frame_rate.num) { - qf->surface.Info.FrameRateExtN = ctx->inputs[0]->frame_rate.num; - qf->surface.Info.FrameRateExtD = ctx->inputs[0]->frame_rate.den; - } else { - qf->surface.Info.FrameRateExtN = ctx->inputs[0]->time_base.num; - qf->surface.Info.FrameRateExtD = ctx->inputs[0]->time_base.den; - } - - qf->surface.Data.TimeStamp = av_rescale_q(qf->frame->pts, - ctx->inputs[0]->time_base, - (AVRational){1, 90000}); - - *surface = &qf->surface; - qf->queued = 1; - - return 0; -} - -static int process_frame(AVFilterContext *ctx, const AVFrame *in, - mfxFrameSurface1 *surf_in) -{ - QSVDeintContext *s = ctx->priv; - AVFilterLink *inlink = ctx->inputs[0]; - AVFilterLink *outlink = ctx->outputs[0]; - - AVFrame *out; - mfxFrameSurface1 *surf_out; - mfxSyncPoint sync = NULL; - mfxStatus err; - int ret, again = 0; - - out = ff_get_video_buffer(outlink, outlink->w, outlink->h); - if (!out) { - ret = AVERROR(ENOMEM); - goto fail; - } - - surf_out = (mfxFrameSurface1*)out->data[3]; - surf_out->Info.CropW = outlink->w; - surf_out->Info.CropH = outlink->h; - surf_out->Info.PicStruct = MFX_PICSTRUCT_PROGRESSIVE; - - do { - err = MFXVideoVPP_RunFrameVPPAsync(s->session, surf_in, surf_out, - NULL, &sync); - if (err == MFX_WRN_DEVICE_BUSY) - av_usleep(1); - } while (err == MFX_WRN_DEVICE_BUSY); - - if (err == MFX_ERR_MORE_DATA) { - av_frame_free(&out); - return QSVDEINT_MORE_INPUT; - } - - if (err < 0 && err != MFX_ERR_MORE_SURFACE) { - ret = ff_qsvvpp_print_error(ctx, err, "Error during deinterlacing"); - goto fail; - } - - if (!sync) { - av_log(ctx, AV_LOG_ERROR, "No sync during deinterlacing\n"); - ret = AVERROR_UNKNOWN; - goto fail; - } - if (err == MFX_ERR_MORE_SURFACE) - again = 1; - - do { - err = MFXVideoCORE_SyncOperation(s->session, sync, 1000); - } while (err == MFX_WRN_IN_EXECUTION); - if (err < 0) { - ret = ff_qsvvpp_print_error(ctx, err, "Error synchronizing the operation"); - goto fail; - } - - ret = av_frame_copy_props(out, in); - if (ret < 0) - goto fail; - - out->width = outlink->w; - out->height = outlink->h; - out->interlaced_frame = 0; - - out->pts = av_rescale_q(out->pts, inlink->time_base, outlink->time_base); - if (out->pts == s->last_pts) - out->pts++; - s->last_pts = out->pts; - - ret = ff_filter_frame(outlink, out); - if (ret < 0) - return ret; - - return again ? QSVDEINT_MORE_OUTPUT : 0; -fail: - av_frame_free(&out); - return ret; + return ff_qsvvpp_init(ctx, ¶m); } static int qsvdeint_filter_frame(AVFilterLink *link, AVFrame *in) { - AVFilterContext *ctx = link->dst; - - mfxFrameSurface1 *surf_in; - int ret; + AVFilterContext *ctx = link->dst; + QSVVPPContext *qsv = ctx->priv; + int ret = 0; - ret = submit_frame(ctx, in, &surf_in); - if (ret < 0) { - av_frame_free(&in); - return ret; - } - - do { - ret = process_frame(ctx, in, surf_in); - if (ret < 0) - return ret; - } while (ret == QSVDEINT_MORE_OUTPUT); + ret = ff_qsvvpp_filter_frame(qsv, link, in); + av_frame_free(&in); - return 0; + return ret; } static int qsvdeint_request_frame(AVFilterLink *outlink)