Showing the changes to libavfilter (1 of 2 files). Show all
Unified · Split
| @@ -34,6 +34,7 @@ typedef struct HistogramContext { · 33 unmodified lines | ||
| 34 | 34 | const AVClass *class; ///< AVClass context for log and options purpose |
| 35 | 35 | int thistogram; |
| 36 | 36 | int envelope; |
| 37 | + int slide; | |
| 37 | 38 | unsigned histogram[256*256]; |
| 38 | 39 | int histogram_size; |
| 39 | 40 | int width; |
| @@ -354,8 +355,25 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 314 unmodified lines | ||
| 354 | 355 | max_hval_log = log2(max_hval + 1); |
| 355 | 356 | |
| 356 | 357 | if (s->thistogram) { |
| 358 | + const int bpp = 1 + (s->histogram_size > 256); | |
| 357 | 359 | int minh = s->histogram_size - 1, maxh = 0; |
| 358 | 360 | |
| 361 | + if (s->slide == 2) { | |
| 362 | + s->x_pos = out->width - 1; | |
| 363 | + for (j = 0; j < outlink->h; j++) { | |
| 364 | + memmove(out->data[p] + j * out->linesize[p] , | |
| 365 | + out->data[p] + j * out->linesize[p] + bpp, | |
| 366 | + (outlink->w - 1) * bpp); | |
| 367 | + } | |
| 368 | + } else if (s->slide == 3) { | |
| 369 | + s->x_pos = 0; | |
| 370 | + for (j = 0; j < outlink->h; j++) { | |
| 371 | + memmove(out->data[p] + j * out->linesize[p] + bpp, | |
| 372 | + out->data[p] + j * out->linesize[p], | |
| 373 | + (outlink->w - 1) * bpp); | |
| 374 | + } | |
| 375 | + } | |
| 376 | + | |
| 359 | 377 | for (int i = 0; i < s->histogram_size; i++) { |
| 360 | 378 | int idx = s->histogram_size - i - 1; |
| 361 | 379 | int value = s->start[p]; |
| @@ -443,8 +461,15 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 81 unmodified lines | ||
| 443 | 461 | out->pts = in->pts; |
| 444 | 462 | av_frame_free(&in); |
| 445 | 463 | s->x_pos++; |
| 446 | − if (s->x_pos >= s->width) | |
| 464 | + if (s->x_pos >= s->width) { | |
| 447 | 465 | s->x_pos = 0; |
| 466 | + if (s->thistogram && (s->slide == 4 || s->slide == 0)) { | |
| 467 | + s->out = NULL; | |
| 468 | + goto end; | |
| 469 | + } | |
| 470 | + } else if (s->thistogram && s->slide == 4) { | |
| 471 | + return 0; | |
| 472 | + } | |
| 448 | 473 | |
| 449 | 474 | if (s->thistogram) { |
| 450 | 475 | AVFrame *clone = av_frame_clone(out); |
| @@ -453,6 +478,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) · 2 unmodified lines | ||
| 453 | 478 | return AVERROR(ENOMEM); |
| 454 | 479 | return ff_filter_frame(outlink, clone); |
| 455 | 480 | } |
| 481 | +end: | |
| 456 | 482 | return ff_filter_frame(outlink, out); |
| 457 | 483 | } |
| 458 | 484 | |
| @@ -491,6 +517,13 @@ AVFilter ff_vf_histogram = { · 32 unmodified lines | ||
| 491 | 517 | |
| 492 | 518 | #if CONFIG_THISTOGRAM_FILTER |
| 493 | 519 | |
| 520 | +static av_cold void uninit(AVFilterContext *ctx) | |
| 521 | +{ | |
| 522 | + HistogramContext *s = ctx->priv; | |
| 523 | + | |
| 524 | + av_frame_free(&s->out); | |
| 525 | +} | |
| 526 | + | |
| 494 | 527 | static const AVOption thistogram_options[] = { |
| 495 | 528 | { "width", "set width", OFFSET(width), AV_OPT_TYPE_INT, {.i64=0}, 0, 8192, FLAGS}, |
| 496 | 529 | { "w", "set width", OFFSET(width), AV_OPT_TYPE_INT, {.i64=0}, 0, 8192, FLAGS}, |
| @@ -501,6 +534,12 @@ static const AVOption thistogram_options[] = { · 4 unmodified lines | ||
| 501 | 534 | { "e", "display envelope", OFFSET(envelope), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS }, |
| 502 | 535 | { "ecolor", "set envelope color", OFFSET(envelope_rgba), AV_OPT_TYPE_COLOR, {.str="gold"}, 0, 0, FLAGS }, |
| 503 | 536 | { "ec", "set envelope color", OFFSET(envelope_rgba), AV_OPT_TYPE_COLOR, {.str="gold"}, 0, 0, FLAGS }, |
| 537 | + { "slide", "set slide mode", OFFSET(slide), AV_OPT_TYPE_INT, {.i64=1}, 0, 4, FLAGS, "slide" }, | |
| 538 | + {"frame", "draw new frames", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "slide"}, | |
| 539 | + {"replace", "replace old columns with new", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "slide"}, | |
| 540 | + {"scroll", "scroll from right to left", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "slide"}, | |
| 541 | + {"rscroll", "scroll from left to right", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=3}, 0, 0, FLAGS, "slide"}, | |
| 542 | + {"picture", "display graph in single frame", OFFSET(slide), AV_OPT_TYPE_CONST, {.i64=4}, 0, 0, FLAGS, "slide"}, | |
| 504 | 543 | { NULL } |
| 505 | 544 | }; |
| 506 | 545 | |
| @@ -513,6 +552,7 @@ AVFilter ff_vf_thistogram = { · 6 unmodified lines | ||
| 513 | 552 | .query_formats = query_formats, |
| 514 | 553 | .inputs = inputs, |
| 515 | 554 | .outputs = outputs, |
| 555 | + .uninit = uninit, | |
| 516 | 556 | .priv_class = &thistogram_class, |
| 517 | 557 | }; |
| 518 | 558 | |