X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavfilter%2Fvf_libopencv.c;h=7c4b57df454635f038744a30cd5b8a90de5dcc9e;hb=39a8275fdf4f607023b483a58b255600d5f7a9e7;hp=88319b8aef3aef35793e0c53749f5d0c72dfe794;hpb=90d8506fbf1b5d9bd6ed1f01a8610df01771e3c3;p=ffmpeg diff --git a/libavfilter/vf_libopencv.c b/libavfilter/vf_libopencv.c index 88319b8aef3..7c4b57df454 100644 --- a/libavfilter/vf_libopencv.c +++ b/libavfilter/vf_libopencv.c @@ -67,11 +67,14 @@ static int query_formats(AVFilterContext *ctx) return 0; } -static void null_draw_slice(AVFilterLink *link, int y, int h, int slice_dir) { } +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, void *opaque); + int (*init)(AVFilterContext *ctx, const char *args); void (*uninit)(AVFilterContext *ctx); void (*end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg); void *priv; @@ -83,7 +86,7 @@ typedef struct { double param3, param4; } SmoothContext; -static av_cold int smooth_init(AVFilterContext *ctx, const char *args, void *opaque) +static av_cold int smooth_init(AVFilterContext *ctx, const char *args) { OCVContext *ocv = ctx->priv; SmoothContext *smooth = ocv->priv; @@ -103,7 +106,7 @@ static av_cold int smooth_init(AVFilterContext *ctx, const char *args, void *opa else if (!strcmp(type_str, "gaussian" )) smooth->type = CV_GAUSSIAN; else if (!strcmp(type_str, "bilateral" )) smooth->type = CV_BILATERAL; else { - av_log(ctx, AV_LOG_ERROR, "Smoothing type '%s' unknown\n.", type_str); + av_log(ctx, AV_LOG_ERROR, "Smoothing type '%s' unknown.\n", type_str); return AVERROR(EINVAL); } @@ -121,7 +124,7 @@ static av_cold int smooth_init(AVFilterContext *ctx, const char *args, void *opa return AVERROR(EINVAL); } - av_log(ctx, AV_LOG_INFO, "type:%s param1:%d param2:%d param3:%f param4:%f\n", + av_log(ctx, AV_LOG_VERBOSE, "type:%s param1:%d param2:%d param3:%f param4:%f\n", type_str, smooth->param1, smooth->param2, smooth->param3, smooth->param4); return 0; } @@ -217,7 +220,7 @@ static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx) return ret; } else { av_log(log_ctx, AV_LOG_ERROR, - "Shape unspecified or type '%s' unknown\n.", shape_str); + "Shape unspecified or type '%s' unknown.\n", shape_str); return AVERROR(EINVAL); } @@ -239,7 +242,7 @@ static int parse_iplconvkernel(IplConvKernel **kernel, char *buf, void *log_ctx) if (!*kernel) return AVERROR(ENOMEM); - av_log(log_ctx, AV_LOG_INFO, "Structuring element: w:%d h:%d x:%d y:%d shape:%s\n", + av_log(log_ctx, AV_LOG_VERBOSE, "Structuring element: w:%d h:%d x:%d y:%d shape:%s\n", rows, cols, anchor_x, anchor_y, shape_str); return 0; } @@ -249,7 +252,7 @@ typedef struct { IplConvKernel *kernel; } DilateContext; -static av_cold int dilate_init(AVFilterContext *ctx, const char *args, void *opaque) +static av_cold int dilate_init(AVFilterContext *ctx, const char *args) { OCVContext *ocv = ctx->priv; DilateContext *dilate = ocv->priv; @@ -269,7 +272,7 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args, void *opa av_free(kernel_str); sscanf(buf, ":%d", &dilate->nb_iterations); - av_log(ctx, AV_LOG_INFO, "iterations_nb:%d\n", dilate->nb_iterations); + av_log(ctx, AV_LOG_VERBOSE, "iterations_nb:%d\n", dilate->nb_iterations); if (dilate->nb_iterations <= 0) { av_log(ctx, AV_LOG_ERROR, "Invalid non-positive value '%d' for nb_iterations\n", dilate->nb_iterations); @@ -303,7 +306,7 @@ static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplIma typedef struct { const char *name; size_t priv_size; - int (*init)(AVFilterContext *ctx, const char *args, void *opaque); + int (*init)(AVFilterContext *ctx, const char *args); void (*uninit)(AVFilterContext *ctx); void (*end_frame_filter)(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg); } OCVFilterEntry; @@ -314,7 +317,7 @@ static OCVFilterEntry ocv_filter_entries[] = { { "smooth", sizeof(SmoothContext), smooth_init, NULL, smooth_end_frame_filter }, }; -static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +static av_cold int init(AVFilterContext *ctx, const char *args) { OCVContext *ocv = ctx->priv; char name[128], priv_args[1024]; @@ -333,7 +336,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) if (!(ocv->priv = av_mallocz(entry->priv_size))) return AVERROR(ENOMEM); - return ocv->init(ctx, priv_args, opaque); + return ocv->init(ctx, priv_args); } } @@ -351,7 +354,7 @@ static av_cold void uninit(AVFilterContext *ctx) memset(ocv, 0, sizeof(*ocv)); } -static void end_frame(AVFilterLink *inlink) +static int end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; OCVContext *ocv = ctx->priv; @@ -359,16 +362,17 @@ static void end_frame(AVFilterLink *inlink) AVFilterBufferRef *inpicref = inlink ->cur_buf; AVFilterBufferRef *outpicref = outlink->out_buf; IplImage inimg, outimg; + int ret; fill_iplimage_from_picref(&inimg , inpicref , inlink->format); fill_iplimage_from_picref(&outimg, outpicref, inlink->format); ocv->end_frame_filter(ctx, &inimg, &outimg); fill_picref_from_iplimage(outpicref, &outimg, inlink->format); - avfilter_unref_buffer(inpicref); - ff_draw_slice(outlink, 0, outlink->h, 1); - ff_end_frame(outlink); - avfilter_unref_buffer(outpicref); + if ((ret = ff_draw_slice(outlink, 0, outlink->h, 1)) < 0 || + (ret = ff_end_frame(outlink)) < 0) + return ret; + return 0; } AVFilter avfilter_vf_ocv = { @@ -381,14 +385,14 @@ AVFilter avfilter_vf_ocv = { .init = init, .uninit = uninit, - .inputs = (const AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .draw_slice = null_draw_slice, - .end_frame = end_frame, - .min_perms = AV_PERM_READ }, - { .name = NULL}}, + .inputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .draw_slice = null_draw_slice, + .end_frame = end_frame, + .min_perms = AV_PERM_READ }, + { .name = NULL}}, - .outputs = (const AVFilterPad[]) {{ .name = "default", - .type = AVMEDIA_TYPE_VIDEO, }, - { .name = NULL}}, + .outputs = (const AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, }, + { .name = NULL}}, };