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
13 13
14API changes, most recent first:14API changes, most recent first:
15 15
162011-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
162011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h202011-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
libavutil/avutil.h+4−1
@@ -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 5142#define LIBAVUTIL_VERSION_MAJOR 51
43#define LIBAVUTIL_VERSION_MINOR 343#define LIBAVUTIL_VERSION_MINOR 4
44#define LIBAVUTIL_VERSION_MICRO 044#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.
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
66 return buf;66 return buf;
67}67}
68 68
69int 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
69int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt)76int 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
libavutil/samplefmt.h+13−3
@@ -19,6 +19,8 @@ · 18 unmodified lines
19#ifndef AVUTIL_SAMPLEFMT_H19#ifndef AVUTIL_SAMPLEFMT_H
20#define AVUTIL_SAMPLEFMT_H20#define AVUTIL_SAMPLEFMT_H
21 21
22#include "avutil.h"
23
22/**24/**
23 * all in native-endian format25 * 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 */
59char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);61char *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 */
67attribute_deprecated
68int 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 format74 * @param sample_fmt the sample format
65 * @return number of bits per sample or zero if unknown for the given75 * @return number of bytes per sample or zero if unknown for the given
66 * sample format76 * sample format
67 */77 */
68int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);78int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
69 79
70#endif /* AVUTIL_SAMPLEFMT_H */80#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