[FFmpeg-cvslog] av(format|device): Add const to muxer packet data pointers

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


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

av(format|device): Add const to muxer packet data pointers

The packets given to muxers 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=d5a0eba8a2481711e708442bcc1d14bf16e9d20b
---

 libavdevice/alsa_enc.c   | 2 +-
 libavdevice/fbdev_enc.c  | 3 ++-
 libavdevice/oss_enc.c    | 2 +-
 libavdevice/sndio_enc.c  | 2 +-
 libavformat/dvenc.c      | 2 +-
 libavformat/gif.c        | 2 +-
 libavformat/movenc.h     | 2 +-
 libavformat/movenchint.c | 2 +-
 libavformat/mxfenc.c     | 2 +-
 libavformat/oggenc.c     | 4 ++--
 libavformat/spdifenc.c   | 4 ++--
 libavformat/swfenc.c     | 4 ++--
 12 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/libavdevice/alsa_enc.c b/libavdevice/alsa_enc.c
index 3d6bccdc2a..ac09e33c49 100644
--- a/libavdevice/alsa_enc.c
+++ b/libavdevice/alsa_enc.c
@@ -86,7 +86,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
     AlsaData *s = s1->priv_data;
     int res;
     int size     = pkt->size;
-    uint8_t *buf = pkt->data;
+    const uint8_t *buf = pkt->data;
 
     size /= s->frame_size;
     if (pkt->dts != AV_NOPTS_VALUE)
