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 AD2A548BDF for ; Wed, 7 Feb 2024 22:35:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 71CA868D1A2; Thu, 8 Feb 2024 00:35:13 +0200 (EET) Received: from btbn.de (btbn.de [144.76.60.213]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1DB4B68CADA for ; Thu, 8 Feb 2024 00:35:07 +0200 (EET) Received: from [authenticated] by btbn.de (Postfix) with ESMTPSA id 0403128A8E09C for ; Wed, 7 Feb 2024 23:35:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rothenpieler.org; s=mail; t=1707345306; 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=N1WdxN3DmvKKp+4f5J0JzRM2w3TGiqaPaanKD301wXc=; b=WbUaf6rRh3rqeB3ky/896H2H1cZSM8Ah5RCcVP1QL53gJkJQtZeLx/120pWWQ9onj76lu1 sm1X7+SVgs9U24975j40RNVKKnivGRT2C70MvXuugcBX5HTNPZrc29ZPr8deyfaZeSwv4G B6uBcoUZGsxZS5M4m24E94VyHL2YzptAxLCBAD0f/b/amWqkNlwv8kYT65uCbhbT4MQQfr nbqSOPPcnHhEBkkMeyyHdYthp6Gc8H2V86RsTWQzDReXNTnn2utZW54KjKfaH6S9j+3n5J mrkzyLteYjaOtrF8KjqZl2ZHNd14JhxwT0UHgTgpey80+4lhwh3YXZSDjyuSyQ== Message-ID: <6abd1314-9721-48a9-89bc-707f563fa2e0@rothenpieler.org> Date: Wed, 7 Feb 2024 23:35:05 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: Content-Language: en-US From: Timo Rothenpieler In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] avcodec/nvdec: Constify bitstream pointee 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 07.02.2024 16:04, Andreas Rheinhardt wrote: > Signed-off-by: Andreas Rheinhardt > --- > libavcodec/nvdec.c | 2 +- > libavcodec/nvdec.h | 2 +- > libavcodec/nvdec_av1.c | 4 ++-- > libavcodec/nvdec_h264.c | 4 ++-- > libavcodec/nvdec_hevc.c | 4 ++-- > 5 files changed, 8 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/nvdec.c b/libavcodec/nvdec.c > index d13b790632..553c9bdf18 100644 > --- a/libavcodec/nvdec.c > +++ b/libavcodec/nvdec.c > @@ -680,7 +680,7 @@ int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > ctx->slice_offsets = tmp; > > if (!ctx->bitstream) > - ctx->bitstream = (uint8_t*)buffer; > + ctx->bitstream = buffer; > > ctx->slice_offsets[ctx->nb_slices] = buffer - ctx->bitstream; > ctx->bitstream_len += size; > diff --git a/libavcodec/nvdec.h b/libavcodec/nvdec.h > index 353e95bf42..555300d27d 100644 > --- a/libavcodec/nvdec.h > +++ b/libavcodec/nvdec.h > @@ -56,7 +56,7 @@ typedef struct NVDECContext { > > struct NVDECDecoder *decoder; ///< RefStruct reference > > - uint8_t *bitstream; > + const uint8_t *bitstream; > int bitstream_len; > unsigned int bitstream_allocated; > uint8_t *bitstream_internal; > diff --git a/libavcodec/nvdec_av1.c b/libavcodec/nvdec_av1.c > index 74b0442177..35f22ebf80 100644 > --- a/libavcodec/nvdec_av1.c > +++ b/libavcodec/nvdec_av1.c > @@ -303,7 +303,7 @@ static int nvdec_av1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > > /* Shortcut if all tiles are in the same buffer */ > if (ctx->nb_slices == s->tg_end - s->tg_start + 1) { > - ctx->bitstream = (uint8_t*)buffer; > + ctx->bitstream = buffer; > ctx->bitstream_len = size; > > for (int i = 0; i < ctx->nb_slices; ++i) { > @@ -321,7 +321,7 @@ static int nvdec_av1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > } > ctx->bitstream = ctx->bitstream_internal = tmp; > > - memcpy(ctx->bitstream + ctx->bitstream_len, buffer, size); > + memcpy(ctx->bitstream_internal + ctx->bitstream_len, buffer, size); > > for (uint32_t tile_num = s->tg_start; tile_num <= s->tg_end; ++tile_num) { > ctx->slice_offsets[tile_num*2 ] = ctx->bitstream_len + s->tile_group_info[tile_num].tile_offset; > diff --git a/libavcodec/nvdec_h264.c b/libavcodec/nvdec_h264.c > index 8c72d5f4f7..ea6c1081eb 100644 > --- a/libavcodec/nvdec_h264.c > +++ b/libavcodec/nvdec_h264.c > @@ -150,8 +150,8 @@ static int nvdec_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > return AVERROR(ENOMEM); > ctx->slice_offsets = tmp; > > - AV_WB24(ctx->bitstream + ctx->bitstream_len, 1); > - memcpy(ctx->bitstream + ctx->bitstream_len + 3, buffer, size); > + AV_WB24(ctx->bitstream_internal + ctx->bitstream_len, 1); > + memcpy(ctx->bitstream_internal + ctx->bitstream_len + 3, buffer, size); > ctx->slice_offsets[ctx->nb_slices] = ctx->bitstream_len ; > ctx->bitstream_len += size + 3; > ctx->nb_slices++; > diff --git a/libavcodec/nvdec_hevc.c b/libavcodec/nvdec_hevc.c > index 25319a1328..ff118af04b 100644 > --- a/libavcodec/nvdec_hevc.c > +++ b/libavcodec/nvdec_hevc.c > @@ -286,8 +286,8 @@ static int nvdec_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, > return AVERROR(ENOMEM); > ctx->slice_offsets = tmp; > > - AV_WB24(ctx->bitstream + ctx->bitstream_len, 1); > - memcpy(ctx->bitstream + ctx->bitstream_len + 3, buffer, size); > + AV_WB24(ctx->bitstream_internal + ctx->bitstream_len, 1); > + memcpy(ctx->bitstream_internal + ctx->bitstream_len + 3, buffer, size); > ctx->slice_offsets[ctx->nb_slices] = ctx->bitstream_len ; > ctx->bitstream_len += size + 3; > ctx->nb_slices++; LGTM _______________________________________________ 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".