You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-11-06 08:29:25 +02:00
avfilter/asrc_anullsrc: switch to activate
Allow to set the EOF timestamp.
This commit is contained in:
@@ -32,6 +32,7 @@
|
|||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
|
#include "filters.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
typedef struct ANullContext {
|
typedef struct ANullContext {
|
||||||
@@ -105,28 +106,35 @@ static int config_props(AVFilterLink *outlink)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int request_frame(AVFilterLink *outlink)
|
static int activate(AVFilterContext *ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
ANullContext *null = ctx->priv;
|
||||||
ANullContext *null = outlink->src->priv;
|
AVFilterLink *outlink = ctx->outputs[0];
|
||||||
AVFrame *samplesref;
|
|
||||||
|
|
||||||
if (null->duration >= 0 &&
|
if (null->duration >= 0 &&
|
||||||
av_rescale_q(null->pts, outlink->time_base, AV_TIME_BASE_Q) >= null->duration)
|
av_rescale_q(null->pts, outlink->time_base, AV_TIME_BASE_Q) >= null->duration) {
|
||||||
return AVERROR_EOF;
|
ff_outlink_set_status(outlink, AVERROR_EOF, null->pts);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
samplesref = ff_get_audio_buffer(outlink, null->nb_samples);
|
if (ff_outlink_frame_wanted(outlink)) {
|
||||||
if (!samplesref)
|
AVFrame *samplesref = ff_get_audio_buffer(outlink, null->nb_samples);
|
||||||
return AVERROR(ENOMEM);
|
int ret;
|
||||||
|
|
||||||
samplesref->pts = null->pts;
|
if (!samplesref)
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
ret = ff_filter_frame(outlink, samplesref);
|
samplesref->pts = null->pts;
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
null->pts += null->nb_samples;
|
ret = ff_filter_frame(outlink, samplesref);
|
||||||
return ret;
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
null->pts += null->nb_samples;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FFERROR_NOT_READY;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = {
|
static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = {
|
||||||
@@ -134,7 +142,6 @@ static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = {
|
|||||||
.name = "default",
|
.name = "default",
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
.config_props = config_props,
|
.config_props = config_props,
|
||||||
.request_frame = request_frame,
|
|
||||||
},
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
@@ -147,5 +154,6 @@ AVFilter ff_asrc_anullsrc = {
|
|||||||
.priv_size = sizeof(ANullContext),
|
.priv_size = sizeof(ANullContext),
|
||||||
.inputs = NULL,
|
.inputs = NULL,
|
||||||
.outputs = avfilter_asrc_anullsrc_outputs,
|
.outputs = avfilter_asrc_anullsrc_outputs,
|
||||||
|
.activate = activate,
|
||||||
.priv_class = &anullsrc_class,
|
.priv_class = &anullsrc_class,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user