lavfi: add vsink_buffer, and use it in ff* tools

Also add the public interface libavfilter/vsink_buffer.h.
This commit is contained in:
Stefano Sabatini
2011-06-11 18:43:11 +02:00
parent e89ba76a59
commit 44f669e7bc
12 changed files with 199 additions and 99 deletions

View File

@ -962,71 +962,3 @@ FILE *get_preset_file(char *filename, size_t filename_size,
return f;
}
#if CONFIG_AVFILTER
static int ffsink_init(AVFilterContext *ctx, const char *args, void *opaque)
{
FFSinkContext *priv = ctx->priv;
if (!opaque)
return AVERROR(EINVAL);
*priv = *(FFSinkContext *)opaque;
return 0;
}
static void null_end_frame(AVFilterLink *inlink) { }
static int ffsink_query_formats(AVFilterContext *ctx)
{
FFSinkContext *priv = ctx->priv;
enum PixelFormat pix_fmts[] = { priv->pix_fmt, PIX_FMT_NONE };
avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts));
return 0;
}
AVFilter ffsink = {
.name = "ffsink",
.priv_size = sizeof(FFSinkContext),
.init = ffsink_init,
.query_formats = ffsink_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;
*picref_ptr = NULL;
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->pkt_pos = picref->pos;
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->sample_aspect_ratio;
return 1;
}
#endif /* CONFIG_AVFILTER */