31 #if FF_API_AVFILTERBUFFER
33 int avfilter_ref_get_channels(AVFilterBufferRef *ref)
35 return ref->audio ? ref->audio->channels : 0;
87 #if FF_API_AVFILTERBUFFER
89 AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays_channels(
uint8_t **
data,
90 int linesize,
int perms,
94 uint64_t channel_layout)
97 AVFilterBuffer *samples =
av_mallocz(
sizeof(*samples));
98 AVFilterBufferRef *samplesref =
av_mallocz(
sizeof(*samplesref));
100 if (!samples || !samplesref)
107 samplesref->buf = samples;
108 samplesref->buf->free = ff_avfilter_default_free_buffer;
109 if (!(samplesref->audio =
av_mallocz(
sizeof(*samplesref->audio))))
112 samplesref->audio->nb_samples = nb_samples;
113 samplesref->audio->channel_layout = channel_layout;
114 samplesref->audio->channels = channels;
119 samplesref->perms = perms | AV_PERM_READ;
121 samples->refcount = 1;
123 samplesref->format = sample_fmt;
125 memcpy(samples->data, data,
127 memcpy(samplesref->data, samples->data,
sizeof(samples->data));
129 samples->linesize[0] = samplesref->linesize[0] = linesize;
134 samplesref->extended_data =
av_mallocz_array(
sizeof(*samplesref->extended_data),
137 if (!samples->extended_data || !samplesref->extended_data)
140 memcpy(samples-> extended_data, data,
sizeof(*data)*planes);
141 memcpy(samplesref->extended_data, data,
sizeof(*data)*planes);
143 samples->extended_data = samples->data;
144 samplesref->extended_data = samplesref->data;
152 if (samples && samples->extended_data != samples->data)
156 if (samplesref->extended_data != samplesref->data)
157 av_freep(&samplesref->extended_data);
164 AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(
uint8_t **data,
165 int linesize,
int perms,
168 uint64_t channel_layout)
171 return avfilter_get_audio_buffer_ref_from_arrays_channels(data, linesize, perms,
172 nb_samples, sample_fmt,
173 channels, channel_layout);
void av_frame_set_channels(AVFrame *frame, int val)
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
Main libavfilter public API header.
AVFilterPad * dstpad
input pad on the dest filter
int av_get_channel_layout_nb_channels(uint64_t channel_layout)
Return the number of channels in the channel layout.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
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.
simple assert() macros that are a bit more flexible than ISO C assert().
Libavcodec external API header.
uint64_t channel_layout
Channel layout of the audio data.
audio channel layout utility functions
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
#define FF_ARRAY_ELEMS(a)
AVFrame *(* get_audio_buffer)(AVFilterLink *link, int nb_samples)
Callback function to get an audio buffer.
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.
AVFilterLink ** outputs
array of pointers to output links
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
#define FF_DISABLE_DEPRECATION_WARNINGS
common internal and external API header
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 channels
Number of channels.
#define FF_ENABLE_DEPRECATION_WARNINGS
AVFilterContext * dst
dest filter
static void * av_mallocz_array(size_t nmemb, size_t size)
uint8_t ** extended_data
pointers to the data planes/channels.
int nb_samples
number of audio samples (per channel) described by this frame
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_NOPTS_VALUE
Undefined timestamp value.