History

samplefmt: add av_get_bytes_per_sample()

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.

Stefano Sabatini committed 15 years ago

Commit a6703fa1 parent 2f373214 files · +29 −4Browse files

Unified · Split

4 files
  1. doc/APIchanges +4 −0
  2. libavutil/avutil.h +4 −1
  3. libavutil/samplefmt.c +8 −0
  4. libavutil/samplefmt.h +13 −3
doc/APIchanges+4−0
@@ -13,6 +13,10 @@ libavutil: 2011-04-18 · 12 unmodified lines
1313
1414 API changes, most recent first:
1515
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+
1620 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h
1721 Add av_opt_free convenience function.
1822
libavutil/avutil.h+4−1
@@ -40,7 +40,7 @@ · 39 unmodified lines
4040 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
4141
4242 #define LIBAVUTIL_VERSION_MAJOR 51
43−#define LIBAVUTIL_VERSION_MINOR 3
43+#define LIBAVUTIL_VERSION_MINOR 4
4444 #define LIBAVUTIL_VERSION_MICRO 0
4545
4646 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -57,6 +57,9 @@ · 10 unmodified lines
5757 * Those FF_API_* defines are not part of public API.
5858 * They may change, break or disappear at any time.
5959 */
60+#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT
61+#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52)
62+#endif
6063
6164 /**
6265 * Return the LIBAVUTIL_VERSION_INT constant.
libavutil/samplefmt.c+8−0
@@ -66,8 +66,16 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam · 65 unmodified lines
6666 return buf;
6767 }
6868
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
6976 int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)
7077 {
7178 return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ?
7279 0 : sample_fmt_info[sample_fmt].bits;
7380 }
81+#endif
libavutil/samplefmt.h+13−3
@@ -19,6 +19,8 @@ · 18 unmodified lines
1919 #ifndef AVUTIL_SAMPLEFMT_H
2020 #define AVUTIL_SAMPLEFMT_H
2121
22+#include "avutil.h"
23+
2224 /**
2325 * all in native-endian format
2426 */
@@ -58,13 +60,21 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); · 33 unmodified lines
5860 */
5961 char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
6062
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+
6171 /**
62− * Return sample format bits per sample.
72+ * Return number of bytes per sample.
6373 *
6474 * @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
6676 * sample format
6777 */
68−int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
78+int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
6979
7080 #endif /* AVUTIL_SAMPLEFMT_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t