mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
avfilter/aevalsrc: switch to activate
Allow to set the EOF timestamp. FATE test is updated, as last 2 frames were duplicated.
This commit is contained in:
parent
6854cc2ec7
commit
99ccad843f
@ -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),
|
||||
|
@ -6,5 +6,3 @@
|
||||
#channel_layout_name 0: mono
|
||||
0, -256, -256, 1536, 416, 0x3001fb2d
|
||||
0, 1280, 1280, 1536, 418, 0xba72fc16
|
||||
0, 2816, 2816, 1536, 418, 0xba72fc16
|
||||
0, 4352, 4352, 1536, 418, 0xba72fc16
|
||||
|
Loading…
Reference in New Issue
Block a user