From patchwork Wed Mar 10 21:54:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26325 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4CFFE44B799 for ; Wed, 10 Mar 2021 23:55:49 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2C82D68AB7C; Wed, 10 Mar 2021 23:55:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2DB1368AB43 for ; Wed, 10 Mar 2021 23:55:38 +0200 (EET) Received: by mail-ed1-f54.google.com with SMTP id bd6so18093edb.10 for ; Wed, 10 Mar 2021 13:55:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=levCGK4T3hRAQ3ILXIE03lTx33MCny2/um3IVBwcWQk=; b=VwYPwkKtTgqaa6rpGInLNcu9q+eLjdW05LPmhm/EOauq+jtJUD8yaI8XgVEOlqknX5 dRYqTLCBx9vmKpGEh1XQoPc/YQ4QCQiyMBAo0WbKa2P+G/ZHSsWTw95GLWMfgejsz6UT 9mqwyFPXEcW08v23C5TsABjb+K8mOPJTfSLMkBb1kXhJXlSMKa45VuSkR0eKKL4ilDRl fGC+9pOmi+kgxhIgM+9wp0XlwAHMgrxyWlfznP+jAta7i8trkOSPVKaPhuuoJfCoCFOF iO8QHNACtY+6jzLOoOfs+puRS8RyMd6V9xdp+cGqzdxF451J/yK3/4Ja7r45vmgROKZZ hSXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=levCGK4T3hRAQ3ILXIE03lTx33MCny2/um3IVBwcWQk=; b=kEao+MG52HrPQbFbAnbZrRF7LLeGc2qiU2TJwPZUHgVFyfqKE3WRqvPWY1Vbkxqjr1 j/aVnZsW9qHb6ShQ/r8j+bDgvwwAurnDOVE8jMQSCvhsDXQIocxwYXj69LpdCAhtPL6U 4i6Xrwo0TcCsTLfPjROb/I8hHRk93zdlHT8QT8CHoUCqqdKT0xK8LITxI1pewUM+aAdf w67sSGhKaTJfylSYc1hWFVbNOdBMdMAOMvZqyXyGoxnYoblUB4AIwwND2HxLWgMpzkWS oeBnOtrN1V3BBf5UWp9ZDrSjxsOV972uV/OPD9dWCyMIWzNyFC4DcJ3jhrwZW8oDcLZF HRuA== X-Gm-Message-State: AOAM533TSnGFG8UZw+OpLPDlIdTpzZHJOtauKD7YD7kB79bwiwjVzv7J 2/kVsdzeE5BomJyO45QlFwEeeNU280s= X-Google-Smtp-Source: ABdhPJywt6VgFOb+wlLpoCWtfgxmt2BOjBW0H2Tgek5j/LW66i/3TXA/ZXgjSWDqYyjnNV5YmvkASg== X-Received: by 2002:a05:6402:35c9:: with SMTP id z9mr5508841edc.94.1615413337573; Wed, 10 Mar 2021 13:55:37 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id m10sm351993ejx.10.2021.03.10.13.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:55:37 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Mar 2021 22:54:38 +0100 Message-Id: <20210310215446.1396386-6-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210310010601.1142819-1-andreas.rheinhardt@gmail.com> References: <20210310010601.1142819-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/23] dnn/dnn_backend_native_layer_conv2d: Join two arrays, avoid allocation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Fixes Coverity issue #1473507. Signed-off-by: Andreas Rheinhardt --- libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c index 2b83896da9..2e5aacdc2b 100644 --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c @@ -38,6 +38,9 @@ typedef struct ThreadCommonParam{ typedef struct ThreadParam{ ThreadCommonParam *thread_common_param; int thread_start, thread_end; +#if HAVE_PTHREAD_CANCEL + pthread_t thread; +#endif } ThreadParam; int ff_dnn_load_layer_conv2d(Layer *layer, AVIOContext *model_file_context, int file_size, int operands_num) @@ -187,7 +190,6 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera int thread_num = (ctx->options.conv2d_threads <= 0 || ctx->options.conv2d_threads > av_cpu_count()) ? (av_cpu_count() + 1) : (ctx->options.conv2d_threads); #if HAVE_PTHREAD_CANCEL - pthread_t *thread_id = av_malloc_array(thread_num, sizeof(*thread_id)); int thread_stride; #endif ThreadParam **thread_param = av_malloc_array(thread_num, sizeof(*thread_param)); @@ -230,17 +232,15 @@ int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera 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); - pthread_create(&thread_id[i], NULL, dnn_execute_layer_conv2d_thread, (void *)thread_param[i]); + pthread_create(&thread_param[i]->thread, NULL, dnn_execute_layer_conv2d_thread, (void *)thread_param[i]); } //join threads, res gets function return for (int i = 0; i < thread_num; i++){ - pthread_join(thread_id[i], NULL); + pthread_join(thread_param[i]->thread, NULL); } //release memory - av_freep(&thread_id); - for (int i = 0; i < thread_num; i++){ av_freep(&thread_param[i]); }