diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-04-09 22:48:20 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-04-09 23:02:33 +0200 |
commit | 6bfb3042b3158f0a87629ab0c126cccb269c3d5a (patch) | |
tree | 08699d0bcef99f30b084db2980759af901f8af91 /libavutil | |
parent | 7f66912f1a303a369f6ac435d630971d74310a81 (diff) | |
parent | 679a973e9701576b1c3c6d71838c45c10ac20564 (diff) | |
download | ffmpeg-6bfb3042b3158f0a87629ab0c126cccb269c3d5a.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
avconv: use default alignment for audio buffer
avcodec: use align == 0 for default alignment in avcodec_fill_audio_frame()
avutil: use align == 0 for default alignment in audio sample buffer functions
avutil: allow NULL linesize in av_samples_fill_arrays() and av_samples_alloc()
avconv: remove OutputStream.picref.
avconv: only set SAR once on the decoded frame.
avcodec: validate the channel layout vs. channel count for decoders
audioconvert: make av_get_channel_layout accept composite names.
avutil: add av_get_packed_sample_fmt() and av_get_planar_sample_fmt()
Conflicts:
doc/APIchanges
ffmpeg.c
libavcodec/utils.c
libavcodec/version.h
libavutil/audioconvert.c
libavutil/audioconvert.h
libavutil/avutil.h
libavutil/samplefmt.c
libavutil/samplefmt.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/audioconvert.c | 3 | ||||
-rw-r--r-- | libavutil/audioconvert.h | 8 | ||||
-rw-r--r-- | libavutil/avutil.h | 2 | ||||
-rw-r--r-- | libavutil/samplefmt.c | 31 | ||||
-rw-r--r-- | libavutil/samplefmt.h | 31 |
5 files changed, 61 insertions, 14 deletions
diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c index aa652a66b1..877027f1f7 100644 --- a/libavutil/audioconvert.c +++ b/libavutil/audioconvert.c @@ -80,19 +80,16 @@ static const struct { { "4.1", 5, AV_CH_LAYOUT_4POINT1 }, { "5.1", 6, AV_CH_LAYOUT_5POINT1_BACK }, { "5.1(side)", 6, AV_CH_LAYOUT_5POINT1 }, -// { "5.1+downmix", 8, AV_CH_LAYOUT_5POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, { "6.0", 6, AV_CH_LAYOUT_6POINT0 }, { "6.0(front)", 6, AV_CH_LAYOUT_6POINT0_FRONT }, { "hexagonal", 6, AV_CH_LAYOUT_HEXAGONAL }, { "6.1", 7, AV_CH_LAYOUT_6POINT1 }, { "6.1", 7, AV_CH_LAYOUT_6POINT1_BACK }, { "6.1(front)", 7, AV_CH_LAYOUT_6POINT1_FRONT }, -// { "6.1+downmix", 9, AV_CH_LAYOUT_6POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, { "7.0", 7, AV_CH_LAYOUT_7POINT0 }, { "7.0(front)", 7, AV_CH_LAYOUT_7POINT0_FRONT }, { "7.1", 8, AV_CH_LAYOUT_7POINT1 }, { "7.1(wide)", 8, AV_CH_LAYOUT_7POINT1_WIDE }, -// { "7.1+downmix", 10, AV_CH_LAYOUT_7POINT1|AV_CH_LAYOUT_STEREO_DOWNMIX, }, { "octagonal", 8, AV_CH_LAYOUT_OCTAGONAL }, { "downmix", 2, AV_CH_LAYOUT_STEREO_DOWNMIX, }, }; diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h index 6414d3c3a0..f402b62f63 100644 --- a/libavutil/audioconvert.h +++ b/libavutil/audioconvert.h @@ -106,19 +106,21 @@ */ /** - * Return a channel layout id that matches name, 0 if no match. + * Return a channel layout id that matches name, or 0 if no match is found. + * * name can be one or several of the following notations, * separated by '+' or '|': * - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0, * 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix); * - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC, * SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR); - * - a number of channels, in decimal, optionnally followed by 'c', yielding + * - a number of channels, in decimal, optionally followed by 'c', yielding * the default channel layout for that number of channels (@see * av_get_default_channel_layout); * - a channel layout mask, in hexadecimal starting with "0x" (see the * AV_CH_* macros). - + Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7" + * + * Example: "stereo+FC" = "2+FC" = "2c+1c" = "0x7" */ uint64_t av_get_channel_layout(const char *name); diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 150b788bfb..6464167473 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -153,7 +153,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 45 +#define LIBAVUTIL_VERSION_MINOR 46 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index f4300036c2..98dacb1f66 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -69,6 +69,24 @@ enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int pl return sample_fmt_info[sample_fmt].altform; } +enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt) +{ + if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) + return AV_SAMPLE_FMT_NONE; + if (sample_fmt_info[sample_fmt].planar) + return sample_fmt_info[sample_fmt].altform; + return sample_fmt; +} + +enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt) +{ + if (sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB) + return AV_SAMPLE_FMT_NONE; + if (sample_fmt_info[sample_fmt].planar) + return sample_fmt; + return sample_fmt_info[sample_fmt].altform; +} + char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sample_fmt) { /* print header */ @@ -114,6 +132,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) @@ -131,17 +153,20 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int align) { - int ch, planar, buf_size; + int ch, planar, buf_size, line_size; planar = av_sample_fmt_is_planar(sample_fmt); - buf_size = av_samples_get_buffer_size(linesize, nb_channels, nb_samples, + buf_size = av_samples_get_buffer_size(&line_size, nb_channels, nb_samples, sample_fmt, align); if (buf_size < 0) return buf_size; audio_data[0] = buf; for (ch = 1; planar && ch < nb_channels; ch++) - audio_data[ch] = audio_data[ch-1] + *linesize; + audio_data[ch] = audio_data[ch-1] + line_size; + + if (linesize) + *linesize = line_size; return 0; } diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h index 855cffd838..af015d0cc3 100644 --- a/libavutil/samplefmt.h +++ b/libavutil/samplefmt.h @@ -62,6 +62,28 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar); /** + * Get the packed alternative form of the given sample format. + * + * If the passed sample_fmt is already in packed format, the format returned is + * the same as the input. + * + * @return the packed alternative form of the given sample format or + AV_SAMPLE_FMT_NONE on error. + */ +enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt); + +/** + * Get the planar alternative form of the given sample format. + * + * If the passed sample_fmt is already in planar format, the format returned is + * the same as the input. + * + * @return the planar alternative form of the given sample format or + AV_SAMPLE_FMT_NONE on error. + */ +enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt); + +/** * Generate a string corresponding to the sample format with * sample_fmt, or a header if sample_fmt is negative. * @@ -107,6 +129,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, @@ -125,12 +148,12 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, * for packed layout. * * @param[out] audio_data array to be filled with the pointer for each channel - * @param[out] linesize calculated linesize + * @param[out] linesize calculated linesize, may be NULL * @param buf the pointer to a buffer containing the 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, @@ -143,10 +166,10 @@ int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, uint8_t *buf, * The allocated samples buffer can be freed by using av_freep(&audio_data[0]) * * @param[out] audio_data array to be filled with the pointer for each channel - * @param[out] linesize aligned size for audio buffer(s) + * @param[out] linesize aligned size for audio buffer(s), may be NULL * @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() */ |