Commit 2c031741 authored by Stefano Sabatini's avatar Stefano Sabatini

lavfi: simplify signature for avfilter_get_audio_buffer() and friends

The additional parameters were never used and are complicating the
function interface. Also, they were inconsistent with the way the
video API works.

So this assumes that a requested samples buffer will have *always* the
format specified in the requested link.

This breaks audio filtering API and ABI.
parent 47886e36
......@@ -13,6 +13,10 @@ libavutil: 2011-04-18
API changes, most recent first:
2011-09-xx - xxxxxxx - lavfi 2.x.0
Simplify signature for avfilter_get_audio_buffer(), make it
consistent with avfilter_get_video_buffer().
2011-09-06 - xxxxxxx - lavfi 2.39.0
Rename libavfilter/vsink_buffer.h to libavfilter/buffersink.h.
......
......@@ -270,10 +270,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref
aresample->outsamplesref = avfilter_get_audio_buffer(outlink,
AV_PERM_WRITE | AV_PERM_REUSE2,
inlink->format,
requested_out_nb_samples,
insamplesref->audio->channel_layout,
insamplesref->audio->planar);
requested_out_nb_samples);
avfilter_copy_buffer_ref_props(aresample->outsamplesref, insamplesref);
aresample->outsamplesref->pts =
......
......@@ -447,17 +447,16 @@ fail:
return NULL;
}
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar)
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link,
int perms, int nb_samples)
{
AVFilterBufferRef *ret = NULL;
if (link->dstpad->get_audio_buffer)
ret = link->dstpad->get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout, planar);
ret = link->dstpad->get_audio_buffer(link, perms, nb_samples);
if (!ret)
ret = avfilter_default_get_audio_buffer(link, perms, sample_fmt, nb_samples, channel_layout, planar);
ret = avfilter_default_get_audio_buffer(link, perms, nb_samples);
if (ret)
ret->type = AVMEDIA_TYPE_AUDIO;
......@@ -664,10 +663,7 @@ void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms);
link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms,
samplesref->format,
samplesref->audio->nb_samples,
samplesref->audio->channel_layout,
samplesref->audio->planar);
samplesref->audio->nb_samples);
link->cur_buf->pts = samplesref->pts;
link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate;
......
......@@ -390,9 +390,7 @@ struct AVFilterPad {
*
* Input audio pads only.
*/
AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar);
AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, int nb_samples);
/**
* Callback called after the slices of a frame are completely sent. If
......@@ -476,9 +474,8 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link,
int perms, int w, int h);
/** default handler for get_audio_buffer() for audio inputs */
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar);
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link,
int perms, int nb_samples);
/**
* Helpers for query_formats() which set all links to the same list of
......@@ -510,9 +507,8 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link,
int perms, int w, int h);
/** get_audio_buffer() handler for filters which simply pass audio along */
AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int size,
int64_t channel_layout, int planar);
AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link,
int perms, int nb_samples);
/**
* Filter definition. This defines the pads a filter contains, and all the
......@@ -739,8 +735,7 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int lin
* avfilter_unref_buffer when you are finished with it.
*/
AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar);
int nb_samples);
/**
* Create an audio buffer reference wrapped around an already
......
......@@ -81,24 +81,23 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per
}
AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int nb_samples,
int64_t channel_layout, int planar)
int nb_samples)
{
AVFilterBufferRef *samplesref = NULL;
int linesize[8];
uint8_t *data[8];
int nb_channels = av_get_channel_layout_nb_channels(channel_layout);
int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout);
/* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */
if (av_samples_alloc(data, linesize,
nb_channels, nb_samples, sample_fmt,
planar, 16) < 0)
nb_channels, nb_samples, link->format,
link->planar, 16) < 0)
return NULL;
samplesref =
avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms,
nb_samples, sample_fmt,
channel_layout, planar);
nb_samples, link->format,
link->channel_layout, link->planar);
if (!samplesref) {
av_free(data[0]);
return NULL;
......@@ -160,10 +159,8 @@ void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *sa
outlink = inlink->dst->outputs[0];
if (outlink) {
outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE, samplesref->format,
samplesref->audio->nb_samples,
samplesref->audio->channel_layout,
samplesref->audio->planar);
outlink->out_buf = avfilter_default_get_audio_buffer(inlink, AV_PERM_WRITE,
samplesref->audio->nb_samples);
outlink->out_buf->pts = samplesref->pts;
outlink->out_buf->audio->sample_rate = samplesref->audio->sample_rate;
avfilter_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0));
......@@ -259,10 +256,8 @@ AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms,
}
AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms,
enum AVSampleFormat sample_fmt, int size,
int64_t channel_layout, int packed)
int nb_samples)
{
return avfilter_get_audio_buffer(link->dst->outputs[0], perms, sample_fmt,
size, channel_layout, packed);
return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples);
}
......@@ -424,9 +424,7 @@ static int amovie_get_samples(AVFilterLink *outlink)
if (decoded_data_size > 0) {
int nb_samples = decoded_data_size / movie->bps / movie->codec_ctx->channels;
movie->samplesref =
avfilter_get_audio_buffer(outlink, AV_PERM_WRITE,
movie->codec_ctx->sample_fmt, nb_samples,
movie->codec_ctx->channel_layout, 0);
avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples);
memcpy(movie->samplesref->data[0], movie->samples_buf, decoded_data_size);
movie->samplesref->pts = movie->pkt.pts;
movie->samplesref->pos = movie->pkt.pos;
......
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