summaryrefslogtreecommitdiff
path: root/libavfilter/vf_sr.c
diff options
context:
space:
mode:
authorGuo, Yejun <yejun.guo@intel.com>2019-04-25 10:14:33 +0800
committerPedro Arthur <bygrandao@gmail.com>2019-05-08 12:33:00 -0300
commit25c1cd909fa6c8b6b778dc24192dc3ec780324b0 (patch)
treeb428c01522b2935d0b6af414580edcdf39370093 /libavfilter/vf_sr.c
parent7adfb6132e0823de06f92ecbcb485eeb4260d407 (diff)
downloadffmpeg-25c1cd909fa6c8b6b778dc24192dc3ec780324b0.tar.gz
libavfilter/dnn: support multiple outputs for tensorflow model
some models such as ssd, yolo have more than one output. the clean up code in this patch is a little complex, it is because that set_input_output_tf could be called for many times together with ff_dnn_execute_model_tf, we have to clean resources for the case that the two interfaces are called interleaved. Signed-off-by: Guo, Yejun <yejun.guo@intel.com> Signed-off-by: Pedro Arthur <bygrandao@gmail.com>
Diffstat (limited to 'libavfilter/vf_sr.c')
-rw-r--r--libavfilter/vf_sr.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c
index 12804d8bdf..0145511d11 100644
--- a/libavfilter/vf_sr.c
+++ b/libavfilter/vf_sr.c
@@ -116,18 +116,19 @@ static int config_props(AVFilterLink *inlink)
AVFilterLink *outlink = context->outputs[0];
DNNReturnType result;
int sws_src_h, sws_src_w, sws_dst_h, sws_dst_w;
+ const char *model_output_name = "y";
sr_context->input.width = inlink->w * sr_context->scale_factor;
sr_context->input.height = inlink->h * sr_context->scale_factor;
sr_context->input.channels = 1;
- result = (sr_context->model->set_input_output)(sr_context->model->model, &sr_context->input, "x", "y");
+ result = (sr_context->model->set_input_output)(sr_context->model->model, &sr_context->input, "x", &model_output_name, 1);
if (result != DNN_SUCCESS){
av_log(context, AV_LOG_ERROR, "could not set input and output for the model\n");
return AVERROR(EIO);
}
- result = (sr_context->dnn_module->execute_model)(sr_context->model, &sr_context->output);
+ result = (sr_context->dnn_module->execute_model)(sr_context->model, &sr_context->output, 1);
if (result != DNN_SUCCESS){
av_log(context, AV_LOG_ERROR, "failed to execute loaded model\n");
return AVERROR(EIO);
@@ -136,12 +137,12 @@ static int config_props(AVFilterLink *inlink)
if (sr_context->input.height != sr_context->output.height || sr_context->input.width != sr_context->output.width){
sr_context->input.width = inlink->w;
sr_context->input.height = inlink->h;
- result = (sr_context->model->set_input_output)(sr_context->model->model, &sr_context->input, "x", "y");
+ result = (sr_context->model->set_input_output)(sr_context->model->model, &sr_context->input, "x", &model_output_name, 1);
if (result != DNN_SUCCESS){
av_log(context, AV_LOG_ERROR, "could not set input and output for the model\n");
return AVERROR(EIO);
}
- result = (sr_context->dnn_module->execute_model)(sr_context->model, &sr_context->output);
+ result = (sr_context->dnn_module->execute_model)(sr_context->model, &sr_context->output, 1);
if (result != DNN_SUCCESS){
av_log(context, AV_LOG_ERROR, "failed to execute loaded model\n");
return AVERROR(EIO);
@@ -256,7 +257,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
}
av_frame_free(&in);
- dnn_result = (sr_context->dnn_module->execute_model)(sr_context->model, &sr_context->output);
+ dnn_result = (sr_context->dnn_module->execute_model)(sr_context->model, &sr_context->output, 1);
if (dnn_result != DNN_SUCCESS){
av_log(context, AV_LOG_ERROR, "failed to execute loaded model\n");
return AVERROR(EIO);