diff mbox series

[FFmpeg-devel] avcodec/nvdec: Constify bitstream pointee

Message ID AS8P250MB0744B20C7F62C72E19E700D08F452@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 9ae40f282d5e68025be553c60cb91d4672ebe5bb
Headers show
Series [FFmpeg-devel] avcodec/nvdec: Constify bitstream pointee | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 7, 2024, 3:04 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 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(-)

Comments

Timo Rothenpieler Feb. 7, 2024, 10:35 p.m. UTC | #1
On 07.02.2024 16:04, Andreas Rheinhardt wrote:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>   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
diff mbox series

Patch

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++;