FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
buffersink.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Stefano Sabatini
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * buffer sink
24  */
25 
26 #include "libavutil/avassert.h"
28 #include "libavutil/common.h"
29 #include "libavutil/internal.h"
30 #include "libavutil/opt.h"
31 
32 #define FF_INTERNAL_FIELDS 1
33 #include "framequeue.h"
34 
35 #include "audio.h"
36 #include "avfilter.h"
37 #include "buffersink.h"
38 #include "filters.h"
39 #include "internal.h"
40 
41 typedef struct BufferSinkContext {
42  const AVClass *class;
43  unsigned warning_limit;
44 
45  /* only used for video */
46  enum AVPixelFormat *pixel_fmts; ///< list of accepted pixel formats, must be terminated with -1
48 
49  /* only used for audio */
50  enum AVSampleFormat *sample_fmts; ///< list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
52  int64_t *channel_layouts; ///< list of accepted channel layouts, terminated by -1
54  int *channel_counts; ///< list of accepted channel counts, terminated by -1
57  int *sample_rates; ///< list of accepted sample rates, terminated by -1
59 
62 
63 #define NB_ITEMS(list) (list ## _size / sizeof(*list))
64 #define FIFO_INIT_SIZE 8
65 #define FIFO_INIT_ELEMENT_SIZE sizeof(void *)
66 
68 {
69  return av_buffersink_get_frame_flags(ctx, frame, 0);
70 }
71 
73 {
74  if ((flags & AV_BUFFERSINK_FLAG_PEEK)) {
75  buf->peeked_frame = in;
76  return out ? av_frame_ref(out, in) : 0;
77  } else {
78  av_assert1(out);
79  buf->peeked_frame = NULL;
80  av_frame_move_ref(out, in);
81  av_frame_free(&in);
82  return 0;
83  }
84 }
85 
86 static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
87 {
88  BufferSinkContext *buf = ctx->priv;
89  AVFilterLink *inlink = ctx->inputs[0];
90  int status, ret;
91  AVFrame *cur_frame;
92  int64_t pts;
93 
94  if (buf->peeked_frame)
95  return return_or_keep_frame(buf, frame, buf->peeked_frame, flags);
96 
97  while (1) {
98  ret = samples ? ff_inlink_consume_samples(inlink, samples, samples, &cur_frame) :
99  ff_inlink_consume_frame(inlink, &cur_frame);
100  if (ret < 0) {
101  return ret;
102  } else if (ret) {
103  /* TODO return the frame instead of copying it */
104  return return_or_keep_frame(buf, frame, cur_frame, flags);
105  } else if (ff_inlink_acknowledge_status(inlink, &status, &pts)) {
106  return status;
107  } else if ((flags & AV_BUFFERSINK_FLAG_NO_REQUEST)) {
108  return AVERROR(EAGAIN);
109  } else if (inlink->frame_wanted_out) {
110  ret = ff_filter_graph_run_once(ctx->graph);
111  if (ret < 0)
112  return ret;
113  } else {
114  ff_inlink_request_frame(inlink);
115  }
116  }
117 }
118 
120 {
121  return get_frame_internal(ctx, frame, flags, ctx->inputs[0]->min_samples);
122 }
123 
125  AVFrame *frame, int nb_samples)
126 {
127  return get_frame_internal(ctx, frame, 0, nb_samples);
128 }
129 
131 {
132  static const int pixel_fmts[] = { AV_PIX_FMT_NONE };
134  if (!params)
135  return NULL;
136 
137  params->pixel_fmts = pixel_fmts;
138  return params;
139 }
140 
142 {
144 
145  if (!params)
146  return NULL;
147  return params;
148 }
149 
151 {
152  BufferSinkContext *buf = ctx->priv;
153 
154  buf->warning_limit = 100;
155  return 0;
156 }
157 
159 {
160  BufferSinkContext *buf = ctx->priv;
161 
162  if (buf->warning_limit &&
163  ff_framequeue_queued_frames(&ctx->inputs[0]->fifo) >= buf->warning_limit) {
164  av_log(ctx, AV_LOG_WARNING,
165  "%d buffers queued in %s, something may be wrong.\n",
166  buf->warning_limit,
167  (char *)av_x_if_null(ctx->name, ctx->filter->name));
168  buf->warning_limit *= 10;
169  }
170 
171  /* The frame is queued, the rest is up to get_frame_internal */
172  return 0;
173 }
174 
176 {
177  AVFilterLink *inlink = ctx->inputs[0];
178 
179  inlink->min_samples = inlink->max_samples =
180  inlink->partial_buf_size = frame_size;
181 }
182 
183 #define MAKE_AVFILTERLINK_ACCESSOR(type, field) \
184 type av_buffersink_get_##field(const AVFilterContext *ctx) { \
185  av_assert0(ctx->filter->activate == activate); \
186  return ctx->inputs[0]->field; \
187 }
188 
192 
193 MAKE_AVFILTERLINK_ACCESSOR(AVRational , frame_rate )
196 MAKE_AVFILTERLINK_ACCESSOR(AVRational , sample_aspect_ratio)
197 
198 MAKE_AVFILTERLINK_ACCESSOR(int , channels )
199 MAKE_AVFILTERLINK_ACCESSOR(uint64_t , channel_layout )
201 
202 MAKE_AVFILTERLINK_ACCESSOR(AVBufferRef * , hw_frames_ctx )
203 
204 static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
205 {
206  BufferSinkContext *buf = ctx->priv;
207  AVBufferSinkParams *params = opaque;
208  int ret;
209 
210  if (params) {
211  if ((ret = av_opt_set_int_list(buf, "pix_fmts", params->pixel_fmts, AV_PIX_FMT_NONE, 0)) < 0)
212  return ret;
213  }
214 
215  return common_init(ctx);
216 }
217 
218 #define CHECK_LIST_SIZE(field) \
219  if (buf->field ## _size % sizeof(*buf->field)) { \
220  av_log(ctx, AV_LOG_ERROR, "Invalid size for " #field ": %d, " \
221  "should be multiple of %d\n", \
222  buf->field ## _size, (int)sizeof(*buf->field)); \
223  return AVERROR(EINVAL); \
224  }
226 {
227  BufferSinkContext *buf = ctx->priv;
229  unsigned i;
230  int ret;
231 
232  CHECK_LIST_SIZE(pixel_fmts)
233  if (buf->pixel_fmts_size) {
234  for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)
235  if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0)
236  return ret;
237  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
238  return ret;
239  } else {
240  if ((ret = ff_default_query_formats(ctx)) < 0)
241  return ret;
242  }
243 
244  return 0;
245 }
246 
247 static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
248 {
249  BufferSinkContext *buf = ctx->priv;
250  AVABufferSinkParams *params = opaque;
251  int ret;
252 
253  if (params) {
254  if ((ret = av_opt_set_int_list(buf, "sample_fmts", params->sample_fmts, AV_SAMPLE_FMT_NONE, 0)) < 0 ||
255  (ret = av_opt_set_int_list(buf, "sample_rates", params->sample_rates, -1, 0)) < 0 ||
256  (ret = av_opt_set_int_list(buf, "channel_layouts", params->channel_layouts, -1, 0)) < 0 ||
257  (ret = av_opt_set_int_list(buf, "channel_counts", params->channel_counts, -1, 0)) < 0 ||
258  (ret = av_opt_set_int(buf, "all_channel_counts", params->all_channel_counts, 0)) < 0)
259  return ret;
260  }
261  return common_init(ctx);
262 }
263 
265 {
266  BufferSinkContext *buf = ctx->priv;
269  unsigned i;
270  int ret;
271 
276 
277  if (buf->sample_fmts_size) {
278  for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++)
279  if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0)
280  return ret;
281  if ((ret = ff_set_common_formats(ctx, formats)) < 0)
282  return ret;
283  }
284 
285  if (buf->channel_layouts_size || buf->channel_counts_size ||
286  buf->all_channel_counts) {
287  for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++)
288  if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0)
289  return ret;
290  for (i = 0; i < NB_ITEMS(buf->channel_counts); i++)
291  if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0)
292  return ret;
293  if (buf->all_channel_counts) {
294  if (layouts)
295  av_log(ctx, AV_LOG_WARNING,
296  "Conflicting all_channel_counts and list in options\n");
297  else if (!(layouts = ff_all_channel_counts()))
298  return AVERROR(ENOMEM);
299  }
300  if ((ret = ff_set_common_channel_layouts(ctx, layouts)) < 0)
301  return ret;
302  }
303 
304  if (buf->sample_rates_size) {
305  formats = NULL;
306  for (i = 0; i < NB_ITEMS(buf->sample_rates); i++)
307  if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0)
308  return ret;
309  if ((ret = ff_set_common_samplerates(ctx, formats)) < 0)
310  return ret;
311  }
312 
313  return 0;
314 }
315 
316 #define OFFSET(x) offsetof(BufferSinkContext, x)
317 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
318 static const AVOption buffersink_options[] = {
319  { "pix_fmts", "set the supported pixel formats", OFFSET(pixel_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
320  { NULL },
321 };
322 #undef FLAGS
323 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
324 static const AVOption abuffersink_options[] = {
325  { "sample_fmts", "set the supported sample formats", OFFSET(sample_fmts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
326  { "sample_rates", "set the supported sample rates", OFFSET(sample_rates), AV_OPT_TYPE_BINARY, .flags = FLAGS },
327  { "channel_layouts", "set the supported channel layouts", OFFSET(channel_layouts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
328  { "channel_counts", "set the supported channel counts", OFFSET(channel_counts), AV_OPT_TYPE_BINARY, .flags = FLAGS },
329  { "all_channel_counts", "accept all channel counts", OFFSET(all_channel_counts), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS },
330  { NULL },
331 };
332 #undef FLAGS
333 
334 AVFILTER_DEFINE_CLASS(buffersink);
335 AVFILTER_DEFINE_CLASS(abuffersink);
336 
338  {
339  .name = "default",
340  .type = AVMEDIA_TYPE_VIDEO,
341  },
342  { NULL }
343 };
344 
346  .name = "buffersink",
347  .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them available to the end of the filter graph."),
348  .priv_size = sizeof(BufferSinkContext),
349  .priv_class = &buffersink_class,
350  .init_opaque = vsink_init,
351 
353  .activate = activate,
354  .inputs = avfilter_vsink_buffer_inputs,
355  .outputs = NULL,
356 };
357 
359  {
360  .name = "default",
361  .type = AVMEDIA_TYPE_AUDIO,
362  },
363  { NULL }
364 };
365 
367  .name = "abuffersink",
368  .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them available to the end of the filter graph."),
369  .priv_class = &abuffersink_class,
370  .priv_size = sizeof(BufferSinkContext),
371  .init_opaque = asink_init,
372 
374  .activate = activate,
375  .inputs = avfilter_asink_abuffer_inputs,
376  .outputs = NULL,
377 };
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:1518
#define NULL
Definition: coverity.c:32
int ff_set_common_channel_layouts(AVFilterContext *ctx, AVFilterChannelLayouts *layouts)
A helper for query_formats() which sets all links to the same list of channel layouts/sample rates...
Definition: formats.c:549
enum AVSampleFormat * sample_fmts
list of accepted sample formats, terminated by AV_SAMPLE_FMT_NONE
Definition: buffersink.c:50
This structure describes decoded (raw) audio or video data.
Definition: frame.h:187
AVOption.
Definition: opt.h:246
AVBufferSinkParams * av_buffersink_params_alloc(void)
Create an AVBufferSinkParams structure.
Definition: buffersink.c:130
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
Main libavfilter public API header.
const int * channel_counts
list of allowed channel counts, terminated by -1
Definition: buffersink.h:82
AVABufferSinkParams * av_abuffersink_params_alloc(void)
Create an AVABufferSinkParams structure.
Definition: buffersink.c:141
#define av_opt_set_int_list(obj, name, val, term, flags)
Set a binary option to an integer list.
Definition: opt.h:709
int * sample_rates
list of accepted sample rates, terminated by -1
Definition: buffersink.c:57
static const AVOption abuffersink_options[]
Definition: buffersink.c:324
int * channel_counts
list of accepted channel counts, terminated by -1
Definition: buffersink.c:54
static int return_or_keep_frame(BufferSinkContext *buf, AVFrame *out, AVFrame *in, int flags)
Definition: buffersink.c:72
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:524
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:222
AVFrame * peeked_frame
Definition: buffersink.c:60
void ff_inlink_request_frame(AVFilterLink *link)
Mark that a frame is wanted on the link.
Definition: avfilter.c:1639
struct AVFilterGraph * graph
filtergraph this filter belongs to
Definition: avfilter.h:340
memory buffer sink API for audio and video
enum AVSampleFormat * sample_fmts
list of allowed sample formats, terminated by AV_SAMPLE_FMT_NONE
Definition: buffersink.h:80
const char * name
Pad name.
Definition: internal.h:60
int ff_filter_graph_run_once(AVFilterGraph *graph)
Run one round of processing on a filter graph.
AVFilterLink ** inputs
array of pointers to input links
Definition: avfilter.h:331
char * name
name of this filter instance
Definition: avfilter.h:328
static av_cold int vsink_init(AVFilterContext *ctx, void *opaque)
Definition: buffersink.c:204
#define av_cold
Definition: attributes.h:82
#define av_malloc(s)
AVOptions.
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition: frame.c:388
static AVFrame * frame
static int flags
Definition: log.c:57
static av_cold int asink_init(AVFilterContext *ctx, void *opaque)
Definition: buffersink.c:247
static const AVOption buffersink_options[]
Definition: buffersink.c:318
#define CHECK_LIST_SIZE(field)
Definition: buffersink.c:218
#define FLAGS
Definition: buffersink.c:323
#define av_log(a,...)
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
Definition: buffersink.h:60
A filter pad used for either input or output.
Definition: internal.h:54
static void * av_x_if_null(const void *p, const void *x)
Return x default pointer in case p is NULL.
Definition: avutil.h:308
AVFILTER_DEFINE_CLASS(buffersink)
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:1483
static int vsink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:225
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout)
Definition: formats.c:343
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
int * sample_rates
list of allowed sample rates, terminated by -1
Definition: buffersink.h:84
void * priv
private data for use by the filter
Definition: avfilter.h:338
static int activate(AVFilterContext *ctx)
Definition: buffersink.c:158
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:558
GLenum GLint * params
Definition: opengl_enc.c:114
simple assert() macros that are a bit more flexible than ISO C assert().
static const AVFilterPad avfilter_asink_abuffer_inputs[]
Definition: buffersink.c:358
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:337
int channel_layouts_size
Definition: buffersink.c:53
AVFilter ff_vsink_buffer
Definition: buffersink.c:345
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:119
common internal API header
int64_t * channel_layouts
list of accepted channel layouts, terminated by -1
Definition: buffersink.c:52
audio channel layout utility functions
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
Definition: avassert.h:53
Struct to use for initializing an abuffersink context.
Definition: buffersink.h:79
int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples)
Same as av_buffersink_get_frame(), but with the ability to specify the number of samples read...
Definition: buffersink.c:124
AVFormatContext * ctx
Definition: movenc.c:48
Struct to use for initializing a buffersink context.
Definition: buffersink.h:65
enum AVPixelFormat * pixel_fmts
list of accepted pixel formats, must be terminated with -1
Definition: buffersink.c:46
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:386
static const uint8_t channel_counts[7]
Definition: dca_lbr.c:114
offset must point to a pointer immediately followed by an int for the length
Definition: opt.h:229
AVFilter ff_asink_abuffer
Definition: buffersink.c:366
A list of supported channel layouts.
Definition: formats.h:85
int ff_default_query_formats(AVFilterContext *ctx)
Definition: formats.c:597
sample_rate
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:376
int frame_size
Definition: mxfenc.c:1820
#define OFFSET(x)
Definition: buffersink.c:316
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:58
int ff_inlink_consume_samples(AVFilterLink *link, unsigned min, unsigned max, AVFrame **rframe)
Take samples from the link's FIFO and update the link's stats.
Definition: avfilter.c:1537
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
void * buf
Definition: avisynth_c.h:690
GLint GLenum type
Definition: opengl_enc.c:105
static const char * format
Definition: movenc.c:47
static const uint16_t channel_layouts[7]
Definition: dca_lbr.c:118
int all_channel_counts
if not 0, accept any channel count or layout
Definition: buffersink.h:83
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
Rational number (pair of numerator and denominator).
Definition: rational.h:58
#define NB_ITEMS(list)
Definition: buffersink.c:63
AVMediaType
Definition: avutil.h:199
const char * name
Filter name.
Definition: avfilter.h:148
enum MovChannelLayoutTag * layouts
Definition: mov_chan.c:434
static int64_t pts
Global timestamp for the audio frames.
static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, int samples)
Definition: buffersink.c:86
A reference to a data buffer.
Definition: buffer.h:81
static int query_formats(AVFilterContext *ctx)
Definition: aeval.c:244
static size_t ff_framequeue_queued_frames(const FFFrameQueue *fq)
Get the number of queued frames.
Definition: framequeue.h:146
sample_rates
common internal and external API header
enum AVPixelFormat * pixel_fmts
list of allowed pixel formats, terminated by AV_PIX_FMT_NONE
Definition: buffersink.h:66
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
Definition: buffersink.c:175
static av_cold int common_init(AVFilterContext *ctx)
Definition: buffersink.c:150
#define AV_BUFFERSINK_FLAG_PEEK
Tell av_buffersink_get_buffer_ref() to read video/samples buffer reference, but not remove it from th...
Definition: buffersink.h:53
static int asink_query_formats(AVFilterContext *ctx)
Definition: buffersink.c:264
A list of supported formats for one end of a filter link.
Definition: formats.h:64
An instance of a filter.
Definition: avfilter.h:323
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:701
FILE * out
Definition: movenc.c:54
#define FF_COUNT2LAYOUT(c)
Encode a channel count as a channel layout.
Definition: formats.h:102
static const AVFilterPad avfilter_vsink_buffer_inputs[]
Definition: buffersink.c:337
formats
Definition: signature.h:48
internal API functions
AVFilterChannelLayouts * ff_all_channel_counts(void)
Construct an AVFilterChannelLayouts coding for any channel layout, with known or unknown disposition...
Definition: formats.c:410
#define MAKE_AVFILTERLINK_ACCESSOR(type, field)
Definition: buffersink.c:183
int attribute_align_arg av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame)
Get a frame with filtered data from sink and put it in frame.
Definition: buffersink.c:67
const int64_t * channel_layouts
list of allowed channel layouts, terminated by -1
Definition: buffersink.h:81
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
unsigned warning_limit
Definition: buffersink.c:43
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:326
int ff_set_common_samplerates(AVFilterContext *ctx, AVFilterFormats *samplerates)
Definition: formats.c:556