annotate lib/libswresample/swresample.h @ 2547:fed97f15d1e1

* SaveLoad * QuickReference * Modal * Character
author a.parshin
date Tue, 12 May 2015 01:45:31 +0200
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 * Copyright (C) 2011-2013 Michael Niedermayer (michaelni@gmx.at)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
3 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
4 * This file is part of libswresample
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
5 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
6 * libswresample is free software; you can redistribute it and/or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
7 * modify it under the terms of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
8 * License as published by the Free Software Foundation; either
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
9 * version 2.1 of the License, or (at your option) any later version.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
10 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
11 * libswresample is distributed in the hope that it will be useful,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
14 * Lesser General Public License for more details.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
15 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
16 * You should have received a copy of the GNU Lesser General Public
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
17 * License along with libswresample; if not, write to the Free Software
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
19 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
20
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
21 #ifndef SWRESAMPLE_SWRESAMPLE_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
22 #define SWRESAMPLE_SWRESAMPLE_H
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
23
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
24 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
25 * @file
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
26 * @ingroup lswr
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
27 * libswresample public header
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
28 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
29
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
30 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
31 * @defgroup lswr Libswresample
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
32 * @{
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
33 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
34 * Libswresample (lswr) is a library that handles audio resampling, sample
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
35 * format conversion and mixing.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
36 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
37 * Interaction with lswr is done through SwrContext, which is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
38 * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
39 * must be set with the @ref avoptions API.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
40 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
41 * For example the following code will setup conversion from planar float sample
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
42 * format to interleaved signed 16-bit integer, downsampling from 48kHz to
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
43 * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
44 * matrix):
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
45 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
46 * SwrContext *swr = swr_alloc();
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
47 * av_opt_set_int(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
48 * av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
49 * av_opt_set_int(swr, "in_sample_rate", 48000, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
50 * av_opt_set_int(swr, "out_sample_rate", 44100, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
51 * av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
52 * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
53 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
54 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
55 * Once all values have been set, it must be initialized with swr_init(). If
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
56 * you need to change the conversion parameters, you can change the parameters
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
57 * as described above, or by using swr_alloc_set_opts(), then call swr_init()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
58 * again.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
59 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
60 * The conversion itself is done by repeatedly calling swr_convert().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
61 * Note that the samples may get buffered in swr if you provide insufficient
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
62 * output space or if sample rate conversion is done, which requires "future"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
63 * samples. Samples that do not require future input can be retrieved at any
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
64 * time by using swr_convert() (in_count can be set to 0).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
65 * At the end of conversion the resampling buffer can be flushed by calling
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
66 * swr_convert() with NULL in and 0 in_count.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
67 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
68 * The delay between input and output, can at any time be found by using
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
69 * swr_get_delay().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
70 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
71 * The following code demonstrates the conversion loop assuming the parameters
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
72 * from above and caller-defined functions get_input() and handle_output():
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
73 * @code
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
74 * uint8_t **input;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
75 * int in_samples;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
76 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
77 * while (get_input(&input, &in_samples)) {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
78 * uint8_t *output;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
79 * int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) +
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
80 * in_samples, 44100, 48000, AV_ROUND_UP);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
81 * av_samples_alloc(&output, NULL, 2, out_samples,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
82 * AV_SAMPLE_FMT_S16, 0);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
83 * out_samples = swr_convert(swr, &output, out_samples,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
84 * input, in_samples);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
85 * handle_output(output, out_samples);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
86 * av_freep(&output);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
87 * }
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
88 * @endcode
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
89 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
90 * When the conversion is finished, the conversion
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
91 * context and everything associated with it must be freed with swr_free().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
92 * There will be no memory leak if the data is not completely flushed before
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
93 * swr_free().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
94 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
95
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
96 #include <stdint.h>
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
97 #include "lib/libavutil/samplefmt.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
98
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
99 #include "lib/libswresample/version.h"
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
100
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
101 #if LIBSWRESAMPLE_VERSION_MAJOR < 1
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
102 #define SWR_CH_MAX 32 ///< Maximum number of channels
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
103 #endif
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
104
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
105 #define SWR_FLAG_RESAMPLE 1 ///< Force resampling even if equal sample rate
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
106 //TODO use int resample ?
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
107 //long term TODO can we enable this dynamically?
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
108
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
109 enum SwrDitherType {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
110 SWR_DITHER_NONE = 0,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
111 SWR_DITHER_RECTANGULAR,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
112 SWR_DITHER_TRIANGULAR,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
113 SWR_DITHER_TRIANGULAR_HIGHPASS,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
114
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
115 SWR_DITHER_NS = 64, ///< not part of API/ABI
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
116 SWR_DITHER_NS_LIPSHITZ,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
117 SWR_DITHER_NS_F_WEIGHTED,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
118 SWR_DITHER_NS_MODIFIED_E_WEIGHTED,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
119 SWR_DITHER_NS_IMPROVED_E_WEIGHTED,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
120 SWR_DITHER_NS_SHIBATA,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
121 SWR_DITHER_NS_LOW_SHIBATA,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
122 SWR_DITHER_NS_HIGH_SHIBATA,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
123 SWR_DITHER_NB, ///< not part of API/ABI
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
124 };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
125
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
126 /** Resampling Engines */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
127 enum SwrEngine {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
128 SWR_ENGINE_SWR, /**< SW Resampler */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
129 SWR_ENGINE_SOXR, /**< SoX Resampler */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
130 SWR_ENGINE_NB, ///< not part of API/ABI
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
131 };
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
132
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
133 /** Resampling Filter Types */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
134 enum SwrFilterType {
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
135 SWR_FILTER_TYPE_CUBIC, /**< Cubic */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
136 SWR_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall Windowed Sinc */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
137 SWR_FILTER_TYPE_KAISER, /**< Kaiser Windowed Sinc */
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 typedef struct SwrContext SwrContext;
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
141
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
142 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
143 * Get the AVClass for swrContext. It can be used in combination with
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
144 * AV_OPT_SEARCH_FAKE_OBJ for examining options.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
145 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
146 * @see av_opt_find().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
147 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
148 const AVClass *swr_get_class(void);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
149
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
150 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
151 * Allocate SwrContext.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
152 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
153 * If you use this function you will need to set the parameters (manually or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
154 * with swr_alloc_set_opts()) before calling swr_init().
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
155 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
156 * @see swr_alloc_set_opts(), swr_init(), swr_free()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
157 * @return NULL on error, allocated context otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
158 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
159 struct SwrContext *swr_alloc(void);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
160
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
161 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
162 * Initialize context after user parameters have been set.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
163 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
164 * @return AVERROR error code in case of failure.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
165 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
166 int swr_init(struct SwrContext *s);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
167
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
168 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
169 * Allocate SwrContext if needed and set/reset common parameters.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
170 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
171 * This function does not require s to be allocated with swr_alloc(). On the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
172 * other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
173 * on the allocated context.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
174 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
175 * @param s Swr context, can be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
176 * @param out_ch_layout output channel layout (AV_CH_LAYOUT_*)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
177 * @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
178 * @param out_sample_rate output sample rate (frequency in Hz)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
179 * @param in_ch_layout input channel layout (AV_CH_LAYOUT_*)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
180 * @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*).
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
181 * @param in_sample_rate input sample rate (frequency in Hz)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
182 * @param log_offset logging level offset
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
183 * @param log_ctx parent logging context, can be NULL
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
184 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
185 * @see swr_init(), swr_free()
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
186 * @return NULL on error, allocated context otherwise
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
187 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
188 struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
189 int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
190 int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
191 int log_offset, void *log_ctx);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
192
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
193 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
194 * Free the given SwrContext and set the pointer to NULL.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
195 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
196 void swr_free(struct SwrContext **s);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
197
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
198 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
199 * Convert audio.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
200 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
201 * in and in_count can be set to 0 to flush the last few samples out at the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
202 * end.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
203 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
204 * If more input is provided than output space then the input will be buffered.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
205 * You can avoid this buffering by providing more output space than input.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
206 * Convertion will run directly without copying whenever possible.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
207 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
208 * @param s allocated Swr context, with parameters set
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
209 * @param out output buffers, only the first one need be set in case of packed audio
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
210 * @param out_count amount of space available for output in samples per channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
211 * @param in input buffers, only the first one need to be set in case of packed audio
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
212 * @param in_count number of input samples available in one channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
213 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
214 * @return number of samples output per channel, negative value on error
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
215 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
216 int swr_convert(struct SwrContext *s, uint8_t **out, int out_count,
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
217 const uint8_t **in , int in_count);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
218
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
219 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
220 * Convert the next timestamp from input to output
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
221 * timestamps are in 1/(in_sample_rate * out_sample_rate) units.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
222 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
223 * @note There are 2 slightly differently behaving modes.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
224 * First is when automatic timestamp compensation is not used, (min_compensation >= FLT_MAX)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
225 * in this case timestamps will be passed through with delays compensated
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
226 * Second is when automatic timestamp compensation is used, (min_compensation < FLT_MAX)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
227 * in this case the output timestamps will match output sample numbers
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
228 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
229 * @param pts timestamp for the next input sample, INT64_MIN if unknown
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
230 * @return the output timestamp for the next output sample
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
231 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
232 int64_t swr_next_pts(struct SwrContext *s, int64_t pts);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
233
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
234 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
235 * Activate resampling compensation.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
236 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
237 int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
238
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
239 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
240 * Set a customized input channel mapping.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
241 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
242 * @param s allocated Swr context, not yet initialized
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
243 * @param channel_map customized input channel mapping (array of channel
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
244 * indexes, -1 for a muted channel)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
245 * @return AVERROR error code in case of failure.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
246 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
247 int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
248
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
249 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
250 * Set a customized remix matrix.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
251 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
252 * @param s allocated Swr context, not yet initialized
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
253 * @param matrix remix coefficients; matrix[i + stride * o] is
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
254 * the weight of input channel i in output channel o
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
255 * @param stride offset between lines of the matrix
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
256 * @return AVERROR error code in case of failure.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
257 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
258 int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
259
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
260 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
261 * Drops the specified number of output samples.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
262 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
263 int swr_drop_output(struct SwrContext *s, int count);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
264
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
265 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
266 * Injects the specified number of silence samples.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
267 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
268 int swr_inject_silence(struct SwrContext *s, int count);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
269
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
270 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
271 * Gets the delay the next input sample will experience relative to the next output sample.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
272 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
273 * Swresample can buffer data if more input has been provided than available
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
274 * output space, also converting between sample rates needs a delay.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
275 * This function returns the sum of all such delays.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
276 * The exact delay is not necessarily an integer value in either input or
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
277 * output sample rate. Especially when downsampling by a large value, the
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
278 * output sample rate may be a poor choice to represent the delay, similarly
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
279 * for upsampling and the input sample rate.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
280 *
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
281 * @param s swr context
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
282 * @param base timebase in which the returned delay will be
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
283 * if its set to 1 the returned delay is in seconds
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
284 * if its set to 1000 the returned delay is in milli seconds
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
285 * if its set to the input sample rate then the returned delay is in input samples
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
286 * if its set to the output sample rate then the returned delay is in output samples
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
287 * an exact rounding free delay can be found by using LCM(in_sample_rate, out_sample_rate)
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
288 * @returns the delay in 1/base units.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
289 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
290 int64_t swr_get_delay(struct SwrContext *s, int64_t base);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
291
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
292 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
293 * Return the LIBSWRESAMPLE_VERSION_INT constant.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
294 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
295 unsigned swresample_version(void);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
296
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
297 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
298 * Return the swr build-time configuration.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
299 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
300 const char *swresample_configuration(void);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
301
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
302 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
303 * Return the swr license.
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
304 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
305 const char *swresample_license(void);
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
306
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
307 /**
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
308 * @}
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
309 */
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
310
992d2e6f907d preparation for libavcodec
zipi
parents:
diff changeset
311 #endif /* SWRESAMPLE_SWRESAMPLE_H */