From patchwork Thu Feb 24 08:22:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 34504 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp1616066nkx; Thu, 24 Feb 2022 00:23:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzUOyFayaNkOFhWnkdo8emG6diyoanJzKM49b/QaETIF2oeqddZsbK3xFrSIUYLi6mifm+S X-Received: by 2002:a05:6402:294e:b0:40f:905b:dab5 with SMTP id ed14-20020a056402294e00b0040f905bdab5mr1224672edb.103.1645690991766; Thu, 24 Feb 2022 00:23:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645690991; cv=none; d=google.com; s=arc-20160816; b=r7WMVUffevKevJXhbydhOhCLIfN+gR6lxgddfj44hW0CcNsZPZMopUvnAxOiP9nfsu rwTX7uW4iH+ObLXG3WDkks/6wQx54s10I8hPRLLP874rzDpxTiwp8dam6rZKdmcxtbnB OL6Va6eOiJN9cbJoGhE0GRQqFwnIF8GokQvQFzrR5UTLMsiuhq4VhUV0JECbQoB/gqHX S4e5Ye3/7vd8JwQJ2R07P5PnFBLrC6AD5te/UTlW7hW+Z/nKpqmQ9tTj9yMTU4+Jo9bQ oY6ZCByciPjj7u37YgyJrvPtU2BRVcpTqynw1fK1QfTwWVVXiXso2ZvGC/K8aNohQoP6 ujsQ== 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=PUVsZCbUDazOz/NyjfDhZjpHfItNqarlkXKVywyrIF1JQlQpTyjt3tCViKo6RQH553 TAYbiiXt+zieF+OpMT7HANuByvwZUKcod0WTfDduzeYMQxGTjvSkpVi6H5mTjKzmXSUF hHGYYmkQqcxntpmPn2ScgNDwyEz50pS5d8oz9/Ry14Is/ptyFQO8S/+za6+Eaix26arr rRbLXCV2cUx0V8et4rGFE/evawdE44qo0RUMZOd1yKd8S9JtDf9wwSAYOZqE9WRNvbyS eNnKFWiWjT3SPMebe6oU+rlpt9W2K6xvL2P7XxafQOgrdhgaoiFE+A/3/+rQGt4EfXso gH3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=aTjCK1hE; 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 ej24si1214146edb.477.2022.02.24.00.23.10; Thu, 24 Feb 2022 00:23:11 -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=aTjCK1hE; 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 3C9CA68B244; Thu, 24 Feb 2022 10:23:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 871C968B192 for ; Thu, 24 Feb 2022 10:22:59 +0200 (EET) Received: by mail-pl1-f172.google.com with SMTP id m11so1058237pls.5 for ; Thu, 24 Feb 2022 00:22:59 -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=aTjCK1hEXE1hqIdkrWeGMbhmg6wcTs8WnGWwdYPRTmQbDqTuaGhSEHN1ko9UPouR6p IdZAR8REtk2zjx/0ncjvRcZPUr0UQXENp/I0hsr+ECF9Z03NAbjcAMj9/AA9IN8oZJPa jH4lNerfpsZ7+Vl8M5D5BlJFIgzQogvXRoHdnWbcmPrgkaFhaCmOwUpGghDapK2Jsqq6 2CujH84Rm2EO6DYHS3xR0REvj7qK8mfJ3cKALyBqBdPhIN0gnkX6gbE2gA1m+CXdBpwk uYK8fro5+XSHNJgdyAAgF17WNqSeQIo+kxaUo7JCOQ3UVPG9utq7QvntPNHfOmcdE7vp zw0A== 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=ArYXH0QZIJh6rNTHIdKEYgU5Aw8OBIzEm4ZZ9+dEqsJxUW8BJwbhII3At55tuMFJ1V xezTNDnSmHBNJqrE/mRHr76JWzZgg+7JLhxlU25DM58hr5yy67qtemr3kSGojNEjw9/l WkPcU1bskFhUVuyxCbyuZdokyypFla8A+pPDFxKgWD+Pyr6qqM5HOpE2QDoTlTtkxVce If6rMBdqCpDksFA85DdK7xKsLcXIiwRrGvXw1mcNrxEs7/0rmfBM8VTR3nWJTchCeZrU u5p9+qVKLN2YBfnV8BVUYe6D7vhfg9xyVAYEpM3r/eqeTUMZY6L1yFR1e5xGue44DsNq FE6w== X-Gm-Message-State: AOAM5332OktQD5Z2PGnxs9xHpbiWdVQa/ok4oJlVot4GejiCDXuC6ZQd ovOwdK20fu5XS83KBHNBmsSxFFyndjgVTA== X-Received: by 2002:a17:90b:3682:b0:1bc:3891:b266 with SMTP id mj2-20020a17090b368200b001bc3891b266mr1667956pjb.137.1645690976953; Thu, 24 Feb 2022 00:22:56 -0800 (PST) Received: from Pavilion-x360.bbrouter ([103.133.123.155]) by smtp.googlemail.com with ESMTPSA id k11sm2174503pff.169.2022.02.24.00.22.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 00:22:56 -0800 (PST) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Thu, 24 Feb 2022 13:52:36 +0530 Message-Id: <20220224082243.11208-1-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: DYmXXer6dKxk 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 {