return AVERROR(EINVAL);
}
- if (s->map[n] < 0 || s->map[n] >= nb_items) {
+ if (s->map[n] < -1 || s->map[n] >= nb_items) {
av_log(ctx, AV_LOG_ERROR, "Index out of range.\n");
av_free(mapping);
return AVERROR(EINVAL);
AVFrame *out;
x = s->map[n];
- out = av_frame_clone(s->frames[x]);
- if (!out)
- return AVERROR(ENOMEM);
- out->pts = s->pts[n];
- ret = ff_filter_frame(ctx->outputs[0], out);
+ if (x >= 0) {
+ out = av_frame_clone(s->frames[x]);
+ if (!out)
+ return AVERROR(ENOMEM);
+ out->pts = s->pts[n];
+ ret = ff_filter_frame(ctx->outputs[0], out);
+ }
s->in_frames--;
}