mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-28 20:53:54 +02:00
avfilter/dnn: Don't show backends which are not supported by a filter
This commit is contained in:
parent
4f051c746b
commit
093f5da534
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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));
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user