Commit 762df56e authored by Anton Khirnov's avatar Anton Khirnov

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

This is shorter and consistent across filters.
parent a2a69699
...@@ -82,24 +82,24 @@ typedef struct { ...@@ -82,24 +82,24 @@ typedef struct {
static av_cold int init(AVFilterContext *ctx) static av_cold int init(AVFilterContext *ctx)
{ {
BoxBlurContext *boxblur = ctx->priv; BoxBlurContext *s = ctx->priv;
if (!boxblur->luma_radius_expr) { if (!s->luma_radius_expr) {
av_log(ctx, AV_LOG_ERROR, "Luma radius expression is not set.\n"); av_log(ctx, AV_LOG_ERROR, "Luma radius expression is not set.\n");
return AVERROR(EINVAL); return AVERROR(EINVAL);
} }
if (!boxblur->chroma_radius_expr) { if (!s->chroma_radius_expr) {
boxblur->chroma_radius_expr = av_strdup(boxblur->luma_radius_expr); s->chroma_radius_expr = av_strdup(s->luma_radius_expr);
if (!boxblur->chroma_radius_expr) if (!s->chroma_radius_expr)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
boxblur->chroma_param.power = boxblur->luma_param.power; s->chroma_param.power = s->luma_param.power;
} }
if (!boxblur->alpha_radius_expr) { if (!s->alpha_radius_expr) {
boxblur->alpha_radius_expr = av_strdup(boxblur->luma_radius_expr); s->alpha_radius_expr = av_strdup(s->luma_radius_expr);
if (!boxblur->alpha_radius_expr) if (!s->alpha_radius_expr)
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
boxblur->alpha_param.power = boxblur->luma_param.power; s->alpha_param.power = s->luma_param.power;
} }
return 0; return 0;
...@@ -107,10 +107,10 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -107,10 +107,10 @@ static av_cold int init(AVFilterContext *ctx)
static av_cold void uninit(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx)
{ {
BoxBlurContext *boxblur = ctx->priv; BoxBlurContext *s = ctx->priv;
av_freep(&boxblur->temp[0]); av_freep(&s->temp[0]);
av_freep(&boxblur->temp[1]); av_freep(&s->temp[1]);
} }
static int query_formats(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx)
...@@ -132,37 +132,37 @@ static int config_input(AVFilterLink *inlink) ...@@ -132,37 +132,37 @@ static int config_input(AVFilterLink *inlink)
{ {
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
BoxBlurContext *boxblur = ctx->priv; BoxBlurContext *s = ctx->priv;
int w = inlink->w, h = inlink->h; int w = inlink->w, h = inlink->h;
int cw, ch; int cw, ch;
double var_values[VARS_NB], res; double var_values[VARS_NB], res;
char *expr; char *expr;
int ret; int ret;
av_freep(&boxblur->temp[0]); av_freep(&s->temp[0]);
av_freep(&boxblur->temp[1]); av_freep(&s->temp[1]);
if (!(boxblur->temp[0] = av_malloc(FFMAX(w, h)))) if (!(s->temp[0] = av_malloc(FFMAX(w, h))))
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
if (!(boxblur->temp[1] = av_malloc(FFMAX(w, h)))) { if (!(s->temp[1] = av_malloc(FFMAX(w, h)))) {
av_freep(&boxblur->temp[0]); av_freep(&s->temp[0]);
return AVERROR(ENOMEM); return AVERROR(ENOMEM);
} }
boxblur->hsub = desc->log2_chroma_w; s->hsub = desc->log2_chroma_w;
boxblur->vsub = desc->log2_chroma_h; s->vsub = desc->log2_chroma_h;
var_values[VAR_W] = inlink->w; var_values[VAR_W] = inlink->w;
var_values[VAR_H] = inlink->h; var_values[VAR_H] = inlink->h;
var_values[VAR_CW] = cw = w>>boxblur->hsub; var_values[VAR_CW] = cw = w>>s->hsub;
var_values[VAR_CH] = ch = h>>boxblur->vsub; var_values[VAR_CH] = ch = h>>s->vsub;
var_values[VAR_HSUB] = 1<<boxblur->hsub; var_values[VAR_HSUB] = 1<<s->hsub;
var_values[VAR_VSUB] = 1<<boxblur->vsub; var_values[VAR_VSUB] = 1<<s->vsub;
#define EVAL_RADIUS_EXPR(comp) \ #define EVAL_RADIUS_EXPR(comp) \
expr = boxblur->comp##_radius_expr; \ expr = s->comp##_radius_expr; \
ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \ ret = av_expr_parse_and_eval(&res, expr, var_names, var_values, \
NULL, NULL, NULL, NULL, NULL, 0, ctx); \ NULL, NULL, NULL, NULL, NULL, 0, ctx); \
boxblur->comp##_param.radius = res; \ s->comp##_param.radius = res; \
if (ret < 0) { \ if (ret < 0) { \
av_log(NULL, AV_LOG_ERROR, \ av_log(NULL, AV_LOG_ERROR, \
"Error when evaluating " #comp " radius expression '%s'\n", expr); \ "Error when evaluating " #comp " radius expression '%s'\n", expr); \
...@@ -177,30 +177,30 @@ static int config_input(AVFilterLink *inlink) ...@@ -177,30 +177,30 @@ static int config_input(AVFilterLink *inlink)
"chroma_radius:%d chroma_power:%d " "chroma_radius:%d chroma_power:%d "
"alpha_radius:%d alpha_power:%d " "alpha_radius:%d alpha_power:%d "
"w:%d chroma_w:%d h:%d chroma_h:%d\n", "w:%d chroma_w:%d h:%d chroma_h:%d\n",
boxblur->luma_param .radius, boxblur->luma_param .power, s->luma_param .radius, s->luma_param .power,
boxblur->chroma_param.radius, boxblur->chroma_param.power, s->chroma_param.radius, s->chroma_param.power,
boxblur->alpha_param .radius, boxblur->alpha_param .power, s->alpha_param .radius, s->alpha_param .power,
w, cw, h, ch); w, cw, h, ch);
#define CHECK_RADIUS_VAL(w_, h_, comp) \ #define CHECK_RADIUS_VAL(w_, h_, comp) \
if (boxblur->comp##_param.radius < 0 || \ if (s->comp##_param.radius < 0 || \
2*boxblur->comp##_param.radius > FFMIN(w_, h_)) { \ 2*s->comp##_param.radius > FFMIN(w_, h_)) { \
av_log(ctx, AV_LOG_ERROR, \ av_log(ctx, AV_LOG_ERROR, \
"Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \ "Invalid " #comp " radius value %d, must be >= 0 and <= %d\n", \
boxblur->comp##_param.radius, FFMIN(w_, h_)/2); \ s->comp##_param.radius, FFMIN(w_, h_)/2); \
return AVERROR(EINVAL); \ return AVERROR(EINVAL); \
} }
CHECK_RADIUS_VAL(w, h, luma); CHECK_RADIUS_VAL(w, h, luma);
CHECK_RADIUS_VAL(cw, ch, chroma); CHECK_RADIUS_VAL(cw, ch, chroma);
CHECK_RADIUS_VAL(w, h, alpha); CHECK_RADIUS_VAL(w, h, alpha);
boxblur->radius[Y] = boxblur->luma_param.radius; s->radius[Y] = s->luma_param.radius;
boxblur->radius[U] = boxblur->radius[V] = boxblur->chroma_param.radius; s->radius[U] = s->radius[V] = s->chroma_param.radius;
boxblur->radius[A] = boxblur->alpha_param.radius; s->radius[A] = s->alpha_param.radius;
boxblur->power[Y] = boxblur->luma_param.power; s->power[Y] = s->luma_param.power;
boxblur->power[U] = boxblur->power[V] = boxblur->chroma_param.power; s->power[U] = s->power[V] = s->chroma_param.power;
boxblur->power[A] = boxblur->alpha_param.power; s->power[A] = s->alpha_param.power;
return 0; return 0;
} }
...@@ -301,11 +301,11 @@ static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_li ...@@ -301,11 +301,11 @@ static void vblur(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_li
static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int filter_frame(AVFilterLink *inlink, AVFrame *in)
{ {
AVFilterContext *ctx = inlink->dst; AVFilterContext *ctx = inlink->dst;
BoxBlurContext *boxblur = ctx->priv; BoxBlurContext *s = ctx->priv;
AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterLink *outlink = inlink->dst->outputs[0];
AVFrame *out; AVFrame *out;
int plane; int plane;
int cw = inlink->w >> boxblur->hsub, ch = in->height >> boxblur->vsub; int cw = inlink->w >> s->hsub, ch = in->height >> s->vsub;
int w[4] = { inlink->w, cw, cw, inlink->w }; int w[4] = { inlink->w, cw, cw, inlink->w };
int h[4] = { in->height, ch, ch, in->height }; int h[4] = { in->height, ch, ch, in->height };
...@@ -319,14 +319,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) ...@@ -319,14 +319,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
for (plane = 0; in->data[plane] && plane < 4; plane++) for (plane = 0; in->data[plane] && plane < 4; plane++)
hblur(out->data[plane], out->linesize[plane], hblur(out->data[plane], out->linesize[plane],
in ->data[plane], in ->linesize[plane], in ->data[plane], in ->linesize[plane],
w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], w[plane], h[plane], s->radius[plane], s->power[plane],
boxblur->temp); s->temp);
for (plane = 0; in->data[plane] && plane < 4; plane++) for (plane = 0; in->data[plane] && plane < 4; plane++)
vblur(out->data[plane], out->linesize[plane], vblur(out->data[plane], out->linesize[plane],
out->data[plane], out->linesize[plane], out->data[plane], out->linesize[plane],
w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], w[plane], h[plane], s->radius[plane], s->power[plane],
boxblur->temp); s->temp);
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