Commit 7ef0adcc authored by Stefano Sabatini's avatar Stefano Sabatini Committed by Anton Khirnov

lavfi: simplify signature for avfilter_get_audio_buffer() and friends

The additional parameters are just complicating the function interface.

Assume that a requested samples buffer will *always* have the format
specified in the requested link.

This breaks audio filtering API and ABI in theory, but since it's
unusable right now this shouldn't be a problem.
Signed-off-by: 's avatarAnton Khirnov <anton@khirnov.net>
parent 6735534f
...@@ -367,16 +367,15 @@ fail: ...@@ -367,16 +367,15 @@ fail:
} }
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples, int nb_samples)
uint64_t channel_layout)
{ {
AVFilterBufferRef *ret = NULL; AVFilterBufferRef *ret = NULL;
if (link->dstpad->get_audio_buffer) if (link->dstpad->get_audio_buffer)
ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout); ret = link->dstpad->get_audio_buffer(link, perms, nb_samples);
if (!ret) if (!ret)
ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout); ret = avfilter_default_get_audio_buffer(link, perms, nb_samples);
if (ret) if (ret)
ret->type = AVMEDIA_TYPE_AUDIO; ret->type = AVMEDIA_TYPE_AUDIO;
...@@ -593,9 +592,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) ...@@ -593,9 +592,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms,
samplesref->format, samplesref->audio->nb_samples);
samplesref->audio->nb_samples,
samplesref->audio->channel_layout);
link->cur_buf->pts = samplesref->pts; link->cur_buf->pts = samplesref->pts;
link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
......
...@@ -387,8 +387,7 @@ struct AVFilterPad { ...@@ -387,8 +387,7 @@ struct AVFilterPad {
* Input audio pads only. * Input audio pads only.
*/ */
AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples, int nb_samples);
uint64_t channel_layout);
/** /**
* Callback called after the slices of a frame are completely sent. If * Callback called after the slices of a frame are completely sent. If
...@@ -473,9 +472,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, ...@@ -473,9 +472,7 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
/** default handler for get_audio_buffer() for audio inputs */ /** default handler for get_audio_buffer() for audio inputs */
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples);
int nb_samples,
uint64_t channel_layout);
/** /**
* A helper for query_formats() which sets all links to the same list of * A helper for query_formats() which sets all links to the same list of
...@@ -505,8 +502,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, ...@@ -505,8 +502,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
/** get_audio_buffer() handler for filters which simply pass audio along */ /** get_audio_buffer() handler for filters which simply pass audio along */
AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples, int nb_samples);
uint64_t channel_layout);
/** /**
* Filter definition. This defines the pads a filter contains, and all the * Filter definition. This defines the pads a filter contains, and all the
...@@ -689,16 +685,12 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int ...@@ -689,16 +685,12 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t *data[4], int linesize[4], int
* @param link the output link to the filter from which the buffer will * @param link the output link to the filter from which the buffer will
* be requested * be requested
* @param perms the required access permissions * @param perms the required access permissions
* @param sample_fmt the format of each sample in the buffer to allocate
* @param nb_samples the number of samples per channel * @param nb_samples the number of samples per channel
* @param channel_layout the number and type of channels per sample in the buffer to allocate
* @param planar audio data layout - planar or packed
* @return A reference to the samples. This must be unreferenced with * @return A reference to the samples. This must be unreferenced with
* avfilter_unref_buffer when you are finished with it. * avfilter_unref_buffer when you are finished with it.
*/ */
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples, int nb_samples);
uint64_t channel_layout);
/** /**
* Create an audio buffer reference wrapped around an already * Create an audio buffer reference wrapped around an already
......
...@@ -58,25 +58,24 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per ...@@ -58,25 +58,24 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
} }
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples, int nb_samples)
uint64_t channel_layout)
{ {
AVFilterBufferRef *samplesref = NULL; AVFilterBufferRef *samplesref = NULL;
uint8_t **data; uint8_t **data;
int planar = av_sample_fmt_is_planar(sample_fmt); int planar = av_sample_fmt_is_planar(link->format);
int nb_channels = av_get_channel_layout_nb_channels(channel_layout); int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
int planes = planar ? nb_channels : 1; int planes = planar ? nb_channels : 1;
int linesize; int linesize;
if (!(data = av_mallocz(sizeof(*data) * planes))) if (!(data = av_mallocz(sizeof(*data) * planes)))
goto fail; goto fail;
if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, sample_fmt, 0) < 0) if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0)
goto fail; goto fail;
samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms, samplesref = avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
nb_samples, sample_fmt, nb_samples, link->format,
channel_layout); link->channel_layout);
if (!samplesref) if (!samplesref)
goto fail; goto fail;
...@@ -142,9 +141,8 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa ...@@ -142,9 +141,8 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa
outlink = inlink->dst->outputs[0]; outlink = inlink->dst->outputs[0];
if (outlink) { if (outlink) {
outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE, samplesref->format, outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE,
samplesref->audio->nb_samples, samplesref->audio->nb_samples);
samplesref->audio->channel_layout);
outlink->out_buf->pts = samplesref->pts; outlink->out_buf->pts = samplesref->pts;
outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate; outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate;
avfilter_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); avfilter_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
...@@ -246,9 +244,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, ...@@ -246,9 +244,7 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms,
} }
AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms, AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples, int nb_samples)
uint64_t channel_layout)
{ {
return avfilter_get_audio_buffer(link->dst->outputs[0], perms, sample_fmt, return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples);
nb_samples, channel_layout);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment