[FFmpeg-devel] [PATCH V4 3/4] libavfilter/dnn: add ff_dnn_set_proc to set pre/post proc
Guo, Yejun
yejun.guo at intel.com
Mon Mar 1 15:20:52 EET 2021
Signed-off-by: Guo, Yejun <yejun.guo at 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(-)
diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c
index 413adba406..2a1d045be1 100644
--- a/libavfilter/dnn_filter_common.c
+++ b/libavfilter/dnn_filter_common.c
@@ -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);
diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h
index 79c4d3efe3..4810c7baaf 100644
--- a/libavfilter/dnn_filter_common.h
+++ b/libavfilter/dnn_filter_common.h
@@ -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);
diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h
index d3a0c58a61..c92434ee55 100644
--- a/libavfilter/dnn_interface.h
+++ b/libavfilter/dnn_interface.h
@@ -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.
--
2.17.1
More information about the ffmpeg-devel
mailing list