summaryrefslogtreecommitdiff
path: root/libavfilter/vf_dnn_processing.c
diff options
context:
space:
mode:
authorGuo, Yejun <yejun.guo@intel.com>2020-09-11 22:15:04 +0800
committerGuo, Yejun <yejun.guo@intel.com>2020-09-21 21:26:56 +0800
commite71d73b09652f4fc96e512a7d6d4c2ab41860f27 (patch)
tree07b84f09dceed8083e0985390f0258e780c4c742 /libavfilter/vf_dnn_processing.c
parentfce3e3e137843d86411f8868f18e1c3f472de0e5 (diff)
dnn: add a new interface DNNModel.get_output
for some cases (for example, super resolution), the DNN model changes the frame size which impacts the filter behavior, so the filter needs to know the out frame size at very beginning. Currently, the filter reuses DNNModule.execute_model to query the out frame size, it is not clear from interface perspective, so add a new explict interface DNNModel.get_output for such query.
Diffstat (limited to 'libavfilter/vf_dnn_processing.c')
-rw-r--r--libavfilter/vf_dnn_processing.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c
index 2c8578c9b0..334243bd2b 100644
--- a/libavfilter/vf_dnn_processing.c
+++ b/libavfilter/vf_dnn_processing.c
@@ -233,24 +233,15 @@ static int config_output(AVFilterLink *outlink)
DnnProcessingContext *ctx = context->priv;
DNNReturnType result;
AVFilterLink *inlink = context->inputs[0];
- AVFrame *out = NULL;
-
- AVFrame *fake_in = ff_get_video_buffer(inlink, inlink->w, inlink->h);
// have a try run in case that the dnn model resize the frame
- out = ff_get_video_buffer(inlink, inlink->w, inlink->h);
- result = (ctx->dnn_module->execute_model)(ctx->model, ctx->model_inputname, fake_in,
- (const char **)&ctx->model_outputname, 1, out);
- if (result != DNN_SUCCESS){
- av_log(ctx, AV_LOG_ERROR, "failed to execute model\n");
+ result = ctx->model->get_output(ctx->model->model, ctx->model_inputname, inlink->w, inlink->h,
+ ctx->model_outputname, &outlink->w, &outlink->h);
+ if (result != DNN_SUCCESS) {
+ av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n");
return AVERROR(EIO);
}
- outlink->w = out->width;
- outlink->h = out->height;
-
- av_frame_free(&fake_in);
- av_frame_free(&out);
prepare_uv_scale(outlink);
return 0;