diff options
author | Clément Bœsch <ubitux@gmail.com> | 2012-11-29 02:04:45 +0100 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2012-11-29 02:16:33 +0100 |
commit | 269cd07702dea0bb1831c465fd49890287c91b1a (patch) | |
tree | 3926a5142a59f26c123525e23afe722e41f8505a | |
parent | 88f8af26a92b66f1e7cdace21be01df25278b0b3 (diff) | |
download | ffmpeg-269cd07702dea0bb1831c465fd49890287c91b1a.tar.gz |
lavfi/colormatrix: switch to filter_frame.
-rw-r--r-- | libavfilter/vf_colormatrix.c | 52 |
1 files changed, 18 insertions, 34 deletions
diff --git a/libavfilter/vf_colormatrix.c b/libavfilter/vf_colormatrix.c index 9b2674577d..ff7b9e0040 100644 --- a/libavfilter/vf_colormatrix.c +++ b/libavfilter/vf_colormatrix.c @@ -31,6 +31,7 @@ #include <float.h> #include "avfilter.h" #include "formats.h" +#include "internal.h" #include "video.h" #include "libavutil/pixdesc.h" #include "libavutil/avstring.h" @@ -60,7 +61,6 @@ typedef struct { char src[256]; char dst[256]; int hsub, vsub; - AVFilterBufferRef *outpicref; } ColorMatrixContext; #define ma m[0][0] @@ -332,53 +332,37 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int w, int h) -{ - AVFilterBufferRef *picref = - ff_get_video_buffer(inlink->dst->outputs[0], perms, w, h); - return picref; -} - -static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref) +static int filter_frame(AVFilterLink *link, AVFilterBufferRef *in) { AVFilterContext *ctx = link->dst; ColorMatrixContext *color = ctx->priv; - AVFilterBufferRef *outpicref = avfilter_ref_buffer(picref, ~0); - - color->outpicref = outpicref; - - return ff_start_frame(link->dst->outputs[0], outpicref); -} + AVFilterLink *outlink = ctx->outputs[0]; + AVFilterBufferRef *out; -static int end_frame(AVFilterLink *link) -{ - AVFilterContext *ctx = link->dst; - ColorMatrixContext *color = ctx->priv; - AVFilterBufferRef *out = color->outpicref; + out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); + if (!out) { + avfilter_unref_bufferp(&in); + return AVERROR(ENOMEM); + } + avfilter_copy_buffer_ref_props(out, in); - if (link->cur_buf->format == AV_PIX_FMT_YUV422P) - process_frame_yuv422p(color, out, link->cur_buf); - else if (link->cur_buf->format == AV_PIX_FMT_YUV420P) - process_frame_yuv420p(color, out, link->cur_buf); + if (in->format == AV_PIX_FMT_YUV422P) + process_frame_yuv422p(color, out, in); + else if (in->format == AV_PIX_FMT_YUV420P) + process_frame_yuv420p(color, out, in); else - process_frame_uyvy422(color, out, link->cur_buf); + process_frame_uyvy422(color, out, in); - ff_draw_slice(ctx->outputs[0], 0, link->dst->outputs[0]->h, 1); - return ff_end_frame(ctx->outputs[0]); + return ff_filter_frame(outlink, out); } -static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; } - static const AVFilterPad colormatrix_inputs[] = { { .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, - .min_perms = AV_PERM_READ | AV_PERM_WRITE, - .start_frame = start_frame, - .get_video_buffer = get_video_buffer, - .draw_slice = null_draw_slice, - .end_frame = end_frame, + .min_perms = AV_PERM_READ, + .filter_frame = filter_frame, }, { NULL } }; |