From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id E64704A837 for ; Wed, 10 Apr 2024 13:31:44 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 21FB768D076; Wed, 10 Apr 2024 16:31:35 +0300 (EEST) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4944168C788 for ; Wed, 10 Apr 2024 16:31:27 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=W9s/F4+f; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 941DE4D72 for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id FJGD-vCcKE0h for ; Wed, 10 Apr 2024 15:31:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1712755884; bh=SG5LCi6nAgTMVl6e13oL/zc9WyLc+RwCqLeAk80aGOM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W9s/F4+fXbKFiSn7Iv0YQetDbZ2EkIFJMz1S+QhguAJevAjTdw6f4uyUnwLfdWMlH mu2Mojow8S8TtDcmOuG8mK70DNRPWVpP0mbOkI7uKH2w5LT+ESgTMpbc8uuLFgLCA/ OGqJJFtGjqVS7AXVBte6NohLAZqCvJFvY2DvXeFpiDM9MWLWmVXiDRiCinoosiMJlc p9lUMQikVIJZwHO+78FUjl1tN6RE2XTahBlLzNfxyt6kdV60Kjxn6dwp1Mm0BN5dGs KorVNc6ko7gmGoI1ChSKSZ/VZOoK5q2Fk9TrO4XCBUcUmyYndJTLtTlbjf8o07wfdh 1knYr4QmKtbEQ== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id A98281D2E for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 908D03A0379 for ; Wed, 10 Apr 2024 15:31:24 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 10 Apr 2024 15:31:10 +0200 Message-ID: <20240410133118.28144-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410133118.28144-1-anton@khirnov.net> References: <20240410133118.28144-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10] lavc/hevcdec: track local context count separately from WPP thread count 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The latter can be lowered while decoding, which would lead to memleaks. --- libavcodec/hevcdec.c | 7 +++++-- libavcodec/hevcdec.h | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index c70937a756..55f72af972 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -2697,11 +2697,13 @@ static int hls_slice_data_wpp(HEVCContext *s, const H2645NAL *nal) } for (i = 1; i < s->threads_number; i++) { - if (s->local_ctx[i]) + if (i < s->nb_local_ctx) continue; s->local_ctx[i] = av_mallocz(sizeof(HEVCLocalContext)); if (!s->local_ctx[i]) return AVERROR(ENOMEM); + s->nb_local_ctx++; + s->local_ctx[i]->logctx = s->avctx; s->local_ctx[i]->parent = s; s->local_ctx[i]->common_cabac_state = &s->cabac; @@ -3475,7 +3477,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx) av_freep(&s->sh.size); if (s->local_ctx) { - for (i = 1; i < s->threads_number; i++) { + for (i = 1; i < s->nb_local_ctx; i++) { av_freep(&s->local_ctx[i]); } } @@ -3504,6 +3506,7 @@ static av_cold int hevc_init_context(AVCodecContext *avctx) s->HEVClc->logctx = avctx; s->HEVClc->common_cabac_state = &s->cabac; s->local_ctx[0] = s->HEVClc; + s->nb_local_ctx = 1; s->output_frame = av_frame_alloc(); if (!s->output_frame) diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 9e3e6a8cd7..a881eb9981 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -442,6 +442,8 @@ typedef struct HEVCContext { AVCodecContext *avctx; HEVCLocalContext **local_ctx; + unsigned nb_local_ctx; + HEVCLocalContext *HEVClc; uint8_t threads_type; -- 2.43.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".