[FFmpeg-devel] [PATCH] at lots of const to lavf
Reimar Döffinger
Reimar.Doeffinger
Sun Aug 24 15:55:23 CEST 2008
Hello,
not sure if all of these make sense (those that are not enabled on my
system are not even tested).
While looking through the code I also noticed, that a lot of those tag
tables are global symbols but do not have a ff_ prefix, e.g. in voc.c.
Greetings,
Reimar D?ffinger
-------------- next part --------------
Index: libavformat/img2.c
===================================================================
--- libavformat/img2.c (revision 14905)
+++ libavformat/img2.c (working copy)
@@ -72,7 +72,7 @@
{ CODEC_ID_NONE , NULL}
};
-static int sizes[][2] = {
+static const int sizes[][2] = {
{ 640, 480 },
{ 720, 480 },
{ 720, 576 },
Index: libavformat/isom.c
===================================================================
--- libavformat/isom.c (revision 14905)
+++ libavformat/isom.c (working copy)
@@ -212,7 +212,7 @@
/* cf. QTFileFormat.pdf p253, qtff.pdf p205 */
/* http://developer.apple.com/documentation/mac/Text/Text-368.html */
/* deprecated by putting the code as 3*5bit ascii */
-static const char *mov_mdhd_language_map[] = {
+static const char * const mov_mdhd_language_map[] = {
/* 0-9 */
"eng", "fra", "ger", "ita", "dut", "sve", "spa", "dan", "por", "nor",
"heb", "jpn", "ara", "fin", "gre", "ice", "mlt", "tur", "hr "/*scr*/, "chi"/*ace?*/,
Index: libavformat/matroskaenc.c
===================================================================
--- libavformat/matroskaenc.c (revision 14905)
+++ libavformat/matroskaenc.c (working copy)
@@ -847,7 +847,7 @@
mkv_write_header,
mkv_write_packet,
mkv_write_trailer,
- .codec_tag = (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0},
+ .codec_tag = (const AVCodecTag* const []){codec_bmp_tags, codec_wav_tags, 0},
.subtitle_codec = CODEC_ID_TEXT,
};
@@ -862,5 +862,5 @@
mkv_write_header,
mkv_write_packet,
mkv_write_trailer,
- .codec_tag = (const AVCodecTag*[]){codec_wav_tags, 0},
+ .codec_tag = (const AVCodecTag* const []){codec_wav_tags, 0},
};
Index: libavformat/oggdec.c
===================================================================
--- libavformat/oggdec.c (revision 14905)
+++ libavformat/oggdec.c (working copy)
@@ -37,7 +37,7 @@
#define MAX_PAGE_SIZE 65307
#define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
-static ogg_codec_t *ogg_codecs[] = {
+static const ogg_codec_t * const ogg_codecs[] = {
&speex_codec,
&vorbis_codec,
&theora_codec,
@@ -126,7 +126,7 @@
return 0;
}
-static ogg_codec_t *
+static const ogg_codec_t *
ogg_find_codec (uint8_t * buf, int size)
{
int i;
Index: libavformat/oggparsevorbis.c
===================================================================
--- libavformat/oggparsevorbis.c (revision 14905)
+++ libavformat/oggparsevorbis.c (working copy)
@@ -219,7 +221,7 @@
return os->seq < 3;
}
-ogg_codec_t vorbis_codec = {
+const ogg_codec_t vorbis_codec = {
.magic = "\001vorbis",
.magicsize = 7,
.header = vorbis_header
Index: libavformat/oggparseflac.c
===================================================================
--- libavformat/oggparseflac.c (revision 14905)
+++ libavformat/oggparseflac.c (working copy)
@@ -85,13 +85,13 @@
return 0;
}
-ogg_codec_t flac_codec = {
+const ogg_codec_t flac_codec = {
.magic = "\177FLAC",
.magicsize = 5,
.header = flac_header
};
-ogg_codec_t old_flac_codec = {
+const ogg_codec_t old_flac_codec = {
.magic = "fLaC",
.magicsize = 4,
.header = old_flac_header
Index: libavformat/matroskadec.c
===================================================================
--- libavformat/matroskadec.c (revision 14905)
+++ libavformat/matroskadec.c (working copy)
@@ -805,7 +805,7 @@
{
uint64_t total = 0;
int len_mask = 0x80, size = 1, n = 1;
- char probe_data[] = "matroska";
+ static const char probe_data[] = "matroska";
/* EBML header? */
if (AV_RB32(p->buf) != EBML_ID_HEADER)
Index: libavformat/oggdec.h
===================================================================
--- libavformat/oggdec.h (revision 14905)
+++ libavformat/oggdec.h (working copy)
@@ -75,15 +76,15 @@
#define OGG_FLAG_BOS 2
#define OGG_FLAG_EOS 4
-extern ogg_codec_t flac_codec;
-extern ogg_codec_t ogm_audio_codec;
-extern ogg_codec_t ogm_old_codec;
-extern ogg_codec_t ogm_text_codec;
-extern ogg_codec_t ogm_video_codec;
-extern ogg_codec_t old_flac_codec;
-extern ogg_codec_t speex_codec;
-extern ogg_codec_t theora_codec;
-extern ogg_codec_t vorbis_codec;
+extern const ogg_codec_t flac_codec;
+extern const ogg_codec_t ogm_audio_codec;
+extern const ogg_codec_t ogm_old_codec;
+extern const ogg_codec_t ogm_text_codec;
+extern const ogg_codec_t ogm_video_codec;
+extern const ogg_codec_t old_flac_codec;
+extern const ogg_codec_t speex_codec;
+extern const ogg_codec_t theora_codec;
+extern const ogg_codec_t vorbis_codec;
extern int vorbis_comment(AVFormatContext *ms, uint8_t *buf, int size);
Index: libavformat/oma.c
===================================================================
--- libavformat/oma.c (revision 14905)
+++ libavformat/oma.c (working copy)
@@ -89,7 +89,7 @@
if (ret != EA3_HEADER_SIZE)
return -1;
- if (memcmp(buf, (uint8_t[]){'E', 'A', '3'},3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
+ if (memcmp(buf, (const uint8_t[]){'E', 'A', '3'},3) || buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n");
return -1;
}
@@ -177,7 +177,7 @@
static int oma_read_probe(AVProbeData *p)
{
- if (!memcmp(p->buf, (uint8_t[]){'e', 'a', '3', 3, 0},5))
+ if (!memcmp(p->buf, (const uint8_t[]){'e', 'a', '3', 3, 0},5))
return AVPROBE_SCORE_MAX;
else
return 0;
@@ -195,6 +195,6 @@
pcm_read_seek,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "oma,aa3",
- .codec_tag= (const AVCodecTag*[]){codec_oma_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_oma_tags, 0},
};
Index: libavformat/rtpdec.c
===================================================================
--- libavformat/rtpdec.c (revision 14905)
+++ libavformat/rtpdec.c (working copy)
@@ -44,7 +44,7 @@
*/
/* statistics functions */
-RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler= NULL;
+const RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler= NULL;
static RTPDynamicProtocolHandler mp4v_es_handler= {"MP4V-ES", CODEC_TYPE_VIDEO, CODEC_ID_MPEG4};
static RTPDynamicProtocolHandler mpeg4_generic_handler= {"mpeg4-generic", CODEC_TYPE_AUDIO, CODEC_ID_AAC};
Index: libavformat/avienc.c
===================================================================
--- libavformat/avienc.c (revision 14905)
+++ libavformat/avienc.c (working copy)
@@ -602,6 +602,6 @@
avi_write_header,
avi_write_packet,
avi_write_trailer,
- .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_bmp_tags, codec_wav_tags, 0},
};
#endif //CONFIG_AVI_MUXER
Index: libavformat/oggparsetheora.c
===================================================================
--- libavformat/oggparsetheora.c (revision 14905)
+++ libavformat/oggparsetheora.c (working copy)
@@ -130,7 +130,7 @@
return iframe + pframe;
}
-ogg_codec_t theora_codec = {
+const ogg_codec_t theora_codec = {
.magic = "\200theora",
.magicsize = 7,
.header = theora_header,
Index: libavformat/oggparseogm.c
===================================================================
--- libavformat/oggparseogm.c (revision 14905)
+++ libavformat/oggparseogm.c (working copy)
@@ -149,28 +155,28 @@
return 0;
}
-ogg_codec_t ogm_video_codec = {
+const ogg_codec_t ogm_video_codec = {
.magic = "\001video",
.magicsize = 6,
.header = ogm_header,
.packet = ogm_packet
};
-ogg_codec_t ogm_audio_codec = {
+const ogg_codec_t ogm_audio_codec = {
.magic = "\001audio",
.magicsize = 6,
.header = ogm_header,
.packet = ogm_packet
};
-ogg_codec_t ogm_text_codec = {
+const ogg_codec_t ogm_text_codec = {
.magic = "\001text",
.magicsize = 5,
.header = ogm_header,
.packet = ogm_packet
};
-ogg_codec_t ogm_old_codec = {
+const ogg_codec_t ogm_old_codec = {
.magic = "\001Direct Show Samples embedded in Ogg",
.magicsize = 35,
.header = ogm_dshow_header,
Index: libavformat/flvenc.c
===================================================================
--- libavformat/flvenc.c (revision 14905)
+++ libavformat/flvenc.c (working copy)
@@ -387,6 +387,6 @@
flv_write_header,
flv_write_packet,
flv_write_trailer,
- .codec_tag= (const AVCodecTag*[]){flv_video_codec_ids, flv_audio_codec_ids, 0},
+ .codec_tag= (const AVCodecTag* const []){flv_video_codec_ids, flv_audio_codec_ids, 0},
.flags= AVFMT_GLOBALHEADER,
};
Index: libavformat/oggparsespeex.c
===================================================================
--- libavformat/oggparsespeex.c (revision 14905)
+++ libavformat/oggparsespeex.c (working copy)
@@ -54,7 +54,7 @@
return 0;
}
-ogg_codec_t speex_codec = {
+const ogg_codec_t speex_codec = {
.magic = "Speex ",
.magicsize = 8,
.header = speex_header
Index: libavformat/mmf.c
===================================================================
--- libavformat/mmf.c (revision 14905)
+++ libavformat/mmf.c (working copy)
@@ -27,7 +27,7 @@
offset_t data_size;
} MMFContext;
-static int mmf_rates[] = { 4000, 8000, 11025, 22050, 44100 };
+static const int mmf_rates[] = { 4000, 8000, 11025, 22050, 44100 };
static int mmf_rate(int code)
{
Index: libavformat/avformat.h
===================================================================
--- libavformat/avformat.h (revision 14905)
+++ libavformat/avformat.h (working copy)
@@ -217,7 +217,7 @@
* list of supported codec_id-codec_tag pairs, ordered by "better choice first"
* the arrays are all CODEC_ID_NONE terminated
*/
- const struct AVCodecTag **codec_tag;
+ const struct AVCodecTag * const *codec_tag;
enum CodecID subtitle_codec; /**< default subtitle codec */
@@ -287,7 +287,7 @@
(RTSP) */
int (*read_pause)(struct AVFormatContext *);
- const struct AVCodecTag **codec_tag;
+ const struct AVCodecTag * const *codec_tag;
/* private fields */
struct AVInputFormat *next;
Index: libavformat/rtsp.c
===================================================================
--- libavformat/rtsp.c (revision 14905)
+++ libavformat/rtsp.c (working copy)
@@ -275,7 +275,7 @@
/* All known fmtp parmeters and the corresping RTPAttrTypeEnum */
#define ATTR_NAME_TYPE_INT 0
#define ATTR_NAME_TYPE_STR 1
-static attrname_map_t attr_names[]=
+static const attrname_map_t attr_names[]=
{
{"SizeLength", ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, sizelength)},
{"IndexLength", ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, indexlength)},
Index: libavformat/utils.c
===================================================================
--- libavformat/utils.c (revision 14905)
+++ libavformat/utils.c (working copy)
@@ -1965,7 +1971,7 @@
#define MAX_STD_TIMEBASES (60*12+5)
static int get_std_framerate(int i){
if(i<60*12) return i*1001;
- else return ((int[]){24,30,60,12,15})[i-60*12]*1000*12;
+ else return ((const int[]){24,30,60,12,15})[i-60*12]*1000*12;
}
/*
@@ -2867,11 +2889,11 @@
int64_t t;
struct tm dt;
int i;
- static const char *date_fmt[] = {
+ static const char * const date_fmt[] = {
"%Y-%m-%d",
"%Y%m%d",
};
- static const char *time_fmt[] = {
+ static const char * const time_fmt[] = {
"%H:%M:%S",
"%H%M%S",
};
Index: libavformat/asf-enc.c
===================================================================
--- libavformat/asf-enc.c (revision 14905)
+++ libavformat/asf-enc.c (working copy)
@@ -829,7 +829,7 @@
asf_write_packet,
asf_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag= (const AVCodecTag*[]){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0},
};
#endif
@@ -850,6 +850,6 @@
asf_write_packet,
asf_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag= (const AVCodecTag*[]){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_asf_bmp_tags, codec_bmp_tags, codec_wav_tags, 0},
};
#endif //CONFIG_ASF_STREAM_MUXER
Index: libavformat/vocenc.c
===================================================================
--- libavformat/vocenc.c (revision 14905)
+++ libavformat/vocenc.c (working copy)
@@ -99,5 +99,5 @@
voc_write_header,
voc_write_packet,
voc_write_trailer,
- .codec_tag=(const AVCodecTag*[]){voc_codec_tags, 0},
+ .codec_tag=(const AVCodecTag* const []){voc_codec_tags, 0},
};
Index: libavformat/movenc.c
===================================================================
--- libavformat/movenc.c (revision 14905)
+++ libavformat/movenc.c (working copy)
@@ -1703,7 +1703,7 @@
mov_write_packet,
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag = (const AVCodecTag*[]){codec_movvideo_tags, codec_movaudio_tags, 0},
+ .codec_tag = (const AVCodecTag* const []){codec_movvideo_tags, codec_movaudio_tags, 0},
};
#endif
#ifdef CONFIG_TGP_MUXER
@@ -1719,7 +1719,7 @@
mov_write_packet,
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag = (const AVCodecTag*[]){codec_3gp_tags, 0},
+ .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
};
#endif
#ifdef CONFIG_MP4_MUXER
@@ -1735,7 +1735,7 @@
mov_write_packet,
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag = (const AVCodecTag*[]){ff_mp4_obj_type, 0},
+ .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
};
#endif
#ifdef CONFIG_PSP_MUXER
@@ -1751,7 +1751,7 @@
mov_write_packet,
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag = (const AVCodecTag*[]){ff_mp4_obj_type, 0},
+ .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
};
#endif
#ifdef CONFIG_TG2_MUXER
@@ -1767,7 +1767,7 @@
mov_write_packet,
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag = (const AVCodecTag*[]){codec_3gp_tags, 0},
+ .codec_tag = (const AVCodecTag* const []){codec_3gp_tags, 0},
};
#endif
#ifdef CONFIG_IPOD_MUXER
@@ -1783,6 +1783,6 @@
mov_write_packet,
mov_write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag = (const AVCodecTag*[]){ff_mp4_obj_type, 0},
+ .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
};
#endif
Index: libavformat/vocdec.c
===================================================================
--- libavformat/vocdec.c (revision 14905)
+++ libavformat/vocdec.c (working copy)
@@ -141,5 +141,5 @@
voc_probe,
voc_read_header,
voc_read_packet,
- .codec_tag=(const AVCodecTag*[]){voc_codec_tags, 0},
+ .codec_tag=(const AVCodecTag* const []){voc_codec_tags, 0},
};
Index: libavformat/au.c
===================================================================
--- libavformat/au.c (revision 14905)
+++ libavformat/au.c (working copy)
@@ -186,7 +186,7 @@
au_read_packet,
NULL,
pcm_read_seek,
- .codec_tag= (const AVCodecTag*[]){codec_au_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_au_tags, 0},
};
#endif
@@ -202,6 +202,6 @@
au_write_header,
au_write_packet,
au_write_trailer,
- .codec_tag= (const AVCodecTag*[]){codec_au_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_au_tags, 0},
};
#endif //CONFIG_AU_MUXER
Index: libavformat/aiff.c
===================================================================
--- libavformat/aiff.c (revision 14905)
+++ libavformat/aiff.c (working copy)
@@ -445,7 +445,7 @@
aiff_read_packet,
NULL,
pcm_read_seek,
- .codec_tag= (const AVCodecTag*[]){codec_aiff_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_aiff_tags, 0},
};
#endif
@@ -461,6 +461,6 @@
aiff_write_header,
aiff_write_packet,
aiff_write_trailer,
- .codec_tag= (const AVCodecTag*[]){codec_aiff_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_aiff_tags, 0},
};
#endif
Index: libavformat/rtp_h264.c
===================================================================
--- libavformat/rtp_h264.c (revision 14905)
+++ libavformat/rtp_h264.c (working copy)
@@ -68,6 +68,8 @@
#define MAGIC_COOKIE (0xdeadbeef) ///< Cookie for the extradata; to verify we are what we think we are, and that we haven't been freed.
#define DEAD_COOKIE (0xdeaddead) ///< Cookie for the extradata; once it is freed.
+static const uint8_t start_sequence[]= { 0, 0, 1 };
+
/* ---------------- private code */
static void sdp_parse_fmtp_config_h264(AVStream * stream,
h264_rtp_extra_data * h264_data,
@@ -113,7 +115,6 @@
h264_data->level_idc = level_idc;
}
} else if (!strcmp(attr, "sprop-parameter-sets")) {
- uint8_t start_sequence[]= { 0, 0, 1 };
codec->extradata_size= 0;
codec->extradata= NULL;
@@ -171,7 +172,6 @@
uint8_t nal = buf[0];
uint8_t type = (nal & 0x1f);
int result= 0;
- uint8_t start_sequence[]= {0, 0, 1};
#ifdef DEBUG
assert(data);
Index: libavformat/nutenc.c
===================================================================
--- libavformat/nutenc.c (revision 14905)
+++ libavformat/nutenc.c (working copy)
@@ -821,5 +821,5 @@
write_packet,
write_trailer,
.flags = AVFMT_GLOBALHEADER,
- .codec_tag= (const AVCodecTag*[]){codec_bmp_tags, codec_wav_tags, ff_nut_subtitle_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_bmp_tags, codec_wav_tags, ff_nut_subtitle_tags, 0},
};
Index: libavformat/wav.c
===================================================================
--- libavformat/wav.c (revision 14905)
+++ libavformat/wav.c (working copy)
@@ -265,7 +265,7 @@
NULL,
wav_read_seek,
.flags= AVFMT_GENERIC_INDEX,
- .codec_tag= (const AVCodecTag*[]){codec_wav_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_wav_tags, 0},
};
#endif
#ifdef CONFIG_WAV_MUXER
@@ -280,6 +280,6 @@
wav_write_header,
wav_write_packet,
wav_write_trailer,
- .codec_tag= (const AVCodecTag*[]){codec_wav_tags, 0},
+ .codec_tag= (const AVCodecTag* const []){codec_wav_tags, 0},
};
#endif
More information about the ffmpeg-devel
mailing list