summaryrefslogtreecommitdiff
path: root/libavfilter/dnn_filter_common.c
diff options
context:
space:
mode:
authorGuo, Yejun <yejun.guo@intel.com>2021-04-01 10:06:06 +0800
committerGuo, Yejun <yejun.guo@intel.com>2021-05-06 10:50:44 +0800
commita3b74651a0408ddb19c2f0334ad4ad3f368376a6 (patch)
tree29d91ae5925644df0d81402e2c0e90e84d25922a /libavfilter/dnn_filter_common.c
parent7eb9accc376dca4f766d87d68c72aa167e4e9c7e (diff)
downloadffmpeg-a3b74651a0408ddb19c2f0334ad4ad3f368376a6.tar.gz
lavfi/dnn: refine dnn interface to add DNNExecBaseParams
Different function type of model requires different parameters, for example, object detection detects lots of objects (cat/dog/...) in the frame, and classifcation needs to know which object (cat or dog) it is going to classify. The current interface needs to add a new function with more parameters to support new requirement, with this change, we can just add a new struct (for example DNNExecClassifyParams) based on DNNExecBaseParams, and so we can continue to use the current interface execute_model just with params changed.
Diffstat (limited to 'libavfilter/dnn_filter_common.c')
-rw-r--r--libavfilter/dnn_filter_common.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c
index 1b922455a3..c085884eb4 100644
--- a/libavfilter/dnn_filter_common.c
+++ b/libavfilter/dnn_filter_common.c
@@ -90,14 +90,26 @@ DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_heig
DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame)
{
- return (ctx->dnn_module->execute_model)(ctx->model, ctx->model_inputname, in_frame,
- (const char **)&ctx->model_outputname, 1, out_frame);
+ DNNExecBaseParams exec_params = {
+ .input_name = ctx->model_inputname,
+ .output_names = (const char **)&ctx->model_outputname,
+ .nb_output = 1,
+ .in_frame = in_frame,
+ .out_frame = out_frame,
+ };
+ return (ctx->dnn_module->execute_model)(ctx->model, &exec_params);
}
DNNReturnType ff_dnn_execute_model_async(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame)
{
- return (ctx->dnn_module->execute_model_async)(ctx->model, ctx->model_inputname, in_frame,
- (const char **)&ctx->model_outputname, 1, out_frame);
+ DNNExecBaseParams exec_params = {
+ .input_name = ctx->model_inputname,
+ .output_names = (const char **)&ctx->model_outputname,
+ .nb_output = 1,
+ .in_frame = in_frame,
+ .out_frame = out_frame,
+ };
+ return (ctx->dnn_module->execute_model_async)(ctx->model, &exec_params);
}
DNNAsyncStatusType ff_dnn_get_async_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame)