[FFmpeg-cvslog] avfilter/vf_shuffleframes: allow also dropping frames
Paul B Mahol
git at videolan.org
Fri Jan 6 13:31:07 EET 2017
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Jan 6 12:27:46 2017 +0100| [520c0736fd2079f04a2a0ba09562bae49f62f472] | committer: Paul B Mahol
avfilter/vf_shuffleframes: allow also dropping frames
Signed-off-by: Paul B Mahol <onemda at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=520c0736fd2079f04a2a0ba09562bae49f62f472
---
doc/filters.texi | 3 ++-
libavfilter/vf_shuffleframes.c | 14 ++++++++------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/doc/filters.texi b/doc/filters.texi
index 42cdd2e..94548b1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -12285,7 +12285,7 @@ Set the size of the box used to represent one palette color entry. Default is
@section shuffleframes
-Reorder and/or duplicate video frames.
+Reorder and/or duplicate and/or drop video frames.
It accepts the following parameters:
@@ -12294,6 +12294,7 @@ It accepts the following parameters:
Set the destination indexes of input frames.
This is space or '|' separated list of indexes that maps input frames to output
frames. Number of indexes also sets maximal value that each index may have.
+'-1' index have special meaning and that is to drop frame.
@end table
The first frame has the index 0. The default is to keep the input unchanged.
diff --git a/libavfilter/vf_shuffleframes.c b/libavfilter/vf_shuffleframes.c
index bfbf4bd..8e59511 100644
--- a/libavfilter/vf_shuffleframes.c
+++ b/libavfilter/vf_shuffleframes.c
@@ -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--;
}
More information about the ffmpeg-cvslog
mailing list