aboutsummaryrefslogtreecommitdiffstats
path: root/avplay.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-04-27 06:56:56 +0200
committerAnton Khirnov <anton@khirnov.net>2012-05-09 08:59:37 +0200
commitac71230902af1a8ebc7abf85143139ffb49838eb (patch)
tree1b3b3b4c484a35e0be341eca4cafe80d8befd930 /avplay.c
parentab165047a6142ca0c8c333c36f4ebb96477622d7 (diff)
downloadffmpeg-ac71230902af1a8ebc7abf85143139ffb49838eb.tar.gz
lavfi: add video buffer sink, and use it in avtools
Also add the public interface libavfilter/buffersink.h. Based on a commit by Stefano Sabatini.
Diffstat (limited to 'avplay.c')
-rw-r--r--avplay.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/avplay.c b/avplay.c
index 9bd83f381e..d291ba384a 100644
--- a/avplay.c
+++ b/avplay.c
@@ -41,6 +41,7 @@
#if CONFIG_AVFILTER
# include "libavfilter/avfilter.h"
# include "libavfilter/avfiltergraph.h"
+# include "libavfilter/buffersink.h"
#endif
#include "cmdutils.h"
@@ -1708,21 +1709,28 @@ static AVFilter input_filter =
static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const char *vfilters)
{
- static const enum PixelFormat pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE };
char sws_flags_str[128];
int ret;
- SinkContext sink_ctx = { .pix_fmts = pix_fmts };
- AVFilterContext *filt_src = NULL, *filt_out = NULL;
+ AVFilterContext *filt_src = NULL, *filt_out = NULL, *filt_format;
snprintf(sws_flags_str, sizeof(sws_flags_str), "flags=%d", sws_flags);
graph->scale_sws_opts = av_strdup(sws_flags_str);
if ((ret = avfilter_graph_create_filter(&filt_src, &input_filter, "src",
NULL, is, graph)) < 0)
return ret;
- if ((ret = avfilter_graph_create_filter(&filt_out, &sink, "out",
- NULL, &sink_ctx, graph)) < 0)
+ if ((ret = avfilter_graph_create_filter(&filt_out,
+ avfilter_get_by_name("buffersink"),
+ "out", NULL, NULL, graph)) < 0)
return ret;
+ if ((ret = avfilter_graph_create_filter(&filt_format,
+ avfilter_get_by_name("format"),
+ "format", "yuv420p", NULL, graph)) < 0)
+ return ret;
+ if ((ret = avfilter_link(filt_format, 0, filt_out, 0)) < 0)
+ return ret;
+
+
if (vfilters) {
AVFilterInOut *outputs = avfilter_inout_alloc();
AVFilterInOut *inputs = avfilter_inout_alloc();
@@ -1733,14 +1741,14 @@ static int configure_video_filters(AVFilterGraph *graph, VideoState *is, const c
outputs->next = NULL;
inputs->name = av_strdup("out");
- inputs->filter_ctx = filt_out;
+ inputs->filter_ctx = filt_format;
inputs->pad_idx = 0;
inputs->next = NULL;
if ((ret = avfilter_graph_parse(graph, vfilters, inputs, outputs, NULL)) < 0)
return ret;
} else {
- if ((ret = avfilter_link(filt_src, 0, filt_out, 0)) < 0)
+ if ((ret = avfilter_link(filt_src, 0, filt_format, 0)) < 0)
return ret;
}
@@ -1796,11 +1804,16 @@ static int video_thread(void *arg)
last_w = is->video_st->codec->width;
last_h = is->video_st->codec->height;
}
- ret = get_filtered_video_frame(filt_out, frame, &picref, &tb);
+ ret = av_buffersink_read(filt_out, &picref);
if (picref) {
+ avfilter_copy_buf_props(frame, picref);
+
pts_int = picref->pts;
+ tb = filt_out->inputs[0]->time_base;
pos = picref->pos;
frame->opaque = picref;
+
+ ret = 1;
}
if (ret >= 0 && av_cmp_q(tb, is->video_st->time_base)) {