diff options
author | Guo, Yejun <yejun.guo@intel.com> | 2020-08-28 12:51:44 +0800 |
---|---|---|
committer | Guo, Yejun <yejun.guo@intel.com> | 2020-09-21 21:26:56 +0800 |
commit | 2003e32f62d94ba75b59d70632c9f2862b383591 (patch) | |
tree | 55ec60788bc740eb45dbafd613bd8cf50a10417a /libavfilter/dnn_interface.h | |
parent | 6918e240d706f7390272976d8b8d502afe426a18 (diff) |
dnn: change dnn interface to replace DNNData* with AVFrame*
Currently, every filter needs to provide code to transfer data from
AVFrame* to model input (DNNData*), and also from model output
(DNNData*) to AVFrame*. Actually, such transfer can be implemented
within DNN module, and so filter can focus on its own business logic.
DNN module also exports the function pointer pre_proc and post_proc
in struct DNNModel, just in case that a filter has its special logic
to transfer data between AVFrame* and DNNData*. The default implementation
within DNN module is used if the filter does not set pre/post_proc.
Diffstat (limited to 'libavfilter/dnn_interface.h')
-rw-r--r-- | libavfilter/dnn_interface.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index 702c8306e0..6debc50607 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -27,6 +27,7 @@ #define AVFILTER_DNN_INTERFACE_H #include <stdint.h> +#include "libavutil/frame.h" typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType; @@ -50,17 +51,23 @@ typedef struct DNNModel{ // Gets model input information // Just reuse struct DNNData here, actually the DNNData.data field is not needed. DNNReturnType (*get_input)(void *model, DNNData *input, const char *input_name); - // Sets model input and output. - // Should be called at least once before model execution. - DNNReturnType (*set_input)(void *model, DNNData *input, const char *input_name); + // Sets model input. + // Should be called every time before model execution. + DNNReturnType (*set_input)(void *model, AVFrame *frame, const char *input_name); + // set the pre process to transfer data from AVFrame to DNNData + // the default implementation within DNN is used if it is not provided by the filter + int (*pre_proc)(AVFrame *frame_in, DNNData *model_input, void *user_data); + // set the post process to transfer data from DNNData to AVFrame + // the default implementation within DNN is used if it is not provided by the filter + int (*post_proc)(AVFrame *frame_out, DNNData *model_output, void *user_data); } DNNModel; // Stores pointers to functions for loading, executing, freeing DNN models for one of the backends. typedef struct DNNModule{ // Loads model and parameters from given file. Returns NULL if it is not possible. DNNModel *(*load_model)(const char *model_filename, const char *options, void *userdata); - // Executes model with specified input and output. Returns DNN_ERROR otherwise. - DNNReturnType (*execute_model)(const DNNModel *model, DNNData *outputs, const char **output_names, uint32_t nb_output); + // Executes model with specified output. Returns DNN_ERROR otherwise. + DNNReturnType (*execute_model)(const DNNModel *model, const char **output_names, uint32_t nb_output, AVFrame *out_frame); // Frees memory allocated for model. void (*free_model)(DNNModel **model); } DNNModule; |