From patchwork Thu Feb 24 08:22:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 34506 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp1616260nkx; Thu, 24 Feb 2022 00:23:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6lbvAre/5yaxQeA14tMb0PPhGLeY0nJ26QxW7EBVDyUq/WBa0SDGUvsCGBneY9Yxsik1o X-Received: by 2002:a17:906:1ccb:b0:6b9:f52:5c60 with SMTP id i11-20020a1709061ccb00b006b90f525c60mr1319955ejh.509.1645691013374; Thu, 24 Feb 2022 00:23:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645691013; cv=none; d=google.com; s=arc-20160816; b=hnLgz19/wUGx0Ec1sfGYiThPrwErhctkrLdFiz8jNzqfjjyicR7MJOfrFPZyHYbkgM lq0TfjyUf1MzSPG+f5bOy8WyNqmSnGY8NmK9fbETiRVLkbH1YQlmiKMYtJW2aZKwp4sj DhXI5z4vpCCtn+nHWajd2LNN3J5rHchmMv1ll5o/hNpX217jaHfkj1PMaNeaOloz43Ba 1ILDm5BtUAsRTYSJMMOI8pZjZXd2hS6nufvhtw723KK+vmexL9JH95W6DxWcTo6sLFin p8v0QA9v2KjipG494AVrGwwX5frOHPTdYK6QcipIupYNltPWQzOntx9nYQNe2s8Ro15/ H8Gg== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=ljfozuquWa6Krdeay+pTBQvuyrJrYfB6WNFW0NKM9ic=; b=TY9rjssWxtK7KoDToQYuj0O1imR0vuWfoEVk0fZ3IRulgHlb1V/3RWK0uca2fh0bXC I/DFp8I7Nw1IJhBCR9LetTwzbUqeeRbLbvkh82ZgNGd6NBMeFU7ThtYUXORSahiEJ5EL W2GeExF9eNkC7d+BvcrXCZYOE9xnjbqzI8Rg+6V8anfQ2uh4AYBByfOeX+vCnuGzfPLl oaGYan3HKLqu7oWXlDkctKPtmslsX4zX1ch+vJnYwuhBpK/FY0Jsag/UaD5oe96SkwGB +rOmSV64q/RI6Y0i6ApuCXCSGgzNItFbR0DCbmgb5fij1olK418v7PlJkqU+5hM4pXLy A99Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=CMwwrJnq; 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 13si1143102ejf.580.2022.02.24.00.23.32; Thu, 24 Feb 2022 00:23:33 -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=CMwwrJnq; 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 67BED68B1DD; Thu, 24 Feb 2022 10:23:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EDF0A68B2B1 for ; Thu, 24 Feb 2022 10:23:09 +0200 (EET) Received: by mail-pj1-f51.google.com with SMTP id bx9-20020a17090af48900b001bc64ee7d3cso1381207pjb.4 for ; Thu, 24 Feb 2022 00:23: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=lTZVxjNumPZPhRJGzBGn+cWsBbQZUdQTJGQW8gO/OSY=; b=CMwwrJnqd0nbM8sqHM/pm4coLtkVPsfohmWkLIuF7wDMOCOXNtF0aRxefC0jBw8SEd VtQ+taN90VvOZAxTDjUBXtfzjtocKCnJKRjO9FAwfoFNBKw3VdbZjMN3GyGxrWmB7kUx Ny1O0uvfztMrnBLB58B7k9dYVBTcQJG77wOmrQjeqSjLMlB98YmJH7pH6w0APAO/yJm7 T7Hf78pO+yy2I0lxqyAzEEKKhGVv7NwHSqUXc3c920ufnyK44KCoYBLAa2xSlxwML6GK nDEY1HivqL/ghRANGT7ECXJgoRwcIrFJuxAMjissvzvuKBhyE/QCoQVu7hSuardNCyu+ FpKQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lTZVxjNumPZPhRJGzBGn+cWsBbQZUdQTJGQW8gO/OSY=; b=VGbqNgH5JgBcz24TWUa/SXFn9gyF99d2JjihR7duXKWLHOnIMoNk8NHDH6wbQR5uz0 imfeY1x/a6fzxAxjDbIqbd2yNDY31bE71j+cBODZ62LAbxBj/30x/LttAErYEWib/MYM kdVRsTtReH1JK1Z8BnZo6Lr0f+L0iSOZQ/lSbWdguyglPjAQzX6+c9mzvFr+lFu0ODp/ mbKbXL2GqIKi4MS69Qb5l9mUDYtXdgmw9yM4DqsRsqQxKN5+9OVBFhNGVGC+YQ+FMP4d +nJr+I+PAXDKpXRkqL92PnxdPzV2AIGaBN6Jz+UQjwP1/VU5PnDVAekKMnp8i6n2XOEc 9a4Q== X-Gm-Message-State: AOAM533mVXnZloxkpijhjFoHI9vASgACoLK7phHLkfWqjZGPr9QHIJWc kM9ZAHkV9FSqrxZ2CJ5FexuN6FkFQiQ9FQ== X-Received: by 2002:a17:902:eaca:b0:14f:fb38:f7b8 with SMTP id p10-20020a170902eaca00b0014ffb38f7b8mr1731735pld.145.1645690988198; Thu, 24 Feb 2022 00:23:08 -0800 (PST) Received: from Pavilion-x360.bbrouter ([103.133.123.155]) by smtp.googlemail.com with ESMTPSA id k11sm2174503pff.169.2022.02.24.00.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 00:23:07 -0800 (PST) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Thu, 24 Feb 2022 13:52:38 +0530 Message-Id: <20220224082243.11208-3-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220224082243.11208-1-shubhanshu.e01@gmail.com> References: <20220224082243.11208-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] lavfi/dnn_io_proc: Return Specific Error Codes 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: U7m6bVr6TPP4 This commit returns specific error codes from the functions in the dnn_io_proc instead of DNN_ERROR. Signed-off-by: Shubhanshu Saxena --- libavfilter/dnn/dnn_io_proc.c | 48 +++++++++++++++++++---------------- libavfilter/dnn/dnn_io_proc.h | 8 +++--- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/libavfilter/dnn/dnn_io_proc.c b/libavfilter/dnn/dnn_io_proc.c index f55424d97c..36cc051e5e 100644 --- a/libavfilter/dnn/dnn_io_proc.c +++ b/libavfilter/dnn/dnn_io_proc.c @@ -24,16 +24,16 @@ #include "libavutil/avassert.h" #include "libavutil/detection_bbox.h" -DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx) +int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx) { struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); if (bytewidth < 0) { - return DNN_ERROR; + return AVERROR(EINVAL); } if (output->dt != DNN_FLOAT) { avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT"); - return DNN_ERROR; + return AVERROR(ENOSYS); } switch (frame->format) { @@ -51,7 +51,7 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32), frame->width * 3, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width * 3, frame->height); - return DNN_ERROR; + return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0}, (const int[4]){frame->width * 3 * sizeof(float), 0, 0, 0}, 0, frame->height, @@ -82,7 +82,7 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32), frame->width, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width, frame->height); - return DNN_ERROR; + return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t *[4]){(const uint8_t *)output->data, 0, 0, 0}, (const int[4]){frame->width * sizeof(float), 0, 0, 0}, 0, frame->height, @@ -91,22 +91,22 @@ DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *l return DNN_SUCCESS; default: avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format)); - return DNN_ERROR; + return AVERROR(ENOSYS); } return DNN_SUCCESS; } -DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx) +int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx) { struct SwsContext *sws_ctx; int bytewidth = av_image_get_linesize(frame->format, frame->width, 0); if (bytewidth < 0) { - return DNN_ERROR; + return AVERROR(EINVAL); } if (input->dt != DNN_FLOAT) { avpriv_report_missing_feature(log_ctx, "data type rather than DNN_FLOAT"); - return DNN_ERROR; + return AVERROR(ENOSYS); } switch (frame->format) { @@ -124,7 +124,7 @@ DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *lo "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width * 3, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32),frame->width * 3, frame->height); - return DNN_ERROR; + return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t **)frame->data, frame->linesize, 0, frame->height, @@ -156,7 +156,7 @@ DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *lo "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(AV_PIX_FMT_GRAY8), frame->width, frame->height, av_get_pix_fmt_name(AV_PIX_FMT_GRAYF32),frame->width, frame->height); - return DNN_ERROR; + return AVERROR(EINVAL); } sws_scale(sws_ctx, (const uint8_t **)frame->data, frame->linesize, 0, frame->height, @@ -166,7 +166,7 @@ DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *lo break; default: avpriv_report_missing_feature(log_ctx, "%s", av_get_pix_fmt_name(frame->format)); - return DNN_ERROR; + return AVERROR(ENOSYS); } return DNN_SUCCESS; @@ -190,13 +190,14 @@ static enum AVPixelFormat get_pixel_format(DNNData *data) return AV_PIX_FMT_BGR24; } -DNNReturnType ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index, void *log_ctx) +int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index, void *log_ctx) { const AVPixFmtDescriptor *desc; int offsetx[4], offsety[4]; uint8_t *bbox_data[4]; struct SwsContext *sws_ctx; int linesizes[4]; + int ret = DNN_SUCCESS; enum AVPixelFormat fmt; int left, top, width, height; const AVDetectionBBoxHeader *header; @@ -221,13 +222,14 @@ DNNReturnType ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(frame->format), width, height, av_get_pix_fmt_name(fmt), input->width, input->height); - return DNN_ERROR; + return AVERROR(EINVAL); } - if (av_image_fill_linesizes(linesizes, fmt, input->width) < 0) { + ret = av_image_fill_linesizes(linesizes, fmt, input->width); + if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "unable to get linesizes with av_image_fill_linesizes"); sws_freeContext(sws_ctx); - return DNN_ERROR; + return ret; } desc = av_pix_fmt_desc_get(frame->format); @@ -246,13 +248,14 @@ DNNReturnType ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t sws_freeContext(sws_ctx); - return DNN_SUCCESS; + return ret; } -DNNReturnType ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx) +int ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx) { struct SwsContext *sws_ctx; int linesizes[4]; + int ret = DNN_SUCCESS; enum AVPixelFormat fmt = get_pixel_format(input); sws_ctx = sws_getContext(frame->width, frame->height, frame->format, input->width, input->height, fmt, @@ -262,18 +265,19 @@ DNNReturnType ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_c "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n", av_get_pix_fmt_name(frame->format), frame->width, frame->height, av_get_pix_fmt_name(fmt), input->width, input->height); - return DNN_ERROR; + return AVERROR(EINVAL); } - if (av_image_fill_linesizes(linesizes, fmt, input->width) < 0) { + ret = av_image_fill_linesizes(linesizes, fmt, input->width); + if (ret < 0) { av_log(log_ctx, AV_LOG_ERROR, "unable to get linesizes with av_image_fill_linesizes"); sws_freeContext(sws_ctx); - return DNN_ERROR; + return ret; } sws_scale(sws_ctx, (const uint8_t *const *)frame->data, frame->linesize, 0, frame->height, (uint8_t *const [4]){input->data, 0, 0, 0}, linesizes); sws_freeContext(sws_ctx); - return DNN_SUCCESS; + return ret; } diff --git a/libavfilter/dnn/dnn_io_proc.h b/libavfilter/dnn/dnn_io_proc.h index daef01aceb..a3dd94675b 100644 --- a/libavfilter/dnn/dnn_io_proc.h +++ b/libavfilter/dnn/dnn_io_proc.h @@ -30,9 +30,9 @@ #include "../dnn_interface.h" #include "libavutil/frame.h" -DNNReturnType ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx); -DNNReturnType ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx); -DNNReturnType ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx); -DNNReturnType ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index, void *log_ctx); +int ff_proc_from_frame_to_dnn(AVFrame *frame, DNNData *input, void *log_ctx); +int ff_proc_from_dnn_to_frame(AVFrame *frame, DNNData *output, void *log_ctx); +int ff_frame_to_dnn_detect(AVFrame *frame, DNNData *input, void *log_ctx); +int ff_frame_to_dnn_classify(AVFrame *frame, DNNData *input, uint32_t bbox_index, void *log_ctx); #endif