From 8d2565c28bcad159d9a223e8d896605f677c7dc7 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 18 Mar 2013 20:44:36 +0100 Subject: [PATCH 1/3] vf_lut: use the name 's' for the pointer to the private context This is shorter and consistent across filters. --- libavfilter/vf_lut.c | 120 +++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/libavfilter/vf_lut.c b/libavfilter/vf_lut.c index 87c028aabf..263bd537d2 100644 --- a/libavfilter/vf_lut.c +++ b/libavfilter/vf_lut.c @@ -104,27 +104,27 @@ static const AVOption lut_options[] = { static av_cold int init(AVFilterContext *ctx) { - LutContext *lut = ctx->priv; + LutContext *s = ctx->priv; - lut->var_values[VAR_PHI] = M_PHI; - lut->var_values[VAR_PI] = M_PI; - lut->var_values[VAR_E ] = M_E; + s->var_values[VAR_PHI] = M_PHI; + s->var_values[VAR_PI] = M_PI; + s->var_values[VAR_E ] = M_E; - lut->is_rgb = !strcmp(ctx->filter->name, "lutrgb"); - lut->is_yuv = !strcmp(ctx->filter->name, "lutyuv"); + s->is_rgb = !strcmp(ctx->filter->name, "lutrgb"); + s->is_yuv = !strcmp(ctx->filter->name, "lutyuv"); return 0; } static av_cold void uninit(AVFilterContext *ctx) { - LutContext *lut = ctx->priv; + LutContext *s = ctx->priv; int i; for (i = 0; i < 4; i++) { - av_expr_free(lut->comp_expr[i]); - lut->comp_expr[i] = NULL; - av_freep(&lut->comp_expr_str[i]); + av_expr_free(s->comp_expr[i]); + s->comp_expr[i] = NULL; + av_freep(&s->comp_expr_str[i]); } } @@ -146,10 +146,10 @@ static enum AVPixelFormat all_pix_fmts[] = { RGB_FORMATS, YUV_FORMATS, AV_PIX_FM static int query_formats(AVFilterContext *ctx) { - LutContext *lut = ctx->priv; + LutContext *s = ctx->priv; - enum AVPixelFormat *pix_fmts = lut->is_rgb ? rgb_pix_fmts : - lut->is_yuv ? yuv_pix_fmts : all_pix_fmts; + enum AVPixelFormat *pix_fmts = s->is_rgb ? rgb_pix_fmts : + s->is_yuv ? yuv_pix_fmts : all_pix_fmts; ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); return 0; @@ -160,9 +160,9 @@ static int query_formats(AVFilterContext *ctx) */ static double clip(void *opaque, double val) { - LutContext *lut = opaque; - double minval = lut->var_values[VAR_MINVAL]; - double maxval = lut->var_values[VAR_MAXVAL]; + LutContext *s = opaque; + double minval = s->var_values[VAR_MINVAL]; + double maxval = s->var_values[VAR_MAXVAL]; return av_clip(val, minval, maxval); } @@ -173,10 +173,10 @@ static double clip(void *opaque, double val) */ static double compute_gammaval(void *opaque, double gamma) { - LutContext *lut = opaque; - double val = lut->var_values[VAR_CLIPVAL]; - double minval = lut->var_values[VAR_MINVAL]; - double maxval = lut->var_values[VAR_MAXVAL]; + LutContext *s = opaque; + double val = s->var_values[VAR_CLIPVAL]; + double minval = s->var_values[VAR_MINVAL]; + double maxval = s->var_values[VAR_MAXVAL]; return pow((val-minval)/(maxval-minval), gamma) * (maxval-minval)+minval; } @@ -196,16 +196,16 @@ static const char * const funcs1_names[] = { static int config_props(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; - LutContext *lut = ctx->priv; + LutContext *s = ctx->priv; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); int min[4], max[4]; int val, comp, ret; - lut->hsub = desc->log2_chroma_w; - lut->vsub = desc->log2_chroma_h; + s->hsub = desc->log2_chroma_w; + s->vsub = desc->log2_chroma_h; - lut->var_values[VAR_W] = inlink->w; - lut->var_values[VAR_H] = inlink->h; + s->var_values[VAR_W] = inlink->w; + s->var_values[VAR_H] = inlink->h; switch (inlink->format) { case AV_PIX_FMT_YUV410P: @@ -225,55 +225,55 @@ static int config_props(AVFilterLink *inlink) max[0] = max[1] = max[2] = max[3] = 255; } - lut->is_yuv = lut->is_rgb = 0; - if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) lut->is_yuv = 1; - else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) lut->is_rgb = 1; + s->is_yuv = s->is_rgb = 0; + if (ff_fmt_is_in(inlink->format, yuv_pix_fmts)) s->is_yuv = 1; + else if (ff_fmt_is_in(inlink->format, rgb_pix_fmts)) s->is_rgb = 1; - if (lut->is_rgb) { + if (s->is_rgb) { switch (inlink->format) { - case AV_PIX_FMT_ARGB: lut->rgba_map[A] = 0; lut->rgba_map[R] = 1; lut->rgba_map[G] = 2; lut->rgba_map[B] = 3; break; - case AV_PIX_FMT_ABGR: lut->rgba_map[A] = 0; lut->rgba_map[B] = 1; lut->rgba_map[G] = 2; lut->rgba_map[R] = 3; break; + case AV_PIX_FMT_ARGB: s->rgba_map[A] = 0; s->rgba_map[R] = 1; s->rgba_map[G] = 2; s->rgba_map[B] = 3; break; + case AV_PIX_FMT_ABGR: s->rgba_map[A] = 0; s->rgba_map[B] = 1; s->rgba_map[G] = 2; s->rgba_map[R] = 3; break; case AV_PIX_FMT_RGBA: - case AV_PIX_FMT_RGB24: lut->rgba_map[R] = 0; lut->rgba_map[G] = 1; lut->rgba_map[B] = 2; lut->rgba_map[A] = 3; break; + case AV_PIX_FMT_RGB24: s->rgba_map[R] = 0; s->rgba_map[G] = 1; s->rgba_map[B] = 2; s->rgba_map[A] = 3; break; case AV_PIX_FMT_BGRA: - case AV_PIX_FMT_BGR24: lut->rgba_map[B] = 0; lut->rgba_map[G] = 1; lut->rgba_map[R] = 2; lut->rgba_map[A] = 3; break; + case AV_PIX_FMT_BGR24: s->rgba_map[B] = 0; s->rgba_map[G] = 1; s->rgba_map[R] = 2; s->rgba_map[A] = 3; break; } - lut->step = av_get_bits_per_pixel(desc) >> 3; + s->step = av_get_bits_per_pixel(desc) >> 3; } for (comp = 0; comp < desc->nb_components; comp++) { double res; /* create the parsed expression */ - ret = av_expr_parse(&lut->comp_expr[comp], lut->comp_expr_str[comp], + ret = av_expr_parse(&s->comp_expr[comp], s->comp_expr_str[comp], var_names, funcs1_names, funcs1, NULL, NULL, 0, ctx); if (ret < 0) { av_log(ctx, AV_LOG_ERROR, "Error when parsing the expression '%s' for the component %d.\n", - lut->comp_expr_str[comp], comp); + s->comp_expr_str[comp], comp); return AVERROR(EINVAL); } - /* compute the lut */ - lut->var_values[VAR_MAXVAL] = max[comp]; - lut->var_values[VAR_MINVAL] = min[comp]; + /* compute the s */ + s->var_values[VAR_MAXVAL] = max[comp]; + s->var_values[VAR_MINVAL] = min[comp]; for (val = 0; val < 256; val++) { - lut->var_values[VAR_VAL] = val; - lut->var_values[VAR_CLIPVAL] = av_clip(val, min[comp], max[comp]); - lut->var_values[VAR_NEGVAL] = - av_clip(min[comp] + max[comp] - lut->var_values[VAR_VAL], + s->var_values[VAR_VAL] = val; + s->var_values[VAR_CLIPVAL] = av_clip(val, min[comp], max[comp]); + s->var_values[VAR_NEGVAL] = + av_clip(min[comp] + max[comp] - s->var_values[VAR_VAL], min[comp], max[comp]); - res = av_expr_eval(lut->comp_expr[comp], lut->var_values, lut); + res = av_expr_eval(s->comp_expr[comp], s->var_values, s); if (isnan(res)) { av_log(ctx, AV_LOG_ERROR, "Error when evaluating the expression '%s' for the value %d for the component #%d.\n", - lut->comp_expr_str[comp], val, comp); + s->comp_expr_str[comp], val, comp); return AVERROR(EINVAL); } - lut->lut[comp][val] = av_clip((int)res, min[comp], max[comp]); - av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, lut->lut[comp][val]); + s->lut[comp][val] = av_clip((int)res, min[comp], max[comp]); + av_log(ctx, AV_LOG_DEBUG, "val[%d][%d] = %d\n", comp, val, s->lut[comp][val]); } } @@ -283,7 +283,7 @@ static int config_props(AVFilterLink *inlink) static int filter_frame(AVFilterLink *inlink, AVFrame *in) { AVFilterContext *ctx = inlink->dst; - LutContext *lut = ctx->priv; + LutContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; AVFrame *out; uint8_t *inrow, *outrow, *inrow0, *outrow0; @@ -296,7 +296,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } av_frame_copy_props(out, in); - if (lut->is_rgb) { + if (s->is_rgb) { /* packed */ inrow0 = in ->data[0]; outrow0 = out->data[0]; @@ -305,10 +305,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) inrow = inrow0; outrow = outrow0; for (j = 0; j < inlink->w; j++) { - for (k = 0; k < lut->step; k++) - outrow[k] = lut->lut[lut->rgba_map[k]][inrow[k]]; - outrow += lut->step; - inrow += lut->step; + for (k = 0; k < s->step; k++) + outrow[k] = s->lut[s->rgba_map[k]][inrow[k]]; + outrow += s->step; + inrow += s->step; } inrow0 += in ->linesize[0]; outrow0 += out->linesize[0]; @@ -316,15 +316,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) } else { /* planar */ for (plane = 0; plane < 4 && in->data[plane]; plane++) { - int vsub = plane == 1 || plane == 2 ? lut->vsub : 0; - int hsub = plane == 1 || plane == 2 ? lut->hsub : 0; + int vsub = plane == 1 || plane == 2 ? s->vsub : 0; + int hsub = plane == 1 || plane == 2 ? s->hsub : 0; inrow = in ->data[plane]; outrow = out->data[plane]; for (i = 0; i < in->height >> vsub; i ++) { for (j = 0; j < inlink->w>>hsub; j++) - outrow[j] = lut->lut[plane][inrow[j]]; + outrow[j] = s->lut[plane][inrow[j]]; inrow += in ->linesize[plane]; outrow += out->linesize[plane]; } @@ -388,15 +388,15 @@ static const AVOption negate_options[] = { static av_cold int negate_init(AVFilterContext *ctx) { - LutContext *lut = ctx->priv; + LutContext *s = ctx->priv; int i; - av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", lut->negate_alpha); + av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", s->negate_alpha); for (i = 0; i < 4; i++) { - lut->comp_expr_str[i] = av_strdup((i == 3 && lut->negate_alpha) ? + s->comp_expr_str[i] = av_strdup((i == 3 && s->negate_alpha) ? "val" : "negval"); - if (!lut->comp_expr_str[i]) { + if (!s->comp_expr_str[i]) { uninit(ctx); return AVERROR(ENOMEM); } From a70519aad1f41afc053d22ad0d90257c06259112 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 18 Mar 2013 20:44:36 +0100 Subject: [PATCH 2/3] vf_overlay: use the name 's' for the pointer to the private context This is shorter and consistent across filters. --- libavfilter/vf_overlay.c | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c index da2ddbe0a2..41940d04d7 100644 --- a/libavfilter/vf_overlay.c +++ b/libavfilter/vf_overlay.c @@ -101,12 +101,12 @@ static int query_formats(AVFilterContext *ctx) static int config_input_main(AVFilterLink *inlink) { - OverlayContext *over = inlink->dst->priv; + OverlayContext *s = inlink->dst->priv; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); - av_image_fill_max_pixsteps(over->max_plane_step, NULL, pix_desc); - over->hsub = pix_desc->log2_chroma_w; - over->vsub = pix_desc->log2_chroma_h; + av_image_fill_max_pixsteps(s->max_plane_step, NULL, pix_desc); + s->hsub = pix_desc->log2_chroma_w; + s->vsub = pix_desc->log2_chroma_h; return 0; } @@ -114,7 +114,7 @@ static int config_input_main(AVFilterLink *inlink) static int config_input_overlay(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; - OverlayContext *over = inlink->dst->priv; + OverlayContext *s = inlink->dst->priv; char *expr; double var_values[VAR_VARS_NB], res; int ret; @@ -130,36 +130,36 @@ static int config_input_overlay(AVFilterLink *inlink) var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w; var_values[VAR_OVERLAY_H] = var_values[VAR_OH] = ctx->inputs[OVERLAY]->h; - if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values, + if ((ret = av_expr_parse_and_eval(&res, (expr = s->x_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto fail; - over->x = res; - if ((ret = av_expr_parse_and_eval(&res, (expr = over->y_expr), var_names, var_values, + s->x = res; + if ((ret = av_expr_parse_and_eval(&res, (expr = s->y_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx))) goto fail; - over->y = res; + s->y = res; /* x may depend on y */ - if ((ret = av_expr_parse_and_eval(&res, (expr = over->x_expr), var_names, var_values, + if ((ret = av_expr_parse_and_eval(&res, (expr = s->x_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto fail; - over->x = res; + s->x = res; av_log(ctx, AV_LOG_VERBOSE, "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n", ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h, av_get_pix_fmt_name(ctx->inputs[MAIN]->format), - over->x, over->y, + s->x, s->y, ctx->inputs[OVERLAY]->w, ctx->inputs[OVERLAY]->h, av_get_pix_fmt_name(ctx->inputs[OVERLAY]->format)); - if (over->x < 0 || over->y < 0 || - over->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] || - over->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) { + if (s->x < 0 || s->y < 0 || + s->x + var_values[VAR_OVERLAY_W] > var_values[VAR_MAIN_W] || + s->y + var_values[VAR_OVERLAY_H] > var_values[VAR_MAIN_H]) { av_log(ctx, AV_LOG_ERROR, "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n", - over->x, over->y, - (int)(over->x + var_values[VAR_OVERLAY_W]), - (int)(over->y + var_values[VAR_OVERLAY_H]), + s->x, s->y, + (int)(s->x + var_values[VAR_OVERLAY_W]), + (int)(s->y + var_values[VAR_OVERLAY_H]), (int)var_values[VAR_MAIN_W], (int)var_values[VAR_MAIN_H]); return AVERROR(EINVAL); } @@ -186,7 +186,7 @@ static void blend_frame(AVFilterContext *ctx, AVFrame *dst, AVFrame *src, int x, int y) { - OverlayContext *over = ctx->priv; + OverlayContext *s = ctx->priv; int i, j, k; int width, height; int overlay_end_y = y + src->height; @@ -218,8 +218,8 @@ static void blend_frame(AVFilterContext *ctx, } } else { for (i = 0; i < 3; i++) { - int hsub = i ? over->hsub : 0; - int vsub = i ? over->vsub : 0; + int hsub = i ? s->hsub : 0; + int vsub = i ? s->vsub : 0; uint8_t *dp = dst->data[i] + (x >> hsub) + (start_y >> vsub) * dst->linesize[i]; uint8_t *sp = src->data[i]; From 3062ac4c47b18305aa55788133b4c8aaded12f11 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 18 Mar 2013 20:44:36 +0100 Subject: [PATCH 3/3] vf_pad: use the name 's' for the pointer to the private context This is shorter and consistent across filters. --- libavfilter/vf_pad.c | 148 +++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/libavfilter/vf_pad.c b/libavfilter/vf_pad.c index 791a561cf7..8f651c635e 100644 --- a/libavfilter/vf_pad.c +++ b/libavfilter/vf_pad.c @@ -114,9 +114,9 @@ typedef struct { static av_cold int init(AVFilterContext *ctx) { - PadContext *pad = ctx->priv; + PadContext *s = ctx->priv; - if (av_parse_color(pad->color, pad->color_str, -1, ctx) < 0) + if (av_parse_color(s->color, s->color_str, -1, ctx) < 0) return AVERROR(EINVAL); return 0; @@ -124,27 +124,27 @@ static av_cold int init(AVFilterContext *ctx) static av_cold void uninit(AVFilterContext *ctx) { - PadContext *pad = ctx->priv; + PadContext *s = ctx->priv; int i; for (i = 0; i < 4; i++) { - av_freep(&pad->line[i]); - pad->line_step[i] = 0; + av_freep(&s->line[i]); + s->line_step[i] = 0; } } static int config_input(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; - PadContext *pad = ctx->priv; + PadContext *s = ctx->priv; const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format); uint8_t rgba_color[4]; int ret, is_packed_rgba; double var_values[VARS_NB], res; char *expr; - pad->hsub = pix_desc->log2_chroma_w; - pad->vsub = pix_desc->log2_chroma_h; + s->hsub = pix_desc->log2_chroma_w; + s->vsub = pix_desc->log2_chroma_h; var_values[VAR_PI] = M_PI; var_values[VAR_PHI] = M_PHI; @@ -154,78 +154,78 @@ static int config_input(AVFilterLink *inlink) var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN; var_values[VAR_A] = (double) inlink->w / inlink->h; - var_values[VAR_HSUB] = 1<hsub; - var_values[VAR_VSUB] = 1<vsub; + var_values[VAR_HSUB] = 1<hsub; + var_values[VAR_VSUB] = 1<vsub; /* evaluate width and height */ - av_expr_parse_and_eval(&res, (expr = pad->w_expr), + av_expr_parse_and_eval(&res, (expr = s->w_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx); - pad->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; - if ((ret = av_expr_parse_and_eval(&res, (expr = pad->h_expr), + s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; + if ((ret = av_expr_parse_and_eval(&res, (expr = s->h_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto eval_fail; - pad->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; + s->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res; /* evaluate the width again, as it may depend on the evaluated output height */ - if ((ret = av_expr_parse_and_eval(&res, (expr = pad->w_expr), + if ((ret = av_expr_parse_and_eval(&res, (expr = s->w_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto eval_fail; - pad->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; + s->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res; /* evaluate x and y */ - av_expr_parse_and_eval(&res, (expr = pad->x_expr), + av_expr_parse_and_eval(&res, (expr = s->x_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx); - pad->x = var_values[VAR_X] = res; - if ((ret = av_expr_parse_and_eval(&res, (expr = pad->y_expr), + s->x = var_values[VAR_X] = res; + if ((ret = av_expr_parse_and_eval(&res, (expr = s->y_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto eval_fail; - pad->y = var_values[VAR_Y] = res; + s->y = var_values[VAR_Y] = res; /* evaluate x again, as it may depend on the evaluated y value */ - if ((ret = av_expr_parse_and_eval(&res, (expr = pad->x_expr), + if ((ret = av_expr_parse_and_eval(&res, (expr = s->x_expr), var_names, var_values, NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0) goto eval_fail; - pad->x = var_values[VAR_X] = res; + s->x = var_values[VAR_X] = res; /* sanity check params */ - if (pad->w < 0 || pad->h < 0 || pad->x < 0 || pad->y < 0) { + if (s->w < 0 || s->h < 0 || s->x < 0 || s->y < 0) { av_log(ctx, AV_LOG_ERROR, "Negative values are not acceptable.\n"); return AVERROR(EINVAL); } - if (!pad->w) - pad->w = inlink->w; - if (!pad->h) - pad->h = inlink->h; + if (!s->w) + s->w = inlink->w; + if (!s->h) + s->h = inlink->h; - pad->w &= ~((1 << pad->hsub) - 1); - pad->h &= ~((1 << pad->vsub) - 1); - pad->x &= ~((1 << pad->hsub) - 1); - pad->y &= ~((1 << pad->vsub) - 1); + s->w &= ~((1 << s->hsub) - 1); + s->h &= ~((1 << s->vsub) - 1); + s->x &= ~((1 << s->hsub) - 1); + s->y &= ~((1 << s->vsub) - 1); - pad->in_w = inlink->w & ~((1 << pad->hsub) - 1); - pad->in_h = inlink->h & ~((1 << pad->vsub) - 1); + s->in_w = inlink->w & ~((1 << s->hsub) - 1); + s->in_h = inlink->h & ~((1 << s->vsub) - 1); - memcpy(rgba_color, pad->color, sizeof(rgba_color)); - ff_fill_line_with_color(pad->line, pad->line_step, pad->w, pad->color, + memcpy(rgba_color, s->color, sizeof(rgba_color)); + ff_fill_line_with_color(s->line, s->line_step, s->w, s->color, inlink->format, rgba_color, &is_packed_rgba, NULL); av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -> w:%d h:%d x:%d y:%d color:0x%02X%02X%02X%02X[%s]\n", - inlink->w, inlink->h, pad->w, pad->h, pad->x, pad->y, - pad->color[0], pad->color[1], pad->color[2], pad->color[3], + inlink->w, inlink->h, s->w, s->h, s->x, s->y, + s->color[0], s->color[1], s->color[2], s->color[3], is_packed_rgba ? "rgba" : "yuva"); - if (pad->x < 0 || pad->y < 0 || - pad->w <= 0 || pad->h <= 0 || - (unsigned)pad->x + (unsigned)inlink->w > pad->w || - (unsigned)pad->y + (unsigned)inlink->h > pad->h) { + if (s->x < 0 || s->y < 0 || + s->w <= 0 || s->h <= 0 || + (unsigned)s->x + (unsigned)inlink->w > s->w || + (unsigned)s->y + (unsigned)inlink->h > s->h) { av_log(ctx, AV_LOG_ERROR, "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n", - pad->x, pad->y, pad->x + inlink->w, pad->y + inlink->h, pad->w, pad->h); + s->x, s->y, s->x + inlink->w, s->y + inlink->h, s->w, s->h); return AVERROR(EINVAL); } @@ -240,20 +240,20 @@ eval_fail: static int config_output(AVFilterLink *outlink) { - PadContext *pad = outlink->src->priv; + PadContext *s = outlink->src->priv; - outlink->w = pad->w; - outlink->h = pad->h; + outlink->w = s->w; + outlink->h = s->h; return 0; } static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h) { - PadContext *pad = inlink->dst->priv; + PadContext *s = inlink->dst->priv; AVFrame *frame = ff_get_video_buffer(inlink->dst->outputs[0], - w + (pad->w - pad->in_w), - h + (pad->h - pad->in_h)); + w + (s->w - s->in_w), + h + (s->h - s->in_h)); int plane; if (!frame) @@ -263,11 +263,11 @@ static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h) frame->height = h; for (plane = 0; plane < 4 && frame->data[plane]; plane++) { - int hsub = (plane == 1 || plane == 2) ? pad->hsub : 0; - int vsub = (plane == 1 || plane == 2) ? pad->vsub : 0; + int hsub = (plane == 1 || plane == 2) ? s->hsub : 0; + int vsub = (plane == 1 || plane == 2) ? s->vsub : 0; - frame->data[plane] += (pad->x >> hsub) * pad->line_step[plane] + - (pad->y >> vsub) * frame->linesize[plane]; + frame->data[plane] += (s->x >> hsub) * s->line_step[plane] + + (s->y >> vsub) * frame->linesize[plane]; } return frame; @@ -342,15 +342,15 @@ static int frame_needs_copy(PadContext *s, AVFrame *frame) static int filter_frame(AVFilterLink *inlink, AVFrame *in) { - PadContext *pad = inlink->dst->priv; + PadContext *s = inlink->dst->priv; AVFrame *out; - int needs_copy = frame_needs_copy(pad, in); + int needs_copy = frame_needs_copy(s, in); if (needs_copy) { av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible allocating new frame\n"); out = ff_get_video_buffer(inlink->dst->outputs[0], - FFMAX(inlink->w, pad->w), - FFMAX(inlink->h, pad->h)); + FFMAX(inlink->w, s->w), + FFMAX(inlink->h, s->h)); if (!out) { av_frame_free(&in); return AVERROR(ENOMEM); @@ -362,45 +362,45 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) out = in; for (i = 0; i < FF_ARRAY_ELEMS(out->data) && out->data[i]; i++) { - int hsub = (i == 1 || i == 2) ? pad->hsub : 0; - int vsub = (i == 1 || i == 2) ? pad->vsub : 0; - out->data[i] -= (pad->x >> hsub) * pad->line_step[i] + - (pad->y >> vsub) * out->linesize[i]; + int hsub = (i == 1 || i == 2) ? s->hsub : 0; + int vsub = (i == 1 || i == 2) ? s->vsub : 0; + out->data[i] -= (s->x >> hsub) * s->line_step[i] + + (s->y >> vsub) * out->linesize[i]; } } /* top bar */ - if (pad->y) { + if (s->y) { ff_draw_rectangle(out->data, out->linesize, - pad->line, pad->line_step, pad->hsub, pad->vsub, - 0, 0, pad->w, pad->y); + s->line, s->line_step, s->hsub, s->vsub, + 0, 0, s->w, s->y); } /* bottom bar */ - if (pad->h > pad->y + pad->in_h) { + if (s->h > s->y + s->in_h) { ff_draw_rectangle(out->data, out->linesize, - pad->line, pad->line_step, pad->hsub, pad->vsub, - 0, pad->y + pad->in_h, pad->w, pad->h - pad->y - pad->in_h); + s->line, s->line_step, s->hsub, s->vsub, + 0, s->y + s->in_h, s->w, s->h - s->y - s->in_h); } /* left border */ - ff_draw_rectangle(out->data, out->linesize, pad->line, pad->line_step, - pad->hsub, pad->vsub, 0, pad->y, pad->x, in->height); + ff_draw_rectangle(out->data, out->linesize, s->line, s->line_step, + s->hsub, s->vsub, 0, s->y, s->x, in->height); if (needs_copy) { ff_copy_rectangle(out->data, out->linesize, in->data, in->linesize, - pad->line_step, pad->hsub, pad->vsub, - pad->x, pad->y, 0, in->width, in->height); + s->line_step, s->hsub, s->vsub, + s->x, s->y, 0, in->width, in->height); } /* right border */ ff_draw_rectangle(out->data, out->linesize, - pad->line, pad->line_step, pad->hsub, pad->vsub, - pad->x + pad->in_w, pad->y, pad->w - pad->x - pad->in_w, + s->line, s->line_step, s->hsub, s->vsub, + s->x + s->in_w, s->y, s->w - s->x - s->in_w, in->height); - out->width = pad->w; - out->height = pad->h; + out->width = s->w; + out->height = s->h; if (in != out) av_frame_free(&in);