Browse code

avutil: use align == 0 for default alignment in audio sample buffer functions

Justin Ruggles authored on 2012/03/28 10:31:14
Showing 3 changed files
... ...
@@ -153,7 +153,7 @@
153 153
 
154 154
 #define LIBAVUTIL_VERSION_MAJOR 51
155 155
 #define LIBAVUTIL_VERSION_MINOR 27
156
-#define LIBAVUTIL_VERSION_MICRO  1
156
+#define LIBAVUTIL_VERSION_MICRO  2
157 157
 
158 158
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
159 159
                                                LIBAVUTIL_VERSION_MINOR, \
... ...
@@ -123,6 +123,10 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
123 123
     if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
124 124
         return AVERROR(EINVAL);
125 125
 
126
+    /* auto-select alignment if not specified */
127
+    if (!align)
128
+        align = 32;
129
+
126 130
     /* check for integer overflow */
127 131
     if (nb_channels > INT_MAX / align ||
128 132
         (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
... ...
@@ -121,6 +121,7 @@ int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
121 121
  * @param nb_channels   the number of channels
122 122
  * @param nb_samples    the number of samples in a single channel
123 123
  * @param sample_fmt    the sample format
124
+ * @param align         buffer size alignment (0 = default, 1 = no alignment)
124 125
  * @return              required buffer size, or negative error code on failure
125 126
  */
126 127
 int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
... ...
@@ -144,7 +145,7 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
144 144
  * @param nb_channels      the number of channels
145 145
  * @param nb_samples       the number of samples in a single channel
146 146
  * @param sample_fmt       the sample format
147
- * @param align            buffer size alignment (1 = no alignment required)
147
+ * @param align            buffer size alignment (0 = default, 1 = no alignment)
148 148
  * @return                 0 on success or a negative error code on failure
149 149
  */
150 150
 int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf,
... ...
@@ -160,7 +161,7 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf,
160 160
  * @param[out] linesize    aligned size for audio buffer(s), may be NULL
161 161
  * @param nb_channels      number of audio channels
162 162
  * @param nb_samples       number of samples per channel
163
- * @param align            buffer size alignment (1 = no alignment required)
163
+ * @param align            buffer size alignment (0 = default, 1 = no alignment)
164 164
  * @return                 0 on success or a negative error code on failure
165 165
  * @see av_samples_fill_arrays()
166 166
  */