]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/vf_shuffleframes.c
Merge commit 'f65285aba0df7d46298abe0c945dfee05cbc6028'
[ffmpeg] / libavfilter / vf_shuffleframes.c
index bfbf4bd2688c0d01a321154d303c057b0eeda3e1..8e595111b80d8332cfdebbbe2714a36a09dd058f 100644 (file)
@@ -68,7 +68,7 @@ static av_cold int init(AVFilterContext *ctx)
             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);
@@ -99,11 +99,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
             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--;
         }