diff --git a/libavdevice/fbdev_enc.c b/libavdevice/fbdev_enc.c
index 898a630aa1..84ec6733ff 100644
--- a/libavdevice/fbdev_enc.c
+++ b/libavdevice/fbdev_enc.c
@@ -100,7 +100,8 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
 static int fbdev_write_packet(AVFormatContext *h, AVPacket *pkt)
 {
     FBDevContext *fbdev = h->priv_data;
-    uint8_t *pin, *pout;
+    const uint8_t *pin;
+    uint8_t *pout;
     enum AVPixelFormat fb_pix_fmt;
     int disp_height;
     int bytes_to_copy;
diff --git a/libavdevice/oss_enc.c b/libavdevice/oss_enc.c
index d6a512a264..704f434c53 100644
--- a/libavdevice/oss_enc.c
+++ b/libavdevice/oss_enc.c
@@ -55,9 +55,9 @@ static int audio_write_header(AVFormatContext *s1)
 static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
 {
     OSSAudioData *s = s1->priv_data;
+    const uint8_t *buf = pkt->data;
     int len, ret;
     int size= pkt->size;
-    uint8_t *buf= pkt->data;
 
     while (size > 0) {
         len = FFMIN(OSS_AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
diff --git a/libavdevice/sndio_enc.c b/libavdevice/sndio_enc.c
index a595438d8a..0cf58fdc6a 100644
--- a/libavdevice/sndio_enc.c
+++ b/libavdevice/sndio_enc.c
@@ -46,7 +46,7 @@ static av_cold int audio_write_header(AVFormatContext *s1)
 static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
 {
     SndioData *s = s1->priv_data;
-    uint8_t *buf= pkt->data;
+    const uint8_t *buf = pkt->data;
     int size = pkt->size;
     int len, ret;
 
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 1917c00694..7ef9692302 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -245,7 +245,7 @@ static void dv_inject_metadata(DVMuxContext *c, uint8_t* frame)
 
 static int dv_assemble_frame(AVFormatContext *s,
                              DVMuxContext *c, AVStream* st,
-                             uint8_t* data, int data_size, uint8_t** frame)
+                             const uint8_t *data, int data_size, uint8_t **frame)
 {
     int i, reqasize;
 
diff --git a/libavformat/gif.c b/libavformat/gif.c
index cba87d3eae..b52ff4dd39 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -54,7 +54,7 @@ static int gif_write_header(AVFormatContext *s)
     return 0;
 }
 
-static int gif_parse_packet(AVFormatContext *s, uint8_t *data, int size)
+static int gif_parse_packet(AVFormatContext *s, const uint8_t *data, int size)
 {
     GetByteContext gb;
     int x;
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index e4550f7900..c6b3313deb 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -62,7 +62,7 @@ typedef struct MOVIentry {
 } MOVIentry;
 
 typedef struct HintSample {
-    uint8_t *data;
+    const uint8_t *data;
     int size;
     int sample_number;
     int offset;
diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c
index aaaaa3ac7b..0169341189 100644
--- a/libavformat/movenchint.c
+++ b/libavformat/movenchint.c
@@ -96,7 +96,7 @@ static void sample_queue_free(HintSampleQueue *queue)
  * not copied. sample_queue_retain should be called before pkt->data
  * is reused/freed.
  */
-static void sample_queue_push(HintSampleQueue *queue, uint8_t *data, int size,
+static void sample_queue_push(HintSampleQueue *queue, const uint8_t *data, int size,
                               int sample)
 {
     /* No need to keep track of smaller samples, since describing them
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 2d08dd6d40..9a9acbfa08 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -2139,7 +2139,7 @@ static int mxf_parse_dv_frame(AVFormatContext *s, AVStream *st, AVPacket *pkt)
 {
     MXFContext *mxf = s->priv_data;
     MXFStreamContext *sc = st->priv_data;
-    uint8_t *vs_pack, *vsc_pack;
+    const uint8_t *vs_pack, *vsc_pack;
     int apt, ul_index, stype, pal;
 
     if (mxf->header_written)
diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index 016047f616..ae0705ba54 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -197,13 +197,13 @@ static int ogg_buffer_page(AVFormatContext *s, OGGStreamContext *oggstream)
 }
 
 static int ogg_buffer_data(AVFormatContext *s, AVStream *st,
-                           uint8_t *data, unsigned size, int64_t granule,
+                           const uint8_t *data, unsigned size, int64_t granule,
                            int header)
 {
     OGGStreamContext *oggstream = st->priv_data;
     OGGContext *ogg = s->priv_data;
     int total_segments = size / 255 + 1;
-    uint8_t *p = data;
+    const uint8_t *p = data;
     int i, segments, len, flush = 0;
 
     // Handles VFR by flushing page because this frame needs to have a timestamp
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index 0a634e4232..7b8e231cff 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -63,7 +63,7 @@ typedef struct IEC61937Context {
     uint8_t *buffer;                ///< allocated buffer, used for swap bytes
     int buffer_size;                ///< size of allocated buffer
 
-    uint8_t *out_buf;               ///< pointer to the outgoing data before byte-swapping
+    const uint8_t *out_buf;         ///< pointer to the outgoing data before byte-swapping
     int out_bytes;                  ///< amount of outgoing bytes
 
     int use_preamble;               ///< preamble enabled (disabled for exactly pre-padded DTS)
@@ -657,7 +657,7 @@ static int spdif_write_packet(struct AVFormatContext *s, AVPacket *pkt)
         av_fast_malloc(&ctx->buffer, &ctx->buffer_size, ctx->out_bytes + AV_INPUT_BUFFER_PADDING_SIZE);
         if (!ctx->buffer)
             return AVERROR(ENOMEM);
-        ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
+        ff_spdif_bswap_buf16((uint16_t *)ctx->buffer, (const uint16_t *)ctx->out_buf, ctx->out_bytes >> 1);
         avio_write(s->pb, ctx->buffer, ctx->out_bytes & ~1);
     }
 
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 2c8c034c42..75b892087f 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -481,8 +481,8 @@ static int swf_write_video(AVFormatContext *s,
     return 0;
 }
 
-static int swf_write_audio(AVFormatContext *s,
-                           AVCodecParameters *par, uint8_t *buf, int size)
+static int swf_write_audio(AVFormatContext *s, AVCodecParameters *par,
+                           const uint8_t *buf, int size)
 {
     SWFEncContext *swf = s->priv_data;
 



More information about the ffmpeg-cvslog mailing list