diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-05-10 22:41:29 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-05-10 23:30:42 +0200 |
commit | 015903294ca983f007ab5cae098a54013e77f2f6 (patch) | |
tree | 66838f53dca82964270a1938692489c36e1fb1b0 /libavfilter | |
parent | 2a793ff2bf2197f36db3bf296668d44915142d03 (diff) | |
parent | 110d0cdc9d1ec414a658f841a3fbefbf6f796d61 (diff) | |
download | ffmpeg-015903294ca983f007ab5cae098a54013e77f2f6.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits)
rv40dsp x86: MMX/MMX2/3DNow/SSE2/SSSE3 implementations of MC
ape: Use unsigned integer maths
arm: dsputil: fix overreads in put/avg_pixels functions
h264: K&R formatting cosmetics for header files (part II/II)
h264: K&R formatting cosmetics for header files (part I/II)
rtmp: Implement check bandwidth notification.
rtmp: Support 'rtmp_swfurl', an option which specifies the URL of the SWF player.
rtmp: Support 'rtmp_flashver', an option which overrides the version of the Flash plugin.
rtmp: Support 'rtmp_tcurl', an option which overrides the URL of the target stream.
cmdutils: Add fallback case to switch in check_stream_specifier().
sctp: be consistent with socket option level
configure: Add _XOPEN_SOURCE=600 to Solaris preprocessor flags.
vcr1enc: drop pointless empty encode_init() wrapper function
vcr1: drop pointless write-only AVCodecContext member from VCR1Context
vcr1: group encoder code together to save #ifdefs
vcr1: cosmetics: K&R prettyprinting, typos, parentheses, dead code, comments
mov: make one comment slightly more specific
lavr: replace the SSE version of ff_conv_fltp_to_flt_6ch() with SSE4 and AVX
lavfi: move audio-related functions to a separate file.
lavfi: remove some audio-related function from public API.
...
Conflicts:
cmdutils.c
libavcodec/h264.h
libavcodec/h264_mvpred.h
libavcodec/vcr1.c
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/defaults.c
libavfilter/internal.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/Makefile | 1 | ||||
-rw-r--r-- | libavfilter/af_aconvert.c | 4 | ||||
-rw-r--r-- | libavfilter/af_aformat.c | 2 | ||||
-rw-r--r-- | libavfilter/af_amerge.c | 4 | ||||
-rw-r--r-- | libavfilter/af_anull.c | 5 | ||||
-rw-r--r-- | libavfilter/af_aresample.c | 4 | ||||
-rw-r--r-- | libavfilter/af_ashowinfo.c | 4 | ||||
-rw-r--r-- | libavfilter/af_asplit.c | 6 | ||||
-rw-r--r-- | libavfilter/af_astreamsync.c | 2 | ||||
-rw-r--r-- | libavfilter/af_earwax.c | 4 | ||||
-rw-r--r-- | libavfilter/af_pan.c | 4 | ||||
-rw-r--r-- | libavfilter/af_silencedetect.c | 4 | ||||
-rw-r--r-- | libavfilter/af_volume.c | 2 | ||||
-rw-r--r-- | libavfilter/asrc_aevalsrc.c | 4 | ||||
-rw-r--r-- | libavfilter/asrc_anullsrc.c | 4 | ||||
-rw-r--r-- | libavfilter/audio.c | 291 | ||||
-rw-r--r-- | libavfilter/audio.h | 65 | ||||
-rw-r--r-- | libavfilter/avfilter.c | 174 | ||||
-rw-r--r-- | libavfilter/avfilter.h | 45 | ||||
-rw-r--r-- | libavfilter/defaults.c | 65 | ||||
-rw-r--r-- | libavfilter/internal.h | 6 | ||||
-rw-r--r-- | libavfilter/src_buffer.c | 4 | ||||
-rw-r--r-- | libavfilter/src_movie.c | 4 | ||||
-rw-r--r-- | libavfilter/version.h | 3 |
24 files changed, 408 insertions, 303 deletions
diff --git a/libavfilter/Makefile b/libavfilter/Makefile index 0647772128..962dbf63a9 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -21,6 +21,7 @@ HEADERS = asrc_abuffer.h \ vsrc_buffer.h \ OBJS = allfilters.o \ + audio.o \ avfilter.o \ avfiltergraph.o \ buffersink.o \ diff --git a/libavfilter/af_aconvert.c b/libavfilter/af_aconvert.c index 8c1b5dc346..e0f347413b 100644 --- a/libavfilter/af_aconvert.c +++ b/libavfilter/af_aconvert.c @@ -144,7 +144,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref AConvertContext *aconvert = inlink->dst->priv; const int n = insamplesref->audio->nb_samples; AVFilterLink *const outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *outsamplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, n); + AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n); swr_convert(aconvert->swr, outsamplesref->data, n, (void *)insamplesref->data, n); @@ -153,7 +153,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref outsamplesref->audio->channel_layout = outlink->channel_layout; outsamplesref->audio->planar = outlink->planar; - avfilter_filter_samples(outlink, outsamplesref); + ff_filter_samples(outlink, outsamplesref); avfilter_unref_buffer(insamplesref); } diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index e7ef7f062a..ab64840c76 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -89,7 +89,7 @@ static int query_formats(AVFilterContext *ctx) static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref) { - avfilter_filter_samples(inlink->dst->outputs[0], insamplesref); + ff_filter_samples(inlink->dst->outputs[0], insamplesref); } AVFilter avfilter_af_aformat = { diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index a160391a57..6d141fef8b 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -208,7 +208,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) nb_samples = FFMIN(am->queue[0].nb_samples, am->queue[1].nb_samples); - outbuf = avfilter_get_audio_buffer(ctx->outputs[0], AV_PERM_WRITE, + outbuf = ff_get_audio_buffer(ctx->outputs[0], AV_PERM_WRITE, nb_samples); outs = outbuf->data[0]; for (i = 0; i < 2; i++) { @@ -264,7 +264,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) am->queue[i].nb_buf * sizeof(**inbuf)); } } - avfilter_filter_samples(ctx->outputs[0], outbuf); + ff_filter_samples(ctx->outputs[0], outbuf); } AVFilter avfilter_af_amerge = { diff --git a/libavfilter/af_anull.c b/libavfilter/af_anull.c index 8419f57cfb..140ecb3759 100644 --- a/libavfilter/af_anull.c +++ b/libavfilter/af_anull.c @@ -21,6 +21,7 @@ * null audio filter */ +#include "audio.h" #include "avfilter.h" AVFilter avfilter_af_anull = { @@ -31,8 +32,8 @@ AVFilter avfilter_af_anull = { .inputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_AUDIO, - .get_audio_buffer = avfilter_null_get_audio_buffer, - .filter_samples = avfilter_null_filter_samples }, + .get_audio_buffer = ff_null_get_audio_buffer, + .filter_samples = ff_null_filter_samples }, { .name = NULL}}, .outputs = (const AVFilterPad[]) {{ .name = "default", diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c index 786fb8565b..23980d1556 100644 --- a/libavfilter/af_aresample.c +++ b/libavfilter/af_aresample.c @@ -92,7 +92,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref const int n_in = insamplesref->audio->nb_samples; int n_out = n_in * aresample->ratio; AVFilterLink *const outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *outsamplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, n_out); + AVFilterBufferRef *outsamplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n_out); n_out = swr_convert(aresample->swr, outsamplesref->data, n_out, (void *)insamplesref->data, n_in); @@ -103,7 +103,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamplesref outsamplesref->pts = insamplesref->pts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE : av_rescale(outlink->sample_rate, insamplesref->pts, inlink ->sample_rate); - avfilter_filter_samples(outlink, outsamplesref); + ff_filter_samples(outlink, outsamplesref); avfilter_unref_buffer(insamplesref); } diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c index 12d0315f0e..c336c52c0b 100644 --- a/libavfilter/af_ashowinfo.c +++ b/libavfilter/af_ashowinfo.c @@ -83,7 +83,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) av_log(ctx, AV_LOG_INFO, "]\n"); showinfo->frame++; - avfilter_filter_samples(inlink->dst->outputs[0], samplesref); + ff_filter_samples(inlink->dst->outputs[0], samplesref); } AVFilter avfilter_af_ashowinfo = { @@ -95,7 +95,7 @@ AVFilter avfilter_af_ashowinfo = { .inputs = (const AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_AUDIO, - .get_audio_buffer = avfilter_null_get_audio_buffer, + .get_audio_buffer = ff_null_get_audio_buffer, .filter_samples = filter_samples, .min_perms = AV_PERM_READ, }, { .name = NULL}}, diff --git a/libavfilter/af_asplit.c b/libavfilter/af_asplit.c index ec5032bd6c..3bdbeac19f 100644 --- a/libavfilter/af_asplit.c +++ b/libavfilter/af_asplit.c @@ -27,9 +27,9 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) { - avfilter_filter_samples(inlink->dst->outputs[0], + ff_filter_samples(inlink->dst->outputs[0], avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); - avfilter_filter_samples(inlink->dst->outputs[1], + ff_filter_samples(inlink->dst->outputs[1], avfilter_ref_buffer(insamples, ~AV_PERM_WRITE)); avfilter_unref_buffer(insamples); } @@ -41,7 +41,7 @@ AVFilter avfilter_af_asplit = { .inputs = (const AVFilterPad[]) { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, - .get_audio_buffer = avfilter_null_get_audio_buffer, + .get_audio_buffer = ff_null_get_audio_buffer, .filter_samples = filter_samples, }, { .name = NULL} }, diff --git a/libavfilter/af_astreamsync.c b/libavfilter/af_astreamsync.c index ccf55c0ce0..2e8a02cd55 100644 --- a/libavfilter/af_astreamsync.c +++ b/libavfilter/af_astreamsync.c @@ -119,7 +119,7 @@ static void send_out(AVFilterContext *ctx, int out_id) av_q2d(ctx->outputs[out_id]->time_base) * buf->pts; as->var_values[VAR_T1 + out_id] += buf->audio->nb_samples / (double)ctx->inputs[out_id]->sample_rate; - avfilter_filter_samples(ctx->outputs[out_id], buf); + ff_filter_samples(ctx->outputs[out_id], buf); queue->nb--; queue->tail = (queue->tail + 1) % QUEUE_SIZE; if (as->req[out_id]) diff --git a/libavfilter/af_earwax.c b/libavfilter/af_earwax.c index 7caeb2f6c3..da5c06eae1 100644 --- a/libavfilter/af_earwax.c +++ b/libavfilter/af_earwax.c @@ -122,7 +122,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) AVFilterLink *outlink = inlink->dst->outputs[0]; int16_t *taps, *endin, *in, *out; AVFilterBufferRef *outsamples = - avfilter_get_audio_buffer(inlink, AV_PERM_WRITE, + ff_get_audio_buffer(inlink, AV_PERM_WRITE, insamples->audio->nb_samples); avfilter_copy_buffer_ref_props(outsamples, insamples); @@ -141,7 +141,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) // save part of input for next round memcpy(taps, endin, NUMTAPS * sizeof(*taps)); - avfilter_filter_samples(outlink, outsamples); + ff_filter_samples(outlink, outsamples); avfilter_unref_buffer(insamples); } diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index 30d5d1b979..dba930e576 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -340,7 +340,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) { int n = insamples->audio->nb_samples; AVFilterLink *const outlink = inlink->dst->outputs[0]; - AVFilterBufferRef *outsamples = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, n); + AVFilterBufferRef *outsamples = ff_get_audio_buffer(outlink, AV_PERM_WRITE, n); PanContext *pan = inlink->dst->priv; swr_convert(pan->swr, outsamples->data, n, (void *)insamples->data, n); @@ -348,7 +348,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) outsamples->audio->channel_layout = outlink->channel_layout; outsamples->audio->planar = outlink->planar; - avfilter_filter_samples(outlink, outsamples); + ff_filter_samples(outlink, outsamples); avfilter_unref_buffer(insamples); } diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index 4f95b54f82..94197d7b85 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -123,7 +123,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) } } - avfilter_filter_samples(inlink->dst->outputs[0], insamples); + ff_filter_samples(inlink->dst->outputs[0], insamples); } static int query_formats(AVFilterContext *ctx) @@ -163,7 +163,7 @@ AVFilter avfilter_af_silencedetect = { .inputs = (const AVFilterPad[]) { { .name = "default", .type = AVMEDIA_TYPE_AUDIO, - .get_audio_buffer = avfilter_null_get_audio_buffer, + .get_audio_buffer = ff_null_get_audio_buffer, .filter_samples = filter_samples, }, { .name = NULL } }, diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c index 99ae8b82fe..881a4516dd 100644 --- a/libavfilter/af_volume.c +++ b/libavfilter/af_volume.c @@ -167,7 +167,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) } } } - avfilter_filter_samples(outlink, insamples); + ff_filter_samples(outlink, insamples); } AVFilter avfilter_af_volume = { diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c index 7bd6a89eb3..11750bb1ce 100644 --- a/libavfilter/asrc_aevalsrc.c +++ b/libavfilter/asrc_aevalsrc.c @@ -205,7 +205,7 @@ static int request_frame(AVFilterLink *outlink) if (eval->duration >= 0 && t > eval->duration) return AVERROR_EOF; - samplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, eval->nb_samples); + samplesref = ff_get_audio_buffer(outlink, AV_PERM_WRITE, eval->nb_samples); /* evaluate expression for each single sample and for each channel */ for (i = 0; i < eval->nb_samples; i++, eval->n++) { @@ -223,7 +223,7 @@ static int request_frame(AVFilterLink *outlink) samplesref->audio->sample_rate = eval->sample_rate; eval->pts += eval->nb_samples; - avfilter_filter_samples(outlink, samplesref); + ff_filter_samples(outlink, samplesref); return 0; } diff --git a/libavfilter/asrc_anullsrc.c b/libavfilter/asrc_anullsrc.c index 288e2bf910..86497b9b9e 100644 --- a/libavfilter/asrc_anullsrc.c +++ b/libavfilter/asrc_anullsrc.c @@ -108,13 +108,13 @@ static int request_frame(AVFilterLink *outlink) AVFilterBufferRef *samplesref; samplesref = - avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, null->nb_samples); + ff_get_audio_buffer(outlink, AV_PERM_WRITE, null->nb_samples); samplesref->pts = null->pts; samplesref->pos = -1; samplesref->audio->channel_layout = null->channel_layout; samplesref->audio->sample_rate = outlink->sample_rate; - avfilter_filter_samples(outlink, avfilter_ref_buffer(samplesref, ~0)); + ff_filter_samples(outlink, avfilter_ref_buffer(samplesref, ~0)); avfilter_unref_buffer(samplesref); null->pts += null->nb_samples; diff --git a/libavfilter/audio.c b/libavfilter/audio.c new file mode 100644 index 0000000000..31f6796437 --- /dev/null +++ b/libavfilter/audio.c @@ -0,0 +1,291 @@ +/* + * Copyright (c) Stefano Sabatini | stefasab at gmail.com + * Copyright (c) S.N. Hemanth Meenakshisundaram | smeenaks at ucsd.edu + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/avassert.h" +#include "libavutil/audioconvert.h" + +#include "audio.h" +#include "avfilter.h" +#include "internal.h" + +AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms, + int nb_samples) +{ + return ff_get_audio_buffer(link->dst->outputs[0], perms, nb_samples); +} + +AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, + int nb_samples) +{ + AVFilterBufferRef *samplesref = NULL; + int linesize[8] = {0}; + uint8_t *data[8] = {0}; + int ch, nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); + + /* right now we don't support more than 8 channels */ + av_assert0(nb_channels <= 8); + + /* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */ + if (av_samples_alloc(data, linesize, + nb_channels, nb_samples, + av_get_alt_sample_fmt(link->format, link->planar), + 16) < 0) + return NULL; + + for (ch = 1; link->planar && ch < nb_channels; ch++) + linesize[ch] = linesize[0]; + samplesref = + avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms, + nb_samples, link->format, + link->channel_layout, link->planar); + if (!samplesref) { + av_free(data[0]); + return NULL; + } + + return samplesref; +} + +static AVFilterBufferRef *ff_default_get_audio_buffer_alt(AVFilterLink *link, int perms, + int nb_samples) +{ + AVFilterBufferRef *samplesref = NULL; + uint8_t **data; + int planar = av_sample_fmt_is_planar(link->format); + int nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); + int planes = planar ? nb_channels : 1; + int linesize; + + if (!(data = av_mallocz(sizeof(*data) * planes))) + goto fail; + + if (av_samples_alloc(data, &linesize, nb_channels, nb_samples, link->format, 0) < 0) + goto fail; + + samplesref = avfilter_get_audio_buffer_ref_from_arrays_alt(data, linesize, perms, + nb_samples, link->format, + link->channel_layout); + if (!samplesref) + goto fail; + + av_freep(&data); + +fail: + if (data) + av_freep(&data[0]); + av_freep(&data); + return samplesref; +} + +AVFilterBufferRef *ff_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, nb_samples); + + if (!ret) + ret = ff_default_get_audio_buffer(link, perms, nb_samples); + + if (ret) + ret->type = AVMEDIA_TYPE_AUDIO; + + return ret; +} + +AVFilterBufferRef * +avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms, + int nb_samples, enum AVSampleFormat sample_fmt, + uint64_t channel_layout, int planar) +{ + AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); + AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef)); + + if (!samples || !samplesref) + goto fail; + + samplesref->buf = samples; + samplesref->buf->free = ff_avfilter_default_free_buffer; + if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps)))) + goto fail; + + samplesref->audio->nb_samples = nb_samples; + samplesref->audio->channel_layout = channel_layout; + samplesref->audio->planar = planar; + + /* make sure the buffer gets read permission or it's useless for output */ + samplesref->perms = perms | AV_PERM_READ; + + samples->refcount = 1; + samplesref->type = AVMEDIA_TYPE_AUDIO; + samplesref->format = sample_fmt; + + memcpy(samples->data, data, sizeof(samples->data)); + memcpy(samples->linesize, linesize, sizeof(samples->linesize)); + memcpy(samplesref->data, data, sizeof(samplesref->data)); + memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize)); + + return samplesref; + +fail: + if (samplesref && samplesref->audio) + av_freep(&samplesref->audio); + av_freep(&samplesref); + av_freep(&samples); + return NULL; +} + +AVFilterBufferRef* avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data, + int linesize,int perms, + int nb_samples, + enum AVSampleFormat sample_fmt, + uint64_t channel_layout) +{ + int planes; + AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); + AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); + + if (!samples || !samplesref) + goto fail; + + samplesref->buf = samples; + samplesref->buf->free = ff_avfilter_default_free_buffer; + if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) + goto fail; + + samplesref->audio->nb_samples = nb_samples; + samplesref->audio->channel_layout = channel_layout; + samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); + + planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; + + /* make sure the buffer gets read permission or it's useless for output */ + samplesref->perms = perms | AV_PERM_READ; + + samples->refcount = 1; + samplesref->type = AVMEDIA_TYPE_AUDIO; + samplesref->format = sample_fmt; + + memcpy(samples->data, data, + FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0])); + memcpy(samplesref->data, samples->data, sizeof(samples->data)); + + samples->linesize[0] = samplesref->linesize[0] = linesize; + + if (planes > FF_ARRAY_ELEMS(samples->data)) { + samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) * + planes); + samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) * + planes); + + if (!samples->extended_data || !samplesref->extended_data) + goto fail; + + memcpy(samples-> extended_data, data, sizeof(*data)*planes); + memcpy(samplesref->extended_data, data, sizeof(*data)*planes); + } else { + samples->extended_data = samples->data; + samplesref->extended_data = samplesref->data; + } + + return samplesref; + +fail: + if (samples && samples->extended_data != samples->data) + av_freep(&samples->extended_data); + if (samplesref) { + av_freep(&samplesref->audio); + if (samplesref->extended_data != samplesref->data) + av_freep(&samplesref->extended_data); + } + av_freep(&samplesref); + av_freep(&samples); + return NULL; +} + +void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) +{ + ff_filter_samples(link->dst->outputs[0], samplesref); +} + +/* FIXME: samplesref is same as link->cur_buf. Need to consider removing the redundant parameter. */ +void ff_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) +{ + AVFilterLink *outlink = NULL; + + if (inlink->dst->output_count) + outlink = inlink->dst->outputs[0]; + + if (outlink) { + outlink->out_buf = ff_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; + ff_filter_samples(outlink, avfilter_ref_buffer(outlink->out_buf, ~0)); + avfilter_unref_buffer(outlink->out_buf); + outlink->out_buf = NULL; + } + avfilter_unref_buffer(samplesref); + inlink->cur_buf = NULL; +} + +void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) +{ + void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); + AVFilterPad *dst = link->dstpad; + int64_t pts; + + FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); + + if (!(filter_samples = dst->filter_samples)) + filter_samples = ff_default_filter_samples; + + /* prepare to copy the samples if the buffer has insufficient permissions */ + if ((dst->min_perms & samplesref->perms) != dst->min_perms || + dst->rej_perms & samplesref->perms) { + int i, planar = av_sample_fmt_is_planar(samplesref->format); + int planes = !planar ? 1: + av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); + + av_log(link->dst, AV_LOG_DEBUG, + "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", + samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); + + link->cur_buf = ff_default_get_audio_buffer(link, dst->min_perms, + samplesref->audio->nb_samples); + link->cur_buf->pts = samplesref->pts; + link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; + + /* Copy actual data into new samples buffer */ + for (i = 0; samplesref->data[i] && i < 8; i++) + memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]); + for (i = 0; i < planes; i++) + memcpy(link->cur_buf->extended_data[i], samplesref->extended_data[i], samplesref->linesize[0]); + + avfilter_unref_buffer(samplesref); + } else + link->cur_buf = samplesref; + + pts = link->cur_buf->pts; + filter_samples(link, link->cur_buf); + ff_update_link_current_pts(link, pts); +} diff --git a/libavfilter/audio.h b/libavfilter/audio.h new file mode 100644 index 0000000000..051efb2024 --- /dev/null +++ b/libavfilter/audio.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) Stefano Sabatini | stefasab at gmail.com + * Copyright (c) S.N. Hemanth Meenakshisundaram | smeenaks at ucsd.edu + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVFILTER_AUDIO_H +#define AVFILTER_AUDIO_H + +#include "avfilter.h" + + +/** default handler for get_audio_buffer() for audio inputs */ +AVFilterBufferRef *ff_default_get_audio_buffer(AVFilterLink *link, int perms, + int nb_samples); + +/** get_audio_buffer() handler for filters which simply pass audio along */ +AVFilterBufferRef *ff_null_get_audio_buffer(AVFilterLink *link, int perms, + int nb_samples); + +/** + * Request an audio samples buffer with a specific set of permissions. + * + * @param link the output link to the filter from which the buffer will + * be requested + * @param perms the required access permissions + * @param nb_samples the number of samples per channel + * @return A reference to the samples. This must be unreferenced with + * avfilter_unref_buffer when you are finished with it. + */ +AVFilterBufferRef *ff_get_audio_buffer(AVFilterLink *link, int perms, + int nb_samples); + +/** default handler for filter_samples() for audio inputs */ +void ff_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); + +/** filter_samples() handler for filters which simply pass audio along */ +void ff_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); + +/** + * Send a buffer of audio samples to the next filter. + * + * @param link the output link over which the audio samples are being sent + * @param samplesref a reference to the buffer of audio samples being sent. The + * receiving filter will free this reference when it no longer + * needs it or pass it on to the next filter. + */ +void ff_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); + +#endif /* AVFILTER_AUDIO_H */ diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 89afee060f..073b259949 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -27,6 +27,7 @@ #include "libavutil/imgutils.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" + #include "avfilter.h" #include "internal.h" @@ -410,7 +411,7 @@ static void ff_dlog_ref(void *ctx, AVFilterBufferRef *ref, int end) av_dlog(ctx, "]%s", end ? "\n" : ""); } -static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) +void ff_dlog_link(void *ctx, AVFilterLink *link, int end) { if (link->type == AVMEDIA_TYPE_VIDEO) { av_dlog(ctx, @@ -434,8 +435,6 @@ static void ff_dlog_link(void *ctx, AVFilterLink *link, int end) } } -#define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func) - AVFilterBufferRef *avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { AVFilterBufferRef *ret = NULL; @@ -501,133 +500,6 @@ fail: return NULL; } -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, nb_samples); - - if (!ret) - ret = avfilter_default_get_audio_buffer(link, perms, nb_samples); - - if (ret) - ret->type = AVMEDIA_TYPE_AUDIO; - - return ret; -} - -AVFilterBufferRef * -avfilter_get_audio_buffer_ref_from_arrays(uint8_t *data[8], int linesize[8], int perms, - int nb_samples, enum AVSampleFormat sample_fmt, - uint64_t channel_layout, int planar) -{ - AVFilterBuffer *samples = av_mallocz(sizeof(AVFilterBuffer)); - AVFilterBufferRef *samplesref = av_mallocz(sizeof(AVFilterBufferRef)); - - if (!samples || !samplesref) - goto fail; - - samplesref->buf = samples; - samplesref->buf->free = ff_avfilter_default_free_buffer; - if (!(samplesref->audio = av_mallocz(sizeof(AVFilterBufferRefAudioProps)))) - goto fail; - - samplesref->audio->nb_samples = nb_samples; - samplesref->audio->channel_layout = channel_layout; - samplesref->audio->planar = planar; - - /* make sure the buffer gets read permission or it's useless for output */ - samplesref->perms = perms | AV_PERM_READ; - - samples->refcount = 1; - samplesref->type = AVMEDIA_TYPE_AUDIO; - samplesref->format = sample_fmt; - - memcpy(samples->data, data, sizeof(samples->data)); - memcpy(samples->linesize, linesize, sizeof(samples->linesize)); - memcpy(samplesref->data, data, sizeof(samplesref->data)); - memcpy(samplesref->linesize, linesize, sizeof(samplesref->linesize)); - - return samplesref; - -fail: - if (samplesref && samplesref->audio) - av_freep(&samplesref->audio); - av_freep(&samplesref); - av_freep(&samples); - return NULL; -} - -AVFilterBufferRef *avfilter_get_audio_buffer_ref_from_arrays_alt(uint8_t **data, - int linesize, int perms, - int nb_samples, - enum AVSampleFormat sample_fmt, - uint64_t channel_layout) -{ - int planes; - AVFilterBuffer *samples = av_mallocz(sizeof(*samples)); - AVFilterBufferRef *samplesref = av_mallocz(sizeof(*samplesref)); - - if (!samples || !samplesref) - goto fail; - - samplesref->buf = samples; - samplesref->buf->free = ff_avfilter_default_free_buffer; - if (!(samplesref->audio = av_mallocz(sizeof(*samplesref->audio)))) - goto fail; - - samplesref->audio->nb_samples = nb_samples; - samplesref->audio->channel_layout = channel_layout; - samplesref->audio->planar = av_sample_fmt_is_planar(sample_fmt); - - planes = samplesref->audio->planar ? av_get_channel_layout_nb_channels(channel_layout) : 1; - - /* make sure the buffer gets read permission or it's useless for output */ - samplesref->perms = perms | AV_PERM_READ; - - samples->refcount = 1; - samplesref->type = AVMEDIA_TYPE_AUDIO; - samplesref->format = sample_fmt; - - memcpy(samples->data, data, - FFMIN(FF_ARRAY_ELEMS(samples->data), planes)*sizeof(samples->data[0])); - memcpy(samplesref->data, samples->data, sizeof(samples->data)); - - samples->linesize[0] = samplesref->linesize[0] = linesize; - - if (planes > FF_ARRAY_ELEMS(samples->data)) { - samples-> extended_data = av_mallocz(sizeof(*samples->extended_data) * - planes); - samplesref->extended_data = av_mallocz(sizeof(*samplesref->extended_data) * - planes); - - if (!samples->extended_data || !samplesref->extended_data) - goto fail; - - memcpy(samples-> extended_data, data, sizeof(*data)*planes); - memcpy(samplesref->extended_data, data, sizeof(*data)*planes); - } else { - samples->extended_data = samples->data; - samplesref->extended_data = samplesref->data; - } - - return samplesref; - -fail: - if (samples && samples->extended_data != samples->data) - av_freep(&samples->extended_data); - if (samplesref) { - av_freep(&samplesref->audio); - if (samplesref->extended_data != samplesref->data) - av_freep(&samplesref->extended_data); - } - av_freep(&samplesref); - av_freep(&samples); - return NULL; -} - int avfilter_request_frame(AVFilterLink *link) { FF_DPRINTF_START(NULL, request_frame); ff_dlog_link(NULL, link, 1); @@ -657,7 +529,7 @@ int avfilter_poll_frame(AVFilterLink *link) return min; } -static void update_link_current_pts(AVFilterLink *link, int64_t pts) +void ff_update_link_current_pts(AVFilterLink *link, int64_t pts) { if (pts == AV_NOPTS_VALUE) return; @@ -706,7 +578,7 @@ void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref) } start_frame(link, link->cur_buf); - update_link_current_pts(link, link->cur_buf->pts); + ff_update_link_current_pts(link, link->cur_buf->pts); } void avfilter_end_frame(AVFilterLink *link) @@ -778,44 +650,6 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha return AVERROR(ENOSYS); } -void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) -{ - void (*filter_samples)(AVFilterLink *, AVFilterBufferRef *); - AVFilterPad *dst = link->dstpad; - int i; - int64_t pts; - - FF_DPRINTF_START(NULL, filter_samples); ff_dlog_link(NULL, link, 1); - - if (!(filter_samples = dst->filter_samples)) - filter_samples = avfilter_default_filter_samples; - - /* prepare to copy the samples if the buffer has insufficient permissions */ - if ((dst->min_perms & samplesref->perms) != dst->min_perms || - dst->rej_perms & samplesref->perms) { - - av_log(link->dst, AV_LOG_DEBUG, - "Copying audio data in avfilter (have perms %x, need %x, reject %x)\n", - samplesref->perms, link->dstpad->min_perms, link->dstpad->rej_perms); - - link->cur_buf = avfilter_default_get_audio_buffer(link, dst->min_perms, - samplesref->audio->nb_samples); - link->cur_buf->pts = samplesref->pts; - link->cur_buf->audio->sample_rate = samplesref->audio->sample_rate; - - /* Copy actual data into new samples buffer */ - for (i = 0; samplesref->data[i] && i < 8; i++) - memcpy(link->cur_buf->data[i], samplesref->data[i], samplesref->linesize[0]); - - avfilter_unref_buffer(samplesref); - } else - link->cur_buf = samplesref; - - pts = link->cur_buf->pts; - filter_samples(link, link->cur_buf); - update_link_current_pts(link, pts); -} - #define MAX_REGISTERED_AVFILTERS_NB 128 static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1]; diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index d7d4c16ec0..9fa6ab4023 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -430,7 +430,8 @@ struct AVFilterPad { * * Input audio pads only. */ - AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, int nb_samples); + AVFilterBufferRef *(*get_audio_buffer)(AVFilterLink *link, int perms, + int nb_samples); /** * Callback called after the slices of a frame are completely sent. If @@ -508,16 +509,10 @@ void avfilter_default_draw_slice(AVFilterLink *link, int y, int h, int slice_dir /** default handler for end_frame() for video inputs */ void avfilter_default_end_frame(AVFilterLink *link); -/** default handler for filter_samples() for audio inputs */ -void avfilter_default_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); - /** default handler for get_video_buffer() for video inputs */ 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, int nb_samples); /** * Helpers for query_formats() which set all links to the same list of @@ -541,17 +536,10 @@ void avfilter_null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); /** end_frame() handler for filters which simply pass video along */ void avfilter_null_end_frame(AVFilterLink *link); -/** filter_samples() handler for filters which simply pass audio along */ -void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); - /** get_video_buffer() handler for filters which simply pass video along */ 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, int nb_samples); - /** * Filter definition. This defines the pads a filter contains, and all the * callback functions used to interact with the filter. @@ -665,7 +653,7 @@ struct AVFilterLink { AVRational sample_aspect_ratio; ///< agreed upon sample aspect ratio /* These parameters apply only to audio */ uint64_t channel_layout; ///< channel layout of current buffer (see libavutil/audioconvert.h) -#if LIBAVFILTER_VERSION_MAJOR < 3 +#if FF_API_SAMPLERATE64 int64_t sample_rate; ///< samples per second #else int sample_rate; ///< samples per second @@ -791,19 +779,6 @@ avfilter_get_video_buffer_ref_from_arrays(uint8_t * const data[4], const int lin int w, int h, enum PixelFormat format); /** - * Request an audio samples buffer with a specific set of permissions. - * - * @param link the output link to the filter from which the buffer will - * be requested - * @param perms the required access permissions - * @param nb_samples the number of samples per channel - * @return A reference to the samples. This must be unreferenced with - * avfilter_unref_buffer when you are finished with it. - */ -AVFilterBufferRef *avfilter_get_audio_buffer(AVFilterLink *link, int perms, - int nb_samples); - -/** * Create an audio buffer reference wrapped around an already * allocated samples buffer. * @@ -904,17 +879,7 @@ void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir); */ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags); -/** - * Send a buffer of audio samples to the next filter. - * - * @param link the output link over which the audio samples are being sent - * @param samplesref a reference to the buffer of audio samples being sent. The - * receiving filter will free this reference when it no longer - * needs it or pass it on to the next filter. - */ -void avfilter_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref); - -/** Initialize the filter system. Register all built-in filters. */ +/** Initialize the filter system. Register all builtin filters. */ void avfilter_register_all(void); /** Uninitialize the filter system. Unregister all filters. */ @@ -1024,4 +989,6 @@ static inline void avfilter_insert_outpad(AVFilterContext *f, unsigned index, &f->output_pads, &f->outputs, p); } +#include "audio.h" + #endif /* AVFILTER_AVFILTER_H */ diff --git a/libavfilter/defaults.c b/libavfilter/defaults.c index e57a1290aa..d2e01499be 100644 --- a/libavfilter/defaults.c +++ b/libavfilter/defaults.c @@ -23,6 +23,7 @@ #include "libavutil/audioconvert.h" #include "libavutil/imgutils.h" #include "libavutil/samplefmt.h" + #include "avfilter.h" #include "internal.h" @@ -87,38 +88,6 @@ AVFilterBufferRef *avfilter_default_get_video_buffer(AVFilterLink *link, int per return picref; } -AVFilterBufferRef *avfilter_default_get_audio_buffer(AVFilterLink *link, int perms, - int nb_samples) -{ - AVFilterBufferRef *samplesref = NULL; - int linesize[8] = {0}; - uint8_t *data[8] = {0}; - int ch, nb_channels = av_get_channel_layout_nb_channels(link->channel_layout); - - /* right now we don't support more than 8 channels */ - av_assert0(nb_channels <= 8); - - /* Calculate total buffer size, round to multiple of 16 to be SIMD friendly */ - if (av_samples_alloc(data, linesize, - nb_channels, nb_samples, - av_get_alt_sample_fmt(link->format, link->planar), - 16) < 0) - return NULL; - - for (ch = 1; link->planar && ch < nb_channels; ch++) - linesize[ch] = linesize[0]; - samplesref = - avfilter_get_audio_buffer_ref_from_arrays(data, linesize, perms, - nb_samples, link->format, - link->channel_layout, link->planar); - if (!samplesref) { - av_free(data[0]); - return NULL; - } - - return samplesref; -} - void avfilter_default_start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref) { AVFilterLink *outlink = NULL; @@ -163,27 +132,6 @@ void avfilter_default_end_frame(AVFilterLink *inlink) } } -/* FIXME: samplesref is same as link->cur_buf. Need to consider removing the redundant parameter. */ -void avfilter_default_filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref) -{ - AVFilterLink *outlink = NULL; - - if (inlink->dst->output_count) - outlink = inlink->dst->outputs[0]; - - if (outlink) { - 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)); - avfilter_unref_buffer(outlink->out_buf); - outlink->out_buf = NULL; - } - avfilter_unref_buffer(samplesref); - inlink->cur_buf = NULL; -} - static void set_common_formats(AVFilterContext *ctx, AVFilterFormats *fmts, enum AVMediaType type, int offin, int offout) { @@ -258,18 +206,7 @@ void avfilter_null_end_frame(AVFilterLink *link) avfilter_end_frame(link->dst->outputs[0]); } -void avfilter_null_filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref) -{ - avfilter_filter_samples(link->dst->outputs[0], samplesref); -} - AVFilterBufferRef *avfilter_null_get_video_buffer(AVFilterLink *link, int perms, int w, int h) { return avfilter_get_video_buffer(link->dst->outputs[0], perms, w, h); } - -AVFilterBufferRef *avfilter_null_get_audio_buffer(AVFilterLink *link, int perms, - int nb_samples) -{ - return avfilter_get_audio_buffer(link->dst->outputs[0], perms, nb_samples); -} diff --git a/libavfilter/internal.h b/libavfilter/internal.h index e8516c3ba1..09d605541f 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -149,4 +149,10 @@ static inline void ff_null_start_frame_keep_ref(AVFilterLink *inlink, avfilter_start_frame(inlink->dst->outputs[0], avfilter_ref_buffer(picref, ~0)); } +void ff_update_link_current_pts(AVFilterLink *link, int64_t pts); + +#define FF_DPRINTF_START(ctx, func) av_dlog(NULL, "%-16s: ", #func) + +void ff_dlog_link(void *ctx, AVFilterLink *link, int end); + #endif /* AVFILTER_INTERNAL_H */ diff --git a/libavfilter/src_buffer.c b/libavfilter/src_buffer.c index 19c49a3a9b..f6c67f4db0 100644 --- a/libavfilter/src_buffer.c +++ b/libavfilter/src_buffer.c @@ -297,7 +297,7 @@ static AVFilterBufferRef *copy_buffer_ref(AVFilterContext *ctx, break; case AVMEDIA_TYPE_AUDIO: - buf = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, + buf = ff_get_audio_buffer(outlink, AV_PERM_WRITE, ref->audio->nb_samples); channels = av_get_channel_layout_nb_channels(ref->audio->channel_layout); data_size = av_samples_get_buffer_size(NULL, channels, @@ -562,7 +562,7 @@ static int request_frame(AVFilterLink *link) avfilter_unref_buffer(buf); break; case AVMEDIA_TYPE_AUDIO: - avfilter_filter_samples(link, avfilter_ref_buffer(buf, ~0)); + ff_filter_samples(link, avfilter_ref_buffer(buf, ~0)); avfilter_unref_buffer(buf); break; default: diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index 1d65ade5c8..15b82ab08d 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -437,7 +437,7 @@ static int amovie_get_samples(AVFilterLink *outlink) if (data_size < 0) return data_size; movie->samplesref = - avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples); + ff_get_audio_buffer(outlink, AV_PERM_WRITE, nb_samples); memcpy(movie->samplesref->data[0], movie->frame->data[0], data_size); movie->samplesref->pts = movie->pkt.pts; movie->samplesref->pos = movie->pkt.pos; @@ -463,7 +463,7 @@ static int amovie_request_frame(AVFilterLink *outlink) return ret; } while (!movie->samplesref); - avfilter_filter_samples(outlink, avfilter_ref_buffer(movie->samplesref, ~0)); + ff_filter_samples(outlink, avfilter_ref_buffer(movie->samplesref, ~0)); avfilter_unref_buffer(movie->samplesref); movie->samplesref = NULL; diff --git a/libavfilter/version.h b/libavfilter/version.h index 1aee0374fe..82817a7115 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -47,5 +47,8 @@ #ifndef FF_API_GRAPH_AVCLASS #define FF_API_GRAPH_AVCLASS (LIBAVFILTER_VERSION_MAJOR > 2) #endif +#ifndef FF_API_SAMPLERATE64 +#define FF_API_SAMPLERATE64 (LIBAVFILTER_VERSION_MAJOR < 3) +#endif #endif // AVFILTER_VERSION_H |