From 7b49ce2e344a5f8864d8365d57f3c6c743f0c8f7 Mon Sep 17 00:00:00 2001 From: Stefan Huehner Date: Sun, 18 Jun 2006 11:33:14 +0000 Subject: [PATCH] Add const to (mostly) char* and make some functions static, which aren't used outside their declaring source file and which have no corresponding prototype. patch by Stefan Huehner stefan^^@^^huehner^^.^^org Originally committed as revision 5497 to svn://svn.ffmpeg.org/ffmpeg/trunk --- ffmpeg.c | 8 ++++---- ffplay.c | 16 ++++++++-------- ffserver.c | 2 +- libavcodec/alac.c | 2 +- libavcodec/png.c | 2 +- libavcodec/resample2.c | 2 +- libavcodec/truespeech.c | 12 +++++++----- libavformat/aiff.c | 2 +- libavformat/movenc.c | 2 +- libavformat/mpegts.c | 12 ++++++------ libavformat/mpegtsenc.c | 4 ++-- libavformat/rtsp.c | 6 +++--- libavformat/udp.c | 14 +++++++------- libpostproc/postprocess.c | 6 +++--- libpostproc/postprocess_internal.h | 4 ++-- vhook/watermark.c | 4 ++-- 16 files changed, 50 insertions(+), 48 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index 348bab084d..6653c78a9a 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -211,12 +211,12 @@ static int video_global_header = 0; static int rate_emu = 0; #ifdef CONFIG_BKTR -static char *video_grab_format = "bktr"; +static const char *video_grab_format = "bktr"; #else #ifdef CONFIG_VIDEO4LINUX2 -static char *video_grab_format = "video4linux2"; +static const char *video_grab_format = "video4linux2"; #else -static char *video_grab_format = "video4linux"; +static const char *video_grab_format = "video4linux"; #endif #endif static char *video_device = NULL; @@ -224,7 +224,7 @@ static char *grab_device = NULL; static int video_channel = 0; static char *video_standard = "ntsc"; -static char *audio_grab_format = "audio_device"; +static const char *audio_grab_format = "audio_device"; static char *audio_device = NULL; static int audio_volume = 256; diff --git a/ffplay.c b/ffplay.c index 720ce324c9..8cffa8f704 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1735,7 +1735,7 @@ static void stream_component_close(VideoState *is, int stream_index) } } -void dump_stream_info(AVFormatContext *s) +static void dump_stream_info(const AVFormatContext *s) { if (s->track != 0) fprintf(stderr, "Track: %d\n", s->track); @@ -2042,7 +2042,7 @@ static void stream_close(VideoState *is) SDL_DestroyMutex(is->video_decoder_mutex); } -void stream_cycle_channel(VideoState *is, int codec_type) +static void stream_cycle_channel(VideoState *is, int codec_type) { AVFormatContext *ic = is->ic; int start_index, stream_index; @@ -2092,7 +2092,7 @@ void stream_cycle_channel(VideoState *is, int codec_type) } -void toggle_full_screen(void) +static void toggle_full_screen(void) { int w, h, flags; is_full_screen = !is_full_screen; @@ -2117,14 +2117,14 @@ void toggle_full_screen(void) } } -void toggle_pause(void) +static void toggle_pause(void) { if (cur_stream) stream_pause(cur_stream); step = 0; } -void step_to_next_frame(void) +static void step_to_next_frame(void) { if (cur_stream) { if (cur_stream->paused) @@ -2134,7 +2134,7 @@ void step_to_next_frame(void) step = 1; } -void do_exit(void) +static void do_exit(void) { if (cur_stream) { stream_close(cur_stream); @@ -2146,7 +2146,7 @@ void do_exit(void) exit(0); } -void toggle_audio_display(void) +static void toggle_audio_display(void) { if (cur_stream) { cur_stream->show_audio = !cur_stream->show_audio; @@ -2154,7 +2154,7 @@ void toggle_audio_display(void) } /* handle an event sent by the GUI */ -void event_loop(void) +static void event_loop(void) { SDL_Event event; double incr, pos, frac; diff --git a/ffserver.c b/ffserver.c index e31a02706c..4fe7b032d7 100644 --- a/ffserver.c +++ b/ffserver.c @@ -3704,7 +3704,7 @@ static int opt_video_codec(const char *arg) /* simplistic plugin support */ #ifdef CONFIG_HAVE_DLOPEN -void load_module(const char *filename) +static void load_module(const char *filename) { void *dll; void (*init_func)(void); diff --git a/libavcodec/alac.c b/libavcodec/alac.c index 2dc1a48559..8bd75e5d90 100644 --- a/libavcodec/alac.c +++ b/libavcodec/alac.c @@ -407,7 +407,7 @@ static void predictor_decompress_fir_adapt(int32_t *error_buffer, } } -void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, +static void deinterlace_16(int32_t *buffer_a, int32_t *buffer_b, int16_t *buffer_out, int numchannels, int numsamples, uint8_t interlacing_shift, diff --git a/libavcodec/png.c b/libavcodec/png.c index c96638c2d8..efe4cdf4ff 100644 --- a/libavcodec/png.c +++ b/libavcodec/png.c @@ -346,7 +346,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/libavcodec/resample2.c b/libavcodec/resample2.c index 735f612d16..11da57651f 100644 --- a/libavcodec/resample2.c +++ b/libavcodec/resample2.c @@ -62,7 +62,7 @@ typedef struct AVResampleContext{ /** * 0th order modified bessel function of the first kind. */ -double bessel(double x){ +static double bessel(double x){ double v=1; double t=1; int i; diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c index 71b3297b66..dbd29b38f5 100644 --- a/libavcodec/truespeech.c +++ b/libavcodec/truespeech.c @@ -188,7 +188,8 @@ static void truespeech_filters_merge(TSContext *dec) static void truespeech_apply_twopoint_filter(TSContext *dec, int quart) { - int16_t tmp[146 + 60], *ptr0, *ptr1, *filter; + int16_t tmp[146 + 60], *ptr0, *ptr1; + const int16_t *filter; int i, t, off; t = dec->offset2[quart]; @@ -201,7 +202,7 @@ static void truespeech_apply_twopoint_filter(TSContext *dec, int quart) off = (t / 25) + dec->offset1[quart >> 1] + 18; ptr0 = tmp + 145 - off; ptr1 = tmp + 146; - filter = (int16_t*)ts_240 + (t % 25) * 2; + filter = (const int16_t*)ts_240 + (t % 25) * 2; for(i = 0; i < 60; i++){ t = (ptr0[0] * filter[0] + ptr0[1] * filter[1] + 0x2000) >> 14; ptr0++; @@ -214,7 +215,8 @@ static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart) { int16_t tmp[7]; int i, j, t; - int16_t *ptr1, *ptr2; + const int16_t *ptr1; + int16_t *ptr2; int coef; memset(out, 0, 60 * 2); @@ -225,7 +227,7 @@ static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart) } coef = dec->pulsepos[quart] >> 15; - ptr1 = (int16_t*)ts_140 + 30; + ptr1 = (const int16_t*)ts_140 + 30; ptr2 = tmp; for(i = 0, j = 3; (i < 30) && (j > 0); i++){ t = *ptr1++; @@ -238,7 +240,7 @@ static void truespeech_place_pulses(TSContext *dec, int16_t *out, int quart) } } coef = dec->pulsepos[quart] & 0x7FFF; - ptr1 = (int16_t*)ts_140; + ptr1 = (const int16_t*)ts_140; for(i = 30, j = 4; (i < 60) && (j > 0); i++){ t = *ptr1++; if(coef >= t) diff --git a/libavformat/aiff.c b/libavformat/aiff.c index 3dbe6b1524..0e7152ca70 100644 --- a/libavformat/aiff.c +++ b/libavformat/aiff.c @@ -110,7 +110,7 @@ static int fix_bps(int codec_id) } /* Returns the number of sound data frames or negative on error */ -unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec, +static unsigned int get_aiff_header(ByteIOContext *pb, AVCodecContext *codec, int size, unsigned version) { AVExtFloat ext; diff --git a/libavformat/movenc.c b/libavformat/movenc.c index cc24e314ab..5920141173 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -1341,7 +1341,7 @@ static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov, return updateSize(pb, pos); } -int mov_write_mdat_tag(ByteIOContext *pb, MOVContext* mov) +static int mov_write_mdat_tag(ByteIOContext *pb, MOVContext* mov) { put_be32(pb, 8); // placeholder for extended size field (64 bit) put_tag(pb, "wide"); diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index 54e7043089..5575cccda4 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -151,7 +151,7 @@ static void write_section_data(AVFormatContext *s, MpegTSFilter *tss1, } } -MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid, +static MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid, SectionCallback *section_cb, void *opaque, int check_crc) @@ -183,7 +183,7 @@ MpegTSFilter *mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid, return filter; } -MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, +static MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, PESCallback *pes_cb, void *opaque) { @@ -205,7 +205,7 @@ MpegTSFilter *mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, return filter; } -void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter) +static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter) { int pid; @@ -609,7 +609,7 @@ static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len) ts->pat_filter = NULL; } -void mpegts_set_service(MpegTSContext *ts, int sid, +static void mpegts_set_service(MpegTSContext *ts, int sid, SetServiceCallback *set_service_cb, void *opaque) { ts->set_service_cb = set_service_cb; @@ -696,7 +696,7 @@ static void sdt_cb(void *opaque, const uint8_t *section, int section_len) } /* scan services in a transport stream by looking at the SDT */ -void mpegts_scan_sdt(MpegTSContext *ts) +static void mpegts_scan_sdt(MpegTSContext *ts) { ts->sdt_filter = mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); @@ -704,7 +704,7 @@ void mpegts_scan_sdt(MpegTSContext *ts) /* scan services in a transport stream by looking at the PAT (better than nothing !) */ -void mpegts_scan_pat(MpegTSContext *ts) +static void mpegts_scan_pat(MpegTSContext *ts) { ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID, pat_scan_cb, ts, 1); diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c index 7086b5dc89..ad19516b46 100644 --- a/libavformat/mpegtsenc.c +++ b/libavformat/mpegtsenc.c @@ -34,7 +34,7 @@ typedef struct MpegTSSection { } MpegTSSection; /* NOTE: 4 bytes must be left at the end for the crc32 */ -void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) +static void mpegts_write_section(MpegTSSection *s, uint8_t *buf, int len) { unsigned int crc; unsigned char packet[TS_PACKET_SIZE]; @@ -89,7 +89,7 @@ static inline void put16(uint8_t **q_ptr, int val) *q_ptr = q; } -int mpegts_write_section1(MpegTSSection *s, int tid, int id, +static int mpegts_write_section1(MpegTSSection *s, int tid, int id, int version, int sec_num, int last_sec_num, uint8_t *buf, int len) { diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 31af3c9c89..a4bd40f25a 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -145,7 +145,7 @@ static int sdp_parse_rtpmap(AVCodecContext *codec, int payload_type, const char char buf[256]; int i; AVCodec *c; - char *c_name; + const char *c_name; /* Loop into AVRtpDynamicPayloadTypes[] and AVRtpPayloadTypes[] and see if we can handle this kind of payload */ @@ -169,7 +169,7 @@ static int sdp_parse_rtpmap(AVCodecContext *codec, int payload_type, const char c = avcodec_find_decoder(codec->codec_id); if (c && c->name) - c_name = (char *)c->name; + c_name = c->name; else c_name = (char *)NULL; @@ -255,7 +255,7 @@ static void sdp_parse_fmtp_config(AVCodecContext *codec, char *attr, char *value typedef struct attrname_map { - char *str; + const char *str; uint16_t type; uint32_t offset; } attrname_map_t; diff --git a/libavformat/udp.c b/libavformat/udp.c index ee4f67d654..fb72096db5 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -51,7 +51,7 @@ typedef struct { #ifdef CONFIG_IPV6 -int udp_ipv6_is_multicast_address(const struct sockaddr *addr) { +static int udp_ipv6_is_multicast_address(const struct sockaddr *addr) { if (addr->sa_family == AF_INET) return IN_MULTICAST(ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr)); if (addr->sa_family == AF_INET6) @@ -59,7 +59,7 @@ int udp_ipv6_is_multicast_address(const struct sockaddr *addr) { return -1; } -int udp_ipv6_set_multicast_ttl(int sockfd, int mcastTTL, struct sockaddr *addr) { +static int udp_ipv6_set_multicast_ttl(int sockfd, int mcastTTL, struct sockaddr *addr) { if (addr->sa_family == AF_INET) { if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { perror("setsockopt(IP_MULTICAST_TTL)"); @@ -75,7 +75,7 @@ int udp_ipv6_set_multicast_ttl(int sockfd, int mcastTTL, struct sockaddr *addr) return 0; } -int udp_ipv6_join_multicast_group(int sockfd, struct sockaddr *addr) { +static int udp_ipv6_join_multicast_group(int sockfd, struct sockaddr *addr) { struct ip_mreq mreq; struct ipv6_mreq mreq6; if (addr->sa_family == AF_INET) { @@ -97,7 +97,7 @@ int udp_ipv6_join_multicast_group(int sockfd, struct sockaddr *addr) { return 0; } -int udp_ipv6_leave_multicast_group(int sockfd, struct sockaddr *addr) { +static int udp_ipv6_leave_multicast_group(int sockfd, struct sockaddr *addr) { struct ip_mreq mreq; struct ipv6_mreq mreq6; if (addr->sa_family == AF_INET) { @@ -119,7 +119,7 @@ int udp_ipv6_leave_multicast_group(int sockfd, struct sockaddr *addr) { return 0; } -struct addrinfo* udp_ipv6_resolve_host(const char *hostname, int port, int type, int family, int flags) { +static struct addrinfo* udp_ipv6_resolve_host(const char *hostname, int port, int type, int family, int flags) { struct addrinfo hints, *res = 0; int error; char sport[16]; @@ -144,7 +144,7 @@ struct addrinfo* udp_ipv6_resolve_host(const char *hostname, int port, int type, return res; } -int udp_ipv6_set_remote_url(URLContext *h, const char *uri) { +static int udp_ipv6_set_remote_url(URLContext *h, const char *uri) { UDPContext *s = h->priv_data; char hostname[256]; int port; @@ -158,7 +158,7 @@ int udp_ipv6_set_remote_url(URLContext *h, const char *uri) { return 0; } -int udp_ipv6_set_local(URLContext *h) { +static int udp_ipv6_set_local(URLContext *h) { UDPContext *s = h->priv_data; int udp_fd = -1; struct sockaddr_storage clientaddr; diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c index 300ea5c42c..870a8a228d 100644 --- a/libpostproc/postprocess.c +++ b/libpostproc/postprocess.c @@ -161,7 +161,7 @@ static struct PPFilter filters[]= {NULL, NULL,0,0,0,0} //End Marker }; -static char *replaceTable[]= +static const char *replaceTable[]= { "default", "hdeblock:a,vdeblock:a,dering:a", "de", "hdeblock:a,vdeblock:a,dering:a", @@ -766,8 +766,8 @@ pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality) { char temp[GET_MODE_BUFFER_SIZE]; char *p= temp; - char *filterDelimiters= ",/"; - char *optionDelimiters= ":"; + const char *filterDelimiters= ",/"; + const char *optionDelimiters= ":"; struct PPMode *ppMode; char *filterToken; diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h index bab4c841ca..90107c733a 100644 --- a/libpostproc/postprocess_internal.h +++ b/libpostproc/postprocess_internal.h @@ -79,8 +79,8 @@ static inline int CLIP(int a){ * Postprocessng filter. */ struct PPFilter{ - char *shortName; - char *longName; + const char *shortName; + const char *longName; int chromDefault; ///< is chrominance filtering on by default if this filter is manually activated int minLumQuality; ///< minimum quality to turn luminance filtering on int minChromQuality; ///< minimum quality to turn chrominance filtering on diff --git a/vhook/watermark.c b/vhook/watermark.c index cf89e60994..e88dd1b30b 100644 --- a/vhook/watermark.c +++ b/vhook/watermark.c @@ -164,7 +164,7 @@ int Configure(void **ctxp, int argc, char *argv[]) /**************************************************************************** * For mode 0 (the original one) ****************************************************************************/ -void Process0(void *ctx, +static void Process0(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int src_width, @@ -276,7 +276,7 @@ void Process0(void *ctx, /**************************************************************************** * For mode 1 (the original one) ****************************************************************************/ -void Process1(void *ctx, +static void Process1(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int src_width, -- GitLab