Commit 4753f802 authored by Anton Khirnov's avatar Anton Khirnov

vf_libopencv: use the name 's' for the pointer to the private context

This is shorter and consistent across filters.
parent 56e4ce0d
...@@ -86,8 +86,8 @@ typedef struct { ...@@ -86,8 +86,8 @@ typedef struct {
static av_cold int smooth_init(AVFilterContext *ctx, const char *args) static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
SmoothContext *smooth = ocv->priv; SmoothContext *smooth = s->priv;
char type_str[128] = "gaussian"; char type_str[128] = "gaussian";
smooth->param1 = 3; smooth->param1 = 3;
...@@ -129,8 +129,8 @@ static av_cold int smooth_init(AVFilterContext *ctx, const char *args) ...@@ -129,8 +129,8 @@ static av_cold int smooth_init(AVFilterContext *ctx, const char *args)
static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg) static void smooth_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
SmoothContext *smooth = ocv->priv; SmoothContext *smooth = s->priv;
cvSmooth(inimg, outimg, smooth->type, smooth->param1, smooth->param2, smooth->param3, smooth->param4); cvSmooth(inimg, outimg, smooth->type, smooth->param1, smooth->param2, smooth->param3, smooth->param4);
} }
...@@ -252,8 +252,8 @@ typedef struct { ...@@ -252,8 +252,8 @@ typedef struct {
static av_cold int dilate_init(AVFilterContext *ctx, const char *args) static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
DilateContext *dilate = ocv->priv; DilateContext *dilate = s->priv;
char default_kernel_str[] = "3x3+0x0/rect"; char default_kernel_str[] = "3x3+0x0/rect";
char *kernel_str; char *kernel_str;
const char *buf = args; const char *buf = args;
...@@ -281,23 +281,23 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args) ...@@ -281,23 +281,23 @@ static av_cold int dilate_init(AVFilterContext *ctx, const char *args)
static av_cold void dilate_uninit(AVFilterContext *ctx) static av_cold void dilate_uninit(AVFilterContext *ctx)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
DilateContext *dilate = ocv->priv; DilateContext *dilate = s->priv;
cvReleaseStructuringElement(&dilate->kernel); cvReleaseStructuringElement(&dilate->kernel);
} }
static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg) static void dilate_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
DilateContext *dilate = ocv->priv; DilateContext *dilate = s->priv;
cvDilate(inimg, outimg, dilate->kernel, dilate->nb_iterations); cvDilate(inimg, outimg, dilate->kernel, dilate->nb_iterations);
} }
static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg) static void erode_end_frame_filter(AVFilterContext *ctx, IplImage *inimg, IplImage *outimg)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
DilateContext *dilate = ocv->priv; DilateContext *dilate = s->priv;
cvErode(inimg, outimg, dilate->kernel, dilate->nb_iterations); cvErode(inimg, outimg, dilate->kernel, dilate->nb_iterations);
} }
...@@ -317,39 +317,39 @@ static OCVFilterEntry ocv_filter_entries[] = { ...@@ -317,39 +317,39 @@ static OCVFilterEntry ocv_filter_entries[] = {
static av_cold int init(AVFilterContext *ctx) static av_cold int init(AVFilterContext *ctx)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
int i; int i;
for (i = 0; i < FF_ARRAY_ELEMS(ocv_filter_entries); i++) { for (i = 0; i < FF_ARRAY_ELEMS(ocv_filter_entries); i++) {
OCVFilterEntry *entry = &ocv_filter_entries[i]; OCVFilterEntry *entry = &ocv_filter_entries[i];
if (!strcmp(ocv->name, entry->name)) { if (!strcmp(s->name, entry->name)) {
ocv->init = entry->init; s->init = entry->init;
ocv->uninit = entry->uninit; s->uninit = entry->uninit;
ocv->end_frame_filter = entry->end_frame_filter; s->end_frame_filter = entry->end_frame_filter;
if (!(ocv->priv = av_mallocz(entry->priv_size))) if (!(s->priv = av_mallocz(entry->priv_size)))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
return ocv->init(ctx, ocv->params); return s->init(ctx, s->params);
} }
} }
av_log(ctx, AV_LOG_ERROR, "No libopencv filter named '%s'\n", ocv->name); av_log(ctx, AV_LOG_ERROR, "No libopencv filter named '%s'\n", s->name);
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
{ {
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
if (ocv->uninit) if (s->uninit)
ocv->uninit(ctx); s->uninit(ctx);
av_free(ocv->priv); av_free(s->priv);
} }
static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
OCVContext *ocv = ctx->priv; OCVContext *s = ctx->priv;
AVFilterLink *outlink= inlink->dst->outputs[0]; AVFilterLink *outlink= inlink->dst->outputs[0];
AVFrame *out; AVFrame *out;
IplImage inimg, outimg; IplImage inimg, outimg;
...@@ -363,7 +363,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -363,7 +363,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
fill_iplimage_from_frame(&inimg , in , inlink->format); fill_iplimage_from_frame(&inimg , in , inlink->format);
fill_iplimage_from_frame(&outimg, out, inlink->format); fill_iplimage_from_frame(&outimg, out, inlink->format);
ocv->end_frame_filter(ctx, &inimg, &outimg); s->end_frame_filter(ctx, &inimg, &outimg);
fill_frame_from_iplimage(out, &outimg, inlink->format); fill_frame_from_iplimage(out, &outimg, inlink->format);
av_frame_free(&in); av_frame_free(&in);
......
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