From patchwork Wed Mar 2 18:05:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 34575 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4883415nkx; Wed, 2 Mar 2022 10:13:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxMph+F4mjDVwytjo7pkeNNVFzhE1VweiU4Q9ImMQWT9v6gy7TNgAm5JElNDmz1Q+03brK X-Received: by 2002:a05:6402:354a:b0:412:8976:82d2 with SMTP id f10-20020a056402354a00b00412897682d2mr31067706edd.213.1646244824128; Wed, 02 Mar 2022 10:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646244824; cv=none; d=google.com; s=arc-20160816; b=czjcFKbLPykyZFuZd+JnHe+rms6oJtYo4ZlpJHId4OYKiNv6fCmIEmB0kE8LqlZi0s ltpdVZumLt8J86LPXhCVUA5YlNdydirQxDIXpkfdQIWBh7TSMyXweyx3TQPfn59UTHqK 9sFFt9T4CW74/GBDZfhJWWQdd0UfZPaBoIKUBF7WTAW7L+3INIJqJ4D05BRXx5OLAuai pcetjHrOHrBxsTDgLVn0IAC9oxXMNZy23dSXfEUxxjZFagMzyIY3iQupMk69ZRyoczDf g/+E1Vv/lXkTbyzMQndwhSoZYtMR+hhtehsLi3q1CYbpkGnL3SX15PsHR/RWbfCZQoeu o5hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=4NjioIpzFfjNnBSKIM/RlZmpYd7V3To/pR0nI2Px1l4=; b=K1XKDu8vmFDdfg+ydzPNAjnrTiW3bBqQYQC3BJ7hpL/pFpNtcvc+Ahy43AmUbXkxc/ abSiMPxZaZJU55jTvwZAIi6hWmU2lCRQ/iNJSEs/d2nG3YjKEpc4RCjx05enFXGIi2Af KJKl6tui8jYcq0csxlunv4rJOwKybivtbgADZbgKoc3IZiQ59MIjbDFVcH9wQadnS83z kzUFSEcCDt1tZjDUdE/ZU+D5npsI2i0Q0BdAE6DqVZRft5XUG/wsWtVGcmsUFx/uKgCD tevmdaEHL/sjv36ajC04ulfZ3BTHaPn08xymSWl4U3PivHnKoSgxv0Aa/uFkUDVC9eXM z84Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=KbI3qlFN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z11-20020a170906434b00b006d58f86c07dsi9829286ejm.482.2022.03.02.10.13.20; Wed, 02 Mar 2022 10:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=KbI3qlFN; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 988BC68B2EE; Wed, 2 Mar 2022 20:13:16 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6962668B174 for ; Wed, 2 Mar 2022 20:13:09 +0200 (EET) Received: by mail-pl1-f174.google.com with SMTP id p17so2254399plo.9 for ; Wed, 02 Mar 2022 10:13:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hbhgw32Sd1qER9LQtkbbcq/5LbN9gCVlNX7PbH3wTk0=; b=KbI3qlFNcOajKMdL5DmmcziwB9iQ0vzgfVrjCtekG5QA/wCTmhxGnBRxnFUZkv2j8k ehDArBQswrV6m2JAZiZie3wYu8Wkmu2+XBfPO0q7Rf50L2kUyRfZzlh7MgnDbLBUr06U Ccag0EeUnRAgwD/+JEk2+AOqLlvAHM/xwafy45HP9WaxFPUK+gfAPT6Vxb/ImuGkCY90 LoQ9bpXp5ZE5uiwJm9ict04t1gcxANdMABRyjSxjiqeT7hhM1j91N45nRASWHb9z5nsb +9893OZX0cEebJRlL9uZnF9PXHtZqtnDOWuPIj1v4xNoDBmRuieCnoNzw0kuBoKiA9ST VI/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hbhgw32Sd1qER9LQtkbbcq/5LbN9gCVlNX7PbH3wTk0=; b=v1Q1+pO62DDn3dSlKi/M7lYp3SSNasOFe+aXqUHzjmYWSnhwIf3TFtu3CLA5BI7mmH 7DCnUVIUCZk/Whw9C1JUwQ/fzz4FzfrsgtgpuzOuvtnsVAMwn2b+HZdcAND6t7/5j8qB VlpLU8QLGhUX992QAyE3EGZ2RWSYIbZU14Er8kLo17Vji7X/0IqYTkecZyNfIdJDCUip l+Iumu0XwYH6z3dQC/rGS52mzaSaZmWIwmP8ShvCYcS5WEj+0xg8UMYG+FeHpVWYDArF 44HaIpUoEDTtI1fKN/3SVZsQEU57t03l2lWFB2hvWTrmRjxR7RLDSeIQcG/iiOwhbBs9 roDQ== X-Gm-Message-State: AOAM530Nz6zGuOf+uLiWeX9qGMXRH2kjZUv5hViFk51nTeparUupkbW3 9Hu2UnbWdHvWxQJtbrRDchXmOpPbyrO7ig== X-Received: by 2002:a17:902:c94b:b0:151:9769:34ff with SMTP id i11-20020a170902c94b00b00151976934ffmr3804298pla.104.1646244787279; Wed, 02 Mar 2022 10:13:07 -0800 (PST) Received: from Pavilion-x360.iitbhu.local ([103.151.209.92]) by smtp.googlemail.com with ESMTPSA id s16-20020a63ff50000000b003650ee901e1sm16153121pgk.68.2022.03.02.10.13.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 10:13:06 -0800 (PST) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 23:35:49 +0530 Message-Id: <20220302180556.19865-1-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2 1/8] libavfilter: Prepare to handle specific error codes in DNN Filters X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Shubhanshu Saxena Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +hSkruefo4Bi 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 --- 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 {