avfilter/vf_tpad: handle case when no frame was ever received

This commit is contained in:
Paul B Mahol 2022-02-24 20:44:46 +01:00
parent 3715f2f864
commit 6f04b43c22

View File

@ -79,6 +79,18 @@ static int activate(AVFilterContext *ctx)
FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink);
if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
if (status == AVERROR_EOF) {
pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
if (!s->pad_stop && !s->pad_start) {
ff_outlink_set_status(outlink, status, pts);
return 0;
}
s->eof = 1;
s->pts += pts;
}
}
if (s->start_mode == 0 && s->pad_start > 0 && ff_outlink_frame_wanted(outlink)) {
frame = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!frame)
@ -93,7 +105,10 @@ static int activate(AVFilterContext *ctx)
}
if (s->start_mode == 1 && s->pad_start > 0) {
if (!s->cache_start && ff_inlink_queued_frames(inlink)) {
if (s->eof) {
ff_outlink_set_status(outlink, AVERROR_EOF, 0);
return 0;
} else if (!s->cache_start && ff_inlink_queued_frames(inlink)) {
s->cache_start = ff_inlink_peek_frame(inlink, 0);
} else if (!s->cache_start) {
FF_FILTER_FORWARD_WANTED(outlink, inlink);
@ -123,18 +138,6 @@ static int activate(AVFilterContext *ctx)
}
}
if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) {
if (status == AVERROR_EOF) {
pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);
if (!s->pad_stop) {
ff_outlink_set_status(outlink, status, pts);
return 0;
}
s->eof = 1;
s->pts += pts;
}
}
if (s->eof) {
if (!s->pad_stop) {
ff_outlink_set_status(outlink, AVERROR_EOF, s->pts);