Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -207,6 +207,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 206 unmodified lines | |||
| 207 | AVFilterContext *ctx = inlink->dst; | 207 | AVFilterContext *ctx = inlink->dst; |
| 208 | AVFilterLink *outlink = ctx->outputs[0]; | 208 | AVFilterLink *outlink = ctx->outputs[0]; |
| 209 | AudioHistogramContext *s = ctx->priv; | 209 | AudioHistogramContext *s = ctx->priv; |
| 210 | const int nb_samples = in->nb_samples; | ||
| 210 | const int H = s->histogram_h; | 211 | const int H = s->histogram_h; |
| 211 | const int w = s->w; | 212 | const int w = s->w; |
| 212 | int c, y, n, p, bin, ret; | 213 | int c, y, n, p, bin, ret; |
| @@ -260,7 +261,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 47 unmodified lines | |||
| 260 | const float *src = (const float *)in->extended_data[c]; | 261 | const float *src = (const float *)in->extended_data[c]; |
| 261 | uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w]; | 262 | uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w]; |
| 262 | 263 | ||
| 263 | for (n = 0; n < in->nb_samples; n++) { | 264 | for (n = 0; n < nb_samples; n++) { |
| 264 | bin = s->get_bin(src[n], w); | 265 | bin = s->get_bin(src[n], w); |
| 265 | 266 | ||
| 266 | achistogram[bin]++; | 267 | achistogram[bin]++; |
| @@ -270,7 +271,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 3 unmodified lines | |||
| 270 | uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w]; | 271 | uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w]; |
| 271 | const float *src2 = (const float *)s->in[s->first]->extended_data[c]; | 272 | const float *src2 = (const float *)s->in[s->first]->extended_data[c]; |
| 272 | 273 | ||
| 273 | for (n = 0; n < in->nb_samples; n++) { | 274 | for (n = 0; n < nb_samples; n++) { |
| 274 | bin = s->get_bin(src2[n], w); | 275 | bin = s->get_bin(src2[n], w); |
| 275 | 276 | ||
| 276 | shistogram[bin]++; | 277 | shistogram[bin]++; |
| @@ -283,7 +284,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 6 unmodified lines | |||
| 283 | const float *src = (const float *)in->extended_data[c]; | 284 | const float *src = (const float *)in->extended_data[c]; |
| 284 | uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w]; | 285 | uint64_t *achistogram = &s->achistogram[(s->dmode == SINGLE ? 0: c) * w]; |
| 285 | 286 | ||
| 286 | for (n = 0; n < in->nb_samples; n++) { | 287 | for (n = 0; n < nb_samples; n++) { |
| 287 | bin = s->get_bin(src[n], w); | 288 | bin = s->get_bin(src[n], w); |
| 288 | 289 | ||
| 289 | achistogram[bin]++; | 290 | achistogram[bin]++; |
| @@ -293,7 +294,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 3 unmodified lines | |||
| 293 | uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w]; | 294 | uint64_t *shistogram = &s->shistogram[(s->dmode == SINGLE ? 0: c) * w]; |
| 294 | const float *src2 = (const float *)s->in[s->first]->extended_data[c]; | 295 | const float *src2 = (const float *)s->in[s->first]->extended_data[c]; |
| 295 | 296 | ||
| 296 | for (n = 0; n < in->nb_samples; n++) { | 297 | for (n = 0; n < nb_samples; n++) { |
| 297 | bin = s->get_bin(src2[n], w); | 298 | bin = s->get_bin(src2[n], w); |
| 298 | 299 | ||
| 299 | shistogram[bin]++; | 300 | shistogram[bin]++; |
| @@ -357,10 +358,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 57 unmodified lines | |||
| 357 | h = aa * (H - 1); | 358 | h = aa * (H - 1); |
| 358 | 359 | ||
| 359 | if (s->dmode == SINGLE) { | 360 | if (s->dmode == SINGLE) { |
| 360 | 361 | int start = H - h, end = H; | |
| 361 | for (y = H - h; y < H; y++) { | 362 | const int linesizey = s->out->linesize[0]; |
| 362 | s->out->data[0][y * s->out->linesize[0] + n] = 255; | 363 | const int linesizea = s->out->linesize[3]; |
| 363 | s->out->data[3][y * s->out->linesize[0] + n] = 255; | 364 | uint8_t *dsty = s->out->data[0] + start * linesizey; |
| 365 | uint8_t *dsta = s->out->data[3] + start * linesizea; | ||
| 366 | |||
| 367 | for (y = start; y < end; y++, dsty += linesizey, dsta += linesizea) { | ||
| 368 | dsty[n] = 255; | ||
| 369 | dsta[n] = 255; | ||
| 364 | } | 370 | } |
| 365 | 371 | ||
| 366 | if (s->h - H > 0) { | 372 | if (s->h - H > 0) { |
| @@ -372,18 +378,32 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 5 unmodified lines | |||
| 372 | s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255; | 378 | s->out->data[3][s->ypos * s->out->linesize[3] + n] = 255; |
| 373 | } | 379 | } |
| 374 | } else if (s->dmode == SEPARATE) { | 380 | } else if (s->dmode == SEPARATE) { |
| 381 | int start = H - h, end = H; | ||
| 375 | float *out = &s->combine_buffer[3 * n]; | 382 | float *out = &s->combine_buffer[3 * n]; |
| 383 | const int linesizey = s->out->linesize[0]; | ||
| 384 | const int linesizeu = s->out->linesize[1]; | ||
| 385 | const int linesizev = s->out->linesize[2]; | ||
| 386 | const int linesizea = s->out->linesize[3]; | ||
| 387 | uint8_t *dsty = s->out->data[0] + start * linesizey; | ||
| 388 | uint8_t *dstu = s->out->data[1] + start * linesizeu; | ||
| 389 | uint8_t *dstv = s->out->data[2] + start * linesizev; | ||
| 390 | uint8_t *dsta = s->out->data[3] + start * linesizea; | ||
| 376 | int old; | 391 | int old; |
| 377 | 392 | ||
| 378 | old = s->out->data[0][(H - h) * s->out->linesize[0] + n]; | 393 | old = dsty[n]; |
| 379 | for (y = H - h; y < H; y++) { | 394 | for (y = start; y < end; y++) { |
| 380 | if (s->out->data[0][y * s->out->linesize[0] + n] != old) | 395 | if (dsty[n] != old) |
| 381 | break; | 396 | break; |
| 382 | old = s->out->data[0][y * s->out->linesize[0] + n]; | 397 | old = dsty[n]; |
| 383 | s->out->data[0][y * s->out->linesize[0] + n] = av_clip_uint8(yf); | 398 | dsty[n] = av_clip_uint8(yf); |
| 384 | s->out->data[1][y * s->out->linesize[1] + n] = av_clip_uint8(128.f+uf); | 399 | dstu[n] = av_clip_uint8(128.f+uf); |
| 385 | s->out->data[2][y * s->out->linesize[2] + n] = av_clip_uint8(128.f+vf); | 400 | dstv[n] = av_clip_uint8(128.f+vf); |
| 386 | s->out->data[3][y * s->out->linesize[3] + n] = 255; | 401 | dsta[n] = 255; |
| 402 | |||
| 403 | dsty += linesizey; | ||
| 404 | dstu += linesizeu; | ||
| 405 | dstv += linesizev; | ||
| 406 | dsta += linesizea; | ||
| 387 | } | 407 | } |
| 388 | 408 | ||
| 389 | out[0] += aa * yf; | 409 | out[0] += aa * yf; |