From patchwork Tue Jun 15 06:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 28309 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5e:c91a:0:0:0:0:0 with SMTP id z26csp3528740iol; Mon, 14 Jun 2021 23:18:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyn9T2x3JWN2Me7JrYT5ck5E/hTaAbF+i3H0B1Od+8TtMmYLD5lz1cR+rOrVEpjungCsvt5 X-Received: by 2002:a17:906:1792:: with SMTP id t18mr18583229eje.38.1623737928593; Mon, 14 Jun 2021 23:18:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623737928; cv=none; d=google.com; s=arc-20160816; b=j3i0SQtNtgXPd/nEe4JhlKxrNXyN3P0tI43pOO+Ne0xIB9UN7uEhjKaVk+54IBFtQz TYtl1wdASR04VVSr777Cb8ncH560swC4JIrR21Q9b2JxS1Kx/d3/HzpKnQ6SaGrnE8Zy flw7G8dIFG9IUlZ8PCNmrE8GjPDKIBpk79T8TnDI3aFV17Iuw5Jihly+zXusOXNDKFhW Cq+Y5ngTmIcK7MRIfunGMuxKriRNYLU6RofQkVLxkrOScRH/saK9ea6cQXEKT5q894af +TGLNiwQ43Ev296cEWhIBVr3E1117fA/lf7UpTNrgQJX4YW5NWmXZLjwWQheOMudHQ7N NvJg== 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=KUKr8Vtc6FofTMoOutw0XQFc3He6zfeS2mj4t9YXrUU=; b=0+ATBqHnOJf9+8gVeXRor/LfJZHQoUR22eP7caA2NDTIZMYJM051XBo3SaJ+SnHqYQ ucc/nCWyfoiFN8OldrB/dx5ggaZsqOdEMTXs4n3SoRNPPECbKkOzL5nJVG6+eLDCYTvY agj1YUCzZBVIt02fuSt6iwWRNpHrg+fmFuAhTdT8rmvPTFniSkevHpurY8XdUBxUFTWT pCdNI9kgL1UfVZM3Sg95I/lZ1XQ76xmm8IXV4cldmzzLHZHMkU7ASbtI/ZL4a98JkIh2 DqeQszf1bc820WuoH6I28Gc/enKCiuJbjVFiPaxYF818kPHZMc2EoSh662OWaNFT+Qfz 3gxA== 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 b12si12614066ede.371.2021.06.14.23.18.48; Mon, 14 Jun 2021 23:18:48 -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 EC940689AA6; Tue, 15 Jun 2021 09:16:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 748FC687FDE for ; Tue, 15 Jun 2021 09:15:47 +0300 (EEST) IronPort-SDR: yMg/+2xsHWqin5LNy53Rz0K2hsd9cHmvifXrk+jN65yAYC6YC3HsFlfCYbg4O+5DulfyrLLEis vN9Hgvh/pIXg== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="205750774" X-IronPort-AV: E=Sophos;i="5.83,275,1616482800"; d="scan'208";a="205750774" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Jun 2021 23:15:45 -0700 IronPort-SDR: ZuvaRN+AhyD+qa2L1nvfomV3iMpy2bjv8FK/44E75dE8d2FVJ26ddDBzSAtx014S9yutU8Vqf0 PBKlzl0Y3tog== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,275,1616482800"; d="scan'208";a="451857237" Received: from xhh-tgl64.sh.intel.com ([10.239.159.53]) by fmsmga008.fm.intel.com with ESMTP; 14 Jun 2021 23:15:45 -0700 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Tue, 15 Jun 2021 14:14:00 +0800 Message-Id: <20210615061403.1576282-20-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210615061403.1576282-1-haihao.xiang@intel.com> References: <20210615061403.1576282-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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: fmnh32y0ZJPt 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 45ac761d06..ba7d3488f1 100644 --- a/libavfilter/vf_vpp_qsv.c +++ b/libavfilter/vf_vpp_qsv.c @@ -708,3 +708,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