FFmpeg
Loading...
Searching...
No Matches
alsa.c
Go to the documentation of this file.
1/*
2 * ALSA input and output
3 * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
4 * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23/**
24 * @file
25 * ALSA input and output: common code
26 * @author Luca Abeni ( lucabe72 email it )
27 * @author Benoit Fouet ( benoit fouet free fr )
28 * @author Nicolas George ( nicolas george normalesup org )
29 */
30
31#include "config_components.h"
32
33#include <alsa/asoundlib.h>
34#include "avdevice.h"
35#include "libavutil/avassert.h"
37#include "libavutil/mem.h"
38
39#include "alsa.h"
40
41static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id)
42{
43 switch(codec_id) {
44 case AV_CODEC_ID_PCM_F64LE: return SND_PCM_FORMAT_FLOAT64_LE;
45 case AV_CODEC_ID_PCM_F64BE: return SND_PCM_FORMAT_FLOAT64_BE;
46 case AV_CODEC_ID_PCM_F32LE: return SND_PCM_FORMAT_FLOAT_LE;
47 case AV_CODEC_ID_PCM_F32BE: return SND_PCM_FORMAT_FLOAT_BE;
48 case AV_CODEC_ID_PCM_S32LE: return SND_PCM_FORMAT_S32_LE;
49 case AV_CODEC_ID_PCM_S32BE: return SND_PCM_FORMAT_S32_BE;
50 case AV_CODEC_ID_PCM_U32LE: return SND_PCM_FORMAT_U32_LE;
51 case AV_CODEC_ID_PCM_U32BE: return SND_PCM_FORMAT_U32_BE;
52 case AV_CODEC_ID_PCM_S24LE: return SND_PCM_FORMAT_S24_3LE;
53 case AV_CODEC_ID_PCM_S24BE: return SND_PCM_FORMAT_S24_3BE;
54 case AV_CODEC_ID_PCM_U24LE: return SND_PCM_FORMAT_U24_3LE;
55 case AV_CODEC_ID_PCM_U24BE: return SND_PCM_FORMAT_U24_3BE;
56 case AV_CODEC_ID_PCM_S16LE: return SND_PCM_FORMAT_S16_LE;
57 case AV_CODEC_ID_PCM_S16BE: return SND_PCM_FORMAT_S16_BE;
58 case AV_CODEC_ID_PCM_U16LE: return SND_PCM_FORMAT_U16_LE;
59 case AV_CODEC_ID_PCM_U16BE: return SND_PCM_FORMAT_U16_BE;
60 case AV_CODEC_ID_PCM_S8: return SND_PCM_FORMAT_S8;
61 case AV_CODEC_ID_PCM_U8: return SND_PCM_FORMAT_U8;
62 case AV_CODEC_ID_PCM_MULAW: return SND_PCM_FORMAT_MU_LAW;
63 case AV_CODEC_ID_PCM_ALAW: return SND_PCM_FORMAT_A_LAW;
64 default: return SND_PCM_FORMAT_UNKNOWN;
65 }
66}
67
68#define MAKE_REORDER_FUNC(NAME, TYPE, CHANNELS, LAYOUT, MAP) \
69static void alsa_reorder_ ## NAME ## _ ## LAYOUT(const void *in_v, \
70 void *out_v, \
71 int n) \
72{ \
73 const TYPE *in = in_v; \
74 TYPE *out = out_v; \
75 \
76 while (n-- > 0) { \
77 MAP \
78 in += CHANNELS; \
79 out += CHANNELS; \
80 } \
81}
82
83#define MAKE_REORDER_FUNCS(CHANNELS, LAYOUT, MAP) \
84 MAKE_REORDER_FUNC(int8, int8_t, CHANNELS, LAYOUT, MAP) \
85 MAKE_REORDER_FUNC(int16, int16_t, CHANNELS, LAYOUT, MAP) \
86 MAKE_REORDER_FUNC(int32, int32_t, CHANNELS, LAYOUT, MAP) \
87 MAKE_REORDER_FUNC(f32, float, CHANNELS, LAYOUT, MAP)
88
90 out[0] = in[0]; \
91 out[1] = in[1]; \
92 out[2] = in[3]; \
93 out[3] = in[4]; \
94 out[4] = in[2]; \
95 )
96
97MAKE_REORDER_FUNCS(6, out_51, \
98 out[0] = in[0]; \
99 out[1] = in[1]; \
100 out[2] = in[4]; \
101 out[3] = in[5]; \
102 out[4] = in[2]; \
103 out[5] = in[3]; \
104 )
105
106MAKE_REORDER_FUNCS(8, out_71, \
107 out[0] = in[0]; \
108 out[1] = in[1]; \
109 out[2] = in[4]; \
110 out[3] = in[5]; \
111 out[4] = in[2]; \
112 out[5] = in[3]; \
113 out[6] = in[6]; \
114 out[7] = in[7]; \
115 )
116
117#define FORMAT_I8 0
118#define FORMAT_I16 1
119#define FORMAT_I32 2
120#define FORMAT_F32 3
121
122#define PICK_REORDER(layout)\
123switch(format) {\
124 case FORMAT_I8: s->reorder_func = alsa_reorder_int8_out_ ##layout; break;\
125 case FORMAT_I16: s->reorder_func = alsa_reorder_int16_out_ ##layout; break;\
126 case FORMAT_I32: s->reorder_func = alsa_reorder_int32_out_ ##layout; break;\
127 case FORMAT_F32: s->reorder_func = alsa_reorder_f32_out_ ##layout; break;\
128}
129
130static const struct {
131 unsigned int pos;
132 enum AVChannel ch;
134 { SND_CHMAP_MONO, AV_CHAN_FRONT_CENTER },
135 { SND_CHMAP_FL, AV_CHAN_FRONT_LEFT },
136 { SND_CHMAP_FR, AV_CHAN_FRONT_RIGHT },
137 { SND_CHMAP_RL, AV_CHAN_BACK_LEFT },
138 { SND_CHMAP_RR, AV_CHAN_BACK_RIGHT },
139 { SND_CHMAP_FC, AV_CHAN_FRONT_CENTER },
140 { SND_CHMAP_LFE, AV_CHAN_LOW_FREQUENCY },
141 { SND_CHMAP_SL, AV_CHAN_SIDE_LEFT },
142 { SND_CHMAP_SR, AV_CHAN_SIDE_RIGHT },
143 { SND_CHMAP_RC, AV_CHAN_BACK_CENTER },
144 { SND_CHMAP_FLC, AV_CHAN_FRONT_LEFT_OF_CENTER },
145 { SND_CHMAP_FRC, AV_CHAN_FRONT_RIGHT_OF_CENTER},
146 { SND_CHMAP_FLW, AV_CHAN_WIDE_LEFT },
147 { SND_CHMAP_FRW, AV_CHAN_WIDE_RIGHT },
148 { SND_CHMAP_TC, AV_CHAN_TOP_CENTER },
149 { SND_CHMAP_TFL, AV_CHAN_TOP_FRONT_LEFT },
150 { SND_CHMAP_TFR, AV_CHAN_TOP_FRONT_RIGHT },
151 { SND_CHMAP_TFC, AV_CHAN_TOP_FRONT_CENTER },
152 { SND_CHMAP_TRL, AV_CHAN_TOP_BACK_LEFT },
153 { SND_CHMAP_TRR, AV_CHAN_TOP_BACK_RIGHT },
154 { SND_CHMAP_TRC, AV_CHAN_TOP_BACK_CENTER },
155 { SND_CHMAP_TSL, AV_CHAN_TOP_SIDE_LEFT },
156 { SND_CHMAP_TSR, AV_CHAN_TOP_SIDE_RIGHT },
157 { SND_CHMAP_LLFE, AV_CHAN_LOW_FREQUENCY },
158 { SND_CHMAP_RLFE, AV_CHAN_LOW_FREQUENCY_2 },
159 { SND_CHMAP_BC, AV_CHAN_BOTTOM_FRONT_CENTER },
160 { SND_CHMAP_BLC, AV_CHAN_BOTTOM_FRONT_LEFT },
161 { SND_CHMAP_BRC, AV_CHAN_BOTTOM_FRONT_RIGHT },
162 { SND_CHMAP_UNKNOWN, AV_CHAN_UNKNOWN },
163 { SND_CHMAP_NA, AV_CHAN_UNUSED },
164};
165
166static enum AVChannel alsa_chmap_pos_to_av_chan(unsigned int pos)
167{
168 for (unsigned i = 0; i < FF_ARRAY_ELEMS(alsa_chmap_table); i++)
169 if (alsa_chmap_table[i].pos == pos)
170 return alsa_chmap_table[i].ch;
171 return AV_CHAN_NONE;
172}
173
175{
176 snd_pcm_chmap_t *chmap = snd_pcm_get_chmap(h);
177 int ret = 0;
178
179 if (!chmap)
180 return 0;
181
182 if (layout->nb_channels != chmap->channels) {
183 av_log(ctx, AV_LOG_ERROR, "Inconsistent channel layout requested!\n");
184 ret = AVERROR(EINVAL);
185 goto out;
186 }
187
189 ret = av_channel_layout_custom_init(layout, chmap->channels);
190 if (ret < 0)
191 goto out;
192
193 for (unsigned i = 0; i < chmap->channels; i++) {
194 enum AVChannel ch = alsa_chmap_pos_to_av_chan(chmap->pos[i] &
195 SND_CHMAP_POSITION_MASK);
196 if (ch == AV_CHAN_NONE) {
198 "unknown ALSA channel position %u.\n",
199 chmap->pos[i] & SND_CHMAP_POSITION_MASK);
200 continue;
201 }
202 layout->u.map[i].id = ch;
203 }
206
207out:
208 free(chmap);
209 return ret;
210}
211
213 const AVChannelLayout *layout, int out)
214{
215 int format;
216
217 /* reordering input is not currently supported */
218 if (!out)
219 return AVERROR(ENOSYS);
220
221 /* reordering is not needed for QUAD or 2_2 layout */
224 return 0;
225
226 switch (codec_id) {
241 default: return AVERROR(ENOSYS);
242 }
243
246 PICK_REORDER(50)
249 PICK_REORDER(51)
251 PICK_REORDER(71)
252
253 return s->reorder_func ? 0 : AVERROR(ENOSYS);
254}
255
257 unsigned int *sample_rate,
259{
260 AlsaData *s = ctx->priv_data;
261 const char *audio_device;
262 int res, flags = 0;
263 snd_pcm_format_t format;
264 snd_pcm_t *h;
265 snd_pcm_hw_params_t *hw_params;
266 snd_pcm_uframes_t buffer_size, period_size;
267
268 if (ctx->url[0] == 0) audio_device = "default";
269 else audio_device = ctx->url;
270
274 if (format == SND_PCM_FORMAT_UNKNOWN) {
275 av_log(ctx, AV_LOG_ERROR, "sample format 0x%04x is not supported\n", *codec_id);
276 return AVERROR(ENOSYS);
277 }
278 if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
279 flags = SND_PCM_NONBLOCK;
280 }
281 res = snd_pcm_open(&h, audio_device, mode, flags);
282 if (res < 0) {
283 av_log(ctx, AV_LOG_ERROR, "cannot open audio device %s (%s)\n",
284 audio_device, snd_strerror(res));
285 return AVERROR(EIO);
286 }
287
288 res = snd_pcm_hw_params_malloc(&hw_params);
289 if (res < 0) {
290 av_log(ctx, AV_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
291 snd_strerror(res));
292 goto fail1;
293 }
294
295 res = snd_pcm_hw_params_any(h, hw_params);
296 if (res < 0) {
297 av_log(ctx, AV_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
298 snd_strerror(res));
299 goto fail;
300 }
301
302 res = snd_pcm_hw_params_set_access(h, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
303 if (res < 0) {
304 av_log(ctx, AV_LOG_ERROR, "cannot set access type (%s)\n",
305 snd_strerror(res));
306 goto fail;
307 }
308
309 res = snd_pcm_hw_params_set_format(h, hw_params, format);
310 if (res < 0) {
311 av_log(ctx, AV_LOG_ERROR, "cannot set sample format 0x%04x %d (%s)\n",
312 *codec_id, format, snd_strerror(res));
313 goto fail;
314 }
315
316 res = snd_pcm_hw_params_set_rate_near(h, hw_params, sample_rate, 0);
317 if (res < 0) {
318 av_log(ctx, AV_LOG_ERROR, "cannot set sample rate (%s)\n",
319 snd_strerror(res));
320 goto fail;
321 }
322
323 // For output streams, the stream should already have a layout.
324 // Adding this check for clarity.
325 if (mode == SND_PCM_STREAM_CAPTURE && layout->nb_channels == 0) {
326 unsigned int channels = 2;
327 if (snd_pcm_hw_params_test_channels(h, hw_params, channels) < 0) {
328 res = snd_pcm_hw_params_get_channels_min(hw_params, &channels);
329 if (res < 0) {
330 av_log(ctx, AV_LOG_ERROR, "cannot get minimum channel count (%s)\n",
331 snd_strerror(res));
332 goto fail;
333 }
335 "stereo not supported, falling back to %u channel(s)\n", channels);
336 }
338 layout->nb_channels = channels;
339 }
340
341 res = snd_pcm_hw_params_set_channels(h, hw_params, layout->nb_channels);
342 if (res < 0) {
343 av_log(ctx, AV_LOG_ERROR, "cannot set channel count to %d (%s)\n",
344 layout->nb_channels, snd_strerror(res));
345 goto fail;
346 }
347
348 s->frame_size = av_get_bits_per_sample(*codec_id) / 8 * layout->nb_channels;
349
350 snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);
351 buffer_size = FFMIN(buffer_size, ALSA_BUFFER_SIZE_MAX);
352 /* TODO: maybe use ctx->max_picture_buffer somehow */
353 res = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);
354 if (res < 0) {
355 av_log(ctx, AV_LOG_ERROR, "cannot set ALSA buffer size (%s)\n",
356 snd_strerror(res));
357 goto fail;
358 }
359
360 snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL);
361 if (!period_size)
362 period_size = buffer_size / 4;
363 res = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL);
364 if (res < 0) {
365 av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n",
366 snd_strerror(res));
367 goto fail;
368 }
369 s->period_size = period_size;
370
371 res = snd_pcm_hw_params(h, hw_params);
372 if (res < 0) {
373 av_log(ctx, AV_LOG_ERROR, "cannot set parameters (%s)\n",
374 snd_strerror(res));
375 goto fail;
376 }
377
378 snd_pcm_hw_params_free(hw_params);
379
380 // TODO: when support for channel layout gets more widespread in alsa
381 // drivers, this might be used to supersede the re-ordering function
382 // below.
383 if (mode == SND_PCM_STREAM_CAPTURE &&
385 res = alsa_get_chmap(ctx, h, layout);
386 if (res < 0)
387 goto fail1;
388 }
389
390 if (layout->nb_channels > 2 && layout->order != AV_CHANNEL_ORDER_UNSPEC) {
391 // See comment above. find_reorder_func is currently only implemented in
392 // playback mode.
393 if (find_reorder_func(s, *codec_id, layout, mode == SND_PCM_STREAM_PLAYBACK) < 0) {
394 char name[128];
396 av_log(ctx, AV_LOG_WARNING, "ALSA channel layout unknown or unimplemented for %s %s.\n",
397 name, mode == SND_PCM_STREAM_PLAYBACK ? "playback" : "capture");
398 }
399 if (s->reorder_func) {
400 s->reorder_buf_size = buffer_size;
401 s->reorder_buf = av_malloc_array(s->reorder_buf_size, s->frame_size);
402 if (!s->reorder_buf)
403 goto fail1;
404 }
405 }
406
407 s->pkt = av_packet_alloc();
408 if (!s->pkt)
409 goto fail1;
410
411 s->h = h;
412 return 0;
413
414fail:
415 snd_pcm_hw_params_free(hw_params);
416fail1:
417 snd_pcm_close(h);
418 return AVERROR(EIO);
419}
420
422{
423 AlsaData *s = s1->priv_data;
424
425 if (snd_pcm_stream(s->h) == SND_PCM_STREAM_PLAYBACK) {
426 snd_pcm_nonblock(s->h, 0);
427 snd_pcm_drain(s->h);
428 }
429 av_freep(&s->reorder_buf);
430 if (CONFIG_ALSA_INDEV)
431 ff_timefilter_destroy(s->timefilter);
432 snd_pcm_close(s->h);
433 av_packet_free(&s->pkt);
434 return 0;
435}
436
438{
439 AlsaData *s = s1->priv_data;
440 snd_pcm_t *handle = s->h;
441
442 av_log(s1, AV_LOG_WARNING, "ALSA buffer xrun.\n");
443 if (err == -EPIPE) {
444 err = snd_pcm_prepare(handle);
445 if (err < 0) {
446 av_log(s1, AV_LOG_ERROR, "cannot recover from underrun (snd_pcm_prepare failed: %s)\n", snd_strerror(err));
447
448 return AVERROR(EIO);
449 }
450#ifdef ESTRPIPE
451 } else if (err == -ESTRPIPE) {
452 av_log(s1, AV_LOG_ERROR, "-ESTRPIPE... Unsupported!\n");
453
454 return -1;
455#endif
456 }
457 return err;
458}
459
461{
462 int size = s->reorder_buf_size;
463 void *r;
464
465 av_assert0(size != 0);
466 while (size < min_size)
467 size *= 2;
468 r = av_realloc_array(s->reorder_buf, size, s->frame_size);
469 if (!r)
470 return AVERROR(ENOMEM);
471 s->reorder_buf = r;
472 s->reorder_buf_size = size;
473 return 0;
474}
475
476/* ported from alsa-utils/aplay.c */
477int ff_alsa_get_device_list(AVDeviceInfoList *device_list, snd_pcm_stream_t stream_type)
478{
479 int ret = 0;
480 void **hints, **n;
481 char *name = NULL, *descr = NULL, *io = NULL, *tmp;
482 AVDeviceInfo *new_device = NULL;
483 const char *filter = stream_type == SND_PCM_STREAM_PLAYBACK ? "Output" : "Input";
484
485 if (snd_device_name_hint(-1, "pcm", &hints) < 0)
486 return AVERROR_EXTERNAL;
487 n = hints;
488 while (*n && !ret) {
489 name = snd_device_name_get_hint(*n, "NAME");
490 descr = snd_device_name_get_hint(*n, "DESC");
491 io = snd_device_name_get_hint(*n, "IOID");
492 if (!io || !strcmp(io, filter)) {
493 new_device = av_mallocz(sizeof(AVDeviceInfo));
494 if (!new_device) {
495 ret = AVERROR(ENOMEM);
496 goto fail;
497 }
498 new_device->device_name = av_strdup(name ? name : "");
499 if (!descr)
500 new_device->device_description = av_strdup("");
501 else if ((tmp = strrchr(descr, '\n')) && tmp[1])
502 new_device->device_description = av_strdup(&tmp[1]);
503 else
504 new_device->device_description = av_strdup(descr);
505 if (!new_device->device_description || !new_device->device_name) {
506 ret = AVERROR(ENOMEM);
507 goto fail;
508 }
509 if ((ret = av_dynarray_add_nofree(&device_list->devices,
510 &device_list->nb_devices, new_device)) < 0) {
511 goto fail;
512 }
513 if (!strcmp(new_device->device_name, "default"))
514 device_list->default_device = device_list->nb_devices - 1;
515 new_device = NULL;
516 }
517 fail:
518 free(io);
519 free(name);
520 free(descr);
521 n++;
522 }
523 if (new_device) {
524 av_free(new_device->device_description);
525 av_free(new_device->device_name);
526 av_free(new_device);
527 }
528 snd_device_name_free_hint(hints);
529 return ret;
530}
static const char *const format[]
Definition af_aiir.c:444
int ff_alsa_xrun_recover(AVFormatContext *s1, int err)
Try to recover from ALSA buffer underrun.
Definition alsa.c:437
#define FORMAT_F32
#define FORMAT_I32
av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, unsigned int *sample_rate, AVChannelLayout *layout, enum AVCodecID *codec_id)
Open an ALSA PCM.
Definition alsa.c:256
#define MAKE_REORDER_FUNCS(CHANNELS, LAYOUT, MAP)
Definition alsa.c:83
int ff_alsa_get_device_list(AVDeviceInfoList *device_list, snd_pcm_stream_t stream_type)
Definition alsa.c:477
alsa_chmap_table[]
Definition alsa.c:133
static av_cold int find_reorder_func(AlsaData *s, int codec_id, const AVChannelLayout *layout, int out)
Definition alsa.c:212
#define PICK_REORDER(layout)
#define FORMAT_I16
static enum AVChannel alsa_chmap_pos_to_av_chan(unsigned int pos)
Definition alsa.c:166
#define FORMAT_I8
int ff_alsa_extend_reorder_buf(AlsaData *s, int min_size)
Definition alsa.c:460
static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id)
Definition alsa.c:41
static int alsa_get_chmap(AVFormatContext *ctx, snd_pcm_t *h, AVChannelLayout *layout)
Definition alsa.c:174
av_cold int ff_alsa_close(AVFormatContext *s1)
Close the ALSA PCM.
Definition alsa.c:421
ALSA input and output: definitions and structures.
#define ALSA_BUFFER_SIZE_MAX
Definition alsa.h:47
#define DEFAULT_CODEC_ID
Definition alsa.h:43
static FILE * out
static AVFormatContext * ctx
channels
Definition aptx.h:31
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition avassert.h:42
Main libavdevice API header.
#define AVFMT_FLAG_NONBLOCK
Do not block when reading packets from input.
Definition avformat.h:1487
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
Public libavutil channel layout APIs header.
#define NULL
Definition coverity.c:32
#define fail
Definition test.h:479
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
Definition utils.c:556
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition codec_id.h:47
@ AV_CODEC_ID_PCM_F32LE
Definition codec_id.h:351
@ AV_CODEC_ID_PCM_S24BE
Definition codec_id.h:343
@ AV_CODEC_ID_PCM_U8
Definition codec_id.h:335
@ AV_CODEC_ID_PCM_S16LE
Definition codec_id.h:330
@ AV_CODEC_ID_PCM_F32BE
Definition codec_id.h:350
@ AV_CODEC_ID_NONE
Definition codec_id.h:48
@ AV_CODEC_ID_PCM_S16BE
Definition codec_id.h:331
@ AV_CODEC_ID_PCM_S24LE
Definition codec_id.h:342
@ AV_CODEC_ID_PCM_U24BE
Definition codec_id.h:345
@ AV_CODEC_ID_PCM_S32LE
Definition codec_id.h:338
@ AV_CODEC_ID_PCM_S8
Definition codec_id.h:334
@ AV_CODEC_ID_PCM_U32LE
Definition codec_id.h:340
@ AV_CODEC_ID_PCM_ALAW
Definition codec_id.h:337
@ AV_CODEC_ID_PCM_F64LE
Definition codec_id.h:353
@ AV_CODEC_ID_PCM_U16BE
Definition codec_id.h:333
@ AV_CODEC_ID_PCM_F64BE
Definition codec_id.h:352
@ AV_CODEC_ID_PCM_S32BE
Definition codec_id.h:339
@ AV_CODEC_ID_PCM_U24LE
Definition codec_id.h:344
@ AV_CODEC_ID_PCM_U16LE
Definition codec_id.h:332
@ AV_CODEC_ID_PCM_U32BE
Definition codec_id.h:341
@ AV_CODEC_ID_PCM_MULAW
Definition codec_id.h:336
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
Definition packet.c:74
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
Definition packet.c:63
int av_channel_layout_retype(AVChannelLayout *channel_layout, enum AVChannelOrder order, int flags)
Change the AVChannelOrder of a channel layout.
#define AV_CHANNEL_LAYOUT_5POINT1_BACK
#define AV_CHANNEL_LAYOUT_RETYPE_FLAG_CANONICAL
The specified retype target order is ignored and the simplest possible (canonical) order is used for ...
#define AV_CHANNEL_LAYOUT_5POINT0
int av_channel_layout_compare(const AVChannelLayout *chl, const AVChannelLayout *chl1)
Check whether two channel layouts are semantically the same, i.e.
#define AV_CHANNEL_LAYOUT_2_2
#define AV_CHANNEL_LAYOUT_5POINT0_BACK
#define AV_CHANNEL_LAYOUT_5POINT1
int av_channel_layout_custom_init(AVChannelLayout *channel_layout, int nb_channels)
Initialize a custom channel layout with the specified number of channels.
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
AVChannel
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.
#define AV_CHANNEL_LAYOUT_7POINT1
#define AV_CHANNEL_LAYOUT_QUAD
@ AV_CHANNEL_ORDER_UNSPEC
Only the channel count is specified, without any further information about the channel order.
@ AV_CHAN_LOW_FREQUENCY
@ AV_CHAN_BACK_RIGHT
@ AV_CHAN_UNUSED
Channel is empty can be safely skipped.
@ AV_CHAN_FRONT_RIGHT_OF_CENTER
@ AV_CHAN_FRONT_LEFT
@ AV_CHAN_TOP_BACK_LEFT
@ AV_CHAN_TOP_FRONT_RIGHT
@ AV_CHAN_FRONT_RIGHT
@ AV_CHAN_BACK_CENTER
@ AV_CHAN_TOP_SIDE_RIGHT
@ AV_CHAN_FRONT_CENTER
@ AV_CHAN_SIDE_RIGHT
@ AV_CHAN_WIDE_LEFT
@ AV_CHAN_FRONT_LEFT_OF_CENTER
@ AV_CHAN_NONE
Invalid channel index.
@ AV_CHAN_LOW_FREQUENCY_2
@ AV_CHAN_TOP_BACK_CENTER
@ AV_CHAN_BACK_LEFT
@ AV_CHAN_UNKNOWN
Channel contains data, but its position is unknown.
@ AV_CHAN_SIDE_LEFT
@ AV_CHAN_BOTTOM_FRONT_CENTER
@ AV_CHAN_TOP_FRONT_LEFT
@ AV_CHAN_TOP_BACK_RIGHT
@ AV_CHAN_BOTTOM_FRONT_RIGHT
@ AV_CHAN_TOP_SIDE_LEFT
@ AV_CHAN_WIDE_RIGHT
@ AV_CHAN_BOTTOM_FRONT_LEFT
@ AV_CHAN_TOP_CENTER
@ AV_CHAN_TOP_FRONT_CENTER
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition error.h:59
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem)
Add an element to a dynamic array.
Definition mem.c:313
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Definition mem.c:217
#define r
Definition input.c:42
#define av_cold
Definition attributes.h:117
#define FFMIN(a, b)
Definition macros.h:49
uint64_t layout
Memory handling functions.
#define av_strdup(s)
Definition ops_static.c:55
const char * name
Definition qsvenc.c:142
#define FF_ARRAY_ELEMS(a)
unsigned int pos
Definition spdifenc.c:431
An AVChannelLayout holds information about the channel layout of audio data.
List of devices.
Definition avdevice.h:343
int nb_devices
number of autodetected devices
Definition avdevice.h:345
int default_device
index of default device or -1 if no default
Definition avdevice.h:346
AVDeviceInfo ** devices
list of autodetected devices
Definition avdevice.h:344
Structure describes basic parameters of the device.
Definition avdevice.h:333
char * device_description
human friendly name
Definition avdevice.h:335
char * device_name
device name, format depends on device
Definition avdevice.h:334
Format I/O context.
Definition avformat.h:1333
void * priv_data
Format private data.
Definition avformat.h:1361
Definition swscale.c:71
#define av_free(p)
#define av_malloc_array(a, b)
#define av_mallocz(s)
#define av_freep(p)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition h263dsp.c:29
void ff_timefilter_destroy(TimeFilter *self)
Free all resources associated with the filter.
Definition timefilter.c:66
int size
enum AVCodecID codec_id