avfilter/vignette: add direct rendering.

This commit is contained in:
Clément Bœsch 2014-05-16 06:53:18 +02:00
parent 8a0ba44e1a
commit ed7bc5471b
1 changed files with 8 additions and 2 deletions

View File

@ -197,18 +197,23 @@ static inline double get_dither_value(VignetteContext *s)
static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{ {
unsigned x, y; unsigned x, y, direct = 0;
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
VignetteContext *s = ctx->priv; VignetteContext *s = ctx->priv;
AVFilterLink *outlink = ctx->outputs[0]; AVFilterLink *outlink = ctx->outputs[0];
AVFrame *out; AVFrame *out;
if (av_frame_is_writable(in)) {
direct = 1;
out = in;
} else {
out = ff_get_video_buffer(outlink, outlink->w, outlink->h); out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
if (!out) { if (!out) {
av_frame_free(&in); av_frame_free(&in);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
av_frame_copy_props(out, in); av_frame_copy_props(out, in);
}
if (s->eval_mode == EVAL_MODE_FRAME) if (s->eval_mode == EVAL_MODE_FRAME)
update_context(s, inlink, in); update_context(s, inlink, in);
@ -268,7 +273,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
} }
} }
av_frame_free(&in); if (!direct)
av_frame_free(&in);
return ff_filter_frame(outlink, out); return ff_filter_frame(outlink, out);
} }