Deprecate av_get_bits_per_sample_fmt(), which was a misnamed function. For the moment we don't have sample formats with a non-integer number of bytes, in that case we may need to create a new av_get_bits_per_sample() function. In the meanwhile we prefer to adopt this variant, since avoids divisions by 8 all over the place.
Unified · Split
| @@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines | |||
| 13 | 13 | ||
| 14 | API changes, most recent first: | 14 | API changes, most recent first: |
| 15 | 15 | ||
| 16 | 2011-06-07 - xxxxxxx - lavu 51.4.0 - av_get_bytes_per_sample() | ||
| 17 | Add av_get_bytes_per_sample() in libavutil/samplefmt.h. | ||
| 18 | Deprecate av_get_bits_per_sample_fmt(). | ||
| 19 | |||
| 16 | 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h | 20 | 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h |
| 17 | Add av_opt_free convenience function. | 21 | Add av_opt_free convenience function. |
| 18 | 22 | ||
| @@ -40,7 +40,7 @@ · 39 unmodified lines | |||
| 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) | 40 | #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) |
| 41 | 41 | ||
| 42 | #define LIBAVUTIL_VERSION_MAJOR 51 | 42 | #define LIBAVUTIL_VERSION_MAJOR 51 |
| 43 | #define LIBAVUTIL_VERSION_MINOR 3 | 43 | #define LIBAVUTIL_VERSION_MINOR 4 |
| 44 | #define LIBAVUTIL_VERSION_MICRO 0 | 44 | #define LIBAVUTIL_VERSION_MICRO 0 |
| 45 | 45 | ||
| 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ | 46 | #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ |
| @@ -57,6 +57,9 @@ · 10 unmodified lines | |||
| 57 | * Those FF_API_* defines are not part of public API. | 57 | * Those FF_API_* defines are not part of public API. |
| 58 | * They may change, break or disappear at any time. | 58 | * They may change, break or disappear at any time. |
| 59 | */ | 59 | */ |
| 60 | #ifndef FF_API_GET_BITS_PER_SAMPLE_FMT | ||
| 61 | #define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52) | ||
| 62 | #endif | ||
| 60 | 63 | ||
| 61 | /** | 64 | /** |
| 62 | * Return the LIBAVUTIL_VERSION_INT constant. | 65 | * Return the LIBAVUTIL_VERSION_INT constant. |
| @@ -66,8 +66,16 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam · 65 unmodified lines | |||
| 66 | return buf; | 66 | return buf; |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt) | ||
| 70 | { | ||
| 71 | return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? | ||
| 72 | 0 : sample_fmt_info[sample_fmt].bits >> 3; | ||
| 73 | } | ||
| 74 | |||
| 75 | #if FF_API_GET_BITS_PER_SAMPLE_FMT | ||
| 69 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) | 76 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) |
| 70 | { | 77 | { |
| 71 | return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? | 78 | return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? |
| 72 | 0 : sample_fmt_info[sample_fmt].bits; | 79 | 0 : sample_fmt_info[sample_fmt].bits; |
| 73 | } | 80 | } |
| 81 | #endif | ||
| @@ -19,6 +19,8 @@ · 18 unmodified lines | |||
| 19 | #ifndef AVUTIL_SAMPLEFMT_H | 19 | #ifndef AVUTIL_SAMPLEFMT_H |
| 20 | #define AVUTIL_SAMPLEFMT_H | 20 | #define AVUTIL_SAMPLEFMT_H |
| 21 | 21 | ||
| 22 | #include "avutil.h" | ||
| 23 | |||
| 22 | /** | 24 | /** |
| 23 | * all in native-endian format | 25 | * all in native-endian format |
| 24 | */ | 26 | */ |
| @@ -58,13 +60,21 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); · 33 unmodified lines | |||
| 58 | */ | 60 | */ |
| 59 | char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); | 61 | char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); |
| 60 | 62 | ||
| 63 | #if FF_API_GET_BITS_PER_SAMPLE_FMT | ||
| 64 | /** | ||
| 65 | * @deprecated Use av_get_bytes_per_sample() instead. | ||
| 66 | */ | ||
| 67 | attribute_deprecated | ||
| 68 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); | ||
| 69 | #endif | ||
| 70 | |||
| 61 | /** | 71 | /** |
| 62 | * Return sample format bits per sample. | 72 | * Return number of bytes per sample. |
| 63 | * | 73 | * |
| 64 | * @param sample_fmt the sample format | 74 | * @param sample_fmt the sample format |
| 65 | * @return number of bits per sample or zero if unknown for the given | 75 | * @return number of bytes per sample or zero if unknown for the given |
| 66 | * sample format | 76 | * sample format |
| 67 | */ | 77 | */ |
| 68 | int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); | 78 | int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); |
| 69 | 79 | ||
| 70 | #endif /* AVUTIL_SAMPLEFMT_H */ | 80 | #endif /* AVUTIL_SAMPLEFMT_H */ |