mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-11-21 10:55:51 +02:00
vf_libopencv: switch to filter_frame, this filter did not support slices
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
5d170b09d3
commit
1f94f86ab5
@ -32,6 +32,7 @@
|
|||||||
#include "libavutil/file.h"
|
#include "libavutil/file.h"
|
||||||
#include "avfilter.h"
|
#include "avfilter.h"
|
||||||
#include "formats.h"
|
#include "formats.h"
|
||||||
|
#include "internal.h"
|
||||||
#include "video.h"
|
#include "video.h"
|
||||||
|
|
||||||
static void fill_iplimage_from_picref(IplImage *img, const AVFilterBufferRef *picref, enum AVPixelFormat pixfmt)
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
const char *name;
|
const char *name;
|
||||||
int (*init)(AVFilterContext *ctx, const char *args);
|
int (*init)(AVFilterContext *ctx, const char *args);
|
||||||
@ -355,33 +351,36 @@ static av_cold void uninit(AVFilterContext *ctx)
|
|||||||
memset(ocv, 0, sizeof(*ocv));
|
memset(ocv, 0, sizeof(*ocv));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int end_frame(AVFilterLink *inlink)
|
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
|
||||||
{
|
{
|
||||||
AVFilterContext *ctx = inlink->dst;
|
AVFilterContext *ctx = inlink->dst;
|
||||||
OCVContext *ocv = ctx->priv;
|
OCVContext *ocv = ctx->priv;
|
||||||
AVFilterLink *outlink= inlink->dst->outputs[0];
|
AVFilterLink *outlink= inlink->dst->outputs[0];
|
||||||
AVFilterBufferRef *inpicref = inlink ->cur_buf;
|
AVFilterBufferRef *out;
|
||||||
AVFilterBufferRef *outpicref = outlink->out_buf;
|
|
||||||
IplImage inimg, outimg;
|
IplImage inimg, outimg;
|
||||||
int ret;
|
|
||||||
|
|
||||||
fill_iplimage_from_picref(&inimg , inpicref , inlink->format);
|
out = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h);
|
||||||
fill_iplimage_from_picref(&outimg, outpicref, inlink->format);
|
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);
|
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 ||
|
avfilter_unref_bufferp(&in);
|
||||||
(ret = ff_end_frame(outlink)) < 0)
|
|
||||||
return ret;
|
return ff_filter_frame(outlink, out);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const AVFilterPad avfilter_vf_ocv_inputs[] = {
|
static const AVFilterPad avfilter_vf_ocv_inputs[] = {
|
||||||
{
|
{
|
||||||
.name = "default",
|
.name = "default",
|
||||||
.type = AVMEDIA_TYPE_VIDEO,
|
.type = AVMEDIA_TYPE_VIDEO,
|
||||||
.draw_slice = null_draw_slice,
|
.filter_frame = filter_frame,
|
||||||
.end_frame = end_frame,
|
|
||||||
.min_perms = AV_PERM_READ
|
.min_perms = AV_PERM_READ
|
||||||
},
|
},
|
||||||
{ NULL }
|
{ NULL }
|
||||||
|
Loading…
Reference in New Issue
Block a user