avutil: use align == 0 for default alignment in audio sample buffer functions
Fixes: http://pad.lv/1264886, http://pad.lv/1241439
(cherry picked from commit 0109a09dc3)
Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Conflicts:
	libavutil/avutil.h
			
			
This commit is contained in:
		
				
					committed by
					
						
						Reinhard Tartler
					
				
			
			
				
	
			
			
			
						parent
						
							cb5d0ea0be
						
					
				
				
					commit
					b68e5b1195
				
			@@ -155,7 +155,7 @@
 | 
			
		||||
 | 
			
		||||
#define LIBAVUTIL_VERSION_MAJOR 51
 | 
			
		||||
#define LIBAVUTIL_VERSION_MINOR 22
 | 
			
		||||
#define LIBAVUTIL_VERSION_MICRO  1
 | 
			
		||||
#define LIBAVUTIL_VERSION_MICRO  2
 | 
			
		||||
 | 
			
		||||
#define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
 | 
			
		||||
                                               LIBAVUTIL_VERSION_MINOR, \
 | 
			
		||||
 
 | 
			
		||||
@@ -104,6 +104,10 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
 | 
			
		||||
    if (!sample_size || nb_samples <= 0 || nb_channels <= 0)
 | 
			
		||||
        return AVERROR(EINVAL);
 | 
			
		||||
 | 
			
		||||
    /* auto-select alignment if not specified */
 | 
			
		||||
    if (!align)
 | 
			
		||||
        align = 32;
 | 
			
		||||
 | 
			
		||||
    /* check for integer overflow */
 | 
			
		||||
    if (nb_channels > INT_MAX / align ||
 | 
			
		||||
        (int64_t)nb_channels * nb_samples > (INT_MAX - (align * nb_channels)) / sample_size)
 | 
			
		||||
 
 | 
			
		||||
@@ -99,6 +99,7 @@ int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
 | 
			
		||||
 * @param nb_channels   the number of channels
 | 
			
		||||
 * @param nb_samples    the number of samples in a single channel
 | 
			
		||||
 * @param sample_fmt    the sample format
 | 
			
		||||
 * @param align         buffer size alignment (0 = default, 1 = no alignment)
 | 
			
		||||
 * @return              required buffer size, or negative error code on failure
 | 
			
		||||
 */
 | 
			
		||||
int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
 | 
			
		||||
@@ -122,7 +123,7 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
 | 
			
		||||
 * @param nb_channels      the number of channels
 | 
			
		||||
 * @param nb_samples       the number of samples in a single channel
 | 
			
		||||
 * @param sample_fmt       the sample format
 | 
			
		||||
 * @param align            buffer size alignment (1 = no alignment required)
 | 
			
		||||
 * @param align            buffer size alignment (0 = default, 1 = no alignment)
 | 
			
		||||
 * @return                 0 on success or a negative error code on failure
 | 
			
		||||
 */
 | 
			
		||||
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf,
 | 
			
		||||
@@ -138,7 +139,7 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf,
 | 
			
		||||
 * @param[out] linesize    aligned size for audio buffer(s)
 | 
			
		||||
 * @param nb_channels      number of audio channels
 | 
			
		||||
 * @param nb_samples       number of samples per channel
 | 
			
		||||
 * @param align            buffer size alignment (1 = no alignment required)
 | 
			
		||||
 * @param align            buffer size alignment (0 = default, 1 = no alignment)
 | 
			
		||||
 * @return                 0 on success or a negative error code on failure
 | 
			
		||||
 * @see av_samples_fill_arrays()
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user