> -----Original Message----- > From: ffmpeg-devel <ffmpeg-devel-boun...@ffmpeg.org> On Behalf Of > Shubhanshu Saxena > Sent: 2021年6月6日 2:08 > To: ffmpeg-devel@ffmpeg.org > Cc: Shubhanshu Saxena <shubhanshu....@gmail.com> > Subject: [FFmpeg-devel] [PATCH V2 5/5] lavfi/dnn: Fill Task using Common > Function > > This commit adds a common function for filling the TaskItems > in all three backends. > > Signed-off-by: Shubhanshu Saxena <shubhanshu....@gmail.com> > --- > libavfilter/dnn/dnn_backend_common.c | 20 ++++++++++++++++++++ > libavfilter/dnn/dnn_backend_common.h | 15 +++++++++++++++ > libavfilter/dnn/dnn_backend_openvino.c | 23 +++++++---------------- > 3 files changed, 42 insertions(+), 16 deletions(-) > > diff --git a/libavfilter/dnn/dnn_backend_common.c > b/libavfilter/dnn/dnn_backend_common.c > index a522ab5650..4d9d3f79b1 100644 > --- a/libavfilter/dnn/dnn_backend_common.c > +++ b/libavfilter/dnn/dnn_backend_common.c > @@ -49,3 +49,23 @@ int ff_check_exec_params(void *ctx, DNNBackendType > backend, DNNFunctionType func > > return 0; > } > + > +DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams > *exec_params, void *backend_model, int async, int do_ioproc) { > + if (task == NULL || exec_params == NULL || backend_model == NULL) > + return DNN_ERROR; > + if (do_ioproc != 0 && do_ioproc != 1) > + return DNN_ERROR; > + if (async != 0 && async != 1) > + return DNN_ERROR; > + > + task->do_ioproc = do_ioproc; > + task->async = async; > + task->input_name = exec_params->input_name; > + task->in_frame = exec_params->in_frame; > + task->out_frame = exec_params->out_frame; > + task->model = backend_model; > + task->nb_output = exec_params->nb_output; > + task->output_names = exec_params->output_names; > + > + return DNN_SUCCESS; > +} > diff --git a/libavfilter/dnn/dnn_backend_common.h > b/libavfilter/dnn/dnn_backend_common.h > index d962312c16..df59615f40 100644 > --- a/libavfilter/dnn/dnn_backend_common.h > +++ b/libavfilter/dnn/dnn_backend_common.h > @@ -48,4 +48,19 @@ typedef struct InferenceItem { > > int ff_check_exec_params(void *ctx, DNNBackendType backend, > DNNFunctionType func_type, DNNExecBaseParams *exec_params); > > +/** > + * Fill the Task for Backend Execution. It should be called after > + * checking execution parameters using ff_check_exec_params. > + * > + * @param task pointer to the allocated task > + * @param exec_param pointer to execution parameters > + * @param backend_model void pointer to the backend model > + * @param async flag for async execution. Must be 0 or 1 > + * @param do_ioproc flag for IO processing. Must be 0 or 1 > + * > + * @retval DNN_SUCCESS if successful > + * @retval DNN_ERROR if flags are invalid or any parameter is NULL > + */ > +DNNReturnType ff_dnn_fill_task(TaskItem *task, DNNExecBaseParams > *exec_params, void *backend_model, int async, int do_ioproc); > + > #endif > diff --git a/libavfilter/dnn/dnn_backend_openvino.c > b/libavfilter/dnn/dnn_backend_openvino.c > index c2487c35be..709a772a4d 100644 > --- a/libavfilter/dnn/dnn_backend_openvino.c > +++ b/libavfilter/dnn/dnn_backend_openvino.c > @@ -793,14 +793,9 @@ DNNReturnType ff_dnn_execute_model_ov(const > DNNModel *model, DNNExecBaseParams * > } > } > > - task.do_ioproc = 1; > - task.async = 0; > - task.input_name = exec_params->input_name; > - task.in_frame = exec_params->in_frame; > - task.output_names = &exec_params->output_names[0]; > - task.out_frame = exec_params->out_frame ? exec_params->out_frame : > exec_params->in_frame; > - task.nb_output = exec_params->nb_output; > - task.model = ov_model; > + if (ff_dnn_fill_task(&task, exec_params, ov_model, 0, 1) != > DNN_SUCCESS) { > + return DNN_ERROR; > + } > > if (extract_inference_from_task(ov_model->model->func_type, &task, > ov_model->inference_queue, exec_params) != DNN_SUCCESS) { > av_log(ctx, AV_LOG_ERROR, "unable to extract inference from > task.\n"); > @@ -841,14 +836,10 @@ DNNReturnType > ff_dnn_execute_model_async_ov(const DNNModel *model, DNNExecBasePa > return DNN_ERROR; > } > > - task->do_ioproc = 1; > - task->async = 1; > - task->input_name = exec_params->input_name; > - task->in_frame = exec_params->in_frame; > - task->output_names = &exec_params->output_names[0]; > - task->out_frame = exec_params->out_frame ? > exec_params->out_frame : exec_params->in_frame; > - task->nb_output = exec_params->nb_output; > - task->model = ov_model; > + if (ff_dnn_fill_task(task, exec_params, ov_model, 1, 1) != DNN_SUCCESS) > { > + return DNN_ERROR; > + } > + > if (ff_queue_push_back(ov_model->task_queue, task) < 0) { > av_freep(&task); > av_log(ctx, AV_LOG_ERROR, "unable to push back task_queue.\n");
will push tomorrow if there's no objection, thanks. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".