[FFmpeg-cvslog] avcodec: Add const to decoder packet data pointers

Andreas Rheinhardt git at videolan.org
Sat Jul 9 20:46:10 EEST 2022


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Jul  4 18:49:37 2022 +0200| [4ad686269d3025a2841b026a82bd26b6a0dd4a3f] | committer: Andreas Rheinhardt

avcodec: Add const to decoder packet data pointers

The packets given to decoder need not be writable,
so it is best to access them via const uint8_t*.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4ad686269d3025a2841b026a82bd26b6a0dd4a3f
---

 libavcodec/cpia.c                | 4 ++--
 libavcodec/dfpwmdec.c            | 3 ++-
 libavcodec/hnm4video.c           | 8 ++++----
 libavcodec/libcodec2.c           | 2 +-
 libavcodec/libvpxdec.c           | 2 +-
 libavcodec/libzvbi-teletextdec.c | 2 +-
 libavcodec/pafvideo.c            | 2 +-
 libavcodec/pixlet.c              | 4 ++--
 libavcodec/webp.c                | 6 +++---
 libavcodec/yop.c                 | 6 +++---
 10 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/libavcodec/cpia.c b/libavcodec/cpia.c
index 2f4ad1fb5b..fcf2621e61 100644
--- a/libavcodec/cpia.c
+++ b/libavcodec/cpia.c
@@ -54,8 +54,8 @@ static int cpia_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
     CpiaContext* const cpia = avctx->priv_data;
     int i,j,ret;
 
-    uint8_t* const header = avpkt->data;
-    uint8_t* src;
+    const uint8_t *const header = avpkt->data;
+    const uint8_t *src;
     int src_size;
     uint16_t linelength;
     uint8_t skip;
