X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Ff_loop.c;h=5ec44d9da2e4b3e7d727dfaaaf3c3a48ff4218d1;hb=f156f4ab2317f22bfef33c7eaead0d5d5f162903;hp=d9d55f983722fd9339f38765e0da39050916ac22;hpb=5ca7eb36b7353f9e6af05a5a952eead5f6d326dd;p=ffmpeg diff --git a/libavfilter/f_loop.c b/libavfilter/f_loop.c index d9d55f98372..5ec44d9da2e 100644 --- a/libavfilter/f_loop.c +++ b/libavfilter/f_loop.c @@ -55,6 +55,15 @@ typedef struct LoopContext { #define VFLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM #define OFFSET(x) offsetof(LoopContext, x) +static void check_size(AVFilterContext *ctx) +{ + LoopContext *s = ctx->priv; + + if (!s->size) + av_log(ctx, AV_LOG_WARNING, "Number of %s to loop is not set!\n", + ctx->input_pads[0].type == AVMEDIA_TYPE_VIDEO ? "frames" : "samples"); +} + #if CONFIG_ALOOP_FILTER static int aconfig_input(AVFilterLink *inlink) @@ -67,6 +76,8 @@ static int aconfig_input(AVFilterLink *inlink) if (!s->fifo || !s->left) return AVERROR(ENOMEM); + check_size(ctx); + return 0; } @@ -250,6 +261,8 @@ static av_cold int init(AVFilterContext *ctx) if (!s->frames) return AVERROR(ENOMEM); + check_size(ctx); + return 0; } @@ -343,7 +356,7 @@ static int activate(AVFilterContext *ctx) FF_FILTER_FORWARD_STATUS_BACK(outlink, inlink); - if (!s->eof && (s->nb_frames < s->size || !s->loop)) { + if (!s->eof && (s->nb_frames < s->size || !s->loop || !s->size)) { ret = ff_inlink_consume_frame(inlink, &frame); if (ret < 0) return ret; @@ -352,11 +365,13 @@ static int activate(AVFilterContext *ctx) } if (!s->eof && ff_inlink_acknowledge_status(inlink, &status, &pts)) { - if (status == AVERROR_EOF) + if (status == AVERROR_EOF) { + s->size = s->nb_frames; s->eof = 1; + } } - if (s->eof && (s->loop == 0 || s->nb_frames < s->size)) { + if (s->eof && (!s->loop || !s->size)) { ff_outlink_set_status(outlink, AVERROR_EOF, s->duration); return 0; }