From a97c1e93aa3c1fbb7cde0699b36ea9be466c6a52 Mon Sep 17 00:00:00 2001
From: Stefan Huehner <stefan@huehner.org>
Date: Sat, 17 Jun 2006 15:53:23 +0000
Subject: [PATCH] Add (mostly) const to variable and parameter declaration,
 where a char* was used and 'const char*' should be, plus make some function
 declarations static if they aren't used outside their declaring source file.
 patch by Stefan Huehner stefan%%at%%huehner%%dot%%org

Originally committed as revision 5492 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavformat/aiff.c     | 4 ++--
 libavformat/asf-enc.c  | 4 ++--
 libavformat/avformat.h | 2 +-
 libavformat/dv.c       | 2 +-
 libavformat/gif.c      | 2 +-
 libavformat/matroska.c | 4 ++--
 libavformat/movenc.c   | 6 +++---
 libavformat/png.c      | 2 +-
 libavformat/utils.c    | 2 +-
 libavformat/yuv4mpeg.c | 2 +-
 10 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavformat/aiff.c b/libavformat/aiff.c
index 00dc7c12b74..3dbe6b15240 100644
--- a/libavformat/aiff.c
+++ b/libavformat/aiff.c
@@ -220,10 +220,10 @@ static int aiff_write_header(AVFormatContext *s)
     put_le32(pb, enc->codec_tag);
     if (coder_len & 1) {
         put_byte(pb, coder_len);
-        put_buffer(pb, (uint8_t*)enc->codec->name, coder_len);
+        put_buffer(pb, (const uint8_t*)enc->codec->name, coder_len);
     } else {
         put_byte(pb, coder_len+1);
-        put_buffer(pb, (uint8_t*)enc->codec->name, coder_len);
+        put_buffer(pb, (const uint8_t*)enc->codec->name, coder_len);
         put_byte(pb, 0);
     }
 
diff --git a/libavformat/asf-enc.c b/libavformat/asf-enc.c
index 1f8a993c66e..cca441b165a 100644
--- a/libavformat/asf-enc.c
+++ b/libavformat/asf-enc.c
@@ -349,7 +349,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
     /* stream headers */
     for(n=0;n<s->nb_streams;n++) {
         int64_t es_pos;
-        uint8_t *er_spr = NULL;
+        const uint8_t *er_spr = NULL;
         int er_spr_len = 0;
         //        ASFStream *stream = &asf->streams[n];
 
@@ -360,7 +360,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data
 
         if (enc->codec_type == CODEC_TYPE_AUDIO) {
             if (enc->codec_id == CODEC_ID_ADPCM_G726) {
-                er_spr     = (uint8_t *)error_spread_ADPCM_G726;
+                er_spr     = error_spread_ADPCM_G726;
                 er_spr_len = sizeof(error_spread_ADPCM_G726);
             }
         }
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 025826892a0..c94a9b1190c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -604,7 +604,7 @@ int fifo_init(FifoBuffer *f, int size);
 void fifo_free(FifoBuffer *f);
 int fifo_size(FifoBuffer *f, uint8_t *rptr);
 int fifo_read(FifoBuffer *f, uint8_t *buf, int buf_size, uint8_t **rptr_ptr);
-void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr);
+void fifo_write(FifoBuffer *f, const uint8_t *buf, int size, uint8_t **wptr_ptr);
 int put_fifo(ByteIOContext *pb, FifoBuffer *f, int buf_size, uint8_t **rptr_ptr);
 void fifo_realloc(FifoBuffer *f, unsigned int size);
 
diff --git a/libavformat/dv.c b/libavformat/dv.c
index bec1759202a..beb94fa0a2f 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -692,7 +692,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
             /* FIXME: we have to have more sensible approach than this one */
             if (fifo_size(&c->audio_data[i], c->audio_data[i].rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
                 av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
-            fifo_write(&c->audio_data[i], (uint8_t *)data, data_size, &c->audio_data[i].wptr);
+            fifo_write(&c->audio_data[i], data, data_size, &c->audio_data[i].wptr);
         }
     }
 out:
