[FFmpeg-devel] [PATCH 2/4] avcodec/dcadec: Treat the input packet's data as const

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon Jul 4 14:02:41 EEST 2022


A decoder's input packet need not be writable, so we must not modify
the data.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/dca_core.c |  4 ++--
 libavcodec/dca_core.h |  4 ++--
 libavcodec/dca_lbr.c  |  2 +-
 libavcodec/dca_lbr.h  |  2 +-
 libavcodec/dca_xll.c  | 10 +++++-----
 libavcodec/dca_xll.h  |  2 +-
 libavcodec/dcadec.c   |  2 +-
 7 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/libavcodec/dca_core.c b/libavcodec/dca_core.c
index 34b5b63159..2b19807ef4 100644
--- a/libavcodec/dca_core.c
+++ b/libavcodec/dca_core.c
@@ -1797,7 +1797,7 @@ static int parse_optional_info(DCACoreDecoder *s)
     return 0;
 }
 
-int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
+int ff_dca_core_parse(DCACoreDecoder *s, const uint8_t *data, int size)
 {
     int ret;
 
@@ -1830,7 +1830,7 @@ int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size)
     return 0;
 }
 
-int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset)
+int ff_dca_core_parse_exss(DCACoreDecoder *s, const uint8_t *data, DCAExssAsset *asset)
 {
     AVCodecContext *avctx = s->avctx;
     DCAContext *dca = avctx->priv_data;
diff --git a/libavcodec/dca_core.h b/libavcodec/dca_core.h
index cb8e38a94b..a01d642e77 100644
--- a/libavcodec/dca_core.h
+++ b/libavcodec/dca_core.h
@@ -245,8 +245,8 @@ static inline void ff_dca_core_dequantize(int32_t *output, const int32_t *input,
     }
 }
 
-int ff_dca_core_parse(DCACoreDecoder *s, uint8_t *data, int size);
-int ff_dca_core_parse_exss(DCACoreDecoder *s, uint8_t *data, DCAExssAsset *asset);
+int ff_dca_core_parse(DCACoreDecoder *s, const uint8_t *data, int size);
+int ff_dca_core_parse_exss(DCACoreDecoder *s, const uint8_t *data, DCAExssAsset *asset);
 int ff_dca_core_filter_fixed(DCACoreDecoder *s, int x96_synth);
 int ff_dca_core_filter_frame(DCACoreDecoder *s, AVFrame *frame);
 av_cold void ff_dca_core_flush(DCACoreDecoder *s);
diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 06c10b96f5..2b8594cd75 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -1156,7 +1156,7 @@ static int parse_decoder_init(DCALbrDecoder *s, GetByteContext *gb)
     return 0;
 }
 
-int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset)
+int ff_dca_lbr_parse(DCALbrDecoder *s, const uint8_t *data, DCAExssAsset *asset)
 {
     struct {
         LBRChunk    lfe;
diff --git a/libavcodec/dca_lbr.h b/libavcodec/dca_lbr.h
index db7a676c31..9e1abec0b4 100644
--- a/libavcodec/dca_lbr.h
+++ b/libavcodec/dca_lbr.h
@@ -124,7 +124,7 @@ typedef struct DCALbrDecoder {
     DCADSPContext       *dcadsp;
 } DCALbrDecoder;
 
-int ff_dca_lbr_parse(DCALbrDecoder *s, uint8_t *data, DCAExssAsset *asset);
+int ff_dca_lbr_parse(DCALbrDecoder *s, const uint8_t *data, DCAExssAsset *asset);
 int ff_dca_lbr_filter_frame(DCALbrDecoder *s, AVFrame *frame);
 av_cold void ff_dca_lbr_flush(DCALbrDecoder *s);
 av_cold void ff_dca_lbr_init_tables(void);
diff --git a/libavcodec/dca_xll.c b/libavcodec/dca_xll.c
index aaccb7a43d..17626b3614 100644
--- a/libavcodec/dca_xll.c
+++ b/libavcodec/dca_xll.c
@@ -1040,7 +1040,7 @@ static int parse_band_data(DCAXllDecoder *s)
     return 0;
 }
 
-static int parse_frame(DCAXllDecoder *s, uint8_t *data, int size, DCAExssAsset *asset)
+static int parse_frame(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
 {
     int ret;
 
@@ -1067,7 +1067,7 @@ static void clear_pbr(DCAXllDecoder *s)
     s->pbr_delay = 0;
 }
 
-static int copy_to_pbr(DCAXllDecoder *s, uint8_t *data, int size, int delay)
+static int copy_to_pbr(DCAXllDecoder *s, const uint8_t *data, int size, int delay)
 {
     if (size > DCA_XLL_PBR_BUFFER_MAX)
         return AVERROR(ENOSPC);
@@ -1081,7 +1081,7 @@ static int copy_to_pbr(DCAXllDecoder *s, uint8_t *data, int size, int delay)
     return 0;
 }
 
-static int parse_frame_no_pbr(DCAXllDecoder *s, uint8_t *data, int size, DCAExssAsset *asset)
+static int parse_frame_no_pbr(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
 {
     int ret = parse_frame(s, data, size, asset);
 
@@ -1119,7 +1119,7 @@ static int parse_frame_no_pbr(DCAXllDecoder *s, uint8_t *data, int size, DCAExss
     return 0;
 }
 
-static int parse_frame_pbr(DCAXllDecoder *s, uint8_t *data, int size, DCAExssAsset *asset)
+static int parse_frame_pbr(DCAXllDecoder *s, const uint8_t *data, int size, DCAExssAsset *asset)
 {
     int ret;
 
@@ -1160,7 +1160,7 @@ fail:
     return ret;
 }
 
-int ff_dca_xll_parse(DCAXllDecoder *s, uint8_t *data, DCAExssAsset *asset)
+int ff_dca_xll_parse(DCAXllDecoder *s, const uint8_t *data, DCAExssAsset *asset)
 {
     int ret;
 
diff --git a/libavcodec/dca_xll.h b/libavcodec/dca_xll.h
index d223133019..d7c1a13ec8 100644
--- a/libavcodec/dca_xll.h
+++ b/libavcodec/dca_xll.h
@@ -139,7 +139,7 @@ typedef struct DCAXllDecoder {
     int32_t *output_samples[DCA_SPEAKER_COUNT];
 } DCAXllDecoder;
 
-int ff_dca_xll_parse(DCAXllDecoder *s, uint8_t *data, DCAExssAsset *asset);
+int ff_dca_xll_parse(DCAXllDecoder *s, const uint8_t *data, DCAExssAsset *asset);
 int ff_dca_xll_filter_frame(DCAXllDecoder *s, AVFrame *frame);
 av_cold void ff_dca_xll_flush(DCAXllDecoder *s);
 av_cold void ff_dca_xll_close(DCAXllDecoder *s);
diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 38ea8733e4..498e0c86f3 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -151,7 +151,7 @@ static int dcadec_decode_frame(AVCodecContext *avctx, AVFrame *frame,
                                int *got_frame_ptr, AVPacket *avpkt)
 {
     DCAContext *s = avctx->priv_data;
-    uint8_t *input = avpkt->data;
+    const uint8_t *input = avpkt->data;
     int input_size = avpkt->size;
     int i, ret, prev_packet = s->packet;
     uint32_t mrk;
-- 
2.34.1



More information about the ffmpeg-devel mailing list