FFmpeg
af_aresample.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Stefano Sabatini
3  * Copyright (c) 2011 Mina Nagy Zaki
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * resampling audio filter
25  */
26 
27 #include "libavutil/avstring.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/samplefmt.h"
31 #include "libavutil/avassert.h"
33 #include "avfilter.h"
34 #include "audio.h"
35 #include "internal.h"
36 
37 typedef struct AResampleContext {
38  const AVClass *class;
40  double ratio;
41  struct SwrContext *swr;
42  int64_t next_pts;
43  int more_data;
45 
47 {
48  AResampleContext *aresample = ctx->priv;
49  int ret = 0;
50 
51  aresample->next_pts = AV_NOPTS_VALUE;
52  aresample->swr = swr_alloc();
53  if (!aresample->swr) {
54  ret = AVERROR(ENOMEM);
55  goto end;
56  }
57 
58  if (opts) {
60 
61  while ((e = av_dict_get(*opts, "", e, AV_DICT_IGNORE_SUFFIX))) {
62  if ((ret = av_opt_set(aresample->swr, e->key, e->value, 0)) < 0)
63  goto end;
64  }
66  }
67  if (aresample->sample_rate_arg > 0)
68  av_opt_set_int(aresample->swr, "osr", aresample->sample_rate_arg, 0);
69 end:
70  return ret;
71 }
72 
74 {
75  AResampleContext *aresample = ctx->priv;
76  swr_free(&aresample->swr);
77 }
78 
80 {
81  AResampleContext *aresample = ctx->priv;
82  enum AVSampleFormat out_format;
83  int64_t out_rate, out_layout;
84 
85  AVFilterLink *inlink = ctx->inputs[0];
86  AVFilterLink *outlink = ctx->outputs[0];
87 
88  AVFilterFormats *in_formats, *out_formats;
89  AVFilterFormats *in_samplerates, *out_samplerates;
90  AVFilterChannelLayouts *in_layouts, *out_layouts;
91  int ret;
92 
93  av_opt_get_sample_fmt(aresample->swr, "osf", 0, &out_format);
94  av_opt_get_int(aresample->swr, "osr", 0, &out_rate);
95  av_opt_get_int(aresample->swr, "ocl", 0, &out_layout);
96 
97  in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
98  if ((ret = ff_formats_ref(in_formats, &inlink->outcfg.formats)) < 0)
99  return ret;
100 
101  in_samplerates = ff_all_samplerates();
102  if ((ret = ff_formats_ref(in_samplerates, &inlink->outcfg.samplerates)) < 0)
103  return ret;
104 
105  in_layouts = ff_all_channel_counts();
106  if ((ret = ff_channel_layouts_ref(in_layouts, &inlink->outcfg.channel_layouts)) < 0)
107  return ret;
108 
109  if(out_rate > 0) {
110  int ratelist[] = { out_rate, -1 };
111  out_samplerates = ff_make_format_list(ratelist);
112  } else {
113  out_samplerates = ff_all_samplerates();
114  }
115 
116  if ((ret = ff_formats_ref(out_samplerates, &outlink->incfg.samplerates)) < 0)
117  return ret;
118 
119  if(out_format != AV_SAMPLE_FMT_NONE) {
120  int formatlist[] = { out_format, -1 };
121  out_formats = ff_make_format_list(formatlist);
122  } else
123  out_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
124  if ((ret = ff_formats_ref(out_formats, &outlink->incfg.formats)) < 0)
125  return ret;
126 
127  if(out_layout) {
128  int64_t layout_list[] = { out_layout, -1 };
129  out_layouts = ff_make_format64_list(layout_list);
130  } else
131  out_layouts = ff_all_channel_counts();
132 
133  return ff_channel_layouts_ref(out_layouts, &outlink->incfg.channel_layouts);
134 }
135 
136 
137 static int config_output(AVFilterLink *outlink)
138 {
139  int ret;
140  AVFilterContext *ctx = outlink->src;
141  AVFilterLink *inlink = ctx->inputs[0];
142  AResampleContext *aresample = ctx->priv;
143  int64_t out_rate, out_layout;
144  enum AVSampleFormat out_format;
145  char inchl_buf[128], outchl_buf[128];
146 
147  aresample->swr = swr_alloc_set_opts(aresample->swr,
148  outlink->channel_layout, outlink->format, outlink->sample_rate,
149  inlink->channel_layout, inlink->format, inlink->sample_rate,
150  0, ctx);
151  if (!aresample->swr)
152  return AVERROR(ENOMEM);
153  if (!inlink->channel_layout)
154  av_opt_set_int(aresample->swr, "ich", inlink->channels, 0);
155  if (!outlink->channel_layout)
156  av_opt_set_int(aresample->swr, "och", outlink->channels, 0);
157 
158  ret = swr_init(aresample->swr);
159  if (ret < 0)
160  return ret;
161 
162  av_opt_get_int(aresample->swr, "osr", 0, &out_rate);
163  av_opt_get_int(aresample->swr, "ocl", 0, &out_layout);
164  av_opt_get_sample_fmt(aresample->swr, "osf", 0, &out_format);
165  outlink->time_base = (AVRational) {1, out_rate};
166 
167  av_assert0(outlink->sample_rate == out_rate);
168  av_assert0(outlink->channel_layout == out_layout || !outlink->channel_layout);
169  av_assert0(outlink->format == out_format);
170 
171  aresample->ratio = (double)outlink->sample_rate / inlink->sample_rate;
172 
173  av_get_channel_layout_string(inchl_buf, sizeof(inchl_buf), inlink ->channels, inlink ->channel_layout);
174  av_get_channel_layout_string(outchl_buf, sizeof(outchl_buf), outlink->channels, outlink->channel_layout);
175 
176  av_log(ctx, AV_LOG_VERBOSE, "ch:%d chl:%s fmt:%s r:%dHz -> ch:%d chl:%s fmt:%s r:%dHz\n",
177  inlink ->channels, inchl_buf, av_get_sample_fmt_name(inlink->format), inlink->sample_rate,
178  outlink->channels, outchl_buf, av_get_sample_fmt_name(outlink->format), outlink->sample_rate);
179  return 0;
180 }
181 
182 static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
183 {
184  AResampleContext *aresample = inlink->dst->priv;
185  const int n_in = insamplesref->nb_samples;
186  int64_t delay;
187  int n_out = n_in * aresample->ratio + 32;
188  AVFilterLink *const outlink = inlink->dst->outputs[0];
189  AVFrame *outsamplesref;
190  int ret;
191 
192  delay = swr_get_delay(aresample->swr, outlink->sample_rate);
193  if (delay > 0)
194  n_out += FFMIN(delay, FFMAX(4096, n_out));
195 
196  outsamplesref = ff_get_audio_buffer(outlink, n_out);
197 
198  if(!outsamplesref) {
199  av_frame_free(&insamplesref);
200  return AVERROR(ENOMEM);
201  }
202 
203  av_frame_copy_props(outsamplesref, insamplesref);
204  outsamplesref->format = outlink->format;
205  outsamplesref->channels = outlink->channels;
206  outsamplesref->channel_layout = outlink->channel_layout;
207  outsamplesref->sample_rate = outlink->sample_rate;
208 
209  if(insamplesref->pts != AV_NOPTS_VALUE) {
210  int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
211  int64_t outpts= swr_next_pts(aresample->swr, inpts);
212  aresample->next_pts =
213  outsamplesref->pts = ROUNDED_DIV(outpts, inlink->sample_rate);
214  } else {
215  outsamplesref->pts = AV_NOPTS_VALUE;
216  }
217  n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
218  (void *)insamplesref->extended_data, n_in);
219  if (n_out <= 0) {
220  av_frame_free(&outsamplesref);
221  av_frame_free(&insamplesref);
222  return 0;
223  }
224 
225  aresample->more_data = outsamplesref->nb_samples == n_out; // Indicate that there is probably more data in our buffers
226 
227  outsamplesref->nb_samples = n_out;
228 
229  ret = ff_filter_frame(outlink, outsamplesref);
230  av_frame_free(&insamplesref);
231  return ret;
232 }
233 
234 static int flush_frame(AVFilterLink *outlink, int final, AVFrame **outsamplesref_ret)
235 {
236  AVFilterContext *ctx = outlink->src;
237  AResampleContext *aresample = ctx->priv;
238  AVFilterLink *const inlink = outlink->src->inputs[0];
239  AVFrame *outsamplesref;
240  int n_out = 4096;
241  int64_t pts;
242 
243  outsamplesref = ff_get_audio_buffer(outlink, n_out);
244  *outsamplesref_ret = outsamplesref;
245  if (!outsamplesref)
246  return AVERROR(ENOMEM);
247 
248  pts = swr_next_pts(aresample->swr, INT64_MIN);
249  pts = ROUNDED_DIV(pts, inlink->sample_rate);
250 
251  n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out, final ? NULL : (void*)outsamplesref->extended_data, 0);
252  if (n_out <= 0) {
253  av_frame_free(&outsamplesref);
254  return (n_out == 0) ? AVERROR_EOF : n_out;
255  }
256 
257  outsamplesref->sample_rate = outlink->sample_rate;
258  outsamplesref->nb_samples = n_out;
259 
260  outsamplesref->pts = pts;
261 
262  return 0;
263 }
264 
265 static int request_frame(AVFilterLink *outlink)
266 {
267  AVFilterContext *ctx = outlink->src;
268  AResampleContext *aresample = ctx->priv;
269  int ret;
270 
271  // First try to get data from the internal buffers
272  if (aresample->more_data) {
273  AVFrame *outsamplesref;
274 
275  if (flush_frame(outlink, 0, &outsamplesref) >= 0) {
276  return ff_filter_frame(outlink, outsamplesref);
277  }
278  }
279  aresample->more_data = 0;
280 
281  // Second request more data from the input
282  ret = ff_request_frame(ctx->inputs[0]);
283 
284  // Third if we hit the end flush
285  if (ret == AVERROR_EOF) {
286  AVFrame *outsamplesref;
287 
288  if ((ret = flush_frame(outlink, 1, &outsamplesref)) < 0)
289  return ret;
290 
291  return ff_filter_frame(outlink, outsamplesref);
292  }
293  return ret;
294 }
295 
296 #if FF_API_CHILD_CLASS_NEXT
297 static const AVClass *resample_child_class_next(const AVClass *prev)
298 {
299  return prev ? NULL : swr_get_class();
300 }
301 #endif
302 
303 static const AVClass *resample_child_class_iterate(void **iter)
304 {
305  const AVClass *c = *iter ? NULL : swr_get_class();
306  *iter = (void*)(uintptr_t)c;
307  return c;
308 }
309 
310 static void *resample_child_next(void *obj, void *prev)
311 {
312  AResampleContext *s = obj;
313  return prev ? NULL : s->swr;
314 }
315 
316 #define OFFSET(x) offsetof(AResampleContext, x)
317 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
318 
319 static const AVOption options[] = {
320  {"sample_rate", NULL, OFFSET(sample_rate_arg), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
321  {NULL}
322 };
323 
324 static const AVClass aresample_class = {
325  .class_name = "aresample",
326  .item_name = av_default_item_name,
327  .option = options,
328  .version = LIBAVUTIL_VERSION_INT,
329 #if FF_API_CHILD_CLASS_NEXT
330  .child_class_next = resample_child_class_next,
331 #endif
332  .child_class_iterate = resample_child_class_iterate,
334 };
335 
336 static const AVFilterPad aresample_inputs[] = {
337  {
338  .name = "default",
339  .type = AVMEDIA_TYPE_AUDIO,
340  .filter_frame = filter_frame,
341  },
342  { NULL }
343 };
344 
345 static const AVFilterPad aresample_outputs[] = {
346  {
347  .name = "default",
348  .config_props = config_output,
349  .request_frame = request_frame,
350  .type = AVMEDIA_TYPE_AUDIO,
351  },
352  { NULL }
353 };
354 
356  .name = "aresample",
357  .description = NULL_IF_CONFIG_SMALL("Resample audio data."),
358  .init_dict = init_dict,
359  .uninit = uninit,
360  .query_formats = query_formats,
361  .priv_size = sizeof(AResampleContext),
362  .priv_class = &aresample_class,
365 };
ff_get_audio_buffer
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
Definition: audio.c:86
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:86
AVFilterFormatsConfig::samplerates
AVFilterFormats * samplerates
Lists of supported sample rates, only for audio.
Definition: avfilter.h:450
SwrContext::outpts
int64_t outpts
output PTS
Definition: swresample_internal.h:160
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:455
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:461
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:55
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
FLAGS
#define FLAGS
Definition: af_aresample.c:317
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
ff_all_channel_counts
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition.
Definition: formats.c:436
av_get_channel_layout_string
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
Definition: channel_layout.c:217
ff_make_format64_list
AVFilterChannelLayouts * ff_make_format64_list(const int64_t *fmts)
Definition: formats.c:295
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:411
AVOption
AVOption.
Definition: opt.h:248
ff_request_frame
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
Definition: avfilter.c:408
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_aresample.c:137
AV_DICT_IGNORE_SUFFIX
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
Definition: dict.h:70
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
AVDictionary
Definition: dict.c:30
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:65
aresample_inputs
static const AVFilterPad aresample_inputs[]
Definition: af_aresample.c:336
samplefmt.h
pts
static int64_t pts
Definition: transcode_aac.c:652
av_opt_set
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
Definition: opt.c:465
ff_all_formats
AVFilterFormats * ff_all_formats(enum AVMediaType type)
Return a list of all formats supported by FFmpeg for the given media type.
Definition: formats.c:345
swr_next_pts
int64_t swr_next_pts(struct SwrContext *s, int64_t pts)
Convert the next timestamp from input to output timestamps are in 1/(in_sample_rate * out_sample_rate...
Definition: swresample.c:917
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
swr_get_delay
int64_t swr_get_delay(struct SwrContext *s, int64_t base)
Gets the delay the next input sample will experience relative to the next output sample.
Definition: swresample.c:867
options
static const AVOption options[]
Definition: af_aresample.c:319
avassert.h
resample_child_next
static void * resample_child_next(void *obj, void *prev)
Definition: af_aresample.c:310
av_cold
#define av_cold
Definition: attributes.h:90
swr_init
av_cold int swr_init(struct SwrContext *s)
Initialize context after user parameters have been set.
Definition: swresample.c:152
av_dict_get
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
Definition: dict.c:40
s
#define s(width, name)
Definition: cbs_vp9.c:257
AVFrame::channels
int channels
number of audio channels, only used for audio.
Definition: frame.h:624
AVDictionaryEntry::key
char * key
Definition: dict.h:82
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
ff_formats_ref
int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref)
Add *ref as a new reference to formats.
Definition: formats.c:466
swr_alloc
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
Definition: options.c:149
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
resample_child_class_iterate
static const AVClass * resample_child_class_iterate(void **iter)
Definition: af_aresample.c:303
swr_convert
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg[SWR_CH_MAX], int in_count)
Definition: swresample.c:714
ctx
AVFormatContext * ctx
Definition: movenc.c:48
channels
channels
Definition: aptx.h:33
av_get_sample_fmt_name
const char * av_get_sample_fmt_name(enum AVSampleFormat sample_fmt)
Return the name of sample_fmt, or NULL if sample_fmt is not recognized.
Definition: samplefmt.c:49
SwrContext
The libswresample context.
Definition: swresample_internal.h:95
swr_alloc_set_opts
struct SwrContext * swr_alloc_set_opts(struct SwrContext *s, int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, int log_offset, void *log_ctx)
Allocate SwrContext if needed and set/reset common parameters.
Definition: swresample.c:59
opts
AVDictionary * opts
Definition: movenc.c:50
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
AResampleContext::sample_rate_arg
int sample_rate_arg
Definition: af_aresample.c:39
swr_get_class
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Definition: options.c:144
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
init_dict
static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts)
Definition: af_aresample.c:46
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:349
ROUNDED_DIV
#define ROUNDED_DIV(a, b)
Definition: common.h:56
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
av_opt_get_sample_fmt
int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt)
Definition: opt.c:1009
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
av_opt_get_int
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
Definition: opt.c:912
swresample.h
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:586
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_aresample.c:73
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
AVClass::child_next
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
Definition: log.h:113
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:490
FFMAX
#define FFMAX(a, b)
Definition: common.h:103
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:59
AResampleContext::ratio
double ratio
Definition: af_aresample.c:40
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
aresample_outputs
static const AVFilterPad aresample_outputs[]
Definition: af_aresample.c:345
swr_free
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
Definition: swresample.c:137
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:391
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
AVFrame::channel_layout
uint64_t channel_layout
Channel layout of the audio data.
Definition: frame.h:495
av_dict_free
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
Definition: dict.c:203
AResampleContext
Definition: af_aresample.c:37
AResampleContext::swr
struct SwrContext * swr
Definition: af_aresample.c:41
internal.h
flush_frame
static int flush_frame(AVFilterLink *outlink, int final, AVFrame **outsamplesref_ret)
Definition: af_aresample.c:234
aresample_class
static const AVClass aresample_class
Definition: af_aresample.c:324
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:384
ff_af_aresample
AVFilter ff_af_aresample
Definition: af_aresample.c:355
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:365
OFFSET
#define OFFSET(x)
Definition: af_aresample.c:316
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
Definition: af_aresample.c:182
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
AVFilter
Filter definition.
Definition: avfilter.h:145
AResampleContext::next_pts
int64_t next_pts
Definition: af_aresample.c:42
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:421
channel_layout.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
AVFilterContext
An instance of a filter.
Definition: avfilter.h:341
audio.h
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:445
AVDictionaryEntry
Definition: dict.h:81
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_aresample.c:79
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_aresample.c:265
AResampleContext::more_data
int more_data
Definition: af_aresample.c:43
AVDictionaryEntry::value
char * value
Definition: dict.h:83
avstring.h