From patchwork Mon May 17 03:24:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 27802 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp2458603iof; Sun, 16 May 2021 20:31:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw7po1UtaNXFtMjAfYABenr85X7f3nHDMbI6qlRghba3jpw6SdBXjVgiz+DmY4fy3PV9Gi2 X-Received: by 2002:a17:906:ecf9:: with SMTP id qt25mr6383255ejb.55.1621222286776; Sun, 16 May 2021 20:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621222286; cv=none; d=google.com; s=arc-20160816; b=kgYUy4RBvte3sWL7zhE9UxyuKOWAyNk3ahY11CW7Gsy4oeMPaO3ihgs5N5dQJxTZIh 0vvnzVIpP1Bc4na5z3YJr6IASHT8aWhZc25nQU8dn8lEwhWNaI74wS3bA+v/TGzL43Wv 0MYLqTPmmHBl96DiDncae3qRfDCBQDrUIVZWFMA7t6qVNWe/zBvz6eEkMmuJQqpVxn2X 2PS/dDcHRZ5HJTRaxkimluO83U5n0ItauC2Tvfe7Et4Yz1ZKP9lys7LNY+id0qIFUT70 7dbGnazZmGm6l8ifokOZdef+YCEudVJxsq54/3BHKBTGxqahPCMC9Ud1uPFGvdBXJjS7 E1Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:ironport-sdr:ironport-sdr:delivered-to; bh=EvUmr/N1aJh+CzKNv53YiBqucl27EPjd8fwGLHjpLg8=; b=aGCkkDmwNshXlBXLKdk3NYrZUAgTOm7NxIIWn9GqA9eDw6kCqvkvGp5nKoBCeantj2 78SSREIQlGBorkCB09T5zZlJMdC7jO0AA4HnKziOGhQITegC95Kk7m5yxq6YrGgMVjpu jGA15114qSJr78+G3QHwhl+hVwB2ArMDlYs38P4ynXb+FN5IwKK4Bby+SMqsvEvAaThz ZAe7yTvm+e7DI2Ac2W/qpYM8Qla3xG/4ZXxPTFhT/bkPW85wnremIGvOOr86c9ricKst 3Pz2uWl0e5dP9YhJqshGdJXQDO/CGUpSv13ZnMwN9vLCfeSYXGQtUbmgS+28hV1aUHkD iN7g== 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 hp22si12382385ejc.174.2021.05.16.20.31.26; Sun, 16 May 2021 20:31:26 -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 6EED46898E4; Mon, 17 May 2021 06:28:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 53E6C689810 for ; Mon, 17 May 2021 06:28:32 +0300 (EEST) IronPort-SDR: cR0dPjk0ipzNRbTGexptdXQIXW6P1lSiGhBQeMU5/3ISd//LbJMRVbmk4RQioNqMZFS0HD1OpD GdIPDwlJaaYg== X-IronPort-AV: E=McAfee;i="6200,9189,9986"; a="187498261" X-IronPort-AV: E=Sophos;i="5.82,306,1613462400"; d="scan'208";a="187498261" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2021 20:28:21 -0700 IronPort-SDR: Hyx1Jk8PAfoFTD15Ow9yB+47aQhFLKLidNSQb15C+JmhyH2AcSX3fjyrPfLqWx/erOy3ajmBP9 TStoEsjPUBAQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,306,1613462400"; d="scan'208";a="626277713" Received: from xhh-tgl64.sh.intel.com ([10.239.159.130]) by fmsmga006.fm.intel.com with ESMTP; 16 May 2021 20:28:21 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 May 2021 11:24:23 +0800 Message-Id: <20210517032426.3376661-20-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210517032426.3376661-1-haihao.xiang@intel.com> References: <20210517032426.3376661-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 19/22] lavfi/deinterlace_qsv: re-use VPPContext for 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 9t4c331VGWRe All features are implemented in vpp_qsv filter now, so deinterlace_qsv can be taken as a specical case of vpp_qsv filter, we re-use VPPContext with a different option array and pix formats for deinterlace_qsv filter --- libavfilter/Makefile | 2 +- libavfilter/vf_deinterlace_qsv.c | 179 ------------------------------- libavfilter/vf_vpp_qsv.c | 19 ++++ 3 files changed, 20 insertions(+), 180 deletions(-) delete mode 100644 libavfilter/vf_deinterlace_qsv.c diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 9e6bb87c4c..feaf6c71a8 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -229,7 +229,7 @@ OBJS-$(CONFIG_DECONVOLVE_FILTER) += vf_convolve.o framesync.o OBJS-$(CONFIG_DEDOT_FILTER) += vf_dedot.o OBJS-$(CONFIG_DEFLATE_FILTER) += vf_neighbor.o OBJS-$(CONFIG_DEFLICKER_FILTER) += vf_deflicker.o -OBJS-$(CONFIG_DEINTERLACE_QSV_FILTER) += vf_deinterlace_qsv.o +OBJS-$(CONFIG_DEINTERLACE_QSV_FILTER) += vf_vpp_qsv.o OBJS-$(CONFIG_DEINTERLACE_VAAPI_FILTER) += vf_deinterlace_vaapi.o vaapi_vpp.o OBJS-$(CONFIG_DEJUDDER_FILTER) += vf_dejudder.o OBJS-$(CONFIG_DELOGO_FILTER) += vf_delogo.o diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c deleted file mode 100644 index 50ff553e6a..0000000000 --- a/libavfilter/vf_deinterlace_qsv.c +++ /dev/null @@ -1,179 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * deinterlace video filter - QSV - */ - -#include - -#include -#include - -#include "libavutil/avstring.h" -#include "libavutil/common.h" -#include "libavutil/hwcontext.h" -#include "libavutil/hwcontext_qsv.h" -#include "libavutil/internal.h" -#include "libavutil/mathematics.h" -#include "libavutil/opt.h" -#include "libavutil/pixdesc.h" -#include "libavutil/time.h" -#include "libavfilter/qsvvpp.h" - -#include "avfilter.h" -#include "formats.h" -#include "internal.h" -#include "video.h" - -typedef struct QSVDeintContext { - QSVVPPContext qsv; - - mfxExtVPPDeinterlacing deint_conf; - - /* option for Deinterlacing algorithm to be used */ - int mode; -} QSVDeintContext; - -static av_cold void qsvdeint_uninit(AVFilterContext *ctx) -{ - ff_qsvvpp_close(ctx); -} - -static int qsvdeint_query_formats(AVFilterContext *ctx) -{ - static const enum AVPixelFormat pixel_formats[] = { - AV_PIX_FMT_QSV, AV_PIX_FMT_NONE, - }; - AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats); - int ret; - - if ((ret = ff_set_common_formats(ctx, pix_fmts)) < 0) - return ret; - - return 0; -} - -static int qsvdeint_config_props(AVFilterLink *outlink) -{ - AVFilterContext *ctx = outlink->src; - AVFilterLink *inlink = ctx->inputs[0]; - QSVDeintContext *s = ctx->priv; - QSVVPPParam param = { NULL }; - mfxExtBuffer *ext_buf[1]; - enum AVPixelFormat in_format; - - qsvdeint_uninit(ctx); - - 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 }); - - 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; - - param.out_sw_format = in_format; - param.ext_buf = ext_buf; - - 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; - - return ff_qsvvpp_init(ctx, ¶m); -} - -static int qsvdeint_filter_frame(AVFilterLink *link, AVFrame *in) -{ - AVFilterContext *ctx = link->dst; - QSVVPPContext *qsv = ctx->priv; - int ret = 0; - - ret = ff_qsvvpp_filter_frame(qsv, link, in); - av_frame_free(&in); - - return ret; -} - -static int qsvdeint_request_frame(AVFilterLink *outlink) -{ - AVFilterContext *ctx = outlink->src; - - return ff_request_frame(ctx->inputs[0]); -} - -#define OFFSET(x) offsetof(QSVDeintContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM -static const AVOption options[] = { - { "mode", "set deinterlace mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, - { "bob", "bob algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_BOB}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, - { "advanced", "Motion adaptive algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, - { NULL }, -}; - -static const AVClass qsvdeint_class = { - .class_name = "deinterlace_qsv", - .item_name = av_default_item_name, - .option = options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVFilterPad qsvdeint_inputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .filter_frame = qsvdeint_filter_frame, - }, - { NULL } -}; - -static const AVFilterPad qsvdeint_outputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = qsvdeint_config_props, - .request_frame = qsvdeint_request_frame, - }, - { NULL } -}; - -const AVFilter ff_vf_deinterlace_qsv = { - .name = "deinterlace_qsv", - .description = NULL_IF_CONFIG_SMALL("QuickSync video deinterlacing"), - - .uninit = qsvdeint_uninit, - .query_formats = qsvdeint_query_formats, - - .priv_size = sizeof(QSVDeintContext), - .priv_class = &qsvdeint_class, - - .inputs = qsvdeint_inputs, - .outputs = qsvdeint_outputs, - - .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, -}; diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index 90b0b25210..c0afb001b9 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -706,3 +706,22 @@ static const AVOption qsvscale_options[] = { }; DEFINE_QSV_FILTER(qsvscale, scale, "scaling and format conversion") + +static const AVOption qsvdeint_options[] = { + { "mode", "set deinterlace mode", OFFSET(deinterlace), AV_OPT_TYPE_INT, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, + { "bob", "bob algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_BOB}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, + { "advanced", "Motion adaptive algorithm", 0, AV_OPT_TYPE_CONST, {.i64 = MFX_DEINTERLACING_ADVANCED}, MFX_DEINTERLACING_BOB, MFX_DEINTERLACING_ADVANCED, FLAGS, "mode"}, + { NULL }, +}; + +static int qsvdeint_query_formats(AVFilterContext *ctx) +{ + static const enum AVPixelFormat pixel_formats[] = { + AV_PIX_FMT_QSV, AV_PIX_FMT_NONE, + }; + AVFilterFormats *pix_fmts = ff_make_format_list(pixel_formats); + + return ff_set_common_formats(ctx, pix_fmts); +} + +DEFINE_QSV_FILTER(qsvdeint, deinterlace, "deinterlacing") \ No newline at end of file