summaryrefslogtreecommitdiff
path: root/libavfilter/vf_derain.c
diff options
context:
space:
mode:
authorGuo, Yejun <yejun.guo@intel.com>2020-09-10 22:29:57 +0800
committerGuo, Yejun <yejun.guo@intel.com>2020-09-21 21:26:56 +0800
commitfce3e3e137843d86411f8868f18e1c3f472de0e5 (patch)
tree4ad669abc4ea7fc78220f4b24f0455fb17a8234b /libavfilter/vf_derain.c
parent2003e32f62d94ba75b59d70632c9f2862b383591 (diff)
dnn: put DNNModel.set_input and DNNModule.execute_model together
suppose we have a detect and classify filter in the future, the detect filter generates some bounding boxes (BBox) as AVFrame sidedata, and the classify filter executes DNN model for each BBox. For each BBox, we need to crop the AVFrame, copy data to DNN model input and do the model execution. So we have to save the in_frame at DNNModel.set_input and use it at DNNModule.execute_model, such saving is not feasible when we support async execute_model. This patch sets the in_frame as execution_model parameter, and so all the information are put together within the same function for each inference. It also makes easy to support BBox async inference.
Diffstat (limited to 'libavfilter/vf_derain.c')
-rw-r--r--libavfilter/vf_derain.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c
index a59cd6e941..77dd401263 100644
--- a/libavfilter/vf_derain.c
+++ b/libavfilter/vf_derain.c
@@ -80,13 +80,6 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
const char *model_output_name = "y";
AVFrame *out;
- dnn_result = (dr_context->model->set_input)(dr_context->model->model, in, "x");
- if (dnn_result != DNN_SUCCESS) {
- av_log(ctx, AV_LOG_ERROR, "could not set input for the model\n");
- av_frame_free(&in);
- return AVERROR(EIO);
- }
-
out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) {
av_log(ctx, AV_LOG_ERROR, "could not allocate memory for output frame\n");
@@ -95,7 +88,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
av_frame_copy_props(out, in);
- dnn_result = (dr_context->dnn_module->execute_model)(dr_context->model, &model_output_name, 1, out);
+ dnn_result = (dr_context->dnn_module->execute_model)(dr_context->model, "x", in, &model_output_name, 1, out);
if (dnn_result != DNN_SUCCESS){
av_log(ctx, AV_LOG_ERROR, "failed to execute model\n");
av_frame_free(&in);