From ac71230902af1a8ebc7abf85143139ffb49838eb Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 27 Apr 2012 06:56:56 +0200 Subject: 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. --- cmdutils.c | 68 -------------------------------------------------------------- 1 file changed, 68 deletions(-) (limited to 'cmdutils.c') diff --git a/cmdutils.c b/cmdutils.c index 6d2e97f694..3cd11ca241 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -1021,74 +1021,6 @@ AVDictionary **setup_find_stream_info_opts(AVFormatContext *s, return opts; } -#if CONFIG_AVFILTER - -static int sink_init(AVFilterContext *ctx, const char *args, void *opaque) -{ - SinkContext *priv = ctx->priv; - - if (!opaque) - return AVERROR(EINVAL); - *priv = *(SinkContext *)opaque; - - return 0; -} - -static void null_end_frame(AVFilterLink *inlink) { } - -static int sink_query_formats(AVFilterContext *ctx) -{ - SinkContext *priv = ctx->priv; - - if (priv->pix_fmts) - avfilter_set_common_formats(ctx, avfilter_make_format_list(priv->pix_fmts)); - else - avfilter_default_query_formats(ctx); - return 0; -} - -AVFilter sink = { - .name = "sink", - .priv_size = sizeof(SinkContext), - .init = sink_init, - - .query_formats = sink_query_formats, - - .inputs = (AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .end_frame = null_end_frame, - .min_perms = AV_PERM_READ, }, - { .name = NULL }}, - .outputs = (AVFilterPad[]) {{ .name = NULL }}, -}; - -int get_filtered_video_frame(AVFilterContext *ctx, AVFrame *frame, - AVFilterBufferRef **picref_ptr, AVRational *tb) -{ - int ret; - AVFilterBufferRef *picref; - - if ((ret = avfilter_request_frame(ctx->inputs[0])) < 0) - return ret; - if (!(picref = ctx->inputs[0]->cur_buf)) - return AVERROR(ENOENT); - *picref_ptr = picref; - ctx->inputs[0]->cur_buf = NULL; - *tb = ctx->inputs[0]->time_base; - - memcpy(frame->data, picref->data, sizeof(frame->data)); - memcpy(frame->linesize, picref->linesize, sizeof(frame->linesize)); - frame->interlaced_frame = picref->video->interlaced; - frame->top_field_first = picref->video->top_field_first; - frame->key_frame = picref->video->key_frame; - frame->pict_type = picref->video->pict_type; - frame->sample_aspect_ratio = picref->video->pixel_aspect; - - return 1; -} - -#endif /* CONFIG_AVFILTER */ - void *grow_array(void *array, int elem_size, int *size, int new_size) { if (new_size >= INT_MAX / elem_size) { -- cgit v1.2.3