From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4828A4A9F9 for ; Tue, 7 May 2024 16:09:03 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B97468D779; Tue, 7 May 2024 19:08:41 +0300 (EEST) Received: from out162-62-58-211.mail.qq.com (out162-62-58-211.mail.qq.com [162.62.58.211]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D3B668D771 for ; Tue, 7 May 2024 19:08:30 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1715098103; bh=UbTDgSn7ho7y2rQoAibfS5CdtoQHGKzGTyoDJjfxLU4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=UEa+4CEfUmCnWCCevFg8xzQ0ur+gwQJp2Oa1E3cQn+WjM0zWIMWK+2KEDJ5kRA8f7 bhTi4Ls2OQrjilcl7vSxLYKVTPNGw0kXJWaonkSJG6djuinfBV5jC/yfVxm/iyhztI bmmg2W8CCjzVrnm+tGq77eVh9tJ44Wei3X4ZMVAo= Received: from localhost.localdomain ([113.118.115.105]) by newxmesmtplogicsvrsza10-0.qq.com (NewEsmtp) with SMTP id 2148D2A6; Wed, 08 May 2024 00:08:20 +0800 X-QQ-mid: xmsmtpt1715098102tm3wuj9m5 Message-ID: X-QQ-XMAILINFO: MyirvGjpKb1j1DHIJC3sVgmH6oho3SejCaG43LieDqJ863RIVNL/vYWHu8T3ka hWZdlTDfWLhDYDUo2LrzLf074DjnFZGEO105LUpts4q0TYbM35O/mwdOQARwhj0IAymWncwL9/1F 0Dkwwk9RLMPrTEmNTVZvAJc/5VSzfK9lxxcxsOoSn3n6i6vSb5z3z1xLcAx9Csh8F+11OCxMkGse 5pSAzPAbt+WQ1VK2GP/k2313enA1Asb+qdwQDsQ6g8litXP38rL8yBWhv/gUJNAP8IIePGvrNiSL pzudQ29WWVLETg4vWUx25C5GTTP1tRBG2RSkItyyKj4iLt3BgxKwoNTTnnRSotkLWcLVjHSfVckV eYgBkemaRVcK61fAeJlLuG8to7pBn/vmwdji4QpTOvq+RV2w/+Zd5mQMx4erT5Cg70TFgqynLeCU NABdwNShBKL8gwgDk3iylaJY3o3MKxQU/6Wq7JNB3AlkMYdB9A+2/kVyCKDcdKTc9wz9nC1JZm0y d01ssT8YZ3NUgrqmL3/jm5Xu95g4O315m/iMa8Rc5Y7xqca/Fg5B62ARHcKLnc61soUTgp/FcRMN bbQT7zqbs0hJ0wR2VzY1UqbjxeaH00c/SMFXoT1mvEWEtRHTJmQo68xrWyZzk9jv+rf367sh7TO0 UVjxjQdFkbkYTT84HLIM4rp3+aVNmDnVznfajRTbIrIbKjJXYHgCUFAdonym5nHwGjUFANma6nJh nyKEmTzovtSf6hY9XqOEB1lNzqycESm7JuidD/WsqQqEdM1r0MkiGcEvuFVnCGFaC3zfgcu/Lt0T xO3REU1ERitZ4K94i8ibAcNnv6d7hb5xMA2/5XcF39CPEHVpYVPjF8+js5wrlAabnKOATFV4ygsR skJ9q3PeKucpCG/wKDbv+4GGh/tP92zhTKZninum8OK1ugowZlXqKuk3YaABXHKuTmDnRuBMfrsb z1KABa90BESBPwtFEQ1tonVXM8VzvJ X-QQ-XMRINFO: Mp0Kj//9VHAxr69bL5MkOOs= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Wed, 8 May 2024 00:08:10 +0800 X-OQ-MSGID: <20240507160818.71113-4-quinkblack@foxmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240507160818.71113-1-quinkblack@foxmail.com> References: <20240507160818.71113-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 03/11] avfilter/dnn: Don't show backends which are not supported by a 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: Zhao Zhili Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Zhao Zhili --- libavfilter/dnn/dnn_interface.c | 11 ++++++++--- libavfilter/dnn_filter_common.h | 11 +++++++++-- libavfilter/dnn_interface.h | 8 ++++++-- libavfilter/vf_derain.c | 2 +- libavfilter/vf_dnn_classify.c | 2 +- libavfilter/vf_dnn_detect.c | 2 +- libavfilter/vf_dnn_processing.c | 2 +- libavfilter/vf_sr.c | 2 +- 8 files changed, 28 insertions(+), 12 deletions(-) diff --git a/libavfilter/dnn/dnn_interface.c b/libavfilter/dnn/dnn_interface.c index b56c22e4c7..dc1593821d 100644 --- a/libavfilter/dnn/dnn_interface.c +++ b/libavfilter/dnn/dnn_interface.c @@ -120,11 +120,16 @@ void *ff_dnn_child_next(DnnContext *obj, void *prev) { return NULL; } -const AVClass *ff_dnn_child_class_iterate(void **iter) +const AVClass *ff_dnn_child_class_iterate_with_mask(void **iter, uint32_t backend_mask) { - uintptr_t i = (uintptr_t) *iter; + for (uintptr_t i = (uintptr_t)*iter; i < FF_ARRAY_ELEMS(dnn_backend_info_list); i++) { + if (i > 0) { + const DNNModule *module = dnn_backend_info_list[i].module; + + if (!(module->type & backend_mask)) + continue; + } - if (i < FF_ARRAY_ELEMS(dnn_backend_info_list)) { *iter = (void *)(i + 1); return dnn_backend_info_list[i].class; } diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h index b52b55a90d..42a4719997 100644 --- a/libavfilter/dnn_filter_common.h +++ b/libavfilter/dnn_filter_common.h @@ -26,6 +26,12 @@ #include "dnn_interface.h" +#define DNN_FILTER_CHILD_CLASS_ITERATE(name, backend_mask) \ + static const AVClass *name##_child_class_iterate(void **iter) \ + { \ + return ff_dnn_child_class_iterate_with_mask(iter, (backend_mask)); \ + } + #define AVFILTER_DNN_DEFINE_CLASS_EXT(name, desc, options) \ static const AVClass name##_class = { \ .class_name = desc, \ @@ -34,10 +40,11 @@ .version = LIBAVUTIL_VERSION_INT, \ .category = AV_CLASS_CATEGORY_FILTER, \ .child_next = ff_dnn_filter_child_next, \ - .child_class_iterate = ff_dnn_child_class_iterate, \ + .child_class_iterate = name##_child_class_iterate, \ } -#define AVFILTER_DNN_DEFINE_CLASS(fname) \ +#define AVFILTER_DNN_DEFINE_CLASS(fname, backend_mask) \ + DNN_FILTER_CHILD_CLASS_ITERATE(fname, backend_mask) \ AVFILTER_DNN_DEFINE_CLASS_EXT(fname, #fname, fname##_options) void *ff_dnn_filter_child_next(void *obj, void *prev); diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index dd603534b2..697b9f3318 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -32,7 +32,11 @@ #define DNN_GENERIC_ERROR FFERRTAG('D','N','N','!') -typedef enum {DNN_TF = 1, DNN_OV, DNN_TH} DNNBackendType; +typedef enum { + DNN_TF = 1, + DNN_OV = 1 << 1, + DNN_TH = 1 << 2 +} DNNBackendType; typedef enum {DNN_FLOAT = 1, DNN_UINT8 = 4} DNNDataType; @@ -190,7 +194,7 @@ const DNNModule *ff_get_dnn_module(DNNBackendType backend_type, void *log_ctx); void ff_dnn_init_child_class(DnnContext *ctx); void *ff_dnn_child_next(DnnContext *obj, void *prev); -const AVClass *ff_dnn_child_class_iterate(void **iter); +const AVClass *ff_dnn_child_class_iterate_with_mask(void **iter, uint32_t backend_mask); static inline int dnn_get_width_idx_by_layout(DNNLayout layout) { diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c index 7f665b73ab..5cefca6b55 100644 --- a/libavfilter/vf_derain.c +++ b/libavfilter/vf_derain.c @@ -49,7 +49,7 @@ static const AVOption derain_options[] = { { NULL } }; -AVFILTER_DNN_DEFINE_CLASS(derain); +AVFILTER_DNN_DEFINE_CLASS(derain, DNN_TF); static int filter_frame(AVFilterLink *inlink, AVFrame *in) { diff --git a/libavfilter/vf_dnn_classify.c b/libavfilter/vf_dnn_classify.c index 965779a8ab..f6d3678796 100644 --- a/libavfilter/vf_dnn_classify.c +++ b/libavfilter/vf_dnn_classify.c @@ -56,7 +56,7 @@ static const AVOption dnn_classify_options[] = { { NULL } }; -AVFILTER_DNN_DEFINE_CLASS(dnn_classify); +AVFILTER_DNN_DEFINE_CLASS(dnn_classify, DNN_OV); static int dnn_classify_post_proc(AVFrame *frame, DNNData *output, uint32_t bbox_index, AVFilterContext *filter_ctx) { diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index 926966368a..b4eee06fe7 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -84,7 +84,7 @@ static const AVOption dnn_detect_options[] = { { NULL } }; -AVFILTER_DNN_DEFINE_CLASS(dnn_detect); +AVFILTER_DNN_DEFINE_CLASS(dnn_detect, DNN_TF | DNN_OV); static inline float sigmoid(float x) { return 1.f / (1.f + exp(-x)); diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c index 9a1dd2a356..7c0f84ec80 100644 --- a/libavfilter/vf_dnn_processing.c +++ b/libavfilter/vf_dnn_processing.c @@ -57,7 +57,7 @@ static const AVOption dnn_processing_options[] = { { NULL } }; -AVFILTER_DNN_DEFINE_CLASS(dnn_processing); +AVFILTER_DNN_DEFINE_CLASS(dnn_processing, DNN_TF | DNN_OV | DNN_TH); static av_cold int init(AVFilterContext *context) { diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c index f14c0c0cd3..3bfca7f042 100644 --- a/libavfilter/vf_sr.c +++ b/libavfilter/vf_sr.c @@ -53,7 +53,7 @@ static const AVOption sr_options[] = { { NULL } }; -AVFILTER_DNN_DEFINE_CLASS(sr); +AVFILTER_DNN_DEFINE_CLASS(sr, DNN_TF); static av_cold int init(AVFilterContext *context) { -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".