@@ -64,6 +64,13 @@ int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *fil
return 0;
}
+int ff_dnn_set_proc(DnnContext *ctx, PrePostProc pre_proc, PrePostProc post_proc)
+{
+ ctx->model->pre_proc = pre_proc;
+ ctx->model->post_proc = post_proc;
+ return 0;
+}
+
DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input)
{
return ctx->model->get_input(ctx->model->model, input, ctx->model_inputname);
@@ -48,6 +48,7 @@ typedef struct DnnContext {
int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *filter_ctx);
+int ff_dnn_set_proc(DnnContext *ctx, PrePostProc pre_proc, PrePostProc post_proc);
DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input);
DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height);
DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame);
@@ -63,6 +63,8 @@ typedef struct DNNData{
DNNColorOrder order;
} DNNData;
+typedef int (*PrePostProc)(AVFrame *frame, DNNData *model, AVFilterContext *filter_ctx);
+
typedef struct DNNModel{
// Stores model that can be different for different backends.
void *model;
@@ -80,10 +82,10 @@ typedef struct DNNModel{
const char *output_name, int *output_width, int *output_height);
// 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, AVFilterContext *filter_ctx);
+ PrePostProc pre_proc;
// 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, AVFilterContext *filter_ctx);
+ PrePostProc post_proc;
} DNNModel;
// Stores pointers to functions for loading, executing, freeing DNN models for one of the backends.
Signed-off-by: Guo, Yejun <yejun.guo@intel.com> --- libavfilter/dnn_filter_common.c | 7 +++++++ libavfilter/dnn_filter_common.h | 1 + libavfilter/dnn_interface.h | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-)