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;
127 samples-> extended_data =
av_mallocz(
sizeof(*samples->extended_data) *
129 samplesref->extended_data =
av_mallocz(
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);