[FFmpeg-devel] [PATCH 5/5] all: fix enum definition for large values

Ganesh Ajjanagadde gajjanagadde at gmail.com
Sat Oct 24 15:29:23 CEST 2015


ISO C restricts enumerator values to the range of int. Thus (for instance) 0x80000000
unfortunately does not work, and throws a warning with -Wpedantic on
clang 3.7.

This fixes such errors by explicitly casting as an int, doing the
desired unsigned to signed conversion. This method works on all current
architectures. Tested with FATE.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 libavcodec/dca_syncwords.h | 24 ++++++++++++------------
 libavformat/cinedec.c      |  8 ++++----
 libavformat/mov_chan.c     |  2 +-
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavcodec/dca_syncwords.h b/libavcodec/dca_syncwords.h
index 3466b6b..a2ff313 100644
--- a/libavcodec/dca_syncwords.h
+++ b/libavcodec/dca_syncwords.h
@@ -20,18 +20,18 @@
 #define AVCODEC_DCA_SYNCWORDS_H
 
 enum DCASyncwords {
-    DCA_SYNCWORD_CORE_BE        = 0x7FFE8001U,
-    DCA_SYNCWORD_CORE_LE        = 0xFE7F0180U,
-    DCA_SYNCWORD_CORE_14B_BE    = 0x1FFFE800U,
-    DCA_SYNCWORD_CORE_14B_LE    = 0xFF1F00E8U,
-    DCA_SYNCWORD_XCH            = 0x5A5A5A5AU,
-    DCA_SYNCWORD_XXCH           = 0x47004A03U,
-    DCA_SYNCWORD_X96            = 0x1D95F262U,
-    DCA_SYNCWORD_XBR            = 0x655E315EU,
-    DCA_SYNCWORD_LBR            = 0x0A801921U,
-    DCA_SYNCWORD_XLL            = 0x41A29547U,
-    DCA_SYNCWORD_SUBSTREAM      = 0x64582025U,
-    DCA_SYNCWORD_SUBSTREAM_CORE = 0x02B09261U,
+    DCA_SYNCWORD_CORE_BE        =      0x7FFE8001U,
+    DCA_SYNCWORD_CORE_LE        = (int)0xFE7F0180U,
+    DCA_SYNCWORD_CORE_14B_BE    =      0x1FFFE800U,
+    DCA_SYNCWORD_CORE_14B_LE    = (int)0xFF1F00E8U,
+    DCA_SYNCWORD_XCH            =      0x5A5A5A5AU,
+    DCA_SYNCWORD_XXCH           =      0x47004A03U,
+    DCA_SYNCWORD_X96            =      0x1D95F262U,
+    DCA_SYNCWORD_XBR            =      0x655E315EU,
+    DCA_SYNCWORD_LBR            =      0x0A801921U,
+    DCA_SYNCWORD_XLL            =      0x41A29547U,
+    DCA_SYNCWORD_SUBSTREAM      =      0x64582025U,
+    DCA_SYNCWORD_SUBSTREAM_CORE =      0x02B09261U,
 };
 
 #endif /* AVCODEC_DCA_SYNCWORDS_H */
diff --git a/libavformat/cinedec.c b/libavformat/cinedec.c
index 632f46c..9a9023e 100644
--- a/libavformat/cinedec.c
+++ b/libavformat/cinedec.c
@@ -50,10 +50,10 @@ enum {
     CFA_BAYER     = 3,  /**< GB/RG */
     CFA_BAYERFLIP = 4,  /**< RG/GB */
 
-    CFA_TLGRAY    = 0x80000000,
-    CFA_TRGRAY    = 0x40000000,
-    CFA_BLGRAY    = 0x20000000,
-    CFA_BRGRAY    = 0x10000000
+    CFA_TLGRAY    = (int)0x80000000,
+    CFA_TRGRAY    =      0x40000000,
+    CFA_BLGRAY    =      0x20000000,
+    CFA_BRGRAY    =      0x10000000
 };
 
 static int cine_read_probe(AVProbeData *p)
diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index a2fa8d6..cb91a05 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -45,7 +45,7 @@
  *            do not specify a particular ordering of those channels."
  */
 enum MovChannelLayoutTag {
-    MOV_CH_LAYOUT_UNKNOWN               = 0xFFFF0000,
+    MOV_CH_LAYOUT_UNKNOWN               = (int)0xFFFF0000,
     MOV_CH_LAYOUT_USE_DESCRIPTIONS      = (  0 << 16) | 0,
     MOV_CH_LAYOUT_USE_BITMAP            = (  1 << 16) | 0,
     MOV_CH_LAYOUT_DISCRETEINORDER       = (147 << 16) | 0,
-- 
2.6.2



More information about the ffmpeg-devel mailing list