status |= ie_blob_get_dims(input_blob, &dims);
status |= ie_blob_get_precision(input_blob, &precision);
if (status != OK) {
+ ie_blob_free(&input_blob);
av_log(ctx, AV_LOG_ERROR, "Failed to get input blob dims/precision\n");
return DNN_ERROR;
}
status = ie_blob_get_buffer(input_blob, &blob_buffer);
if (status != OK) {
+ ie_blob_free(&input_blob);
av_log(ctx, AV_LOG_ERROR, "Failed to get input blob buffer\n");
return DNN_ERROR;
}
for (int i = 0; i < request->task_count; ++i) {
task = request->tasks[i];
if (task->do_ioproc) {
- if (ov_model->model->pre_proc != NULL) {
- ov_model->model->pre_proc(task->in_frame, &input, ov_model->model->filter_ctx);
+ if (ov_model->model->frame_pre_proc != NULL) {
+ ov_model->model->frame_pre_proc(task->in_frame, &input, ov_model->model->filter_ctx);
} else {
ff_proc_from_frame_to_dnn(task->in_frame, &input, ov_model->model->func_type, ctx);
}
status = ie_blob_get_buffer(output_blob, &blob_buffer);
if (status != OK) {
+ ie_blob_free(&output_blob);
av_log(ctx, AV_LOG_ERROR, "Failed to access output memory\n");
return;
}
status |= ie_blob_get_dims(output_blob, &dims);
status |= ie_blob_get_precision(output_blob, &precision);
if (status != OK) {
+ ie_blob_free(&output_blob);
av_log(ctx, AV_LOG_ERROR, "Failed to get dims or precision of output\n");
return;
}
av_assert0(request->task_count >= 1);
for (int i = 0; i < request->task_count; ++i) {
task = request->tasks[i];
- if (task->do_ioproc) {
- if (task->ov_model->model->post_proc != NULL) {
- task->ov_model->model->post_proc(task->out_frame, &output, task->ov_model->model->filter_ctx);
+
+ switch (task->ov_model->model->func_type) {
+ case DFT_PROCESS_FRAME:
+ if (task->do_ioproc) {
+ if (task->ov_model->model->frame_post_proc != NULL) {
+ task->ov_model->model->frame_post_proc(task->out_frame, &output, task->ov_model->model->filter_ctx);
+ } else {
+ ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx);
+ }
} else {
- ff_proc_from_dnn_to_frame(task->out_frame, &output, ctx);
+ task->out_frame->width = output.width;
+ task->out_frame->height = output.height;
}
- } else {
- task->out_frame->width = output.width;
- task->out_frame->height = output.height;
+ break;
+ case DFT_ANALYTICS_DETECT:
+ if (!task->ov_model->model->detect_post_proc) {
+ av_log(ctx, AV_LOG_ERROR, "detect filter needs to provide post proc\n");
+ return;
+ }
+ task->ov_model->model->detect_post_proc(task->out_frame, &output, 1, task->ov_model->model->filter_ctx);
+ break;
+ default:
+ av_assert0(!"should not reach here");
+ break;
}
+
task->done = 1;
output.data = (uint8_t *)output.data
+ output.width * output.height * output.channels * get_datatype_size(output.dt);
}
// all models in openvino open model zoo use BGR with range [0.0f, 255.0f] as input,
- // we don't have a AVPixelFormat to descibe it, so we'll use AV_PIX_FMT_BGR24 and
+ // we don't have a AVPixelFormat to describe it, so we'll use AV_PIX_FMT_BGR24 and
// ask openvino to do the conversion internally.
// the current supported SR model (frame processing) is generated from tensorflow model,
// and its input is Y channel as float with range [0.0f, 1.0f], so do not set for this case.
status = ie_network_set_input_precision(ov_model->network, input_name, U8);
if (status != OK) {
av_log(ctx, AV_LOG_ERROR, "Failed to set input precision as U8 for %s\n", input_name);
- return DNN_ERROR;
+ goto err;
}
}
goto err;
}
+ item->callback.completeCallBackFunc = infer_completion_callback;
+ item->callback.args = item;
+ if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
+ av_freep(&item);
+ goto err;
+ }
+
status = ie_exec_network_create_infer_request(ov_model->exe_network, &item->infer_request);
if (status != OK) {
- av_freep(&item);
goto err;
}
item->tasks = av_malloc_array(ctx->options.batch_size, sizeof(*item->tasks));
if (!item->tasks) {
- av_freep(&item);
goto err;
}
item->task_count = 0;
-
- item->callback.completeCallBackFunc = infer_completion_callback;
- item->callback.args = item;
- if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
- av_freep(&item);
- goto err;
- }
}
ov_model->task_queue = ff_queue_create();
IEStatusCode status;
input_shapes_t input_shapes;
+ if (ov_model->model->func_type != DFT_PROCESS_FRAME) {
+ av_log(ctx, AV_LOG_ERROR, "Get output dim only when processing frame.\n");
+ return DNN_ERROR;
+ }
+
if (ctx->options.input_resizable) {
status = ie_network_get_input_shapes(ov_model->network, &input_shapes);
input_shapes.shapes->shape.dims[2] = input_height;
return DNN_ERROR;
}
- task = av_malloc(sizeof(*task));
- if (!task) {
- av_log(ctx, AV_LOG_ERROR, "unable to alloc memory for task item.\n");
- return DNN_ERROR;
- }
-
if (!ov_model->exe_network) {
if (init_model_ov(ov_model, input_name, output_names[0]) != DNN_SUCCESS) {
av_log(ctx, AV_LOG_ERROR, "Failed init OpenVINO exectuable network or inference request\n");
}
}
+ task = av_malloc(sizeof(*task));
+ if (!task) {
+ av_log(ctx, AV_LOG_ERROR, "unable to alloc memory for task item.\n");
+ return DNN_ERROR;
+ }
+
task->done = 0;
task->do_ioproc = 1;
task->async = 1;