[FFmpeg-devel] [PATCH] Fix more of icc's warnings #188

Carl Eugen Hoyos cehoyos
Mon May 12 22:52:40 CEST 2008


Hi!

Attached patch silences most of icc's warnings "enumerated type mixed with 
another type".
I don't know if all changes make actually sense, so please comment.

Carl Eugen
-------------- next part --------------
Index: ffmpeg.c
===================================================================
--- ffmpeg.c	(revision 13132)
+++ ffmpeg.c	(working copy)
@@ -125,7 +125,7 @@
 #endif
 static const char *video_rc_override_string=NULL;
 static int video_disable = 0;
-static int video_discard = 0;
+static enum AVDiscard video_discard = AVDISCARD_DEFAULT;
 static char *video_codec_name = NULL;
 static int video_codec_tag = 0;
 static int same_quality = 0;
@@ -2898,7 +2898,7 @@
 {
     AVStream *st;
     AVCodecContext *video_enc;
-    int codec_id;
+    enum CodecID codec_id;
 
     st = av_new_stream(oc, oc->nb_streams);
     if (!st) {
@@ -3053,7 +3053,8 @@
 {
     AVStream *st;
     AVCodecContext *audio_enc;
-    int codec_id, i;
+    int i;
+    enum CodecID codec_id;
 
     st = av_new_stream(oc, oc->nb_streams);
     if (!st) {
@@ -3902,14 +3903,14 @@
 
 int main(int argc, char **argv)
 {
-    int i;
+    enum CodecType i;
     int64_t ti;
 
     avcodec_register_all();
     avdevice_register_all();
     av_register_all();
 
-    for(i=0; i<CODEC_TYPE_NB; i++){
+    for(i=CODEC_TYPE_VIDEO; i<CODEC_TYPE_NB; i++){
         avctx_opts[i]= avcodec_alloc_context2(i);
     }
     avformat_opts = av_alloc_format_context();
Index: ffserver.c
===================================================================
--- ffserver.c	(revision 13132)
+++ ffserver.c	(working copy)
@@ -3625,7 +3625,7 @@
     memcpy(st->codec, av, sizeof(AVCodecContext));
 }
 
-static int opt_audio_codec(const char *arg)
+static enum CodecID opt_audio_codec(const char *arg)
 {
     AVCodec *p= avcodec_find_encoder_by_name(arg);
 
@@ -3635,7 +3635,7 @@
     return p->id;
 }
 
-static int opt_video_codec(const char *arg)
+static enum CodecID opt_video_codec(const char *arg)
 {
     AVCodec *p= avcodec_find_encoder_by_name(arg);
 
@@ -3682,7 +3682,7 @@
     FFStream **last_stream, *stream, *redirect;
     FFStream **last_feed, *feed;
     AVCodecContext audio_enc, video_enc;
-    int audio_id, video_id;
+    enum CodecID audio_id, video_id;
 
     f = fopen(filename, "r");
     if (!f) {
Index: libavcodec/rawdec.c
===================================================================
--- libavcodec/rawdec.c	(revision 13132)
+++ libavcodec/rawdec.c	(working copy)
@@ -40,7 +40,7 @@
     { PIX_FMT_RGB555, 16 },
     { PIX_FMT_BGR24,  24 },
     { PIX_FMT_RGB32,  32 },
-    { -1, 0 },
+    { PIX_FMT_NONE, 0 },
 };
 
 static const PixelFormatTag pixelFormatBpsMOV[] = {
@@ -51,10 +51,10 @@
     { PIX_FMT_BGR555,   16 },
     { PIX_FMT_RGB24,    24 },
     { PIX_FMT_BGR32_1,  32 },
-    { -1, 0 },
+    { PIX_FMT_NONE, 0 },
 };
 
-static int findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
+static enum PixelFormat findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc)
 {
     while (tags->pix_fmt >= 0) {
         if (tags->fourcc == fourcc)
Index: libavcodec/raw.c
===================================================================
--- libavcodec/raw.c	(revision 13132)
+++ libavcodec/raw.c	(working copy)
@@ -52,7 +52,7 @@
     { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
     { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */
 
-    { -1, 0 },
+    { PIX_FMT_NONE, 0 },
 };
 
 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat fmt)
Index: libavcodec/raw.h
===================================================================
--- libavcodec/raw.h	(revision 13132)
+++ libavcodec/raw.h	(working copy)
@@ -30,7 +30,7 @@
 #include "avcodec.h"
 
 typedef struct PixelFormatTag {
-    int pix_fmt;
+    enum PixelFormat pix_fmt;
     unsigned int fourcc;
 } PixelFormatTag;
 
Index: libavcodec/vp56.c
===================================================================
--- libavcodec/vp56.c	(revision 13132)
+++ libavcodec/vp56.c	(working copy)
@@ -552,12 +552,12 @@
         s->prev_dc[2][VP56_FRAME_CURRENT] = 128;
 
         for (block=0; block < 4*s->mb_width+6; block++) {
-            s->above_blocks[block].ref_frame = -1;
+            s->above_blocks[block].ref_frame = VP56_FRAME_NONE;
             s->above_blocks[block].dc_coeff = 0;
             s->above_blocks[block].not_null_dc = 0;
         }
-        s->above_blocks[2*s->mb_width + 2].ref_frame = 0;
-        s->above_blocks[3*s->mb_width + 4].ref_frame = 0;
+        s->above_blocks[2*s->mb_width + 2].ref_frame = VP56_FRAME_CURRENT;
+        s->above_blocks[3*s->mb_width + 4].ref_frame = VP56_FRAME_CURRENT;
 
         stride_y  = p->linesize[0];
         stride_uv = p->linesize[1];
@@ -573,7 +573,7 @@
                 mb_row_flip = mb_row;
 
             for (block=0; block<4; block++) {
-                s->left_block[block].ref_frame = -1;
+                s->left_block[block].ref_frame = VP56_FRAME_NONE;
                 s->left_block[block].dc_coeff = 0;
                 s->left_block[block].not_null_dc = 0;
             }
Index: libavcodec/imgresample.c
===================================================================
--- libavcodec/imgresample.c	(revision 13132)
+++ libavcodec/imgresample.c	(working copy)
@@ -514,8 +514,8 @@
 
 static const AVClass context_class = { "imgresample", NULL, NULL };
 
-struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
-                                  int dstW, int dstH, int dstFormat,
+struct SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat,
+                                  int dstW, int dstH, enum PixelFormat dstFormat,
                                   int flags, SwsFilter *srcFilter,
                                   SwsFilter *dstFilter, double *param)
 {
@@ -572,8 +572,8 @@
  * asumed to remain valid.
  */
 struct SwsContext *sws_getCachedContext(struct SwsContext *ctx,
-                        int srcW, int srcH, int srcFormat,
-                        int dstW, int dstH, int dstFormat, int flags,
+                        int srcW, int srcH, enum PixelFormat srcFormat,
+                        int dstW, int dstH, enum PixelFormat dstFormat, int flags,
                         SwsFilter *srcFilter, SwsFilter *dstFilter, double *param)
 {
     if (ctx != NULL) {
Index: libavcodec/vp56data.h
===================================================================
--- libavcodec/vp56data.h	(revision 13132)
+++ libavcodec/vp56data.h	(working copy)
@@ -27,6 +27,7 @@
 #include "libavutil/common.h"
 
 typedef enum {
+    VP56_FRAME_NONE     =-1,
     VP56_FRAME_CURRENT  = 0,
     VP56_FRAME_PREVIOUS = 1,
     VP56_FRAME_GOLDEN   = 2,
Index: libavcodec/imgconvert.c
===================================================================
--- libavcodec/imgconvert.c	(revision 13132)
+++ libavcodec/imgconvert.c	(working copy)
@@ -397,9 +397,9 @@
 
 enum PixelFormat avcodec_get_pix_fmt(const char* name)
 {
-    int i;
+    enum PixelFormat i;
 
-    for (i=0; i < PIX_FMT_NB; i++)
+    for (i=PIX_FMT_NONE; i < PIX_FMT_NB; i++)
          if (!strcmp(pix_fmt_info[i].name, name))
              break;
     return i;
@@ -883,7 +883,7 @@
 }
 
 void av_picture_copy(AVPicture *dst, const AVPicture *src,
-              int pix_fmt, int width, int height)
+              enum PixelFormat pix_fmt, int width, int height)
 {
     int i;
     const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
@@ -2088,7 +2088,7 @@
 
 #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
 void img_copy(AVPicture *dst, const AVPicture *src,
-              int pix_fmt, int width, int height)
+              enum PixelFormat pix_fmt, int width, int height)
 {
     av_picture_copy(dst, src, pix_fmt, width, height);
 }
@@ -2382,12 +2382,13 @@
 }
 
 /* XXX: always use linesize. Return -1 if not supported */
-int img_convert(AVPicture *dst, int dst_pix_fmt,
+int img_convert(AVPicture *dst, enum PixelFormat dst_pix_fmt,
                 const AVPicture *src, int src_pix_fmt,
                 int src_width, int src_height)
 {
     static int initialized;
-    int i, ret, dst_width, dst_height, int_pix_fmt;
+    int i, ret, dst_width, dst_height;
+    enum PixelFormat int_pix_fmt;
     const PixFmtInfo *src_pix, *dst_pix;
     const ConvertEntry *ce;
     AVPicture tmp1, *tmp = &tmp1;
Index: libavformat/ipmovie.c
===================================================================
--- libavformat/ipmovie.c	(revision 13132)
+++ libavformat/ipmovie.c	(working copy)
@@ -101,7 +101,7 @@
     unsigned int audio_bits;
     unsigned int audio_channels;
     unsigned int audio_sample_rate;
-    unsigned int audio_type;
+    enum CodecID audio_type;
     unsigned int audio_frame_count;
 
     int video_stream_index;
@@ -544,7 +544,7 @@
     url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
 
     if (chunk_type == CHUNK_VIDEO)
-        ipmovie->audio_type = 0;  /* no audio */
+        ipmovie->audio_type = CODEC_ID_NONE;  /* no audio */
     else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
         return AVERROR_INVALIDDATA;
 
Index: libavformat/electronicarts.c
===================================================================
--- libavformat/electronicarts.c	(revision 13132)
+++ libavformat/electronicarts.c	(working copy)
@@ -49,11 +49,11 @@
 typedef struct EaDemuxContext {
     int big_endian;
 
-    int video_codec;
+    enum CodecID video_codec;
     AVRational time_base;
     int video_stream_index;
 
-    int audio_codec;
+    enum CodecID audio_codec;
     int audio_stream_index;
     int audio_frame_counter;
 
Index: libavformat/avs.c
===================================================================
--- libavformat/avs.c	(revision 13132)
+++ libavformat/avs.c	(working copy)
@@ -37,6 +37,7 @@
 } avs_format_t;
 
 typedef enum avs_block_type {
+    AVS_NONE      = 0x00,
     AVS_VIDEO     = 0x01,
     AVS_AUDIO     = 0x02,
     AVS_PALETTE   = 0x03,
@@ -142,7 +143,7 @@
 {
     avs_format_t *avs = s->priv_data;
     int sub_type = 0, size = 0;
-    avs_block_type_t type = 0;
+    avs_block_type_t type = AVS_NONE;
     int palette_size = 0;
     uint8_t palette[4 + 3 * 256];
     int ret;
Index: libavformat/matroskadec.c
===================================================================
--- libavformat/matroskadec.c	(revision 13132)
+++ libavformat/matroskadec.c	(working copy)
@@ -1053,7 +1053,7 @@
 
             /* track type (video, audio, combined, subtitle, etc.) */
             case MATROSKA_ID_TRACKTYPE: {
-                uint64_t num;
+                MatroskaTrackType num;
                 if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
                     break;
                 if (track->type && track->type != num) {
@@ -1075,7 +1075,7 @@
                         av_log(matroska->ctx, AV_LOG_INFO,
                                "Unknown or unsupported track type 0x%x\n",
                                track->type);
-                        track->type = 0;
+                        track->type = MATROSKA_TRACK_TYPE_NONE;
                         break;
                 }
                 matroska->tracks[matroska->num_tracks - 1] = track;
@@ -1187,7 +1187,7 @@
                          * the right eye, which creates a 3D-like
                          * effect) */
                         case MATROSKA_ID_VIDEOSTEREOMODE: {
-                            uint64_t num;
+                            MatroskaEyeMode num;
                             if ((res = ebml_read_uint(matroska, &id,
                                                       &num)) < 0)
                                 break;
@@ -1206,7 +1206,7 @@
 
                         /* aspect ratio behaviour */
                         case MATROSKA_ID_VIDEOASPECTRATIO: {
-                            uint64_t num;
+                            MatroskaAspectRatioMode num;
                             if ((res = ebml_read_uint(matroska, &id,
                                                       &num)) < 0)
                                 break;
@@ -1496,7 +1496,7 @@
 
                                             switch (id) {
                                                 case MATROSKA_ID_ENCODINGCOMPALGO: {
-                                                    uint64_t num;
+                                                    MatroskaTrackEncodingCompAlgo num;
                                                     if ((res = ebml_read_uint(matroska, &id, &num)) < 0)
                                                         break;
                                                     if (num != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP &&
Index: libavformat/mpegts.c
===================================================================
--- libavformat/mpegts.c	(revision 13132)
+++ libavformat/mpegts.c	(working copy)
@@ -921,7 +921,8 @@
 static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code)
 {
     AVStream *st;
-    int codec_type, codec_id;
+    enum CodecType codec_type;
+    enum CodecID codec_id;
 
     switch(pes->stream_type){
     case STREAM_TYPE_AUDIO_MPEG1:
Index: libavformat/riff.c
===================================================================
--- libavformat/riff.c	(revision 13132)
+++ libavformat/riff.c	(working copy)
@@ -393,9 +393,9 @@
 }
 
 
-int wav_codec_get_id(unsigned int tag, int bps)
+enum CodecID wav_codec_get_id(unsigned int tag, int bps)
 {
-    int id;
+    enum CodecID id;
     id = codec_get_id(codec_wav_tags, tag);
     if (id <= 0)
         return id;
Index: libavformat/rtsp.c
===================================================================
--- libavformat/rtsp.c	(revision 13132)
+++ libavformat/rtsp.c	(working copy)
@@ -367,7 +367,8 @@
     RTSPState *rt = s->priv_data;
     char buf1[64], st_type[64];
     const char *p;
-    int codec_type, payload_type, i;
+    int payload_type, i;
+    enum CodecType codec_type;
     AVStream *st;
     RTSPStream *rtsp_st;
     struct in_addr sdp_ip;
Index: libavformat/riff.h
===================================================================
--- libavformat/riff.h	(revision 13132)
+++ libavformat/riff.h	(working copy)
@@ -41,7 +41,7 @@
 
 void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf);
 int put_wav_header(ByteIOContext *pb, AVCodecContext *enc);
-int wav_codec_get_id(unsigned int tag, int bps);
+enum CodecID wav_codec_get_id(unsigned int tag, int bps);
 void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size);
 
 extern const AVCodecTag codec_bmp_tags[];
Index: libavformat/matroska.h
===================================================================
--- libavformat/matroska.h	(revision 13132)
+++ libavformat/matroska.h	(working copy)
@@ -156,6 +156,7 @@
 #define MATROSKA_ID_FILEUID             0x46AE
 
 typedef enum {
+  MATROSKA_TRACK_TYPE_NONE     = 0x0,
   MATROSKA_TRACK_TYPE_VIDEO    = 0x1,
   MATROSKA_TRACK_TYPE_AUDIO    = 0x2,
   MATROSKA_TRACK_TYPE_COMPLEX  = 0x3,
Index: libavformat/asf.c
===================================================================
--- libavformat/asf.c	(revision 13132)
+++ libavformat/asf.c	(working copy)
@@ -197,7 +197,8 @@
             asf->hdr.max_bitrate        = get_le32(pb);
             asf->packet_size = asf->hdr.max_pktsize;
         } else if (!memcmp(&g, &stream_header, sizeof(GUID))) {
-            int type, type_specific_size, sizeX;
+            int type_specific_size, sizeX;
+            enum CodecType type;
             uint64_t total_size;
             unsigned int tag1;
             int64_t pos1, pos2, start_time;
Index: libavformat/mpeg.c
===================================================================
--- libavformat/mpeg.c	(revision 13132)
+++ libavformat/mpeg.c	(working copy)
@@ -409,7 +409,9 @@
 {
     MpegDemuxContext *m = s->priv_data;
     AVStream *st;
-    int len, startcode, i, type, codec_id = 0, es_type;
+    int len, startcode, i, es_type;
+    enum CodecType type;
+    enum CodecID codec_id = CODEC_ID_NONE;
     int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
 
  redo:
Index: libavformat/raw.c
===================================================================
--- libavformat/raw.c	(revision 13135)
+++ libavformat/raw.c	(working copy)
@@ -68,7 +68,7 @@
 static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
     AVStream *st;
-    int id;
+    enum CodecID id;
 
     st = av_new_stream(s, 0);
     if (!st)
Index: libavformat/sol.c
===================================================================
--- libavformat/sol.c	(revision 13132)
+++ libavformat/sol.c	(working copy)
@@ -48,7 +48,7 @@
 #define SOL_16BIT   4
 #define SOL_STEREO 16
 
-static int sol_codec_id(int magic, int type)
+static enum CodecID sol_codec_id(int magic, int type)
 {
     if (magic == 0x0B8D)
     {
@@ -89,7 +89,8 @@
     int size;
     unsigned int magic,tag;
     ByteIOContext *pb = s->pb;
-    unsigned int id, codec, channels, rate, type;
+    unsigned int id, channels, rate, type;
+    enum CodecID codec;
     AVStream *st;
 
     /* check ".snd" header */
Index: libavformat/au.c
===================================================================
--- libavformat/au.c	(revision 13132)
+++ libavformat/au.c	(working copy)
@@ -118,7 +118,8 @@
     int size;
     unsigned int tag;
     ByteIOContext *pb = s->pb;
-    unsigned int id, codec, channels, rate;
+    unsigned int id, channels, rate;
+    enum CodecID codec;
     AVStream *st;
 
     /* check ".snd" header */
Index: libavformat/aiff.c
===================================================================
--- libavformat/aiff.c	(revision 13132)
+++ libavformat/aiff.c	(working copy)
@@ -44,7 +44,7 @@
 #define AIFF                    0
 #define AIFF_C_VERSION1         0xA2805140
 
-static int aiff_codec_get_id (int bps)
+static enum CodecID aiff_codec_get_id (int bps)
 {
     if (bps <= 8)
         return CODEC_ID_PCM_S8;
@@ -56,7 +56,7 @@
         return CODEC_ID_PCM_S32BE;
 
     /* bigger than 32 isn't allowed  */
-    return 0;
+    return CODEC_ID_NONE;
 }
 
 /* returns the size of the found tag */
Index: libavformat/westwood.c
===================================================================
--- libavformat/westwood.c	(revision 13132)
+++ libavformat/westwood.c	(working copy)
@@ -66,7 +66,7 @@
     int audio_samplerate;
     int audio_channels;
     int audio_bits;
-    int audio_type;
+    enum CodecID audio_type;
     int audio_stream_index;
     int64_t audio_frame_counter;
 } WsAudDemuxContext;
Index: libavformat/segafilm.c
===================================================================
--- libavformat/segafilm.c	(revision 13132)
+++ libavformat/segafilm.c	(working copy)
@@ -46,12 +46,12 @@
     int video_stream_index;
     int audio_stream_index;
 
-    unsigned int audio_type;
+    enum CodecID audio_type;
     unsigned int audio_samplerate;
     unsigned int audio_bits;
     unsigned int audio_channels;
 
-    unsigned int video_type;
+    enum CodecID video_type;
     unsigned int sample_count;
     film_sample_t *sample_table;
     unsigned int current_sample;
@@ -115,7 +115,7 @@
         else if (film->audio_bits == 16)
             film->audio_type = CODEC_ID_PCM_S16BE;
         else
-            film->audio_type = 0;
+            film->audio_type = CODEC_ID_NONE;
     }
 
     if (AV_RB32(&scratch[0]) != FDSC_TAG)
@@ -124,7 +124,7 @@
     if (AV_RB32(&scratch[8]) == CVID_TAG) {
         film->video_type = CODEC_ID_CINEPAK;
     } else
-        film->video_type = 0;
+        film->video_type = CODEC_ID_NONE;
 
     /* initialize the decoder streams */
     if (film->video_type) {
Index: libavdevice/libdc1394.c
===================================================================
--- libavdevice/libdc1394.c	(revision 13132)
+++ libavdevice/libdc1394.c	(working copy)
@@ -68,7 +68,7 @@
     { 320, 240, PIX_FMT_UYVY422, DC1394_VIDEO_MODE_320x240_YUV422 },
     { 640, 480, PIX_FMT_UYYVYY411, DC1394_VIDEO_MODE_640x480_YUV411 },
     { 640, 480, PIX_FMT_UYVY422, DC1394_VIDEO_MODE_640x480_YUV422 },
-    { 0, 0, 0, 0 } /* gotta be the last one */
+    { 0, 0, PIX_FMT_NONE, 0 } /* gotta be the last one */
 };
 
 struct dc1394_frame_rate {
Index: libavdevice/audio.c
===================================================================
--- libavdevice/audio.c	(revision 13132)
+++ libavdevice/audio.c	(working copy)
@@ -46,7 +46,7 @@
     int sample_rate;
     int channels;
     int frame_size; /* in bytes ! */
-    int codec_id;
+    enum CodecID codec_id;
     int flip_left : 1;
     uint8_t buffer[AUDIO_BLOCK_SIZE];
     int buffer_ptr;



More information about the ffmpeg-devel mailing list