X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fdnn%2Fdnn_backend_native.h;h=d313c48f3a47a01d96c6cf607063307441defd89;hb=f7db77bd8785d1715d3e7ed7e69bd1cc991f2d07;hp=53ed22c5e203e5662ceda932cb9bee9c9b56200b;hpb=2558e62713ebc5f3ea22c1a28d8e9cf3249badaf;p=ffmpeg diff --git a/libavfilter/dnn/dnn_backend_native.h b/libavfilter/dnn/dnn_backend_native.h index 53ed22c5e20..d313c48f3a4 100644 --- a/libavfilter/dnn/dnn_backend_native.h +++ b/libavfilter/dnn/dnn_backend_native.h @@ -29,6 +29,7 @@ #include "../dnn_interface.h" #include "libavformat/avio.h" +#include "libavutil/opt.h" /** * the enum value of DNNLayerType should not be changed, @@ -41,10 +42,16 @@ typedef enum { DLT_DEPTH_TO_SPACE = 2, DLT_MIRROR_PAD = 3, DLT_MAXIMUM = 4, + DLT_MATH_BINARY = 5, + DLT_MATH_UNARY = 6, + DLT_AVG_POOL = 7, + DLT_DENSE = 8, DLT_COUNT } DNNLayerType; -typedef enum {DOT_INPUT = 1, DOT_OUTPUT = 2, DOT_INTERMEDIATE = DOT_INPUT | DOT_INPUT} DNNOperandType; +typedef enum {DOT_INPUT = 1, DOT_OUTPUT = 2, DOT_INTERMEDIATE = DOT_INPUT | DOT_OUTPUT} DNNOperandType; +typedef enum {VALID, SAME, SAME_CLAMP_TO_EDGE} DNNPaddingParam; +typedef enum {RELU, TANH, SIGMOID, NONE, LEAKY_RELU} DNNActivationFunc; typedef struct Layer{ DNNLayerType type; @@ -102,22 +109,34 @@ typedef struct InputParams{ int height, width, channels; } InputParams; +typedef struct NativeOptions{ + uint32_t conv2d_threads; +} NativeOptions; + +typedef struct NativeContext { + const AVClass *class; + NativeOptions options; +} NativeContext; + // Represents simple feed-forward convolutional network. -typedef struct ConvolutionalNetwork{ +typedef struct NativeModel{ + NativeContext ctx; + DNNModel *model; Layer *layers; int32_t layers_num; DnnOperand *operands; int32_t operands_num; - int32_t *output_indexes; - uint32_t nb_output; -} ConvolutionalNetwork; +} NativeModel; -DNNModel *ff_dnn_load_model_native(const char *model_filename); +DNNModel *ff_dnn_load_model_native(const char *model_filename, DNNFunctionType func_type, const char *options, AVFilterContext *filter_ctx); -DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, DNNData *outputs, uint32_t nb_output); +DNNReturnType ff_dnn_execute_model_native(const DNNModel *model, const char *input_name, AVFrame *in_frame, + const char **output_names, uint32_t nb_output, AVFrame *out_frame); void ff_dnn_free_model_native(DNNModel **model); -int32_t calculate_operand_data_length(const DnnOperand *oprd); -int32_t calculate_operand_dims_count(const DnnOperand *oprd); +// NOTE: User must check for error (return value <= 0) to handle +// case like integer overflow. +int32_t ff_calculate_operand_data_length(const DnnOperand *oprd); +int32_t ff_calculate_operand_dims_count(const DnnOperand *oprd); #endif