mirror of
https://github.com/librempeg/librempeg
synced 2024-11-22 18:49:58 +00:00
lavfi: move AVFilterLink.m{ax,in}_samples to FilterLink
Also, document who sets these fields and when. Signed-off-by: Paul B Mahol <onemda@gmail.com>
This commit is contained in:
parent
d805cdb19b
commit
5e8bd1219f
@ -26,6 +26,7 @@
|
||||
#include "libavutil/avassert.h"
|
||||
#include "libavutil/tx.h"
|
||||
#include "avfilter.h"
|
||||
#include "filters.h"
|
||||
#include "internal.h"
|
||||
#include "audio.h"
|
||||
|
||||
@ -725,6 +726,7 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
|
||||
|
||||
static int config_input(AVFilterLink *inlink)
|
||||
{
|
||||
FilterLink *l = ff_filter_link(inlink);
|
||||
AVFilterContext *ctx = inlink->dst;
|
||||
FIREqualizerContext *s = ctx->priv;
|
||||
float iscale, scale = 1.f;
|
||||
@ -824,7 +826,7 @@ static int config_input(AVFilterLink *inlink)
|
||||
inlink->sample_rate, inlink->ch_layout.nb_channels, s->analysis_rdft_len, s->rdft_len, s->fir_len, s->nsamples_max);
|
||||
|
||||
if (s->fixed)
|
||||
inlink->min_samples = inlink->max_samples = s->nsamples_max;
|
||||
l->min_samples = l->max_samples = s->nsamples_max;
|
||||
|
||||
return generate_kernel(ctx, SELECT_GAIN(s), SELECT_GAIN_ENTRY(s));
|
||||
}
|
||||
|
@ -37,6 +37,7 @@
|
||||
#include "libavutil/opt.h"
|
||||
#include "audio.h"
|
||||
#include "avfilter.h"
|
||||
#include "filters.h"
|
||||
#include "formats.h"
|
||||
#include "internal.h"
|
||||
|
||||
@ -354,7 +355,7 @@ static int config_output(AVFilterLink *outlink)
|
||||
s->inplace_broken = lilv_plugin_has_feature(s->plugin, s->lv2_inPlaceBroken);
|
||||
|
||||
if (s->nb_inputs) {
|
||||
AVFilterLink *inlink = ctx->inputs[0];
|
||||
FilterLink *inlink = ff_filter_link(ctx->inputs[0]);
|
||||
|
||||
if (lilv_plugin_has_feature(s->plugin, s->powerOf2BlockLength)) {
|
||||
s->min_samples = 1 << av_ceil_log2(s->min_samples);
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "libavutil/opt.h"
|
||||
#include "audio.h"
|
||||
#include "avfilter.h"
|
||||
#include "filters.h"
|
||||
#include "formats.h"
|
||||
#include "internal.h"
|
||||
|
||||
@ -349,6 +350,7 @@ static int query_formats(AVFilterContext *ctx)
|
||||
|
||||
static int config_input(AVFilterLink *inlink)
|
||||
{
|
||||
FilterLink *l = ff_filter_link(inlink);
|
||||
AVFilterContext *ctx = inlink->dst;
|
||||
ReplayGainContext *s = ctx->priv;
|
||||
int i;
|
||||
@ -366,8 +368,8 @@ static int config_input(AVFilterLink *inlink)
|
||||
|
||||
s->yule_hist_i = 20;
|
||||
s->butter_hist_i = 4;
|
||||
inlink->min_samples =
|
||||
inlink->max_samples = inlink->sample_rate / 20;
|
||||
l->min_samples =
|
||||
l->max_samples = inlink->sample_rate / 20;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1077,14 +1077,15 @@ static int samples_ready(FilterLinkInternal *link, unsigned min)
|
||||
static int take_samples(FilterLinkInternal *li, unsigned min, unsigned max,
|
||||
AVFrame **rframe)
|
||||
{
|
||||
AVFilterLink *link = &li->l.pub;
|
||||
FilterLink *l = &li->l;
|
||||
AVFilterLink *link = &l->pub;
|
||||
AVFrame *frame0, *frame, *buf;
|
||||
unsigned nb_samples, nb_frames, i, p;
|
||||
int ret;
|
||||
|
||||
/* Note: this function relies on no format changes and must only be
|
||||
called with enough samples. */
|
||||
av_assert1(samples_ready(li, link->min_samples));
|
||||
av_assert1(samples_ready(li, l->min_samples));
|
||||
frame0 = frame = ff_framequeue_peek(&li->fifo, 0);
|
||||
if (!li->fifo.samples_skipped && frame->nb_samples >= min && frame->nb_samples <= max) {
|
||||
*rframe = ff_framequeue_take(&li->fifo);
|
||||
@ -1142,8 +1143,8 @@ static int ff_filter_frame_to_filter(AVFilterLink *link)
|
||||
int ret;
|
||||
|
||||
av_assert1(ff_framequeue_queued_frames(&li->fifo));
|
||||
ret = link->min_samples ?
|
||||
ff_inlink_consume_samples(link, link->min_samples, link->max_samples, &frame) :
|
||||
ret = li->l.min_samples ?
|
||||
ff_inlink_consume_samples(link, li->l.min_samples, li->l.max_samples, &frame) :
|
||||
ff_inlink_consume_frame(link, &frame);
|
||||
av_assert1(ret);
|
||||
if (ret < 0) {
|
||||
@ -1218,8 +1219,8 @@ static int ff_filter_activate_default(AVFilterContext *filter)
|
||||
}
|
||||
|
||||
for (i = 0; i < filter->nb_inputs; i++) {
|
||||
if (samples_ready(ff_link_internal(filter->inputs[i]),
|
||||
filter->inputs[i]->min_samples)) {
|
||||
FilterLinkInternal *li = ff_link_internal(filter->inputs[i]);
|
||||
if (samples_ready(li, li->l.min_samples)) {
|
||||
return ff_filter_frame_to_filter(filter->inputs[i]);
|
||||
}
|
||||
}
|
||||
|
@ -626,21 +626,6 @@ struct AVFilterLink {
|
||||
*/
|
||||
AVRational frame_rate;
|
||||
|
||||
/**
|
||||
* Minimum number of samples to filter at once. If filter_frame() is
|
||||
* called with fewer samples, it will accumulate them in fifo.
|
||||
* This field and the related ones must not be changed after filtering
|
||||
* has started.
|
||||
* If 0, all related fields are ignored.
|
||||
*/
|
||||
int min_samples;
|
||||
|
||||
/**
|
||||
* Maximum number of samples to filter at once. If filter_frame() is
|
||||
* called with more samples, it will split them.
|
||||
*/
|
||||
int max_samples;
|
||||
|
||||
/**
|
||||
* Number of past frames sent through the link.
|
||||
*/
|
||||
|
@ -119,7 +119,8 @@ static int get_frame_internal(AVFilterContext *ctx, AVFrame *frame, int flags, i
|
||||
|
||||
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
|
||||
{
|
||||
return get_frame_internal(ctx, frame, flags, ctx->inputs[0]->min_samples);
|
||||
return get_frame_internal(ctx, frame, flags,
|
||||
ff_filter_link(ctx->inputs[0])->min_samples);
|
||||
}
|
||||
|
||||
int attribute_align_arg av_buffersink_get_samples(AVFilterContext *ctx,
|
||||
@ -163,7 +164,7 @@ static int activate(AVFilterContext *ctx)
|
||||
|
||||
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
|
||||
{
|
||||
AVFilterLink *inlink = ctx->inputs[0];
|
||||
FilterLink *inlink = ff_filter_link(ctx->inputs[0]);
|
||||
|
||||
inlink->min_samples = inlink->max_samples = frame_size;
|
||||
}
|
||||
|
@ -41,8 +41,29 @@
|
||||
*/
|
||||
typedef struct FilterLink {
|
||||
AVFilterLink pub;
|
||||
|
||||
/**
|
||||
* Minimum number of samples to filter at once.
|
||||
*
|
||||
* May be set by the link destination filter in its config_props().
|
||||
* If 0, all related fields are ignored.
|
||||
*/
|
||||
int min_samples;
|
||||
|
||||
/**
|
||||
* Maximum number of samples to filter at once. If filter_frame() is
|
||||
* called with more samples, it will split them.
|
||||
*
|
||||
* May be set by the link destination filter in its config_props().
|
||||
*/
|
||||
int max_samples;
|
||||
} FilterLink;
|
||||
|
||||
static inline FilterLink* ff_filter_link(AVFilterLink *link)
|
||||
{
|
||||
return (FilterLink*)link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a filter ready and schedule it for activation.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user