aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_libopencv.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-11-27 07:49:45 +0100
committerAnton Khirnov <anton@khirnov.net>2012-11-28 08:50:19 +0100
commit565e4993c63f797e2d50ad2f1e8f62fdbe299666 (patch)
treebae5282b2ee875de4b01467f3cfaab54b0ab6ec0 /libavfilter/vf_libopencv.c
parentbb6c67bb36b136de10256f0999128df4a42f9ffc (diff)
downloadffmpeg-565e4993c63f797e2d50ad2f1e8f62fdbe299666.tar.gz
lavfi: merge start_frame/draw_slice/end_frame
Any alleged performance benefits gained from the split are purely mythological and do not justify added code complexity.
Diffstat (limited to 'libavfilter/vf_libopencv.c')
-rw-r--r--libavfilter/vf_libopencv.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c
index 3e802cde26..e558a4a9c1 100644
--- a/libavfilter/vf_libopencv.c
+++ b/libavfilter/vf_libopencv.c
@@ -32,6 +32,7 @@
#include "libavutil/file.h"
#include "avfilter.h"
#include "formats.h"
+#include "internal.h"
#include "video.h"
static void fill_iplimage_from_picref(IplImage *img, const AVFilterBufferRef *picref, enum AVPixelFormat pixfmt)
@@ -68,11 +69,6 @@ static int query_formats(AVFilterContext *ctx)
return 0;
}
-static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
-{
- return 0;
-}
-
typedef struct {
const char *name;
int (*init)(AVFilterContext *ctx, const char *args);
@@ -355,33 +351,36 @@ static av_cold void uninit(AVFilterContext *ctx)
memset(ocv, 0, sizeof(*ocv));
}
-static int end_frame(AVFilterLink *inlink)
+static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
{
AVFilterContext *ctx = inlink->dst;
OCVContext *ocv = ctx->priv;
AVFilterLink *outlink= inlink->dst->outputs[0];
- AVFilterBufferRef *inpicref = inlink ->cur_buf;
- AVFilterBufferRef *outpicref = outlink->out_buf;
+ AVFilterBufferRef *out;
IplImage inimg, outimg;
- int ret;
- fill_iplimage_from_picref(&inimg , inpicref , inlink->format);
- fill_iplimage_from_picref(&outimg, outpicref, inlink->format);
+ 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);
+
+ fill_iplimage_from_picref(&inimg , in , inlink->format);
+ fill_iplimage_from_picref(&outimg, out, inlink->format);
ocv->end_frame_filter(ctx, &inimg, &outimg);
- fill_picref_from_iplimage(outpicref, &outimg, inlink->format);
+ fill_picref_from_iplimage(out, &outimg, inlink->format);
- if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 ||
- (ret = ff_end_frame(outlink)) < 0)
- return ret;
- return 0;
+ avfilter_unref_bufferp(&in);
+
+ return ff_filter_frame(outlink, out);
}
static const AVFilterPad avfilter_vf_ocv_inputs[] = {
{
.name = "default",
.type = AVMEDIA_TYPE_VIDEO,
- .draw_slice = null_draw_slice,
- .end_frame = end_frame,
+ .filter_frame = filter_frame,
.min_perms = AV_PERM_READ
},
{ NULL }