summaryrefslogtreecommitdiff
path: root/libavfilter/dnn/dnn_backend_openvino.c
diff options
context:
space:
mode:
authorShubhanshu Saxena <shubhanshu.e01@gmail.com>2021-08-08 16:25:37 +0530
committerGuo Yejun <yejun.guo@intel.com>2021-08-10 22:27:27 +0800
commit009b2e5b5ee602e2a27dc54077bf6fd46bdc9b9d (patch)
tree5ca6950063902b5efb8ea99d5eb5d9f2b2e39342 /libavfilter/dnn/dnn_backend_openvino.c
parent4d627acefab73b1d52c2185f975a0b082b4a7d5d (diff)
lavfi/dnn: Extract Common Parts from get_output functions
The frame allocation and filling the TaskItem with execution parameters is common in the three backends. This commit shifts this logic to dnn_backend_common. Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com>
Diffstat (limited to 'libavfilter/dnn/dnn_backend_openvino.c')
-rw-r--r--libavfilter/dnn/dnn_backend_openvino.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 47cbd48ba2..c825e70c82 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -640,10 +640,15 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu
OVContext *ctx = &ov_model->ctx;
TaskItem task;
OVRequestItem *request;
- AVFrame *in_frame = NULL;
- AVFrame *out_frame = NULL;
IEStatusCode status;
input_shapes_t input_shapes;
+ DNNExecBaseParams exec_params = {
+ .input_name = input_name,
+ .output_names = &output_name,
+ .nb_output = 1,
+ .in_frame = NULL,
+ .out_frame = NULL,
+ };
if (ov_model->model->func_type != DFT_PROCESS_FRAME) {
av_log(ctx, AV_LOG_ERROR, "Get output dim only when processing frame.\n");
@@ -669,51 +674,29 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu
}
}
- in_frame = av_frame_alloc();
- if (!in_frame) {
- av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input frame\n");
+ if (ff_dnn_fill_gettingoutput_task(&task, &exec_params, ov_model, input_height, input_width, ctx) != DNN_SUCCESS) {
return DNN_ERROR;
}
- in_frame->width = input_width;
- in_frame->height = input_height;
-
- out_frame = av_frame_alloc();
- if (!out_frame) {
- av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output frame\n");
- av_frame_free(&in_frame);
- return DNN_ERROR;
- }
-
- task.do_ioproc = 0;
- task.async = 0;
- task.input_name = input_name;
- task.in_frame = in_frame;
- task.output_names = &output_name;
- task.out_frame = out_frame;
- task.nb_output = 1;
- task.model = ov_model;
if (extract_inference_from_task(ov_model->model->func_type, &task, ov_model->inference_queue, NULL) != DNN_SUCCESS) {
- av_frame_free(&out_frame);
- av_frame_free(&in_frame);
av_log(ctx, AV_LOG_ERROR, "unable to extract inference from task.\n");
- return DNN_ERROR;
+ ret = DNN_ERROR;
+ goto err;
}
request = ff_safe_queue_pop_front(ov_model->request_queue);
if (!request) {
- av_frame_free(&out_frame);
- av_frame_free(&in_frame);
av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n");
- return DNN_ERROR;
+ ret = DNN_ERROR;
+ goto err;
}
ret = execute_model_ov(request, ov_model->inference_queue);
- *output_width = out_frame->width;
- *output_height = out_frame->height;
-
- av_frame_free(&out_frame);
- av_frame_free(&in_frame);
+ *output_width = task.out_frame->width;
+ *output_height = task.out_frame->height;
+err:
+ av_frame_free(&task.out_frame);
+ av_frame_free(&task.in_frame);
return ret;
}