annotate lib/libavutil/samplefmt.h @ 2174:5ca3251ea543

autosave continue
author Ritor1
date Tue, 21 Jan 2014 16:37:23 +0600
parents 992d2e6f907d
children
rev   line source
2134
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
1 /*
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
2 * This file is part of FFmpeg.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 * FFmpeg is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 * FFmpeg is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 * License along with FFmpeg; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19 #ifndef AVUTIL_SAMPLEFMT_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20 #define AVUTIL_SAMPLEFMT_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 #include <stdint.h>
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24 #include "avutil.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 #include "attributes.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28 * Audio Sample Formats
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30 * @par
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 * The data described by the sample format is always in native-endian order.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32 * Sample values can be expressed by native C types, hence the lack of a signed
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33 * 24-bit sample format even though it is a common raw audio data format.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 * @par
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36 * The floating-point formats are based on full volume being in the range
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 * [-1.0, 1.0]. Any values outside this range are beyond full volume level.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39 * @par
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 * The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 * (such as AVFrame in libavcodec) is as follows:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 * For planar sample formats, each audio channel is in a separate data plane,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 * and linesize is the buffer size, in bytes, for a single plane. All data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45 * planes must be the same size. For packed sample formats, only the first data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 * plane is used, and samples for each channel are interleaved. In this case,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 * linesize is the buffer size, in bytes, for the 1 plane.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 enum AVSampleFormat {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 AV_SAMPLE_FMT_NONE = -1,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51 AV_SAMPLE_FMT_U8, ///< unsigned 8 bits
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 AV_SAMPLE_FMT_S16, ///< signed 16 bits
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 AV_SAMPLE_FMT_S32, ///< signed 32 bits
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 AV_SAMPLE_FMT_FLT, ///< float
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 AV_SAMPLE_FMT_DBL, ///< double
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59 AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 AV_SAMPLE_FMT_FLTP, ///< float, planar
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 AV_SAMPLE_FMT_DBLP, ///< double, planar
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67 * Return the name of sample_fmt, or NULL if sample_fmt is not
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68 * recognized.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73 * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 * on error.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
75 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
76 enum AVSampleFormat av_get_sample_fmt(const char *name);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
77
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
78 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
79 * Return the planar<->packed alternative form of the given sample format, or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
80 * AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
81 * requested planar/packed format, the format returned is the same as the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
82 * input.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
83 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
84 enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
85
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
86 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
87 * Get the packed alternative form of the given sample format.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
88 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
89 * If the passed sample_fmt is already in packed format, the format returned is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
90 * the same as the input.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
91 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
92 * @return the packed alternative form of the given sample format or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
93 AV_SAMPLE_FMT_NONE on error.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
94 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
95 enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
96
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
97 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
98 * Get the planar alternative form of the given sample format.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
99 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
100 * If the passed sample_fmt is already in planar format, the format returned is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
101 * the same as the input.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
102 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
103 * @return the planar alternative form of the given sample format or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
104 AV_SAMPLE_FMT_NONE on error.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
105 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
106 enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
107
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
108 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
109 * Generate a string corresponding to the sample format with
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
110 * sample_fmt, or a header if sample_fmt is negative.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
111 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
112 * @param buf the buffer where to write the string
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
113 * @param buf_size the size of buf
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
114 * @param sample_fmt the number of the sample format to print the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
115 * corresponding info string, or a negative value to print the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
116 * corresponding header.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
117 * @return the pointer to the filled buffer or NULL if sample_fmt is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
118 * unknown or in case of other errors
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
119 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
120 char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
121
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
122 #if FF_API_GET_BITS_PER_SAMPLE_FMT
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
123 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
124 * @deprecated Use av_get_bytes_per_sample() instead.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
125 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
126 attribute_deprecated
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
127 int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
128 #endif
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
129
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
130 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
131 * Return number of bytes per sample.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
132 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
133 * @param sample_fmt the sample format
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
134 * @return number of bytes per sample or zero if unknown for the given
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
135 * sample format
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
136 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
137 int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
138
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
139 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
140 * Check if the sample format is planar.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
141 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
142 * @param sample_fmt the sample format to inspect
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
143 * @return 1 if the sample format is planar, 0 if it is interleaved
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
144 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
145 int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
146
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
147 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
148 * Get the required buffer size for the given audio parameters.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
149 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
150 * @param[out] linesize calculated linesize, may be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
151 * @param nb_channels the number of channels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
152 * @param nb_samples the number of samples in a single channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
153 * @param sample_fmt the sample format
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
154 * @param align buffer size alignment (0 = default, 1 = no alignment)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
155 * @return required buffer size, or negative error code on failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
156 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
157 int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
158 enum AVSampleFormat sample_fmt, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
159
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
160 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
161 * Fill plane data pointers and linesize for samples with sample
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
162 * format sample_fmt.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
163 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
164 * The audio_data array is filled with the pointers to the samples data planes:
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
165 * for planar, set the start point of each channel's data within the buffer,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
166 * for packed, set the start point of the entire buffer only.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
167 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
168 * The value pointed to by linesize is set to the aligned size of each
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
169 * channel's data buffer for planar layout, or to the aligned size of the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
170 * buffer for all channels for packed layout.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
171 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
172 * The buffer in buf must be big enough to contain all the samples
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
173 * (use av_samples_get_buffer_size() to compute its minimum size),
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
174 * otherwise the audio_data pointers will point to invalid data.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
175 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
176 * @see enum AVSampleFormat
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
177 * The documentation for AVSampleFormat describes the data layout.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
178 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
179 * @param[out] audio_data array to be filled with the pointer for each channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
180 * @param[out] linesize calculated linesize, may be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
181 * @param buf the pointer to a buffer containing the samples
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
182 * @param nb_channels the number of channels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
183 * @param nb_samples the number of samples in a single channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
184 * @param sample_fmt the sample format
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
185 * @param align buffer size alignment (0 = default, 1 = no alignment)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
186 * @return >=0 on success or a negative error code on failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
187 * @todo return minimum size in bytes required for the buffer in case
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
188 * of success at the next bump
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
189 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
190 int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
191 const uint8_t *buf,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
192 int nb_channels, int nb_samples,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
193 enum AVSampleFormat sample_fmt, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
194
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
195 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
196 * Allocate a samples buffer for nb_samples samples, and fill data pointers and
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
197 * linesize accordingly.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
198 * The allocated samples buffer can be freed by using av_freep(&audio_data[0])
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
199 * Allocated data will be initialized to silence.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
200 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
201 * @see enum AVSampleFormat
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
202 * The documentation for AVSampleFormat describes the data layout.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
203 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
204 * @param[out] audio_data array to be filled with the pointer for each channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
205 * @param[out] linesize aligned size for audio buffer(s), may be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
206 * @param nb_channels number of audio channels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
207 * @param nb_samples number of samples per channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
208 * @param align buffer size alignment (0 = default, 1 = no alignment)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
209 * @return >=0 on success or a negative error code on failure
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
210 * @todo return the size of the allocated buffer in case of success at the next bump
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
211 * @see av_samples_fill_arrays()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
212 * @see av_samples_alloc_array_and_samples()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
213 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
214 int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
215 int nb_samples, enum AVSampleFormat sample_fmt, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
216
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
217 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
218 * Allocate a data pointers array, samples buffer for nb_samples
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
219 * samples, and fill data pointers and linesize accordingly.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
220 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
221 * This is the same as av_samples_alloc(), but also allocates the data
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
222 * pointers array.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
223 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
224 * @see av_samples_alloc()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
225 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
226 int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
227 int nb_samples, enum AVSampleFormat sample_fmt, int align);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
228
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
229 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
230 * Copy samples from src to dst.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
231 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
232 * @param dst destination array of pointers to data planes
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
233 * @param src source array of pointers to data planes
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
234 * @param dst_offset offset in samples at which the data will be written to dst
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
235 * @param src_offset offset in samples at which the data will be read from src
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
236 * @param nb_samples number of samples to be copied
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
237 * @param nb_channels number of audio channels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
238 * @param sample_fmt audio sample format
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
239 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
240 int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
241 int src_offset, int nb_samples, int nb_channels,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
242 enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
243
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
244 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
245 * Fill an audio buffer with silence.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
246 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
247 * @param audio_data array of pointers to data planes
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
248 * @param offset offset in samples at which to start filling
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
249 * @param nb_samples number of samples to fill
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
250 * @param nb_channels number of audio channels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
251 * @param sample_fmt audio sample format
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
252 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
253 int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
254 int nb_channels, enum AVSampleFormat sample_fmt);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
255
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
256 #endif /* AVUTIL_SAMPLEFMT_H */