From patchwork Wed Mar 2 18:05:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 34577 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:d078:0:0:0:0 with SMTP id x24csp4883525nkx; Wed, 2 Mar 2022 10:13:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwo3W1akZ0oCRCTI/9x/W3QA7RlCVPnOMgl3Je2mL6jlNm9NsLuZu9+bWAHYAmrgOb7WbhZ X-Received: by 2002:a17:906:a398:b0:6ce:71b:deff with SMTP id k24-20020a170906a39800b006ce071bdeffmr23615531ejz.204.1646244834606; Wed, 02 Mar 2022 10:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646244834; cv=none; d=google.com; s=arc-20160816; b=bBZKHBdfxyWw8EJYWjA0mduSM1nRSJIi1Erp5a1hZEDPC/PRJ3blWe9DCqJxcDcXqV rSnsh/rqhFzO4ngP36a6wHdninz8S3W/71F8Zp5bTTq9K3AFs9y6Bk477A4xoH0eQJ+T x9Diuc0UlCgSdOCMkCr40ASC9v6OTB7KCWB4DSHMjRxduLmeqTBKZgi/8Iqw1x2OIWFw m1p2bdv6YklehjhCMFr+FY0v+rLPKKdcG+mo1XXELEBRXAnyBjp4XOPvteiIIq3QQd/z gHdQ2WjJWMzIPc1k1DXIXWl5G0Xe5WlI8Qxlb4UKivbd30qEucvGNdhipyMRgZbEYE48 Y7zQ== 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=lBp6oWYaaBb3N7gw5VU166lhFv+AD+r6ap+/TQK7zWI=; b=aKfSMINK05rhuomoEzf3VXO/fUppFFPfa5W25zo9SVcVfRmgOomkKd9KP4RruwPyHW Mv1BO6xlLGuhXEuaaZQdnHRBVqbgY5ubBMJAKblz2pO99qcOUt2W31LyrWfrR1iu8kVZ 5mRLeXXxJyu/dcjlmPsFvn8Z5RnldpvnRbfY+lKUYRSfnWhQIKLTh7acG9xUNYXCjCYU GChYiClP3FgwqhuNVRGJ9H4TEuoUh+j1KdzBFsaZcmPV+fkIpyiCMJt9EfueKfUOYsgb 1DrNRNKAMND4xGUiz9ALn853bZPe15BZ4he3SvcQQ9tMi/i0oMlowW7HqC9MPKPWf59h LyGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=nlTQl6LN; 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 r24-20020aa7cfd8000000b00410ee99fc4fsi10971087edy.247.2022.03.02.10.13.32; Wed, 02 Mar 2022 10:13:54 -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=nlTQl6LN; 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 9F15068B302; Wed, 2 Mar 2022 20:13:18 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3562368B2F8 for ; Wed, 2 Mar 2022 20:13:12 +0200 (EET) Received: by mail-pg1-f176.google.com with SMTP id 132so2317321pga.5 for ; Wed, 02 Mar 2022 10:13:12 -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=D8iuWV1nCXSRo5aILmGVMPQ1WT8rf7/mHmiQp0jKS8k=; b=nlTQl6LNciBeOnZZleB/7ga+rG39xYHen0rlnNbEDcBvOZoVHDb19hgahOr8Q+QqjJ b7MAkLikulmBVB2cTdUWGyyivrqRzqU4BYekGLZniuWRwgXLScbAuzu4ziLV8GV2zip9 bhHcg9pWjUdUqVhgnfh55gQc1nTQ6nCvvlYgJNRsJwc3AJsUrVguH5gKKQZ40N2xCMIE GoVjniKpw9Uo7j23QGn7peJn/7gMpegLBvyHXZkAS5jWLm48wvpazvZvwaKXBy4lOTxj fAlkV4B/cCP+s+e4iopwkCkSRHTOioc9Repwfj0LpmEKFs7sXHxZgUqOdlaLTG93h2uU drNA== 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=D8iuWV1nCXSRo5aILmGVMPQ1WT8rf7/mHmiQp0jKS8k=; b=P4gccFKq0iTtM/GNjhCKToFUtSHEPbCu7NgQIOszEDVQsL1/fvV3JKPgnuG57tFtpS qLt2law+ZmYylFMEorFC7TR9u/pu89CqbJkXU1aNS8RZCh62H3OypctdOUiP7EIHgihA WaeRnSKyZiu0e6Q+syjCBbhHms3eDjdaZuxx0JZmDJgTygGiLaFav8zwwNcjM7lCitqh mJAwd7YJLpE19mpR6Eucm1pYAvJT11XHFx0m6+r79u5B+dPuUboQdILSWOUqXuZEqR0f sOxHSekXspQ4RRMycoY/qVdcXEOzFv5XCG9lCGNiQE2iVH1TsSmv6Skd8sjl0DX0hYnL ViAg== X-Gm-Message-State: AOAM533ubsyhvKqbpHGvd+313Hoj78kKokeMPhsTy++q8ri5atvIWqbm Cwo9nzzI3W7BFGOMi0iF4Z+yQMKRg+U0Vw== X-Received: by 2002:a05:6a00:1a04:b0:4e1:786c:cce3 with SMTP id g4-20020a056a001a0400b004e1786ccce3mr34259412pfv.81.1646244790019; Wed, 02 Mar 2022 10:13:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 10:13:09 -0800 (PST) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Wed, 2 Mar 2022 23:35:50 +0530 Message-Id: <20220302180556.19865-2-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220302180556.19865-1-shubhanshu.e01@gmail.com> References: <20220302180556.19865-1-shubhanshu.e01@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH V2 2/8] lavfi/dnn: Error Specificity in Native Backend Layers 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: ZQ9lWa4Hv5bU This commit returns specific error codes from the execution functions in the Native Backend layers instead of DNN_ERROR. Signed-off-by: Shubhanshu Saxena --- libavfilter/dnn/dnn_backend_native_layer_avgpool.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_avgpool.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 14 ++++++++------ libavfilter/dnn/dnn_backend_native_layer_conv2d.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_dense.c | 6 +++--- libavfilter/dnn/dnn_backend_native_layer_dense.h | 3 ++- .../dnn/dnn_backend_native_layer_depth2space.c | 6 +++--- .../dnn/dnn_backend_native_layer_depth2space.h | 3 ++- .../dnn/dnn_backend_native_layer_mathbinary.c | 6 +++--- .../dnn/dnn_backend_native_layer_mathunary.c | 6 +++--- .../dnn/dnn_backend_native_layer_mathunary.h | 3 ++- libavfilter/dnn/dnn_backend_native_layer_maximum.c | 4 ++-- libavfilter/dnn/dnn_backend_native_layer_pad.c | 4 ++-- libavfilter/dnn_interface.h | 2 ++ 14 files changed, 39 insertions(+), 30 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c index 89f1787523..510a28a8c9 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.c +++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.c @@ -109,12 +109,12 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_ope output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } output = output_operand->data; @@ -143,5 +143,5 @@ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_ope } } - return 0; + return DNN_SUCCESS; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h index d8972487de..118a160090 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_avgpool.h +++ b/libavfilter/dnn/dnn_backend_native_layer_avgpool.h @@ -60,7 +60,8 @@ int ff_dnn_load_layer_avg_pool(Layer *layer, AVIOContext *model_file_context, in * @param parameters average pooling parameters * @param ctx pointer to Native model context for logging * @retval 0 if the execution succeeds - * @retval DNN_ERROR if the execution fails + * @retval AVERROR(ENOMEM) if memory allocation fails + * @retval AVERROR(EINVAL) for invalid arguments */ int ff_dnn_execute_layer_avg_pool(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx); diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 7a60aa6a4b..dfa0d1ed36 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -211,12 +211,12 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } tmp = av_realloc(output_operand->data, output_operand->length); if (!tmp) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } output_operand->data = tmp; thread_common_param.output_data = output_operand->data; @@ -229,17 +229,19 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera #if HAVE_PTHREAD_CANCEL thread_param = av_malloc_array(thread_num, sizeof(*thread_param)); if (!thread_param) - return DNN_ERROR; + return AVERROR(ENOMEM); thread_stride = (height - pad_size * 2) / thread_num; //create threads for (int i = 0; i < thread_num; i++){ + int thread_ret = 0; thread_param[i].thread_common_param = &thread_common_param; thread_param[i].thread_start = thread_stride * i + pad_size; thread_param[i].thread_end = (i == thread_num - 1) ? (height - pad_size) : (thread_param[i].thread_start + thread_stride); - if (pthread_create(&thread_param[i].thread, NULL, - dnn_execute_layer_conv2d_thread, &thread_param[i])) { + thread_ret = pthread_create(&thread_param[i].thread, NULL, + dnn_execute_layer_conv2d_thread, &thread_param[i]); + if (thread_ret) { thread_num = i; - ret = DNN_ERROR; + ret = AVERROR(thread_ret); break; } } diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h index 446f48f608..f754a9ba18 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.h +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.h @@ -60,7 +60,8 @@ int ff_dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int * @param parameters convolution parameters * @param ctx pointer to Native model context for logging * @retval 0 if the execution succeeds - * @retval DNN_ERROR if the execution fails + * @retval AVERROR(ENOMEM) if memory allocation fails + * @retval AVERROR(EINVAL) for invalid arguments */ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx); diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.c b/libavfilter/dnn/dnn_backend_native_layer_dense.c index 117590d7bb..a22a484464 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_dense.c +++ b/libavfilter/dnn/dnn_backend_native_layer_dense.c @@ -104,12 +104,12 @@ int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operan output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } output = output_operand->data; @@ -147,5 +147,5 @@ int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operan output += dense_params->output_num; } } - return 0; + return DNN_SUCCESS; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_dense.h b/libavfilter/dnn/dnn_backend_native_layer_dense.h index 0488b03cc3..607fc3e684 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_dense.h +++ b/libavfilter/dnn/dnn_backend_native_layer_dense.h @@ -57,7 +57,8 @@ int ff_dnn_load_layer_dense(Layer *layer, AVIOContext *model_file_context, int f * @param parameters dense layer parameters * @param ctx pointer to Native model context for logging * @retval 0 if the execution succeeds - * @retval DNN_ERROR if the execution fails + * @retval AVERROR(ENOMEM) if memory allocation fails + * @retval AVERROR(EINVAL) for invalid arguments */ int ff_dnn_execute_layer_dense(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx); diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c index 30ced43cd5..82b1a52be2 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.c +++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.c @@ -76,12 +76,12 @@ int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_ output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } output = output_operand->data; @@ -98,5 +98,5 @@ int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_ } output += output_linesize; } - return 0; + return DNN_SUCCESS; } diff --git a/libavfilter/dnn/dnn_backend_native_layer_depth2space.h b/libavfilter/dnn/dnn_backend_native_layer_depth2space.h index 2792a33ebe..aaf2df4c13 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_depth2space.h +++ b/libavfilter/dnn/dnn_backend_native_layer_depth2space.h @@ -63,7 +63,8 @@ int ff_dnn_load_layer_depth2space(Layer *layer, AVIOContext *model_file_context, * @param parameters depth to space layer parameters * @param ctx pointer to Native model context for logging * @retval 0 if the execution succeeds - * @retval DNN_ERROR if the execution fails + * @retval AVERROR(ENOMEM) if memory allocation fails + * @retval AVERROR(EINVAL) for invalid arguments */ int ff_dnn_execute_layer_depth2space(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx); diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c index 81901c56d9..1a3fa3f132 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathbinary.c @@ -159,12 +159,12 @@ int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_ output->length = ff_calculate_operand_data_length(output); if (output->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output->data = av_realloc(output->data, output->length); if (!output->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } switch (params->bin_op) { @@ -188,6 +188,6 @@ int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_ return 0; default: av_log(ctx, AV_LOG_ERROR, "Unmatch math binary operator\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c index b8694910d9..e3c5106e5e 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.c +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.c @@ -68,12 +68,12 @@ int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_o output->length = ff_calculate_operand_data_length(output); if (output->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output->data = av_realloc(output->data, output->length); if (!output->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } dims_count = ff_calculate_operand_dims_count(output); @@ -151,6 +151,6 @@ int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_o return 0; default: av_log(ctx, AV_LOG_ERROR, "Unmatch math unary operator\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } } diff --git a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h index ed79947896..806e73b29f 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_mathunary.h +++ b/libavfilter/dnn/dnn_backend_native_layer_mathunary.h @@ -83,7 +83,8 @@ int ff_dnn_load_layer_math_unary(Layer *layer, AVIOContext *model_file_context, * @param parameters unary math layer parameters * @param ctx pointer to Native model context for logging * @retval 0 if the execution succeeds - * @retval DNN_ERROR if the execution fails + * @retval AVERROR(ENOMEM) if memory allocation fails + * @retval AVERROR(EINVAL) for invalid arguments */ int ff_dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx); diff --git a/libavfilter/dnn/dnn_backend_native_layer_maximum.c b/libavfilter/dnn/dnn_backend_native_layer_maximum.c index a38759eeee..667efaa3b8 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_maximum.c +++ b/libavfilter/dnn/dnn_backend_native_layer_maximum.c @@ -65,12 +65,12 @@ int ff_dnn_execute_layer_maximum(DnnOperand *operands, const int32_t *input_oper output->length = ff_calculate_operand_data_length(output); if (output->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output->data = av_realloc(output->data, output->length); if (!output->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } dims_count = ff_calculate_operand_dims_count(output); diff --git a/libavfilter/dnn/dnn_backend_native_layer_pad.c b/libavfilter/dnn/dnn_backend_native_layer_pad.c index a60451a8de..e274fe12c6 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_pad.c +++ b/libavfilter/dnn/dnn_backend_native_layer_pad.c @@ -113,12 +113,12 @@ int ff_dnn_execute_layer_pad(DnnOperand *operands, const int32_t *input_operand_ output_operand->length = ff_calculate_operand_data_length(output_operand); if (output_operand->length <= 0) { av_log(ctx, AV_LOG_ERROR, "The output data length overflow\n"); - return DNN_ERROR; + return AVERROR(EINVAL); } output_operand->data = av_realloc(output_operand->data, output_operand->length); if (!output_operand->data) { av_log(ctx, AV_LOG_ERROR, "Failed to reallocate memory for output\n"); - return DNN_ERROR; + return AVERROR(ENOMEM); } output = output_operand->data; diff --git a/libavfilter/dnn_interface.h b/libavfilter/dnn_interface.h index 37e89d9789..24e0b66661 100644 --- a/libavfilter/dnn_interface.h +++ b/libavfilter/dnn_interface.h @@ -30,6 +30,8 @@ #include "libavutil/frame.h" #include "avfilter.h" +#define DNN_GENERIC_ERROR FFERRTAG('D','N','N','!') + typedef enum {DNN_SUCCESS, DNN_ERROR} DNNReturnType; typedef enum {DNN_NATIVE, DNN_TF, DNN_OV} DNNBackendType;