From: Shubhanshu Saxena <shubhanshu.e01@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Shubhanshu Saxena <shubhanshu.e01@gmail.com> Subject: [FFmpeg-devel] [PATCH V2 1/8] libavfilter: Prepare to handle specific error codes in DNN Filters Date: Wed, 2 Mar 2022 23:35:49 +0530 Message-ID: <20220302180556.19865-1-shubhanshu.e01@gmail.com> (raw) This commit prepares the filter side to handle specific error codes from the DNN backends instead of current DNN_ERROR. Signed-off-by: Shubhanshu Saxena <shubhanshu.e01@gmail.com> --- libavfilter/dnn_filter_common.c | 10 +++++----- libavfilter/dnn_filter_common.h | 10 +++++----- libavfilter/vf_derain.c | 4 ++-- libavfilter/vf_dnn_processing.c | 8 ++++---- libavfilter/vf_sr.c | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/libavfilter/dnn_filter_common.c b/libavfilter/dnn_filter_common.c index 3c7a962b3a..5083e3de19 100644 --- a/libavfilter/dnn_filter_common.c +++ b/libavfilter/dnn_filter_common.c @@ -106,18 +106,18 @@ int ff_dnn_set_classify_post_proc(DnnContext *ctx, ClassifyPostProc post_proc) return 0; } -DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input) +int ff_dnn_get_input(DnnContext *ctx, DNNData *input) { return ctx->model->get_input(ctx->model->model, input, ctx->model_inputname); } -DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height) +int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height) { return ctx->model->get_output(ctx->model->model, ctx->model_inputname, input_width, input_height, (const char *)ctx->model_outputnames[0], output_width, output_height); } -DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame) +int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame) { DNNExecBaseParams exec_params = { .input_name = ctx->model_inputname, @@ -129,7 +129,7 @@ DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame * return (ctx->dnn_module->execute_model)(ctx->model, &exec_params); } -DNNReturnType ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target) +int ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target) { DNNExecClassificationParams class_params = { { @@ -149,7 +149,7 @@ DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFram return (ctx->dnn_module->get_result)(ctx->model, in_frame, out_frame); } -DNNReturnType ff_dnn_flush(DnnContext *ctx) +int ff_dnn_flush(DnnContext *ctx) { return (ctx->dnn_module->flush)(ctx->model); } diff --git a/libavfilter/dnn_filter_common.h b/libavfilter/dnn_filter_common.h index 635ae631c1..bcdf37c815 100644 --- a/libavfilter/dnn_filter_common.h +++ b/libavfilter/dnn_filter_common.h @@ -53,12 +53,12 @@ int ff_dnn_init(DnnContext *ctx, DNNFunctionType func_type, AVFilterContext *fil int ff_dnn_set_frame_proc(DnnContext *ctx, FramePrePostProc pre_proc, FramePrePostProc post_proc); int ff_dnn_set_detect_post_proc(DnnContext *ctx, DetectPostProc post_proc); int ff_dnn_set_classify_post_proc(DnnContext *ctx, ClassifyPostProc post_proc); -DNNReturnType ff_dnn_get_input(DnnContext *ctx, DNNData *input); -DNNReturnType ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height); -DNNReturnType ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame); -DNNReturnType ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target); +int ff_dnn_get_input(DnnContext *ctx, DNNData *input); +int ff_dnn_get_output(DnnContext *ctx, int input_width, int input_height, int *output_width, int *output_height); +int ff_dnn_execute_model(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame); +int ff_dnn_execute_model_classification(DnnContext *ctx, AVFrame *in_frame, AVFrame *out_frame, const char *target); DNNAsyncStatusType ff_dnn_get_result(DnnContext *ctx, AVFrame **in_frame, AVFrame **out_frame); -DNNReturnType ff_dnn_flush(DnnContext *ctx); +int ff_dnn_flush(DnnContext *ctx); void ff_dnn_uninit(DnnContext *ctx); #endif diff --git a/libavfilter/vf_derain.c b/libavfilter/vf_derain.c index 0eb7da18da..6758cc05d2 100644 --- a/libavfilter/vf_derain.c +++ b/libavfilter/vf_derain.c @@ -62,7 +62,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; DRContext *dr_context = ctx->priv; - DNNReturnType dnn_result; + int dnn_result; AVFrame *out; out = ff_get_video_buffer(outlink, outlink->w, outlink->h); @@ -77,7 +77,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) if (dnn_result != DNN_SUCCESS){ av_log(ctx, AV_LOG_ERROR, "failed to execute model\n"); av_frame_free(&in); - return AVERROR(EIO); + return dnn_result; } do { async_state = ff_dnn_get_result(&dr_context->dnnctx, &in, &out); diff --git a/libavfilter/vf_dnn_processing.c b/libavfilter/vf_dnn_processing.c index c5ca36ef09..4a1ff5898f 100644 --- a/libavfilter/vf_dnn_processing.c +++ b/libavfilter/vf_dnn_processing.c @@ -134,14 +134,14 @@ static int config_input(AVFilterLink *inlink) { AVFilterContext *context = inlink->dst; DnnProcessingContext *ctx = context->priv; - DNNReturnType result; + int result; DNNData model_input; int check; result = ff_dnn_get_input(&ctx->dnnctx, &model_input); if (result != DNN_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "could not get input from the model\n"); - return AVERROR(EIO); + return result; } check = check_modelinput_inlink(&model_input, inlink); @@ -194,14 +194,14 @@ static int config_output(AVFilterLink *outlink) { AVFilterContext *context = outlink->src; DnnProcessingContext *ctx = context->priv; - DNNReturnType result; + int result; AVFilterLink *inlink = context->inputs[0]; // have a try run in case that the dnn model resize the frame result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &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); + return result; } prepare_uv_scale(outlink); diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c index b07335bc30..02d9452681 100644 --- a/libavfilter/vf_sr.c +++ b/libavfilter/vf_sr.c @@ -76,7 +76,7 @@ static int config_output(AVFilterLink *outlink) { AVFilterContext *context = outlink->src; SRContext *ctx = context->priv; - DNNReturnType result; + int result; AVFilterLink *inlink = context->inputs[0]; int out_width, out_height; @@ -84,7 +84,7 @@ static int config_output(AVFilterLink *outlink) result = ff_dnn_get_output(&ctx->dnnctx, inlink->w, inlink->h, &out_width, &out_height); if (result != DNN_SUCCESS) { av_log(ctx, AV_LOG_ERROR, "could not get output from the model\n"); - return AVERROR(EIO); + return result; } if (inlink->w != out_width || inlink->h != out_height) { @@ -121,7 +121,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) SRContext *ctx = context->priv; AVFilterLink *outlink = context->outputs[0]; AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); - DNNReturnType dnn_result; + int dnn_result; if (!out){ av_log(context, AV_LOG_ERROR, "could not allocate memory for output frame\n"); @@ -143,7 +143,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) av_log(ctx, AV_LOG_ERROR, "failed to execute loaded model\n"); av_frame_free(&in); av_frame_free(&out); - return AVERROR(EIO); + return dnn_result; } do { -- 2.32.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2022-03-02 18:13 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-02 18:05 Shubhanshu Saxena [this message] 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 2/8] lavfi/dnn: Error Specificity in Native Backend Layers Shubhanshu Saxena 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 3/8] lavfi/dnn_io_proc: Return Specific Error Codes Shubhanshu Saxena 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 4/8] lavfi/dnn_backend_openvino: " Shubhanshu Saxena 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 5/8] lavfi/dnn_backend_tf: " Shubhanshu Saxena 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 6/8] lavfi/dnn_backend_native: " Shubhanshu Saxena 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 7/8] lavfi/dnn_backend_common: Return specific error codes Shubhanshu Saxena 2022-03-02 18:05 ` [FFmpeg-devel] [PATCH V2 8/8] libavfilter: Remove DNNReturnType from DNN Module Shubhanshu Saxena 2022-03-08 14:18 ` Guo, Yejun
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220302180556.19865-1-shubhanshu.e01@gmail.com \ --to=shubhanshu.e01@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git