]> git.sesse.net Git - ffmpeg/blob - libavutil/samplefmt.h
libavutil: add planar sample formats and av_sample_fmt_is_planar()
[ffmpeg] / libavutil / samplefmt.h
1 /*
2  * This file is part of Libav.
3  *
4  * Libav is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * Libav is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with Libav; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18
19 #ifndef AVUTIL_SAMPLEFMT_H
20 #define AVUTIL_SAMPLEFMT_H
21
22 #include "avutil.h"
23
24 /**
25  * all in native-endian format
26  */
27 enum AVSampleFormat {
28     AV_SAMPLE_FMT_NONE = -1,
29     AV_SAMPLE_FMT_U8,          ///< unsigned 8 bits
30     AV_SAMPLE_FMT_S16,         ///< signed 16 bits
31     AV_SAMPLE_FMT_S32,         ///< signed 32 bits
32     AV_SAMPLE_FMT_FLT,         ///< float
33     AV_SAMPLE_FMT_DBL,         ///< double
34
35     AV_SAMPLE_FMT_U8P,         ///< unsigned 8 bits, planar
36     AV_SAMPLE_FMT_S16P,        ///< signed 16 bits, planar
37     AV_SAMPLE_FMT_S32P,        ///< signed 32 bits, planar
38     AV_SAMPLE_FMT_FLTP,        ///< float, planar
39     AV_SAMPLE_FMT_DBLP,        ///< double, planar
40
41     AV_SAMPLE_FMT_NB           ///< Number of sample formats. DO NOT USE if linking dynamically
42 };
43
44 /**
45  * Return the name of sample_fmt, or NULL if sample_fmt is not
46  * recognized.
47  */
48 const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
49
50 /**
51  * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
52  * on error.
53  */
54 enum AVSampleFormat av_get_sample_fmt(const char *name);
55
56 /**
57  * Generate a string corresponding to the sample format with
58  * sample_fmt, or a header if sample_fmt is negative.
59  *
60  * @param buf the buffer where to write the string
61  * @param buf_size the size of buf
62  * @param sample_fmt the number of the sample format to print the
63  * corresponding info string, or a negative value to print the
64  * corresponding header.
65  * @return the pointer to the filled buffer or NULL if sample_fmt is
66  * unknown or in case of other errors
67  */
68 char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
69
70 #if FF_API_GET_BITS_PER_SAMPLE_FMT
71 /**
72  * @deprecated Use av_get_bytes_per_sample() instead.
73  */
74 attribute_deprecated
75 int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
76 #endif
77
78 /**
79  * Return number of bytes per sample.
80  *
81  * @param sample_fmt the sample format
82  * @return number of bytes per sample or zero if unknown for the given
83  * sample format
84  */
85 int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
86
87 /**
88  * Check if the sample format is planar.
89  *
90  * @param sample_fmt the sample format to inspect
91  * @return 1 if the sample format is planar, 0 if it is interleaved
92  */
93 int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
94
95 #endif /* AVUTIL_SAMPLEFMT_H */