From patchwork Thu Nov 26 05:30:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 24039 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D2DE244AFBD for ; Thu, 26 Nov 2020 07:30:15 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9157B68B83C; Thu, 26 Nov 2020 07:30:15 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 04AB068A2D7 for ; Thu, 26 Nov 2020 07:30:07 +0200 (EET) IronPort-SDR: aEZO7tysdL2kiPVZpJbPrElpKQkrLXh04EIVkagJdUcDbm4VyUz+xodtAm13sZbzLQfjAf5ZBP aZCQIkmEDz+g== X-IronPort-AV: E=McAfee;i="6000,8403,9816"; a="168731157" X-IronPort-AV: E=Sophos;i="5.78,371,1599548400"; d="scan'208";a="168731157" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 21:30:05 -0800 IronPort-SDR: +/z+LL08AhUQd+1uTss8OT0ta7XyETtM/E033k6Z+JfqWRxZZGxFWnFcOwutc63yG22OZlUnOy DPfsYQW8fceA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,371,1599548400"; d="scan'208";a="547578504" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by orsmga005.jf.intel.com with ESMTP; 25 Nov 2020 21:30:03 -0800 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Nov 2020 13:30:00 +0800 Message-Id: <20201126053001.4164257-1-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] qsvdec: factor common options out X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" --- libavcodec/qsvdec.h | 13 +++++++++++++ libavcodec/qsvdec_h2645.c | 12 ++---------- libavcodec/qsvdec_other.c | 6 +----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index f3b7344cba..10e8cf7f91 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -36,6 +36,19 @@ #include "hwconfig.h" #include "qsv_internal.h" +#define QSVDEC_COMMON_OPTIONS \ + { "async_depth", \ + "Internal parallelization depth, the higher the value the higher the latency.", \ + OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, \ + { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD }, \ + { "gpu_copy", \ + "A GPU-accelerated copy between video and system memory", \ + OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, \ + { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy" }, \ + { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy" }, \ + { "on", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON }, 0, 0, VD, "gpu_copy" }, \ + { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF }, 0, 0, VD, "gpu_copy" } + typedef struct QSVContext { // the session used for decoding mfxSession session; diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c index 02c41883b6..f767033ecf 100644 --- a/libavcodec/qsvdec_h2645.c +++ b/libavcodec/qsvdec_h2645.c @@ -184,7 +184,7 @@ static void qsv_decode_flush(AVCodecContext *avctx) #if CONFIG_HEVC_QSV_DECODER static const AVOption hevc_options[] = { - { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD }, + QSVDEC_COMMON_OPTIONS, { "load_plugin", "A user plugin to load in an internal session", OFFSET(load_plugin), AV_OPT_TYPE_INT, { .i64 = LOAD_PLUGIN_HEVC_HW }, LOAD_PLUGIN_NONE, LOAD_PLUGIN_HEVC_HW, VD, "load_plugin" }, { "none", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LOAD_PLUGIN_NONE }, 0, 0, VD, "load_plugin" }, @@ -194,10 +194,6 @@ static const AVOption hevc_options[] = { { "load_plugins", "A :-separate list of hexadecimal plugin UIDs to load in an internal session", OFFSET(qsv.load_plugins), AV_OPT_TYPE_STRING, { .str = "" }, 0, 0, VD }, - { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"}, - { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"}, - { "on", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON }, 0, 0, VD, "gpu_copy"}, - { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF }, 0, 0, VD, "gpu_copy"}, { NULL }, }; @@ -232,12 +228,8 @@ AVCodec ff_hevc_qsv_decoder = { #if CONFIG_H264_QSV_DECODER static const AVOption options[] = { - { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD }, + QSVDEC_COMMON_OPTIONS, - { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"}, - { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"}, - { "on", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON }, 0, 0, VD, "gpu_copy"}, - { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF }, 0, 0, VD, "gpu_copy"}, { NULL }, }; diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c index 2775e07955..65cefff2ab 100644 --- a/libavcodec/qsvdec_other.c +++ b/libavcodec/qsvdec_other.c @@ -180,12 +180,8 @@ static void qsv_decode_flush(AVCodecContext *avctx) #define OFFSET(x) offsetof(QSVOtherContext, x) #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD }, + QSVDEC_COMMON_OPTIONS, - { "gpu_copy", "A GPU-accelerated copy between video and system memory", OFFSET(qsv.gpu_copy), AV_OPT_TYPE_INT, { .i64 = MFX_GPUCOPY_DEFAULT }, MFX_GPUCOPY_DEFAULT, MFX_GPUCOPY_OFF, VD, "gpu_copy"}, - { "default", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_DEFAULT }, 0, 0, VD, "gpu_copy"}, - { "on", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_ON }, 0, 0, VD, "gpu_copy"}, - { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF }, 0, 0, VD, "gpu_copy"}, { NULL }, }; From patchwork Thu Nov 26 05:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xiang, Haihao" X-Patchwork-Id: 24040 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id EAC9244AFBD for ; Thu, 26 Nov 2020 07:30:20 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D5EDB68B84B; Thu, 26 Nov 2020 07:30:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EA10E68A2D7 for ; Thu, 26 Nov 2020 07:30:13 +0200 (EET) IronPort-SDR: ghVr/fS+xQOC23ByrlRHYoE2DEJe5EeTxhngOXSBgVIVJszKyq0ohqpY/0HF4W4aFvqQsRiuL7 U42KqZvAwfmA== X-IronPort-AV: E=McAfee;i="6000,8403,9816"; a="168731160" X-IronPort-AV: E=Sophos;i="5.78,371,1599548400"; d="scan'208";a="168731160" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Nov 2020 21:30:06 -0800 IronPort-SDR: 1g2HGDQZzGtIpNezKoUfVM9+68yocng5mJQK4EiAT3V4twvXBG/qsnkULjZ3Ou35bcZDMlzQPw xzVpbx3EzOBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,371,1599548400"; d="scan'208";a="547578512" Received: from xhh-tgl64.sh.intel.com ([10.239.159.152]) by orsmga005.jf.intel.com with ESMTP; 25 Nov 2020 21:30:05 -0800 From: Haihao Xiang To: ffmpeg-devel@ffmpeg.org Date: Thu, 26 Nov 2020 13:30:01 +0800 Message-Id: <20201126053001.4164257-2-haihao.xiang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201126053001.4164257-1-haihao.xiang@intel.com> References: <20201126053001.4164257-1-haihao.xiang@intel.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] qsvdec_av1: add an option to disable film grain X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" User may use '-disable_film_grain 1' to disable film grain. --- libavcodec/qsvdec.c | 5 +++++ libavcodec/qsvdec.h | 2 ++ libavcodec/qsvdec_other.c | 13 ++++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index c666aaeb52..f34487bdbb 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -290,6 +290,11 @@ static int qsv_decode_header(AVCodecContext *avctx, QSVContext *q, AVPacket *avp return ff_qsv_print_error(avctx, ret, "Error decoding stream header"); +#if CONFIG_AV1_QSV_DECODER + if (avctx->codec_id == AV_CODEC_ID_AV1) + param->mfx.FilmGrain = q->disable_film_grain ? 0 : param->mfx.FilmGrain; +#endif + return 0; } diff --git a/libavcodec/qsvdec.h b/libavcodec/qsvdec.h index 10e8cf7f91..b5914834d9 100644 --- a/libavcodec/qsvdec.h +++ b/libavcodec/qsvdec.h @@ -85,6 +85,8 @@ typedef struct QSVContext { mfxExtBuffer **ext_buffers; int nb_ext_buffers; + + int disable_film_grain; } QSVContext; extern const AVCodecHWConfigInternal *const ff_qsv_hw_configs[]; diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c index 65cefff2ab..ac1e2ea84a 100644 --- a/libavcodec/qsvdec_other.c +++ b/libavcodec/qsvdec_other.c @@ -325,10 +325,21 @@ AVCodec ff_vp9_qsv_decoder = { #endif #if CONFIG_AV1_QSV_DECODER +static const AVOption av1_options[] = { + QSVDEC_COMMON_OPTIONS, + + { "disable_film_grain", + "Disable the film grain synthesis", + OFFSET(qsv.disable_film_grain), AV_OPT_TYPE_BOOL, + { .i64 = 0}, 0, 1, VD}, + + { NULL }, +}; + static const AVClass av1_qsv_class = { .class_name = "av1_qsv", .item_name = av_default_item_name, - .option = options, + .option = av1_options, .version = LIBAVUTIL_VERSION_INT, };