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 "filters.h"
36 #include "formats.h"
37 #include "internal.h"
38 
39 typedef struct AResampleContext {
40  const AVClass *class;
42  double ratio;
43  struct SwrContext *swr;
45  int more_data;
46  int eof;
48 
50 {
51  AResampleContext *aresample = ctx->priv;
52 
53  aresample->next_pts = AV_NOPTS_VALUE;
54  aresample->swr = swr_alloc();
55  if (!aresample->swr)
56  return AVERROR(ENOMEM);
57 
58  return 0;
59 }
60 
62 {
63  AResampleContext *aresample = ctx->priv;
64  swr_free(&aresample->swr);
65 }
66 
68 {
69  AResampleContext *aresample = ctx->priv;
70  enum AVSampleFormat out_format;
71  AVChannelLayout out_layout = { 0 };
72  int64_t out_rate;
73 
74  AVFilterLink *inlink = ctx->inputs[0];
75  AVFilterLink *outlink = ctx->outputs[0];
76 
77  AVFilterFormats *in_formats, *out_formats;
78  AVFilterFormats *in_samplerates, *out_samplerates;
79  AVFilterChannelLayouts *in_layouts, *out_layouts;
80  int ret;
81 
82  if (aresample->sample_rate_arg > 0)
83  av_opt_set_int(aresample->swr, "osr", aresample->sample_rate_arg, 0);
84  av_opt_get_sample_fmt(aresample->swr, "osf", 0, &out_format);
85  av_opt_get_int(aresample->swr, "osr", 0, &out_rate);
86 
87  in_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
88  if ((ret = ff_formats_ref(in_formats, &inlink->outcfg.formats)) < 0)
89  return ret;
90 
91  in_samplerates = ff_all_samplerates();
92  if ((ret = ff_formats_ref(in_samplerates, &inlink->outcfg.samplerates)) < 0)
93  return ret;
94 
95  in_layouts = ff_all_channel_counts();
96  if ((ret = ff_channel_layouts_ref(in_layouts, &inlink->outcfg.channel_layouts)) < 0)
97  return ret;
98 
99  if(out_rate > 0) {
100  int ratelist[] = { out_rate, -1 };
101  out_samplerates = ff_make_format_list(ratelist);
102  } else {
103  out_samplerates = ff_all_samplerates();
104  }
105 
106  if ((ret = ff_formats_ref(out_samplerates, &outlink->incfg.samplerates)) < 0)
107  return ret;
108 
109  if(out_format != AV_SAMPLE_FMT_NONE) {
110  int formatlist[] = { out_format, -1 };
111  out_formats = ff_make_format_list(formatlist);
112  } else
113  out_formats = ff_all_formats(AVMEDIA_TYPE_AUDIO);
114  if ((ret = ff_formats_ref(out_formats, &outlink->incfg.formats)) < 0)
115  return ret;
116 
117  av_opt_get_chlayout(aresample->swr, "ochl", 0, &out_layout);
118  if (av_channel_layout_check(&out_layout)) {
119  const AVChannelLayout layout_list[] = { out_layout, { 0 } };
120  out_layouts = ff_make_channel_layout_list(layout_list);
121  } else
122  out_layouts = ff_all_channel_counts();
123  av_channel_layout_uninit(&out_layout);
124 
125  return ff_channel_layouts_ref(out_layouts, &outlink->incfg.channel_layouts);
126 }
127 
128 
129 static int config_output(AVFilterLink *outlink)
130 {
131  int ret;
132  AVFilterContext *ctx = outlink->src;
133  AVFilterLink *inlink = ctx->inputs[0];
134  AResampleContext *aresample = ctx->priv;
135  AVChannelLayout out_layout = { 0 };
136  int64_t out_rate;
137  enum AVSampleFormat out_format;
138  char inchl_buf[128], outchl_buf[128];
139 
140  ret = swr_alloc_set_opts2(&aresample->swr,
141  &outlink->ch_layout, outlink->format, outlink->sample_rate,
142  &inlink->ch_layout, inlink->format, inlink->sample_rate,
143  0, ctx);
144  if (ret < 0)
145  return ret;
146 
147  ret = swr_init(aresample->swr);
148  if (ret < 0)
149  return ret;
150 
151  av_opt_get_int(aresample->swr, "osr", 0, &out_rate);
152  av_opt_get_chlayout(aresample->swr, "ochl", 0, &out_layout);
153  av_opt_get_sample_fmt(aresample->swr, "osf", 0, &out_format);
154  outlink->time_base = (AVRational) {1, out_rate};
155 
156  av_assert0(outlink->sample_rate == out_rate);
157  av_assert0(!av_channel_layout_compare(&outlink->ch_layout, &out_layout));
158  av_assert0(outlink->format == out_format);
159 
160  av_channel_layout_uninit(&out_layout);
161 
162  aresample->ratio = (double)outlink->sample_rate / inlink->sample_rate;
163 
164  av_channel_layout_describe(&inlink ->ch_layout, inchl_buf, sizeof(inchl_buf));
165  av_channel_layout_describe(&outlink->ch_layout, outchl_buf, sizeof(outchl_buf));
166 
167  av_log(ctx, AV_LOG_VERBOSE, "ch:%d chl:%s fmt:%s r:%dHz -> ch:%d chl:%s fmt:%s r:%dHz\n",
168  inlink ->ch_layout.nb_channels, inchl_buf, av_get_sample_fmt_name(inlink->format), inlink->sample_rate,
169  outlink->ch_layout.nb_channels, outchl_buf, av_get_sample_fmt_name(outlink->format), outlink->sample_rate);
170  return 0;
171 }
172 
173 static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
174 {
175  AVFilterContext *ctx = inlink->dst;
176  AResampleContext *aresample = ctx->priv;
177  const int n_in = insamplesref->nb_samples;
178  int64_t delay;
179  int n_out = n_in * aresample->ratio + 32;
180  AVFilterLink *const outlink = inlink->dst->outputs[0];
181  AVFrame *outsamplesref;
182  int ret;
183 
184  delay = swr_get_delay(aresample->swr, outlink->sample_rate);
185  if (delay > 0)
186  n_out += FFMIN(delay, FFMAX(4096, n_out));
187 
188  outsamplesref = ff_get_audio_buffer(outlink, n_out);
189 
190  if(!outsamplesref) {
191  av_frame_free(&insamplesref);
192  return AVERROR(ENOMEM);
193  }
194 
195  av_frame_copy_props(outsamplesref, insamplesref);
196  outsamplesref->format = outlink->format;
197  ret = av_channel_layout_copy(&outsamplesref->ch_layout, &outlink->ch_layout);
198  if (ret < 0) {
199  av_frame_free(&outsamplesref);
200  av_frame_free(&insamplesref);
201  return ret;
202  }
203  outsamplesref->sample_rate = outlink->sample_rate;
204 
205  if(insamplesref->pts != AV_NOPTS_VALUE) {
206  int64_t inpts = av_rescale(insamplesref->pts, inlink->time_base.num * (int64_t)outlink->sample_rate * inlink->sample_rate, inlink->time_base.den);
207  int64_t outpts= swr_next_pts(aresample->swr, inpts);
208  aresample->next_pts =
209  outsamplesref->pts = ROUNDED_DIV(outpts, inlink->sample_rate);
210  } else {
211  outsamplesref->pts = AV_NOPTS_VALUE;
212  }
213  n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out,
214  (void *)insamplesref->extended_data, n_in);
215  if (n_out <= 0) {
216  av_frame_free(&outsamplesref);
217  av_frame_free(&insamplesref);
219  return 0;
220  }
221 
222  aresample->more_data = outsamplesref->nb_samples == n_out; // Indicate that there is probably more data in our buffers
223 
224  outsamplesref->nb_samples = n_out;
225 
226  ret = ff_filter_frame(outlink, outsamplesref);
227  av_frame_free(&insamplesref);
228  return ret;
229 }
230 
231 static int flush_frame(AVFilterLink *outlink, int final, AVFrame **outsamplesref_ret)
232 {
233  AVFilterContext *ctx = outlink->src;
234  AResampleContext *aresample = ctx->priv;
235  AVFilterLink *const inlink = outlink->src->inputs[0];
236  AVFrame *outsamplesref;
237  int n_out = 4096;
238  int64_t pts;
239 
240  outsamplesref = ff_get_audio_buffer(outlink, n_out);
241  *outsamplesref_ret = outsamplesref;
242  if (!outsamplesref)
243  return AVERROR(ENOMEM);
244 
245  pts = swr_next_pts(aresample->swr, INT64_MIN);
246  pts = ROUNDED_DIV(pts, inlink->sample_rate);
247 
248  n_out = swr_convert(aresample->swr, outsamplesref->extended_data, n_out, final ? NULL : (void*)outsamplesref->extended_data, 0);
249  if (n_out <= 0) {
250  av_frame_free(&outsamplesref);
251  return (n_out == 0) ? AVERROR_EOF : n_out;
252  }
253 
254  outsamplesref->sample_rate = outlink->sample_rate;
255  outsamplesref->nb_samples = n_out;
256 
257  outsamplesref->pts = pts;
258 
259  return 0;
260 }
261 
262 static int request_frame(AVFilterLink *outlink)
263 {
264  AVFilterContext *ctx = outlink->src;
265  AVFilterLink *inlink = ctx->inputs[0];
266  AResampleContext *aresample = ctx->priv;
267  int ret = 0, status;
268  int64_t pts;
269 
270  // First try to get data from the internal buffers
271  if (aresample->more_data) {
272  AVFrame *outsamplesref;
273 
274  if (flush_frame(outlink, 0, &outsamplesref) >= 0) {
275  return ff_filter_frame(outlink, outsamplesref);
276  }
277  }
278  aresample->more_data = 0;
279 
280  if (!aresample->eof && ff_inlink_acknowledge_status(inlink, &status, &pts))
281  aresample->eof = 1;
282 
283  // Second request more data from the input
284  if (!aresample->eof)
286 
287  // Third if we hit the end flush
288  if (aresample->eof) {
289  AVFrame *outsamplesref;
290 
291  if ((ret = flush_frame(outlink, 1, &outsamplesref)) < 0) {
292  if (ret == AVERROR_EOF) {
293  ff_outlink_set_status(outlink, AVERROR_EOF, aresample->next_pts);
294  return 0;
295  }
296  return ret;
297  }
298 
299  return ff_filter_frame(outlink, outsamplesref);
300  }
301 
302  ff_filter_set_ready(ctx, 100);
303  return 0;
304 }
305 
307 {
308  AResampleContext *aresample = ctx->priv;
309  AVFilterLink *inlink = ctx->inputs[0];
310  AVFilterLink *outlink = ctx->outputs[0];
311 
313 
314  if (!aresample->eof && ff_inlink_queued_frames(inlink)) {
315  AVFrame *frame = NULL;
316  int ret;
317 
319  if (ret < 0)
320  return ret;
321  if (ret > 0)
322  return filter_frame(inlink, frame);
323  }
324 
325  return request_frame(outlink);
326 }
327 
328 static const AVClass *resample_child_class_iterate(void **iter)
329 {
330  const AVClass *c = *iter ? NULL : swr_get_class();
331  *iter = (void*)(uintptr_t)c;
332  return c;
333 }
334 
335 static void *resample_child_next(void *obj, void *prev)
336 {
337  AResampleContext *s = obj;
338  return prev ? NULL : s->swr;
339 }
340 
341 #define OFFSET(x) offsetof(AResampleContext, x)
342 #define FLAGS AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
343 
344 static const AVOption options[] = {
345  {"sample_rate", NULL, OFFSET(sample_rate_arg), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
346  {NULL}
347 };
348 
349 static const AVClass aresample_class = {
350  .class_name = "aresample",
351  .item_name = av_default_item_name,
352  .option = options,
353  .version = LIBAVUTIL_VERSION_INT,
354  .child_class_iterate = resample_child_class_iterate,
356 };
357 
358 static const AVFilterPad aresample_outputs[] = {
359  {
360  .name = "default",
361  .config_props = config_output,
362  .type = AVMEDIA_TYPE_AUDIO,
363  },
364 };
365 
367  .name = "aresample",
368  .description = NULL_IF_CONFIG_SMALL("Resample audio data."),
369  .preinit = preinit,
370  .activate = activate,
371  .uninit = uninit,
372  .priv_size = sizeof(AResampleContext),
373  .priv_class = &aresample_class,
377 };
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:97
AVFilterChannelLayouts
A list of supported channel layouts.
Definition: formats.h:85
AVFilterFormatsConfig::samplerates
AVFilterFormats * samplerates
Lists of supported sample rates, only for audio.
Definition: avfilter.h:515
SwrContext::outpts
int64_t outpts
output PTS
Definition: swresample_internal.h:158
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:436
AVFilterFormatsConfig::channel_layouts
AVFilterChannelLayouts * channel_layouts
Lists of supported channel layouts, only for audio.
Definition: avfilter.h:520
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1015
ff_channel_layouts_ref
int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref)
Add *ref as a new reference to f.
Definition: formats.c:674
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
int64_t
long long int64_t
Definition: coverity.c:34
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:342
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:160
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:622
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:374
AVFrame::pts
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
Definition: frame.h:486
AVOption
AVOption.
Definition: opt.h:357
FILTER_QUERY_FUNC
#define FILTER_QUERY_FUNC(func)
Definition: internal.h:159
config_output
static int config_output(AVFilterLink *outlink)
Definition: af_aresample.c:129
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
preinit
static av_cold int preinit(AVFilterContext *ctx)
Definition: af_aresample.c:49
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:170
AVChannelLayout::nb_channels
int nb_channels
Number of channels in this layout.
Definition: channel_layout.h:321
FF_FILTER_FORWARD_STATUS_BACK
#define FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink)
Forward the status on an output link to an input link.
Definition: filters.h:199
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
ff_inlink_consume_frame
int ff_inlink_consume_frame(AVFilterLink *link, AVFrame **rframe)
Take a frame from the link's FIFO and update the link's stats.
Definition: avfilter.c:1442
activate
static int activate(AVFilterContext *ctx)
Definition: af_aresample.c:306
samplefmt.h
AVFrame::ch_layout
AVChannelLayout ch_layout
Channel layout of the audio data.
Definition: frame.h:775
pts
static int64_t pts
Definition: transcode_aac.c:644
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:536
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:924
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:33
swr_convert
int attribute_align_arg swr_convert(struct SwrContext *s, uint8_t *const *out_arg, int out_count, const uint8_t *const *in_arg, int in_count)
Convert audio.
Definition: swresample.c:719
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:874
options
static const AVOption options[]
Definition: af_aresample.c:344
avassert.h
resample_child_next
static void * resample_child_next(void *obj, void *prev)
Definition: af_aresample.c:335
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:140
av_channel_layout_describe
int av_channel_layout_describe(const AVChannelLayout *channel_layout, char *buf, size_t buf_size)
Get a human-readable string describing the channel layout properties.
Definition: channel_layout.c:648
ff_outlink_set_status
static void ff_outlink_set_status(AVFilterLink *link, int status, int64_t pts)
Set the status field of a link from the source filter.
Definition: filters.h:189
ff_inlink_request_frame
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1568
s
#define s(width, name)
Definition: cbs_vp9.c:198
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:679
swr_alloc
av_cold struct SwrContext * swr_alloc(void)
Allocate SwrContext.
Definition: options.c:148
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
filters.h
resample_child_class_iterate
static const AVClass * resample_child_class_iterate(void **iter)
Definition: af_aresample.c:328
ctx
AVFormatContext * ctx
Definition: movenc.c:49
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:51
SwrContext
The libswresample context.
Definition: swresample_internal.h:95
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:182
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
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:709
AResampleContext::sample_rate_arg
int sample_rate_arg
Definition: af_aresample.c:41
swr_get_class
const AVClass * swr_get_class(void)
Get the AVClass for SwrContext.
Definition: options.c:143
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVFilterContext::inputs
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:415
ROUNDED_DIV
#define ROUNDED_DIV(a, b)
Definition: common.h:58
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
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:1317
ff_audio_default_filterpad
const AVFilterPad ff_audio_default_filterpad[1]
An AVFilterPad array whose only entry has name "default" and is of type AVMEDIA_TYPE_AUDIO.
Definition: audio.c:33
double
double
Definition: af_crystalizer.c:131
av_opt_get_int
int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val)
Definition: opt.c:1217
ff_inlink_acknowledge_status
int ff_inlink_acknowledge_status(AVFilterLink *link, int *rstatus, int64_t *rpts)
Test and acknowledge the change of status on the link.
Definition: avfilter.c:1389
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:799
ff_inlink_queued_frames
size_t ff_inlink_queued_frames(AVFilterLink *link)
Get the number of frames available on the link.
Definition: avfilter.c:1405
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: af_aresample.c:61
swr_alloc_set_opts2
int swr_alloc_set_opts2(struct SwrContext **ps, const AVChannelLayout *out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, const AVChannelLayout *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:40
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:94
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:311
AVClass::child_next
void *(* child_next)(void *obj, void *prev)
Return next AVOptions-enabled child or NULL.
Definition: log.h:131
AVFrame::sample_rate
int sample_rate
Sample rate of the audio data.
Definition: frame.h:573
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AResampleContext::ratio
double ratio
Definition: af_aresample.c:42
AV_NOPTS_VALUE
#define AV_NOPTS_VALUE
Undefined timestamp value.
Definition: avutil.h:248
AResampleContext::eof
int eof
Definition: af_aresample.c:46
aresample_outputs
static const AVFilterPad aresample_outputs[]
Definition: af_aresample.c:358
swr_free
av_cold void swr_free(SwrContext **ss)
Free the given SwrContext and set the pointer to NULL.
Definition: swresample.c:121
AVFrame::format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
Definition: frame.h:461
FF_FILTER_FORWARD_WANTED
FF_FILTER_FORWARD_WANTED(outlink, inlink)
AResampleContext
Definition: af_aresample.c:39
av_channel_layout_compare
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
Definition: channel_layout.c:804
AResampleContext::swr
struct SwrContext * swr
Definition: af_aresample.c:43
internal.h
flush_frame
static int flush_frame(AVFilterLink *outlink, int final, AVFrame **outsamplesref_ret)
Definition: af_aresample.c:231
aresample_class
static const AVClass aresample_class
Definition: af_aresample.c:349
AVFrame::nb_samples
int nb_samples
number of audio samples (per channel) described by this frame
Definition: frame.h:454
AVFrame::extended_data
uint8_t ** extended_data
pointers to the data planes/channels.
Definition: frame.h:435
OFFSET
#define OFFSET(x)
Definition: af_aresample.c:341
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *insamplesref)
Definition: af_aresample.c:173
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:39
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:166
AResampleContext::next_pts
int64_t next_pts
Definition: af_aresample.c:44
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:71
frame
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 the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
av_channel_layout_check
int av_channel_layout_check(const AVChannelLayout *channel_layout)
Check whether a channel layout is valid, i.e.
Definition: channel_layout.c:778
ff_all_samplerates
AVFilterFormats * ff_all_samplerates(void)
Definition: formats.c:607
status
ov_status_e status
Definition: dnn_backend_openvino.c:101
channel_layout.h
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
avfilter.h
av_channel_layout_uninit
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
Definition: channel_layout.c:437
av_opt_get_chlayout
int av_opt_get_chlayout(void *obj, const char *name, int search_flags, AVChannelLayout *cl)
Definition: opt.c:1322
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
av_channel_layout_copy
int av_channel_layout_copy(AVChannelLayout *dst, const AVChannelLayout *src)
Make a copy of a channel layout.
Definition: channel_layout.c:444
audio.h
AVFilterFormatsConfig::formats
AVFilterFormats * formats
List of supported formats (pixel or sample).
Definition: avfilter.h:510
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: af_aresample.c:67
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:183
ff_af_aresample
const AVFilter ff_af_aresample
Definition: af_aresample.c:366
ff_make_channel_layout_list
AVFilterChannelLayouts * ff_make_channel_layout_list(const AVChannelLayout *fmts)
Definition: formats.c:445
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
request_frame
static int request_frame(AVFilterLink *outlink)
Definition: af_aresample.c:262
AResampleContext::more_data
int more_data
Definition: af_aresample.c:45
avstring.h
ff_filter_set_ready
void ff_filter_set_ready(AVFilterContext *filter, unsigned priority)
Mark a filter ready and schedule it for activation.
Definition: avfilter.c:235