|
|
|
@ -30,6 +30,7 @@ |
|
|
|
|
#include "libavutil/parseutils.h" |
|
|
|
|
#include "avfilter.h" |
|
|
|
|
#include "audio.h" |
|
|
|
|
#include "filters.h" |
|
|
|
|
#include "internal.h" |
|
|
|
|
|
|
|
|
|
static const char * const var_names[] = { |
|
|
|
@ -259,21 +260,27 @@ static int query_formats(AVFilterContext *ctx) |
|
|
|
|
return ff_set_common_samplerates_from_list(ctx, sample_rates); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int request_frame(AVFilterLink *outlink) |
|
|
|
|
static int activate(AVFilterContext *ctx) |
|
|
|
|
{ |
|
|
|
|
AVFilterLink *outlink = ctx->outputs[0]; |
|
|
|
|
EvalContext *eval = outlink->src->priv; |
|
|
|
|
AVFrame *samplesref; |
|
|
|
|
int i, j; |
|
|
|
|
int64_t t = av_rescale(eval->n, AV_TIME_BASE, eval->sample_rate); |
|
|
|
|
int nb_samples; |
|
|
|
|
|
|
|
|
|
if (!ff_outlink_frame_wanted(outlink)) |
|
|
|
|
return FFERROR_NOT_READY; |
|
|
|
|
|
|
|
|
|
if (eval->duration >= 0 && t >= eval->duration) |
|
|
|
|
return AVERROR_EOF; |
|
|
|
|
|
|
|
|
|
if (eval->duration >= 0) { |
|
|
|
|
nb_samples = FFMIN(eval->nb_samples, av_rescale(eval->duration, eval->sample_rate, AV_TIME_BASE) - eval->pts); |
|
|
|
|
if (!nb_samples) |
|
|
|
|
return AVERROR_EOF; |
|
|
|
|
if (!nb_samples) { |
|
|
|
|
ff_outlink_set_status(outlink, AVERROR_EOF, eval->pts); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
nb_samples = eval->nb_samples; |
|
|
|
|
} |
|
|
|
@ -305,7 +312,6 @@ static const AVFilterPad aevalsrc_outputs[] = { |
|
|
|
|
.name = "default", |
|
|
|
|
.type = AVMEDIA_TYPE_AUDIO, |
|
|
|
|
.config_props = config_props, |
|
|
|
|
.request_frame = request_frame, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -315,6 +321,7 @@ const AVFilter ff_asrc_aevalsrc = { |
|
|
|
|
.query_formats = query_formats, |
|
|
|
|
.init = init, |
|
|
|
|
.uninit = uninit, |
|
|
|
|
.activate = activate, |
|
|
|
|
.priv_size = sizeof(EvalContext), |
|
|
|
|
.inputs = NULL, |
|
|
|
|
FILTER_OUTPUTS(aevalsrc_outputs), |
|
|
|
|