From patchwork Thu Aug 22 10:28:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xuewei Meng X-Patchwork-Id: 14654 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 3BFEB449FD9 for ; Thu, 22 Aug 2019 13:28:57 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 16B4D68ABE3; Thu, 22 Aug 2019 13:28:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D666668ABC0 for ; Thu, 22 Aug 2019 13:28:49 +0300 (EEST) Received: by mail-pl1-f178.google.com with SMTP id 4so3201692pld.10 for ; Thu, 22 Aug 2019 03:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=2YDHIh234dqaOlZOwkKr0SwAHmP5uUjMCmcLFYXilr0=; b=DSH4iLX0tr2+yGrnc1XE5hJ4MBGdvnUTc4X6dXZexAc+0OQjkWsDEnna6vk9C0cvRI 4r+ry/LDcSo54bJy7IaNp/V5vH72maMmD+Dfee+LsOhmBG52+IAylt7AKUwjkNJQ6ryQ sSpMHJ2FqVCkezdAMfaSNf0LJWFrgYnjKuuuTTw9hZHTE1lp9LCBRRHViShq7Zkx/rlj tGVicSxMoRmxFob+l3RbG98BD02bi4vpK0UTe53KQtzo9Mz+BHZo0TJWZyryAY/8CEwc ZPXmwRC4MLoIToPGaqTrjP4BL/LUZmyTezLCZ+4JmMDXGKH0h9OK9yBXcP+ZHLbDExAB 99qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=2YDHIh234dqaOlZOwkKr0SwAHmP5uUjMCmcLFYXilr0=; b=jaktQR7Q7V3m+kM6+jGbhnzY4/EJojNg+cBD+3mTcbcdy9UTfYyq7XF4K4gStgcbno VDoWIpZV0hXhYHdrfkAbBHytvmHJwOJsqbZmFmYTlpj/j43bEfVKRBR93WKY3yKw4LNb x3ahh8MaZ/Ku+f7HJe7We4/JlT08Fm44GjGCmr12dYEIfTR4/dWAsdom51erE3Ji31ZA vroMpkBNHG/UcpMg7nKlvX1QW7uaJjicCtVsaojnCPrv4Vu5SaSuvbB72N81mMHTBzYJ /bkAn6MAOZH3H/Cd3A7HpZ0NHYxBjOey71CelPU6/3T5rY/O2uCPdptBnlojw+0Q4Ybk xXXg== X-Gm-Message-State: APjAAAVrmjISAzdhrdRXTpZTKjPS0v0fAz46rhF4uHN+ZnXrclE1+TnI Qoor7EJae0fh6wqr9tKMiIhg8zCeMHg= X-Google-Smtp-Source: APXvYqz/KZ+1BP0pCIiX/n0FPqaHuM9zBVFwnHb/e2kWpj+rMjJRwEeeWqE/P6BVAZC5gwOlIV8OUw== X-Received: by 2002:a17:902:244:: with SMTP id 62mr38352743plc.243.1566469727874; Thu, 22 Aug 2019 03:28:47 -0700 (PDT) Received: from DESKTOP-IACK8OK.localdomain ([2001:da8:201:3250:1459:1827:9d0e:70ed]) by smtp.gmail.com with ESMTPSA id u24sm22987411pgk.31.2019.08.22.03.28.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Aug 2019 03:28:47 -0700 (PDT) From: Xuewei Meng To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Aug 2019 18:28:44 +0800 Message-Id: <20190822102844.63-1-xwmeng96@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <1509E399-0E16-40AA-A978-B1506276A69B@chinaffmpeg.org> References: <1509E399-0E16-40AA-A978-B1506276A69B@chinaffmpeg.org> Subject: [FFmpeg-devel] [PATCH v2] libavfilter: Add dehaze-filter option in existing derain. 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Add the support of dehaze filter in existing derain filter source code. As the processing procedure in FFmpeg is the same for current derain and dehaze, we reuse the derain filter source code. The model training and generation scripts are in repo https://github.com/XueweiMeng/derain_filter.git Signed-off-by: Xuewei Meng --- doc/filters.texi | 12 ++++++++++++ libavfilter/vf_derain.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index 323c02970e..5d63b337f8 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -8449,6 +8449,18 @@ files (.pb) by using tools/python/convert.py The filter accepts the following options: @table @option +@item filter_type +Specify which filter to use. This option accepts the following values: + +@table @samp +@item derain +Derain filter. To conduct derain filter, you need to use a derain model. + +@item dehaze +Dehaze filter. To conduct dehaze filter, you need to use a dehaze model. +@end table +Default value is @samp{derain}. + @item dnn_backend Specify which DNN backend to use for model loading and execution. This option accepts the following values: diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c index c380b40122..110eab54ff 100644 --- a/libavfilter/vf_derain.c +++ b/libavfilter/vf_derain.c @@ -34,6 +34,7 @@ typedef struct DRContext { const AVClass *class; + int filter_type; char *model_filename; DNNBackendType backend_type; DNNModule *dnn_module; @@ -46,6 +47,10 @@ typedef struct DRContext { #define OFFSET(x) offsetof(DRContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM static const AVOption derain_options[] = { + { "filter_type", "filter type(derain/dehaze)", OFFSET(filter_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "type" }, + { "derain", "derain filter flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "type" }, + { "dehaze", "dehaze filter flag", 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, FLAGS, "type" }, + { "dnn_backend", "DNN backend", OFFSET(backend_type), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, "backend" }, { "native", "native backend flag", 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, FLAGS, "backend" }, #if (CONFIG_LIBTENSORFLOW == 1)