[FFmpeg-cvslog] vf_select: switch to filter_frame
Anton Khirnov
git at videolan.org
Wed Nov 28 21:36:28 CET 2012
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Nov 28 21:02:09 2012 +0100| [2c3b665379de0358006199de8604e10323c1037a] | committer: Michael Niedermayer
vf_select: switch to filter_frame
The new code reads the input frame when its ready, the previous
code did read the input frame during start_frame at which point it
may not yet be available.
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2c3b665379de0358006199de8604e10323c1037a
---
libavfilter/vf_select.c | 52 ++++++----------------------
tests/ref/fate/filter-metadata-scenedetect | 21 ++++++-----
2 files changed, 21 insertions(+), 52 deletions(-)
diff --git a/libavfilter/vf_select.c b/libavfilter/vf_select.c
index 341361d..e0e1863 100644
--- a/libavfilter/vf_select.c
+++ b/libavfilter/vf_select.c
@@ -289,50 +289,27 @@ static int select_frame(AVFilterContext *ctx, AVFilterBufferRef *picref)
return res;
}
-static int start_frame(AVFilterLink *inlink, AVFilterBufferRef *picref)
+static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *frame)
{
SelectContext *select = inlink->dst->priv;
- select->select = select_frame(inlink->dst, picref);
+ select->select = select_frame(inlink->dst, frame);
if (select->select) {
- AVFilterBufferRef *buf_out;
/* frame was requested through poll_frame */
if (select->cache_frames) {
- if (!av_fifo_space(select->pending_frames))
+ if (!av_fifo_space(select->pending_frames)) {
av_log(inlink->dst, AV_LOG_ERROR,
"Buffering limit reached, cannot cache more frames\n");
- else
- av_fifo_generic_write(select->pending_frames, &picref,
- sizeof(picref), NULL);
+ avfilter_unref_bufferp(&frame);
+ } else
+ av_fifo_generic_write(select->pending_frames, &frame,
+ sizeof(frame), NULL);
return 0;
}
- buf_out = avfilter_ref_buffer(picref, ~0);
- if (!buf_out)
- return AVERROR(ENOMEM);
- return ff_start_frame(inlink->dst->outputs[0], buf_out);
+ return ff_filter_frame(inlink->dst->outputs[0], frame);
}
- return 0;
-}
-
-static int draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
-{
- SelectContext *select = inlink->dst->priv;
-
- if (select->select && !select->cache_frames)
- return ff_draw_slice(inlink->dst->outputs[0], y, h, slice_dir);
- return 0;
-}
-
-static int end_frame(AVFilterLink *inlink)
-{
- SelectContext *select = inlink->dst->priv;
-
- if (select->select) {
- if (select->cache_frames)
- return 0;
- return ff_end_frame(inlink->dst->outputs[0]);
- }
+ avfilter_unref_bufferp(&frame);
return 0;
}
@@ -345,14 +322,9 @@ static int request_frame(AVFilterLink *outlink)
if (av_fifo_size(select->pending_frames)) {
AVFilterBufferRef *picref;
- int ret;
av_fifo_generic_read(select->pending_frames, &picref, sizeof(picref), NULL);
- if ((ret = ff_start_frame(outlink, picref)) < 0 ||
- (ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 ||
- (ret = ff_end_frame(outlink)) < 0);
-
- return ret;
+ return ff_filter_frame(outlink, picref);
}
while (!select->select) {
@@ -432,9 +404,7 @@ static const AVFilterPad avfilter_vf_select_inputs[] = {
.get_video_buffer = ff_null_get_video_buffer,
.min_perms = AV_PERM_PRESERVE,
.config_props = config_input,
- .start_frame = start_frame,
- .draw_slice = draw_slice,
- .end_frame = end_frame
+ .filter_frame = filter_frame,
},
{ NULL }
};
diff --git a/tests/ref/fate/filter-metadata-scenedetect b/tests/ref/fate/filter-metadata-scenedetect
index af39ec6..0b344d9 100644
--- a/tests/ref/fate/filter-metadata-scenedetect
+++ b/tests/ref/fate/filter-metadata-scenedetect
@@ -1,11 +1,10 @@
-video|1|20|0.033333|20|0.033333|1|0.001667|29927|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
-video|1|1640|2.733333|1640|2.733333|1|0.001667|164269|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
-video|1|4160|6.933333|4160|6.933333|1|0.001667|808833|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.880000
-video|1|5820|9.700000|5820|9.700000|1|0.001667|933313|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
-video|1|6740|11.233333|6740|11.233333|1|0.001667|1040437|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.460000
-video|1|8180|13.633333|8180|13.633333|1|0.001667|1248589|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
-video|1|9780|16.300000|9780|16.300000|1|0.001667|1348821|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
-video|1|14100|23.500000|14100|23.500000|1|0.001667|2006431|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.840000
-video|1|15720|26.200000|15720|26.200000|1|0.001667|2151283|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
-video|1|18520|30.866667|18520|30.866667|1|0.001667|2515017|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.470000
-video|1|21780|36.300000|21780|36.300000|1|0.001667|2933379|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
+video|1|1620|2.700000|1620|2.700000|1|0.001667|155751|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
+video|1|4140|6.900000|4140|6.900000|1|0.001667|808205|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.880000
+video|1|5800|9.666667|5800|9.666667|1|0.001667|928577|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
+video|1|6720|11.200000|6720|11.200000|1|0.001667|1027359|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.460000
+video|1|8160|13.600000|8160|13.600000|1|0.001667|1247869|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
+video|1|9760|16.266667|9760|16.266667|1|0.001667|1337561|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
+video|1|14080|23.466667|14080|23.466667|1|0.001667|1994159|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.840000
+video|1|15700|26.166667|15700|26.166667|1|0.001667|2145781|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
+video|1|18500|30.833333|18500|30.833333|1|0.001667|2507729|320|240|rgb24|1:1|I|0|0|0|0|0|0|0.470000
+video|1|21760|36.266667|21760|36.266667|1|0.001667|2932267|320|240|rgb24|1:1|I|0|0|0|0|0|0|1.000000
More information about the ffmpeg-cvslog
mailing list