Commit 269cd077 authored by Clément Bœsch's avatar Clément Bœsch

lavfi/colormatrix: switch to filter_frame.

parent 88f8af26
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include <float.h> #include <float.h>
#include "avfilter.h" #include "avfilter.h"
#include "formats.h" #include "formats.h"
#include "internal.h"
#include "video.h" #include "video.h"
#include "libavutil/pixdesc.h" #include "libavutil/pixdesc.h"
#include "libavutil/avstring.h" #include "libavutil/avstring.h"
...@@ -60,7 +61,6 @@ typedef struct { ...@@ -60,7 +61,6 @@ typedef struct {
char src[256]; char src[256];
char dst[256]; char dst[256];
int hsub, vsub; int hsub, vsub;
AVFilterBufferRef *outpicref;
} ColorMatrixContext; } ColorMatrixContext;
#define ma m[0][0] #define ma m[0][0]
...@@ -332,53 +332,37 @@ static int query_formats(AVFilterContext *ctx) ...@@ -332,53 +332,37 @@ static int query_formats(AVFilterContext *ctx)
return 0; return 0;
} }
static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int w, int h) static int filter_frame(AVFilterLink *link, AVFilterBufferRef *in)
{
AVFilterBufferRef *picref =
ff_get_video_buffer(inlink->dst->outputs[0], perms, w, h);
return picref;
}
static int start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
{ {
AVFilterContext *ctx = link->dst; AVFilterContext *ctx = link->dst;
ColorMatrixContext *color = ctx->priv; ColorMatrixContext *color = ctx->priv;
AVFilterBufferRef *outpicref = avfilter_ref_buffer(picref, ~0); AVFilterLink *outlink = ctx->outputs[0];
AVFilterBufferRef *out;
color->outpicref = outpicref;
return ff_start_frame(link->dst->outputs[0], outpicref);
}
static int end_frame(AVFilterLink *link) out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
{ if (!out) {
AVFilterContext *ctx = link->dst; avfilter_unref_bufferp(&in);
ColorMatrixContext *color = ctx->priv; return AVERROR(ENOMEM);
AVFilterBufferRef *out = color->outpicref; }
avfilter_copy_buffer_ref_props(out, in);
if (link->cur_buf->format == AV_PIX_FMT_YUV422P) if (in->format == AV_PIX_FMT_YUV422P)
process_frame_yuv422p(color, out, link->cur_buf); process_frame_yuv422p(color, out, in);
else if (link->cur_buf->format == AV_PIX_FMT_YUV420P) else if (in->format == AV_PIX_FMT_YUV420P)
process_frame_yuv420p(color, out, link->cur_buf); process_frame_yuv420p(color, out, in);
else 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_filter_frame(outlink, out);
return ff_end_frame(ctx->outputs[0]);
} }
static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { return 0; }
static const AVFilterPad colormatrix_inputs[] = { static const AVFilterPad colormatrix_inputs[] = {
{ {
.name = "default", .name = "default",
.type = AVMEDIA_TYPE_VIDEO, .type = AVMEDIA_TYPE_VIDEO,
.config_props = config_input, .config_props = config_input,
.min_perms = AV_PERM_READ | AV_PERM_WRITE, .min_perms = AV_PERM_READ,
.start_frame = start_frame, .filter_frame = filter_frame,
.get_video_buffer = get_video_buffer,
.draw_slice = null_draw_slice,
.end_frame = end_frame,
}, },
{ NULL } { NULL }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment