33 return ref->audio ? ref->audio->channels : 0;
83 #if FF_API_AVFILTERBUFFER
84 AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays_channels(
uint8_t **
data,
85 int linesize,
int perms,
89 uint64_t channel_layout)
92 AVFilterBuffer *samples =
av_mallocz(
sizeof(*samples));
93 AVFilterBufferRef *samplesref =
av_mallocz(
sizeof(*samplesref));
95 if (!samples || !samplesref)
102 samplesref->buf = samples;
103 samplesref->buf->free = ff_avfilter_default_free_buffer;
104 if (!(samplesref->audio =
av_mallocz(
sizeof(*samplesref->audio))))
107 samplesref->audio->nb_samples = nb_samples;
108 samplesref->audio->channel_layout = channel_layout;
109 samplesref->audio->channels = channels;
114 samplesref->perms = perms | AV_PERM_READ;
116 samples->refcount = 1;
118 samplesref->format = sample_fmt;
120 memcpy(samples->data, data,
122 memcpy(samplesref->data, samples->data,
sizeof(samples->data));
124 samples->linesize[0] = samplesref->linesize[0] = linesize;
129 samplesref->extended_data =
av_mallocz_array(
sizeof(*samplesref->extended_data),
132 if (!samples->extended_data || !samplesref->extended_data)
135 memcpy(samples-> extended_data, data,
sizeof(*data)*planes);
136 memcpy(samplesref->extended_data, data,
sizeof(*data)*planes);
138 samples->extended_data = samples->data;
139 samplesref->extended_data = samplesref->data;
147 if (samples && samples->extended_data != samples->data)
151 if (samplesref->extended_data != samplesref->data)
152 av_freep(&samplesref->extended_data);
159 AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays(
uint8_t **data,
160 int linesize,
int perms,
163 uint64_t channel_layout)
166 return avfilter_get_audio_buffer_ref_from_arrays_channels(data, linesize, perms,
167 nb_samples, sample_fmt,
168 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.
#define FF_ARRAY_ELEMS(a)
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
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.
int avfilter_ref_get_channels(AVFilterBufferRef *ref)
Get the number of channels of a buffer reference.
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.
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.