19 #include "libavutil/channel_layout.h"
20 #include "libavutil/common.h"
61 if (link->
dstpad->get_audio_buffer)
62 ret = link->
dstpad->get_audio_buffer(link, nb_samples);
70 #if FF_API_AVFILTERBUFFER
72 int linesize,
int perms,
75 uint64_t channel_layout)
78 AVFilterBuffer *samples =
av_mallocz(
sizeof(*samples));
79 AVFilterBufferRef *samplesref =
av_mallocz(
sizeof(*samplesref));
81 if (!samples || !samplesref)
84 samplesref->buf = samples;
86 if (!(samplesref->audio =
av_mallocz(
sizeof(*samplesref->audio))))
89 samplesref->audio->nb_samples = nb_samples;
90 samplesref->audio->channel_layout = channel_layout;
96 samplesref->perms = perms | AV_PERM_READ;
98 samples->refcount = 1;
102 memcpy(samples->data, data,
104 memcpy(samplesref->data, samples->data,
sizeof(samples->data));
106 samples->linesize[0] = samplesref->linesize[0] = linesize;
109 samples-> extended_data =
av_mallocz(
sizeof(*samples->extended_data) *
111 samplesref->extended_data =
av_mallocz(
sizeof(*samplesref->extended_data) *
114 if (!samples->extended_data || !samplesref->extended_data)
117 memcpy(samples-> extended_data, data,
sizeof(*data)*planes);
118 memcpy(samplesref->extended_data, data,
sizeof(*data)*planes);
120 samples->extended_data = samples->data;
121 samplesref->extended_data = samplesref->data;
129 if (samples && samples->extended_data != samples->data)
133 if (samplesref->extended_data != samplesref->data)
134 av_freep(&samplesref->extended_data);
This structure describes decoded (raw) audio or video data.
uint8_t ** extended_data
pointers to the data planes/channels.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
void av_freep(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void ff_avfilter_default_free_buffer(AVFilterBuffer *ptr)
default handler for freeing audio/video buffer when there are no references left
int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt)
Check if the sample format is planar.
A link between two filters.
int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, int nb_channels, enum AVSampleFormat sample_fmt)
Fill an audio buffer with silence.
int sample_rate
samples per second
AVFrame * ff_get_audio_buffer(AVFilterLink *link, int nb_samples)
Request an audio samples buffer with a specific set of permissions.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
AVFilterPad * dstpad
input pad on the dest filter
uint64_t channel_layout
Channel layout of the audio data.
#define FF_ARRAY_ELEMS(a)
AVFrame * ff_null_get_audio_buffer(AVFilterLink *link, int nb_samples)
get_audio_buffer() handler for filters which simply pass audio along
int format
agreed upon media format
Main libavfilter public API header.
AVFilterLink ** outputs
array of pointers to output links
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
AVSampleFormat
Audio Sample Formats.
int sample_rate
Sample rate of the audio data.
AVFilterContext * dst
dest filter
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
AVFilterBufferRef * avfilter_get_audio_buffer_ref_from_arrays(uint8_t **data, int linesize, int perms, int nb_samples, enum AVSampleFormat sample_fmt, uint64_t channel_layout)
AVFrame * ff_default_get_audio_buffer(AVFilterLink *link, int nb_samples)
default handler for get_audio_buffer() for audio inputs
uint64_t channel_layout
channel layout of current buffer (see libavutil/channel_layout.h)
int nb_samples
number of audio samples (per channel) described by this frame
#define AV_NOPTS_VALUE
Undefined timestamp value.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...