History

avfilter/vf_histogram: use the name 's' for the pointer to the private context

This is consistent across filters.

Paul B Mahol committed 6 years ago

Commit b5f0cea1 parent 4fa2d5a1 file · +62 −62Browse files

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_histogram.c+62−62
@@ -192,12 +192,12 @@ static const uint8_t white_gbrp_color[4] = { 255, 255, 255, 255 }; · 191 unmodified lines
192192
193193 static int config_input(AVFilterLink *inlink)
194194 {
195− HistogramContext *h = inlink->dst->priv;
195+ HistogramContext *s = inlink->dst->priv;
196196
197− h->desc = av_pix_fmt_desc_get(inlink->format);
198− h->ncomp = h->desc->nb_components;
199− h->histogram_size = 1 << h->desc->comp[0].depth;
200− h->mult = h->histogram_size / 256;
197+ s->desc = av_pix_fmt_desc_get(inlink->format);
198+ s->ncomp = s->desc->nb_components;
199+ s->histogram_size = 1 << s->desc->comp[0].depth;
200+ s->mult = s->histogram_size / 256;
201201
202202 switch (inlink->format) {
203203 case AV_PIX_FMT_GBRAP12:
@@ -207,21 +207,21 @@ static int config_input(AVFilterLink *inlink) · 3 unmodified lines
207207 case AV_PIX_FMT_GBRP9:
208208 case AV_PIX_FMT_GBRAP:
209209 case AV_PIX_FMT_GBRP:
210− memcpy(h->bg_color, black_gbrp_color, 4);
211− memcpy(h->fg_color, white_gbrp_color, 4);
210+ memcpy(s->bg_color, black_gbrp_color, 4);
211+ memcpy(s->fg_color, white_gbrp_color, 4);
212212 break;
213213 default:
214− memcpy(h->bg_color, black_yuva_color, 4);
215− memcpy(h->fg_color, white_yuva_color, 4);
214+ memcpy(s->bg_color, black_yuva_color, 4);
215+ memcpy(s->fg_color, white_yuva_color, 4);
216216 }
217217
218− h->fg_color[3] = h->fgopacity * 255;
219− h->bg_color[3] = h->bgopacity * 255;
218+ s->fg_color[3] = s->fgopacity * 255;
219+ s->bg_color[3] = s->bgopacity * 255;
220220
221− h->planeheight[1] = h->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, h->desc->log2_chroma_h);
222− h->planeheight[0] = h->planeheight[3] = inlink->h;
223− h->planewidth[1] = h->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, h->desc->log2_chroma_w);
224− h->planewidth[0] = h->planewidth[3] = inlink->w;
221+ s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, s->desc->log2_chroma_h);
222+ s->planeheight[0] = s->planeheight[3] = inlink->h;
223+ s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, s->desc->log2_chroma_w);
224+ s->planewidth[0] = s->planewidth[3] = inlink->w;
225225
226226 return 0;
227227 }
@@ -229,18 +229,18 @@ static int config_input(AVFilterLink *inlink) · 1 unmodified line
229229 static int config_output(AVFilterLink *outlink)
230230 {
231231 AVFilterContext *ctx = outlink->src;
232− HistogramContext *h = ctx->priv;
232+ HistogramContext *s = ctx->priv;
233233 int ncomp = 0, i;
234234
235− for (i = 0; i < h->ncomp; i++) {
236− if ((1 << i) & h->components)
235+ for (i = 0; i < s->ncomp; i++) {
236+ if ((1 << i) & s->components)
237237 ncomp++;
238238 }
239− outlink->w = h->histogram_size * FFMAX(ncomp * (h->display_mode == 1), 1);
240− outlink->h = (h->level_height + h->scale_height) * FFMAX(ncomp * (h->display_mode == 2), 1);
239+ outlink->w = s->histogram_size * FFMAX(ncomp * (s->display_mode == 1), 1);
240+ outlink->h = (s->level_height + s->scale_height) * FFMAX(ncomp * (s->display_mode == 2), 1);
241241
242− h->odesc = av_pix_fmt_desc_get(outlink->format);
243− h->dncomp = h->odesc->nb_components;
242+ s->odesc = av_pix_fmt_desc_get(outlink->format);
243+ s->dncomp = s->odesc->nb_components;
244244 outlink->sample_aspect_ratio = (AVRational){1,1};
245245
246246 return 0;
@@ -248,7 +248,7 @@ static int config_output(AVFilterLink *outlink) · 1 unmodified line
248248
249249 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
250250 {
251− HistogramContext *h = inlink->dst->priv;
251+ HistogramContext *s = inlink->dst->priv;
252252 AVFilterContext *ctx = inlink->dst;
253253 AVFilterLink *outlink = ctx->outputs[0];
254254 AVFrame *out;
@@ -264,92 +264,92 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 9 unmodified lines
264264
265265 for (k = 0; k < 4 && out->data[k]; k++) {
266266 const int is_chroma = (k == 1 || k == 2);
267− const int dst_h = AV_CEIL_RSHIFT(outlink->h, (is_chroma ? h->odesc->log2_chroma_h : 0));
268− const int dst_w = AV_CEIL_RSHIFT(outlink->w, (is_chroma ? h->odesc->log2_chroma_w : 0));
267+ const int dst_h = AV_CEIL_RSHIFT(outlink->h, (is_chroma ? s->odesc->log2_chroma_h : 0));
268+ const int dst_w = AV_CEIL_RSHIFT(outlink->w, (is_chroma ? s->odesc->log2_chroma_w : 0));
269269
270− if (h->histogram_size <= 256) {
270+ if (s->histogram_size <= 256) {
271271 for (i = 0; i < dst_h ; i++)
272− memset(out->data[h->odesc->comp[k].plane] +
273− i * out->linesize[h->odesc->comp[k].plane],
274− h->bg_color[k], dst_w);
272+ memset(out->data[s->odesc->comp[k].plane] +
273+ i * out->linesize[s->odesc->comp[k].plane],
274+ s->bg_color[k], dst_w);
275275 } else {
276− const int mult = h->mult;
276+ const int mult = s->mult;
277277
278278 for (i = 0; i < dst_h ; i++)
279279 for (j = 0; j < dst_w; j++)
280− AV_WN16(out->data[h->odesc->comp[k].plane] +
281− i * out->linesize[h->odesc->comp[k].plane] + j * 2,
282− h->bg_color[k] * mult);
280+ AV_WN16(out->data[s->odesc->comp[k].plane] +
281+ i * out->linesize[s->odesc->comp[k].plane] + j * 2,
282+ s->bg_color[k] * mult);
283283 }
284284 }
285285
286− for (m = 0, k = 0; k < h->ncomp; k++) {
287− const int p = h->desc->comp[k].plane;
288− const int height = h->planeheight[p];
289− const int width = h->planewidth[p];
286+ for (m = 0, k = 0; k < s->ncomp; k++) {
287+ const int p = s->desc->comp[k].plane;
288+ const int height = s->planeheight[p];
289+ const int width = s->planewidth[p];
290290 double max_hval_log;
291291 unsigned max_hval = 0;
292292 int start, startx;
293293
294− if (!((1 << k) & h->components))
294+ if (!((1 << k) & s->components))
295295 continue;
296− startx = m * h->histogram_size * (h->display_mode == 1);
297− start = m++ * (h->level_height + h->scale_height) * (h->display_mode == 2);
296+ startx = m * s->histogram_size * (s->display_mode == 1);
297+ start = m++ * (s->level_height + s->scale_height) * (s->display_mode == 2);
298298
299− if (h->histogram_size <= 256) {
299+ if (s->histogram_size <= 256) {
300300 for (i = 0; i < height; i++) {
301301 const uint8_t *src = in->data[p] + i * in->linesize[p];
302302 for (j = 0; j < width; j++)
303− h->histogram[src[j]]++;
303+ s->histogram[src[j]]++;
304304 }
305305 } else {
306306 for (i = 0; i < height; i++) {
307307 const uint16_t *src = (const uint16_t *)(in->data[p] + i * in->linesize[p]);
308308 for (j = 0; j < width; j++)
309− h->histogram[src[j]]++;
309+ s->histogram[src[j]]++;
310310 }
311311 }
312312
313− for (i = 0; i < h->histogram_size; i++)
314− max_hval = FFMAX(max_hval, h->histogram[i]);
313+ for (i = 0; i < s->histogram_size; i++)
314+ max_hval = FFMAX(max_hval, s->histogram[i]);
315315 max_hval_log = log2(max_hval + 1);
316316
317− for (i = 0; i < h->histogram_size; i++) {
317+ for (i = 0; i < s->histogram_size; i++) {
318318 int col_height;
319319
320− if (h->levels_mode)
321− col_height = lrint(h->level_height * (1. - (log2(h->histogram[i] + 1) / max_hval_log)));
320+ if (s->levels_mode)
321+ col_height = lrint(s->level_height * (1. - (log2(s->histogram[i] + 1) / max_hval_log)));
322322 else
323− col_height = h->level_height - (h->histogram[i] * (int64_t)h->level_height + max_hval - 1) / max_hval;
323+ col_height = s->level_height - (s->histogram[i] * (int64_t)s->level_height + max_hval - 1) / max_hval;
324324
325− if (h->histogram_size <= 256) {
326− for (j = h->level_height - 1; j >= col_height; j--) {
327− if (h->display_mode) {
328− for (l = 0; l < h->dncomp; l++)
329− out->data[l][(j + start) * out->linesize[l] + startx + i] = h->fg_color[l];
325+ if (s->histogram_size <= 256) {
326+ for (j = s->level_height - 1; j >= col_height; j--) {
327+ if (s->display_mode) {
328+ for (l = 0; l < s->dncomp; l++)
329+ out->data[l][(j + start) * out->linesize[l] + startx + i] = s->fg_color[l];
330330 } else {
331331 out->data[p][(j + start) * out->linesize[p] + startx + i] = 255;
332332 }
333333 }
334− for (j = h->level_height + h->scale_height - 1; j >= h->level_height; j--)
334+ for (j = s->level_height + s->scale_height - 1; j >= s->level_height; j--)
335335 out->data[p][(j + start) * out->linesize[p] + startx + i] = i;
336336 } else {
337− const int mult = h->mult;
337+ const int mult = s->mult;
338338
339− for (j = h->level_height - 1; j >= col_height; j--) {
340− if (h->display_mode) {
341− for (l = 0; l < h->dncomp; l++)
342− AV_WN16(out->data[l] + (j + start) * out->linesize[l] + startx * 2 + i * 2, h->fg_color[l] * mult);
339+ for (j = s->level_height - 1; j >= col_height; j--) {
340+ if (s->display_mode) {
341+ for (l = 0; l < s->dncomp; l++)
342+ AV_WN16(out->data[l] + (j + start) * out->linesize[l] + startx * 2 + i * 2, s->fg_color[l] * mult);
343343 } else {
344344 AV_WN16(out->data[p] + (j + start) * out->linesize[p] + startx * 2 + i * 2, 255 * mult);
345345 }
346346 }
347− for (j = h->level_height + h->scale_height - 1; j >= h->level_height; j--)
347+ for (j = s->level_height + s->scale_height - 1; j >= s->level_height; j--)
348348 AV_WN16(out->data[p] + (j + start) * out->linesize[p] + startx * 2 + i * 2, i);
349349 }
350350 }
351351
352− memset(h->histogram, 0, h->histogram_size * sizeof(unsigned));
352+ memset(s->histogram, 0, s->histogram_size * sizeof(unsigned));
353353 }
354354
355355 av_frame_free(&in);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t