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 6632849293 for ; Tue, 6 Feb 2024 23:00:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BCB7368D109; Wed, 7 Feb 2024 01:00:30 +0200 (EET) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5A13A68BC30 for ; Wed, 7 Feb 2024 01:00:24 +0200 (EET) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 58D81298C5021 for ; Wed, 7 Feb 2024 00:00:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1707260423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QgwOobZykh5qThyCK7YYoBFP33MuyBaMfWug2k+otaQ=; b=DUDkZ5mp98Z8cfUwwNvhxLGAHqQ/rim6GJd4vMOLn3IiAHR0HdzjmB6whh85l/m+NMBXk3 JuuhhH7U9gkUlt2t+RGLwr2dMUTjt/yQFXnLA0bjX/1ls9eN+OGpeRLY2eSztlM0G55KoW 6eyLI3XzUKvY00XINUhRPH+UjuPKKGpAhY8lJuGE1x+wQ/IRpy2nBoDdqpV4nq6hj6g8D8 iyxrEfmZefMg0uhVG5L6N5tSp34Ci4OFthe5lqn7U3WxSCZ7wxSaFRWTfGKHFAbbaRQIN5 MYP0S1AyhBk5AfCpopo/Zet+nCc0mpHjgevE05gBpL+hcmquetXu93L1515oOg== Message-ID: Date: Wed, 7 Feb 2024 00:00:21 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240206225735.12251-1-jamrial@gmail.com> From: Timo Rothenpieler In-Reply-To: <20240206225735.12251-1-jamrial@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/nvdec: don't free NVDECContext->bitstream 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-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 06.02.2024 23:57, James Almer wrote: > Ensure all hwaccels that allocate a buffer use NVDECContext->bitstream_internal. > > Signed-off-by: James Almer > --- > libavcodec/nvdec.c | 2 +- > libavcodec/nvdec_h264.c | 4 ++-- > libavcodec/nvdec_hevc.c | 4 ++-- > 3 files changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c > index 27be644356..d13b790632 100644 > --- a/libavcodec/nvdec.c > +++ b/libavcodec/nvdec.c > @@ -259,8 +259,8 @@ int ff_nvdec_decode_uninit(AVCodecContext *avctx) > { > NVDECContext *ctx = avctx->internal->hwaccel_priv_data; > > - av_freep(&ctx->bitstream); > av_freep(&ctx->bitstream_internal); > + ctx->bitstream = NULL; > ctx->bitstream_len = 0; > ctx->bitstream_allocated = 0; > > diff --git a/libavcodec/nvdec_h264.c b/libavcodec/nvdec_h264.c > index f022619b64..8c72d5f4f7 100644 > --- a/libavcodec/nvdec_h264.c > +++ b/libavcodec/nvdec_h264.c > @@ -138,11 +138,11 @@ static int nvdec_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > const H264SliceContext *sl = &h->slice_ctx[0]; > void *tmp; > > - tmp = av_fast_realloc(ctx->bitstream, &ctx->bitstream_allocated, > + tmp = av_fast_realloc(ctx->bitstream_internal, &ctx->bitstream_allocated, > ctx->bitstream_len + size + 3); > if (!tmp) > return AVERROR(ENOMEM); > - ctx->bitstream = tmp; > + ctx->bitstream = ctx->bitstream_internal = tmp; > > tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated, > (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets)); > diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c > index b83d5edcf9..25319a1328 100644 > --- a/libavcodec/nvdec_hevc.c > +++ b/libavcodec/nvdec_hevc.c > @@ -274,11 +274,11 @@ static int nvdec_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > NVDECContext *ctx = avctx->internal->hwaccel_priv_data; > void *tmp; > > - tmp = av_fast_realloc(ctx->bitstream, &ctx->bitstream_allocated, > + tmp = av_fast_realloc(ctx->bitstream_internal, &ctx->bitstream_allocated, > ctx->bitstream_len + size + 3); > if (!tmp) > return AVERROR(ENOMEM); > - ctx->bitstream = tmp; > + ctx->bitstream = ctx->bitstream_internal = tmp; > > tmp = av_fast_realloc(ctx->slice_offsets, &ctx->slice_offsets_allocated, > (ctx->nb_slices + 1) * sizeof(*ctx->slice_offsets)); bitstream_internal was added for the av1 slice reconstructions. Probably for the exact reason to avoid this confusion. Looking at this some more... With this patch in place, there should never be a situation in which we want to free/freep ctx->bitstream? So the freep() on it should probably be removed alongside, and replace with just setting it to NULL. _______________________________________________ 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".