On date Sunday 2011-03-13 17:27:24 -0400, Justin Ruggles wrote: > On 03/13/2011 05:24 PM, Alex Converse wrote: > > > On Sun, Mar 13, 2011 at 2:20 PM, Justin Ruggles > > <[email protected]> wrote: > >> On 03/13/2011 04:59 PM, Stefano Sabatini wrote: [...] > >>> The second one, av_get_bits_per_sample_fmt(), is misnamed (should be > >>> av_get_bits_per_sample()), so we may change the name to > >>> av_get_bits_per_sample2() for avoiding the conflict with the name > >>> already taken. > >> > >> > >> I agree. But as long as we're reworking it, why not > >> av_get_bytes_per_sample() so it doesn't have to be divided by 8 everywhere? > >> > > > > Don't some ADPCM codecs have less than 8 bits per sample.
First variant attached, if we have no reasons to in the future we won't add some sample format with a non integer number of bytes then I'll post the av_get_bytes_per_sample() variant. -- <RoboHak> hmm, lunch does sound like a good idea <Knghtbrd> would taste like a good idea too
>From 324b2f7c06768a927cb75d4842ec4034e478cade Mon Sep 17 00:00:00 2001 From: Stefano Sabatini <[email protected]> Date: Sun, 5 Jun 2011 18:54:31 +0200 Subject: [PATCH] samplefmt: add av_get_bits_per_sample2() Deprecate av_get_bits_per_sample_fmt(), which was a misnamed function. --- libavutil/avutil.h | 3 +++ libavutil/samplefmt.c | 9 ++++++++- libavutil/samplefmt.h | 10 +++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libavutil/avutil.h b/libavutil/avutil.h index cdd4f71..5c293fe 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -60,6 +60,9 @@ #ifndef FF_API_OLD_EVAL_NAMES #define FF_API_OLD_EVAL_NAMES (LIBAVUTIL_VERSION_MAJOR < 52) #endif +#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT +#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52) +#endif /** * Return the LIBAVUTIL_VERSION_INT constant. diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index ea004d9..e6e9b6d 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -66,12 +66,19 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam return buf; } -int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) +int av_get_bits_per_sample2(enum AVSampleFormat sample_fmt) { return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? 0 : sample_fmt_info[sample_fmt].bits; } +#if FF_API_GET_BITS_PER_SAMPLE_FMT +int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) +{ + return av_get_bits_per_sample2(sample_fmt); +} +#endif + int av_samples_fill_arrays(uint8_t *pointers[8], int linesizes[8], uint8_t *buf, int nb_channels, int nb_samples, enum AVSampleFormat sample_fmt, int planar, int align) diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h index 9b9c0d4..2bee6b5 100644 --- a/libavutil/samplefmt.h +++ b/libavutil/samplefmt.h @@ -60,6 +60,14 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); */ char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); +#if FF_API_GET_BITS_PER_SAMPLE_FMT +/** + * @deprecated Use av_get_bits_per_sample2() instead. + */ +attribute_deprecated +int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); +#endif + /** * Return sample format bits per sample. * @@ -67,7 +75,7 @@ char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat samp * @return number of bits per sample or zero if unknown for the given * sample format */ -int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); +int av_get_bits_per_sample2(enum AVSampleFormat sample_fmt); /** * Fill channel data pointers and linesizes for samples with sample -- 1.7.2.3
_______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