diff --git a/libavformat/gif.c b/libavformat/gif.c
index 34d01c49f9c..f81a70def50 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -187,7 +187,7 @@ static int gif_image_write_header(ByteIOContext *pb,
 
     /* the global palette */
     if (!palette) {
-        put_buffer(pb, (unsigned char *)gif_clut, 216*3);
+        put_buffer(pb, (const unsigned char *)gif_clut, 216*3);
         for(i=0;i<((256-216)*3);i++)
             put_byte(pb, 0);
     } else {
diff --git a/libavformat/matroska.c b/libavformat/matroska.c
index 9a1a69bc5a0..3e33eccab93 100644
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -183,14 +183,14 @@ typedef enum {
  */
 
 typedef struct CodecTags{
-    char *str;
+    const char *str;
     enum CodecID id;
 }CodecTags;
 
 #define MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC   "V_MS/VFW/FOURCC"
 #define MATROSKA_CODEC_ID_AUDIO_ACM          "A_MS/ACM"
 
-CodecTags codec_tags[]={
+static CodecTags codec_tags[]={
 //    {"V_MS/VFW/FOURCC"  , CODEC_ID_NONE},
     {"V_UNCOMPRESSED"   , CODEC_ID_RAWVIDEO},
     {"V_MPEG4/ISO/SP"   , CODEC_ID_MPEG4},
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 9d1da5fdeba..cc24e314ab8 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -788,7 +788,7 @@ static int mov_write_vmhd_tag(ByteIOContext *pb)
 
 static int mov_write_hdlr_tag(ByteIOContext *pb, MOVTrack* track)
 {
-    char *descr, *hdlr, *hdlr_type;
+    const char *descr, *hdlr, *hdlr_type;
     offset_t pos = url_ftell(pb);
 
     if (!track) { /* no media --> data handler */
@@ -1085,7 +1085,7 @@ static int mov_write_string_data_tag(ByteIOContext *pb, const char *data, int lo
     }
 }
 
-static int mov_write_string_tag(ByteIOContext *pb, char *name, char *value, int long_style){
+static int mov_write_string_tag(ByteIOContext *pb, const char *name, const char *value, int long_style){
     int size = 0;
     if ( value && value[0] ) {
         offset_t pos = url_ftell(pb);
@@ -1225,7 +1225,7 @@ static size_t ascii_to_wc (ByteIOContext *pb, char *b, size_t n)
     return 2*n;
 }
 
-static uint16_t language_code (char *str)
+static uint16_t language_code (const char *str)
 {
     return ((((str[0]-0x60) & 0x1F)<<10) + (((str[1]-0x60) & 0x1F)<<5) + ((str[2]-0x60) & 0x1F));
 }
diff --git a/libavformat/png.c b/libavformat/png.c
index e775cc520ff..4a41b21cc4b 100644
--- a/libavformat/png.c
+++ b/libavformat/png.c
@@ -326,7 +326,7 @@ static void convert_from_rgba32(uint8_t *dst, const uint8_t *src, int width)
 
     d = dst;
     for(j = 0; j < width; j++) {
-        v = ((uint32_t *)src)[j];
+        v = ((const uint32_t *)src)[j];
         d[0] = v >> 16;
         d[1] = v >> 8;
         d[2] = v;
diff --git a/libavformat/utils.c b/libavformat/utils.c
index f011bc2d650..375a878059e 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -342,7 +342,7 @@ void fifo_realloc(FifoBuffer *f, unsigned int new_size){
     }
 }
 
-void fifo_write(FifoBuffer *f, uint8_t *buf, int size, uint8_t **wptr_ptr)
+void fifo_write(FifoBuffer *f, const uint8_t *buf, int size, uint8_t **wptr_ptr)
 {
     int len;
     uint8_t *wptr;
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
index dd623205da8..9993de43b42 100644
--- a/libavformat/yuv4mpeg.c
+++ b/libavformat/yuv4mpeg.c
@@ -35,7 +35,7 @@ static int yuv4_generate_header(AVFormatContext *s, char* buf)
     int width, height;
     int raten, rated, aspectn, aspectd, n;
     char inter;
-    char *colorspace = "";
+    const char *colorspace = "";
 
     st = s->streams[0];
     width = st->codec->width;
-- 
GitLab