Browse code

Make channel layout masks unsigned

It makes more sense for a bit mask to use an unsigned type.
The change should be source and binary compatible on all
supported systems, hence micro version bump.

Fixes a few invalid shifts.

Signed-off-by: Mans Rullgard <mans@mansr.com>

Mans Rullgard authored on 2011/11/25 21:51:57
Showing 21 changed files
... ...
@@ -48,7 +48,7 @@ typedef struct AACAC3ParseContext {
48 48
     int sample_rate;
49 49
     int bit_rate;
50 50
     int samples;
51
-    int64_t channel_layout;
51
+    uint64_t channel_layout;
52 52
     int service_type;
53 53
 
54 54
     int remaining_size;
... ...
@@ -90,7 +90,7 @@ static const uint8_t aac_channel_layout_map[7][5][2] = {
90 90
     { { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 2 }, { TYPE_CPE, 1 }, },
91 91
 };
92 92
 
93
-static const int64_t aac_channel_layout[8] = {
93
+static const uint64_t aac_channel_layout[8] = {
94 94
     AV_CH_LAYOUT_MONO,
95 95
     AV_CH_LAYOUT_STEREO,
96 96
     AV_CH_LAYOUT_SURROUND,
... ...
@@ -118,7 +118,7 @@ typedef struct {
118 118
     uint32_t bit_rate;
119 119
     uint8_t channels;
120 120
     uint16_t frame_size;
121
-    int64_t channel_layout;
121
+    uint64_t channel_layout;
122 122
     /** @} */
123 123
 } AC3HeaderInfo;
124 124
 
... ...
@@ -77,7 +77,7 @@ static uint8_t exponent_group_tab[2][3][256];
77 77
 /**
78 78
  * List of supported channel layouts.
79 79
  */
80
-const int64_t ff_ac3_channel_layouts[19] = {
80
+const uint64_t ff_ac3_channel_layouts[19] = {
81 81
      AV_CH_LAYOUT_MONO,
82 82
      AV_CH_LAYOUT_STEREO,
83 83
      AV_CH_LAYOUT_2_1,
... ...
@@ -2063,13 +2063,13 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx)
2063 2063
  * Set channel information during initialization.
2064 2064
  */
2065 2065
 static av_cold int set_channel_info(AC3EncodeContext *s, int channels,
2066
-                                    int64_t *channel_layout)
2066
+                                    uint64_t *channel_layout)
2067 2067
 {
2068 2068
     int ch_layout;
2069 2069
 
2070 2070
     if (channels < 1 || channels > AC3_MAX_CHANNELS)
2071 2071
         return AVERROR(EINVAL);
2072
-    if ((uint64_t)*channel_layout > 0x7FF)
2072
+    if (*channel_layout > 0x7FF)
2073 2073
         return AVERROR(EINVAL);
2074 2074
     ch_layout = *channel_layout;
2075 2075
     if (!ch_layout)
... ...
@@ -258,7 +258,7 @@ typedef struct AC3EncodeContext {
258 258
 } AC3EncodeContext;
259 259
 
260 260
 
261
-extern const int64_t ff_ac3_channel_layouts[19];
261
+extern const uint64_t ff_ac3_channel_layouts[19];
262 262
 
263 263
 int ff_ac3_encode_init(AVCodecContext *avctx);
264 264
 
... ...
@@ -48,7 +48,7 @@ void avcodec_sample_fmt_string (char *buf, int buf_size, int sample_fmt)
48 48
 }
49 49
 #endif
50 50
 
51
-int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)
51
+uint64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name)
52 52
 {
53 53
     switch(nb_channels) {
54 54
     case 1: return AV_CH_LAYOUT_MONO;
... ...
@@ -80,7 +80,7 @@ int avcodec_channel_layout_num_channels(int64_t channel_layout);
80 80
  * @param fmt_name Format name, or NULL if unknown
81 81
  * @return Channel layout mask
82 82
  */
83
-int64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
83
+uint64_t avcodec_guess_channel_layout(int nb_channels, enum CodecID codec_id, const char *fmt_name);
84 84
 
85 85
 struct AVAudioConvert;
86 86
 typedef struct AVAudioConvert AVAudioConvert;
... ...
@@ -2696,14 +2696,14 @@ typedef struct AVCodecContext {
2696 2696
      * - encoding: set by user.
2697 2697
      * - decoding: set by libavcodec.
2698 2698
      */
2699
-    int64_t channel_layout;
2699
+    uint64_t channel_layout;
2700 2700
 
2701 2701
     /**
2702 2702
      * Request decoder to use this channel layout if it can (0 for default)
2703 2703
      * - encoding: unused
2704 2704
      * - decoding: Set by user.
2705 2705
      */
2706
-    int64_t request_channel_layout;
2706
+    uint64_t request_channel_layout;
2707 2707
 
2708 2708
     /**
2709 2709
      * Ratecontrol attempt to use, at maximum, <value> of what can be used without an underflow.
... ...
@@ -3044,7 +3044,7 @@ typedef struct AVCodec {
3044 3044
     const char *long_name;
3045 3045
     const int *supported_samplerates;       ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0
3046 3046
     const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1
3047
-    const int64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3047
+    const uint64_t *channel_layouts;         ///< array of support channel layouts, or NULL if unknown. array is terminated by 0
3048 3048
     uint8_t max_lowres;                     ///< maximum value for lowres supported by the decoder
3049 3049
     const AVClass *priv_class;              ///< AVClass for the private context
3050 3050
     const AVProfile *profiles;              ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN}
... ...
@@ -128,7 +128,7 @@ static const int dca_ext_audio_descr_mask[] = {
128 128
  * All 2 channel configurations -> AV_CH_LAYOUT_STEREO
129 129
  */
130 130
 
131
-static const int64_t dca_core_channel_layout[] = {
131
+static const uint64_t dca_core_channel_layout[] = {
132 132
     AV_CH_FRONT_CENTER,                                                      ///< 1, A
133 133
     AV_CH_LAYOUT_STEREO,                                                     ///< 2, A + B (dual mono)
134 134
     AV_CH_LAYOUT_STEREO,                                                     ///< 2, L + R (stereo)
... ...
@@ -107,7 +107,7 @@ static int truehd_channels(int chanmap)
107 107
     return channels;
108 108
 }
109 109
 
110
-static int64_t truehd_layout(int chanmap)
110
+static uint64_t truehd_layout(int chanmap)
111 111
 {
112 112
     int layout = 0, i;
113 113
 
... ...
@@ -22,7 +22,7 @@
22 22
 
23 23
 #define LIBAVCODEC_VERSION_MAJOR 53
24 24
 #define LIBAVCODEC_VERSION_MINOR 22
25
-#define LIBAVCODEC_VERSION_MICRO  0
25
+#define LIBAVCODEC_VERSION_MICRO  1
26 26
 
27 27
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
28 28
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -27,7 +27,7 @@ extern const float ff_vorbis_floor1_inverse_db_table[256];
27 27
 extern const float * const ff_vorbis_vwin[8];
28 28
 extern const uint8_t ff_vorbis_channel_layout_offsets[8][8];
29 29
 extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8];
30
-extern const int64_t ff_vorbis_channel_layouts[9];
30
+extern const uint64_t ff_vorbis_channel_layouts[9];
31 31
 
32 32
 typedef struct {
33 33
     uint16_t x;
... ...
@@ -44,7 +44,7 @@ const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8] = {
44 44
     { 0, 2, 1, 6, 7, 4, 5, 3 },
45 45
 };
46 46
 
47
-const int64_t ff_vorbis_channel_layouts[9] = {
47
+const uint64_t ff_vorbis_channel_layouts[9] = {
48 48
     AV_CH_LAYOUT_MONO,
49 49
     AV_CH_LAYOUT_STEREO,
50 50
     AV_CH_LAYOUT_SURROUND,
... ...
@@ -143,7 +143,7 @@ switch(format) {\
143 143
     case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout;   break;\
144 144
 }
145 145
 
146
-static av_cold int find_reorder_func(AlsaData *s, int codec_id, int64_t layout, int out)
146
+static av_cold int find_reorder_func(AlsaData *s, int codec_id, uint64_t layout, int out)
147 147
 {
148 148
     int format;
149 149
 
... ...
@@ -194,7 +194,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
194 194
     snd_pcm_t *h;
195 195
     snd_pcm_hw_params_t *hw_params;
196 196
     snd_pcm_uframes_t buffer_size, period_size;
197
-    int64_t layout = ctx->streams[0]->codec->channel_layout;
197
+    uint64_t layout = ctx->streams[0]->codec->channel_layout;
198 198
 
199 199
     if (ctx->filename[0] == 0) audio_device = "default";
200 200
     else                       audio_device = ctx->filename;
... ...
@@ -25,7 +25,7 @@
25 25
 #include "libavutil/audioconvert.h"
26 26
 
27 27
 typedef struct {
28
-    int64_t channel_layout;
28
+    uint64_t channel_layout;
29 29
     int64_t sample_rate;
30 30
 } ANullContext;
31 31
 
... ...
@@ -349,7 +349,7 @@ fail:
349 349
 
350 350
 AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
351 351
                                              enum AVSampleFormat sample_fmt, int size,
352
-                                             int64_t channel_layout, int planar)
352
+                                             uint64_t channel_layout, int planar)
353 353
 {
354 354
     AVFilterBufferRef *ret = NULL;
355 355
 
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  2
32 32
 #define LIBAVFILTER_VERSION_MINOR  13
33
-#define LIBAVFILTER_VERSION_MICRO  0
33
+#define LIBAVFILTER_VERSION_MICRO  1
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 36
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -100,7 +100,7 @@ typedef struct AVFilterBuffer {
100 100
  * per reference properties must be separated out.
101 101
  */
102 102
 typedef struct AVFilterBufferRefAudioProps {
103
-    int64_t channel_layout;     ///< channel layout of audio buffer
103
+    uint64_t channel_layout;    ///< channel layout of audio buffer
104 104
     int nb_samples;             ///< number of audio samples
105 105
     int size;                   ///< audio buffer size
106 106
     uint32_t sample_rate;       ///< audio buffer sample rate
... ...
@@ -376,7 +376,7 @@ struct AVFilterPad {
376 376
      */
377 377
     AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
378 378
                                            enum AVSampleFormat sample_fmt, int size,
379
-                                           int64_t channel_layout, int planar);
379
+                                           uint64_t channel_layout, int planar);
380 380
 
381 381
     /**
382 382
      * Callback called after the slices of a frame are completely sent. If
... ...
@@ -465,7 +465,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
465 465
 /** default handler for get_audio_buffer() for audio inputs */
466 466
 AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
467 467
                                                      enum AVSampleFormat sample_fmt, int size,
468
-                                                     int64_t channel_layout, int planar);
468
+                                                     uint64_t channel_layout, int planar);
469 469
 
470 470
 /**
471 471
  * A helper for query_formats() which sets all links to the same list of
... ...
@@ -496,7 +496,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
496 496
 /** get_audio_buffer() handler for filters which simply pass audio along */
497 497
 AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
498 498
                                                   enum AVSampleFormat sample_fmt, int size,
499
-                                                  int64_t channel_layout, int planar);
499
+                                                  uint64_t channel_layout, int planar);
500 500
 
501 501
 /**
502 502
  * Filter definition. This defines the pads a filter contains, and all the
... ...
@@ -589,7 +589,7 @@ struct AVFilterLink {
589 589
     int h;                      ///< agreed upon image height
590 590
     AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio
591 591
     /* These two parameters apply only to audio */
592
-    int64_t channel_layout;     ///< channel layout of current buffer (see libavutil/audioconvert.h)
592
+    uint64_t channel_layout;    ///< channel layout of current buffer (see libavutil/audioconvert.h)
593 593
     int64_t sample_rate;        ///< samples per second
594 594
 
595 595
     int format;                 ///< agreed upon media format
... ...
@@ -688,7 +688,7 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int
688 688
  */
689 689
 AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
690 690
                                              enum AVSampleFormat sample_fmt, int size,
691
-                                             int64_t channel_layout, int planar);
691
+                                             uint64_t channel_layout, int planar);
692 692
 
693 693
 /**
694 694
  * Request an input frame from the filter at the other end of the link.
... ...
@@ -57,7 +57,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
57 57
 
58 58
 AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
59 59
                                                      enum AVSampleFormat sample_fmt, int size,
60
-                                                     int64_t channel_layout, int planar)
60
+                                                     uint64_t channel_layout, int planar)
61 61
 {
62 62
     AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer));
63 63
     AVFilterBufferRef *ref = NULL;
... ...
@@ -292,7 +292,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms,
292 292
 
293 293
 AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
294 294
                                                   enum AVSampleFormat sample_fmt, int size,
295
-                                                  int64_t channel_layout, int packed)
295
+                                                  uint64_t channel_layout, int packed)
296 296
 {
297 297
     return avfilter_get_audio_buffer(link->dst->outputs[0], perms, sample_fmt,
298 298
                                      size, channel_layout, packed);
... ...
@@ -60,7 +60,7 @@ static const char *get_channel_name(int channel_id)
60 60
 static const struct {
61 61
     const char *name;
62 62
     int         nb_channels;
63
-    int64_t     layout;
63
+    uint64_t     layout;
64 64
 } channel_layout_map[] = {
65 65
     { "mono",        1,  AV_CH_LAYOUT_MONO },
66 66
     { "stereo",      2,  AV_CH_LAYOUT_STEREO },
... ...
@@ -77,7 +77,7 @@ static const struct {
77 77
     { 0 }
78 78
 };
79 79
 
80
-int64_t av_get_channel_layout(const char *name)
80
+uint64_t av_get_channel_layout(const char *name)
81 81
 {
82 82
     int i = 0;
83 83
     do {
... ...
@@ -90,7 +90,7 @@ int64_t av_get_channel_layout(const char *name)
90 90
 }
91 91
 
92 92
 void av_get_channel_layout_string(char *buf, int buf_size,
93
-                                  int nb_channels, int64_t channel_layout)
93
+                                  int nb_channels, uint64_t channel_layout)
94 94
 {
95 95
     int i;
96 96
 
... ...
@@ -123,7 +123,7 @@ void av_get_channel_layout_string(char *buf, int buf_size,
123 123
     }
124 124
 }
125 125
 
126
-int av_get_channel_layout_nb_channels(int64_t channel_layout)
126
+int av_get_channel_layout_nb_channels(uint64_t channel_layout)
127 127
 {
128 128
     int count;
129 129
     uint64_t x = channel_layout;
... ...
@@ -62,7 +62,7 @@
62 62
 /** Channel mask value used for AVCodecContext.request_channel_layout
63 63
     to indicate that the user requests the channel order of the decoder output
64 64
     to be the native codec channel order. */
65
-#define AV_CH_LAYOUT_NATIVE          0x8000000000000000LL
65
+#define AV_CH_LAYOUT_NATIVE          0x8000000000000000ULL
66 66
 
67 67
 /**
68 68
  * @}
... ...
@@ -92,7 +92,7 @@
92 92
 /**
93 93
  * Return a channel layout id that matches name, 0 if no match.
94 94
  */
95
-int64_t av_get_channel_layout(const char *name);
95
+uint64_t av_get_channel_layout(const char *name);
96 96
 
97 97
 /**
98 98
  * Return a description of a channel layout.
... ...
@@ -101,12 +101,12 @@ int64_t av_get_channel_layout(const char *name);
101 101
  * @param buf put here the string containing the channel layout
102 102
  * @param buf_size size in bytes of the buffer
103 103
  */
104
-void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, int64_t channel_layout);
104
+void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);
105 105
 
106 106
 /**
107 107
  * Return the number of channels in the channel layout.
108 108
  */
109
-int av_get_channel_layout_nb_channels(int64_t channel_layout);
109
+int av_get_channel_layout_nb_channels(uint64_t channel_layout);
110 110
 
111 111
 /**
112 112
  * @}
... ...
@@ -154,7 +154,7 @@
154 154
 
155 155
 #define LIBAVUTIL_VERSION_MAJOR 51
156 156
 #define LIBAVUTIL_VERSION_MINOR 19
157
-#define LIBAVUTIL_VERSION_MICRO  0
157
+#define LIBAVUTIL_VERSION_MICRO  1
158 158
 
159 159
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
160 160
                                                LIBAVUTIL_VERSION_MINOR, \