This is shorter and consistent across filters.
Anton Khirnov authored on 2013/03/19 04:44:36... | ... |
@@ -122,26 +122,26 @@ static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, i |
122 | 122 |
|
123 | 123 |
static av_cold int init(AVFilterContext *ctx) |
124 | 124 |
{ |
125 |
- GradFunContext *gf = ctx->priv; |
|
125 |
+ GradFunContext *s = ctx->priv; |
|
126 | 126 |
|
127 |
- gf->thresh = (1 << 15) / gf->strength; |
|
128 |
- gf->radius &= ~1; |
|
127 |
+ s->thresh = (1 << 15) / s->strength; |
|
128 |
+ s->radius &= ~1; |
|
129 | 129 |
|
130 |
- gf->blur_line = ff_gradfun_blur_line_c; |
|
131 |
- gf->filter_line = ff_gradfun_filter_line_c; |
|
130 |
+ s->blur_line = ff_gradfun_blur_line_c; |
|
131 |
+ s->filter_line = ff_gradfun_filter_line_c; |
|
132 | 132 |
|
133 | 133 |
if (ARCH_X86) |
134 |
- ff_gradfun_init_x86(gf); |
|
134 |
+ ff_gradfun_init_x86(s); |
|
135 | 135 |
|
136 |
- av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", gf->strength, gf->radius); |
|
136 |
+ av_log(ctx, AV_LOG_VERBOSE, "threshold:%.2f radius:%d\n", s->strength, s->radius); |
|
137 | 137 |
|
138 | 138 |
return 0; |
139 | 139 |
} |
140 | 140 |
|
141 | 141 |
static av_cold void uninit(AVFilterContext *ctx) |
142 | 142 |
{ |
143 |
- GradFunContext *gf = ctx->priv; |
|
144 |
- av_freep(&gf->buf); |
|
143 |
+ GradFunContext *s = ctx->priv; |
|
144 |
+ av_freep(&s->buf); |
|
145 | 145 |
} |
146 | 146 |
|
147 | 147 |
static int query_formats(AVFilterContext *ctx) |
... | ... |
@@ -161,25 +161,25 @@ static int query_formats(AVFilterContext *ctx) |
161 | 161 |
|
162 | 162 |
static int config_input(AVFilterLink *inlink) |
163 | 163 |
{ |
164 |
- GradFunContext *gf = inlink->dst->priv; |
|
164 |
+ GradFunContext *s = inlink->dst->priv; |
|
165 | 165 |
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); |
166 | 166 |
int hsub = desc->log2_chroma_w; |
167 | 167 |
int vsub = desc->log2_chroma_h; |
168 | 168 |
|
169 |
- gf->buf = av_mallocz((FFALIGN(inlink->w, 16) * (gf->radius + 1) / 2 + 32) * sizeof(uint16_t)); |
|
170 |
- if (!gf->buf) |
|
169 |
+ s->buf = av_mallocz((FFALIGN(inlink->w, 16) * (s->radius + 1) / 2 + 32) * sizeof(uint16_t)); |
|
170 |
+ if (!s->buf) |
|
171 | 171 |
return AVERROR(ENOMEM); |
172 | 172 |
|
173 |
- gf->chroma_w = -((-inlink->w) >> hsub); |
|
174 |
- gf->chroma_h = -((-inlink->h) >> vsub); |
|
175 |
- gf->chroma_r = av_clip(((((gf->radius >> hsub) + (gf->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32); |
|
173 |
+ s->chroma_w = -((-inlink->w) >> hsub); |
|
174 |
+ s->chroma_h = -((-inlink->h) >> vsub); |
|
175 |
+ s->chroma_r = av_clip(((((s->radius >> hsub) + (s->radius >> vsub)) / 2 ) + 1) & ~1, 4, 32); |
|
176 | 176 |
|
177 | 177 |
return 0; |
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
181 | 181 |
{ |
182 |
- GradFunContext *gf = inlink->dst->priv; |
|
182 |
+ GradFunContext *s = inlink->dst->priv; |
|
183 | 183 |
AVFilterLink *outlink = inlink->dst->outputs[0]; |
184 | 184 |
AVFrame *out; |
185 | 185 |
int p, direct; |
... | ... |
@@ -203,15 +203,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) |
203 | 203 |
for (p = 0; p < 4 && in->data[p]; p++) { |
204 | 204 |
int w = inlink->w; |
205 | 205 |
int h = inlink->h; |
206 |
- int r = gf->radius; |
|
206 |
+ int r = s->radius; |
|
207 | 207 |
if (p) { |
208 |
- w = gf->chroma_w; |
|
209 |
- h = gf->chroma_h; |
|
210 |
- r = gf->chroma_r; |
|
208 |
+ w = s->chroma_w; |
|
209 |
+ h = s->chroma_h; |
|
210 |
+ r = s->chroma_r; |
|
211 | 211 |
} |
212 | 212 |
|
213 | 213 |
if (FFMIN(w, h) > 2 * r) |
214 |
- filter(gf, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r); |
|
214 |
+ filter(s, out->data[p], in->data[p], w, h, out->linesize[p], in->linesize[p], r); |
|
215 | 215 |
else if (out->data[p] != in->data[p]) |
216 | 216 |
av_image_copy_plane(out->data[p], out->linesize[p], in->data[p], in->linesize[p], w, h); |
217 | 217 |
} |