diff --git a/libavcodec/dfpwmdec.c b/libavcodec/dfpwmdec.c
index 77c6d2cb18..d013d4c215 100644
--- a/libavcodec/dfpwmdec.c
+++ b/libavcodec/dfpwmdec.c
@@ -38,7 +38,8 @@ typedef struct {
 // DFPWM codec from https://github.com/ChenThread/dfpwm/blob/master/1a/
 // Licensed in the public domain
 
-static void au_decompress(DFPWMState *state, int fs, int len, uint8_t *outbuf, uint8_t *inbuf)
+static void au_decompress(DFPWMState *state, int fs, int len,
+                          uint8_t *outbuf, const uint8_t *inbuf)
 {
     unsigned d;
     for (int i = 0; i < len; i++) {
diff --git a/libavcodec/hnm4video.c b/libavcodec/hnm4video.c
index 9eb9f3a694..1326d5f872 100644
--- a/libavcodec/hnm4video.c
+++ b/libavcodec/hnm4video.c
@@ -64,7 +64,7 @@ static int getbit(GetByteContext *gb, uint32_t *bitbuf, int *bits)
     return ret;
 }
 
-static void unpack_intraframe(AVCodecContext *avctx, uint8_t *src,
+static void unpack_intraframe(AVCodecContext *avctx, const uint8_t *src,
                               uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
@@ -147,7 +147,7 @@ static void copy_processed_frame(AVCodecContext *avctx, AVFrame *frame)
     }
 }
 
-static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t size)
+static int decode_interframe_v4(AVCodecContext *avctx, const uint8_t *src, uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
     GetByteContext gb;
@@ -276,7 +276,7 @@ static int decode_interframe_v4(AVCodecContext *avctx, uint8_t *src, uint32_t si
     return 0;
 }
 
-static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
+static void decode_interframe_v4a(AVCodecContext *avctx, const uint8_t *src,
                                   uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
@@ -355,7 +355,7 @@ static void decode_interframe_v4a(AVCodecContext *avctx, uint8_t *src,
     }
 }
 
-static void hnm_update_palette(AVCodecContext *avctx, uint8_t *src,
+static void hnm_update_palette(AVCodecContext *avctx, const uint8_t *src,
                                uint32_t size)
 {
     Hnm4VideoContext *hnm = avctx->priv_data;
diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c
index 9064b823ee..abb1130e80 100644
--- a/libavcodec/libcodec2.c
+++ b/libavcodec/libcodec2.c
@@ -135,7 +135,7 @@ static int libcodec2_decode(AVCodecContext *avctx, AVFrame *frame,
 {
     LibCodec2Context *c2 = avctx->priv_data;
     int ret, nframes, i;
-    uint8_t *input;
+    const uint8_t *input;
     int16_t *output;
 
     nframes           = pkt->size / avctx->block_align;
diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
index ef690a7093..0b279e7eda 100644
--- a/libavcodec/libvpxdec.c
+++ b/libavcodec/libvpxdec.c
@@ -199,7 +199,7 @@ static int set_pix_fmt(AVCodecContext *avctx, struct vpx_image *img,
 }
 
 static int decode_frame(AVCodecContext *avctx, vpx_codec_ctx_t *decoder,
-                        uint8_t *data, uint32_t data_sz)
+                        const uint8_t *data, uint32_t data_sz)
 {
     if (vpx_codec_decode(decoder, data, data_sz, NULL, 0) != VPX_CODEC_OK) {
         const char *error  = vpx_codec_error(decoder);
diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c
index 92466cc11e..514e76f1b6 100644
--- a/libavcodec/libzvbi-teletextdec.c
+++ b/libavcodec/libzvbi-teletextdec.c
@@ -581,7 +581,7 @@ static void handler(vbi_event *ev, void *user_data)
     vbi_unref_page(&page);
 }
 
-static int slice_to_vbi_lines(TeletextContext *ctx, uint8_t* buf, int size)
+static int slice_to_vbi_lines(TeletextContext *ctx, const uint8_t *buf, int size)
 {
     int lines = 0;
     while (size >= 2 && lines < MAX_SLICES) {
diff --git a/libavcodec/pafvideo.c b/libavcodec/pafvideo.c
index a0bd22e8fd..60cdd34add 100644
--- a/libavcodec/pafvideo.c
+++ b/libavcodec/pafvideo.c
@@ -159,7 +159,7 @@ static void set_src_position(PAFVideoDecContext *c,
     *pend = c->frame[page] + c->frame_size;
 }
 
-static int decode_0(PAFVideoDecContext *c, uint8_t *pkt, uint8_t code)
+static int decode_0(PAFVideoDecContext *c, const uint8_t *pkt, uint8_t code)
 {
     uint32_t opcode_size, offset;
     uint8_t *dst, *dend, mask = 0, color = 0;
diff --git a/libavcodec/pixlet.c b/libavcodec/pixlet.c
index 18a6587257..3174f30e91 100644
--- a/libavcodec/pixlet.c
+++ b/libavcodec/pixlet.c
@@ -198,7 +198,7 @@ static int read_low_coeffs(AVCodecContext *avctx, int16_t *dst, int size,
     return get_bits_count(bc) >> 3;
 }
 
-static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
+static int read_high_coeffs(AVCodecContext *avctx, const uint8_t *src, int16_t *dst,
                             int size, int c, int a, int d,
                             int width, ptrdiff_t stride)
 {
@@ -313,7 +313,7 @@ static int read_high_coeffs(AVCodecContext *avctx, uint8_t *src, int16_t *dst,
     return get_bits_count(bc) >> 3;
 }
 
-static int read_highpass(AVCodecContext *avctx, uint8_t *ptr,
+static int read_highpass(AVCodecContext *avctx, const uint8_t *ptr,
                          int plane, AVFrame *frame)
 {
     PixletContext *ctx = avctx->priv_data;
diff --git a/libavcodec/webp.c b/libavcodec/webp.c
index 1b5e943a6e..e57a5a2917 100644
--- a/libavcodec/webp.c
+++ b/libavcodec/webp.c
@@ -200,7 +200,7 @@ typedef struct WebPContext {
     int has_alpha;                      /* has a separate alpha chunk */
     enum AlphaCompression alpha_compression; /* compression type for alpha chunk */
     enum AlphaFilter alpha_filter;      /* filtering method for alpha chunk */
-    uint8_t *alpha_data;                /* alpha chunk data */
+    const uint8_t *alpha_data;          /* alpha chunk data */
     int alpha_data_size;                /* alpha chunk data size */
     int has_exif;                       /* set after an EXIF chunk has been processed */
     int has_iccp;                       /* set after an ICCP chunk has been processed */
@@ -1084,7 +1084,7 @@ static void update_canvas_size(AVCodecContext *avctx, int w, int h)
 }
 
 static int vp8_lossless_decode_frame(AVCodecContext *avctx, AVFrame *p,
-                                     int *got_frame, uint8_t *data_start,
+                                     int *got_frame, const uint8_t *data_start,
                                      unsigned int data_size, int is_alpha_chunk)
 {
     WebPContext *s = avctx->priv_data;
@@ -1240,7 +1240,7 @@ static void alpha_inverse_prediction(AVFrame *frame, enum AlphaFilter m)
 }
 
 static int vp8_lossy_decode_alpha(AVCodecContext *avctx, AVFrame *p,
-                                  uint8_t *data_start,
+                                  const uint8_t *data_start,
                                   unsigned int data_size)
 {
     WebPContext *s = avctx->priv_data;
diff --git a/libavcodec/yop.c b/libavcodec/yop.c
index 5befbb072e..7a11ca77b8 100644
--- a/libavcodec/yop.c
+++ b/libavcodec/yop.c
@@ -40,9 +40,9 @@ typedef struct YopDecContext {
     int first_color[2];
     int frame_data_length;
 
-    uint8_t *low_nibble;
-    uint8_t *srcptr;
-    uint8_t *src_end;
+    const uint8_t *low_nibble;
+    const uint8_t *srcptr;
+    const uint8_t *src_end;
     uint8_t *dstptr;
     uint8_t *dstbuf;
 } YopDecContext;



More information about the ffmpeg-cvslog mailing list