History

avfilter/vf_vectorscope: improve tint output for gbrp formats

Paul B Mahol committed 6 years ago

Commit b3216f11 parent 2e700ec1 file · +60 −76Browse files

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

Unified · Split

libavfilter/vf_vectorscope.c+60−76
@@ -433,6 +433,8 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int · 432 unmodified lines
433 uint16_t *dpx = dst[px];433 uint16_t *dpx = dst[px];
434 uint16_t *dpy = dst[py];434 uint16_t *dpy = dst[py];
435 uint16_t *dpd = dst[pd];435 uint16_t *dpd = dst[pd];
436 uint16_t *dp1 = dst[1];
437 uint16_t *dp2 = dst[2];
436 const int max = s->size - 1;438 const int max = s->size - 1;
437 const int mid = s->size / 2;439 const int mid = s->size / 2;
438 const int tmin = s->tmin;440 const int tmin = s->tmin;
@@ -450,41 +452,20 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int · 11 unmodified lines
450 case COLOR:452 case COLOR:
451 case COLOR5:453 case COLOR5:
452 case TINT:454 case TINT:
453 if (s->is_yuv) {455 for (i = 0; i < h; i++) {
454 for (i = 0; i < h; i++) {456 const int iwx = i * slinesizex;
455 const int iwx = i * slinesizex;457 const int iwy = i * slinesizey;
456 const int iwy = i * slinesizey;458 const int iwd = i * slinesized;
457 const int iwd = i * slinesized;459 for (j = 0; j < w; j++) {
458 for (j = 0; j < w; j++) {460 const int x = FFMIN(spx[iwx + j], max);
459 const int x = FFMIN(spx[iwx + j], max);461 const int y = FFMIN(spy[iwy + j], max);
460 const int y = FFMIN(spy[iwy + j], max);462 const int z = spd[iwd + j];
461 const int z = spd[iwd + j];463 const int pos = y * dlinesize + x;
462 const int pos = y * dlinesize + x;
463
464 if (z < tmin || z > tmax)
465 continue;
466
467 dpd[pos] = FFMIN(dpd[pos] + intensity, max);
468 }
469 }
470 } else {
471 for (i = 0; i < h; i++) {
472 const int iwx = i * slinesizex;
473 const int iwy = i * slinesizey;
474 const int iwd = i * slinesized;
475 for (j = 0; j < w; j++) {
476 const int x = FFMIN(spx[iwx + j], max);
477 const int y = FFMIN(spy[iwy + j], max);
478 const int z = spd[iwd + j];
479 const int pos = y * dlinesize + x;
480 464
481 if (z < tmin || z > tmax)465 if (z < tmin || z > tmax)
482 continue;466 continue;
483 467
484 dst[0][pos] = FFMIN(dst[0][pos] + intensity, max);468 dpd[pos] = FFMIN(dpd[pos] + intensity, max);
485 dst[1][pos] = FFMIN(dst[1][pos] + intensity, max);
486 dst[2][pos] = FFMIN(dst[2][pos] + intensity, max);
487 }
488 }469 }
489 }470 }
490 break;471 break;
@@ -588,13 +569,24 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int · 97 unmodified lines
588 }569 }
589 }570 }
590 571
591 if (s->mode == TINT && (s->tint[0] != mid ||572 if (s->mode == TINT && s->is_yuv &&
592 s->tint[1] != mid)) {573 (s->tint[0] != mid || s->tint[1] != mid)) {
574 for (i = 0; i < out->height; i++) {
575 for (j = 0; j < out->width; j++) {
576 const int pos = i * dlinesize + j;
577 if (dpd[pos]) {
578 dp1[pos] = s->tint[0];
579 dp2[pos] = s->tint[1];
580 }
581 }
582 }
583 } else if (s->mode == TINT && !s->is_yuv) {
593 for (i = 0; i < out->height; i++) {584 for (i = 0; i < out->height; i++) {
594 for (j = 0; j < out->width; j++) {585 for (j = 0; j < out->width; j++) {
595 if (dpd[i * dlinesize + j]) {586 const int pos = i * dlinesize + j;
596 dst[1][i * dlinesize + j] = s->tint[0];587 if (dpd[pos]) {
597 dst[2][i * dlinesize + j] = s->tint[1];588 dpx[pos] = av_clip(dpd[pos] + dpd[pos] * s->ftint[0], 0, max);
589 dpy[pos] = av_clip(dpd[pos] + dpd[pos] * s->ftint[1], 0, max);
598 }590 }
599 }591 }
600 }592 }
@@ -641,6 +633,8 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p · 40 unmodified lines
641 uint8_t *dpx = dst[px];633 uint8_t *dpx = dst[px];
642 uint8_t *dpy = dst[py];634 uint8_t *dpy = dst[py];
643 uint8_t *dpd = dst[pd];635 uint8_t *dpd = dst[pd];
636 uint8_t *dp1 = dst[1];
637 uint8_t *dp2 = dst[2];
644 const int tmin = s->tmin;638 const int tmin = s->tmin;
645 const int tmax = s->tmax;639 const int tmax = s->tmax;
646 int i, j, k;640 int i, j, k;
@@ -654,41 +648,20 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p · 7 unmodified lines
654 case COLOR5:648 case COLOR5:
655 case COLOR:649 case COLOR:
656 case TINT:650 case TINT:
657 if (s->is_yuv) {651 for (i = 0; i < h; i++) {
658 for (i = 0; i < h; i++) {652 const int iwx = i * slinesizex;
659 const int iwx = i * slinesizex;653 const int iwy = i * slinesizey;
660 const int iwy = i * slinesizey;654 const int iwd = i * slinesized;
661 const int iwd = i * slinesized;655 for (j = 0; j < w; j++) {
662 for (j = 0; j < w; j++) {656 const int x = spx[iwx + j];
663 const int x = spx[iwx + j];657 const int y = spy[iwy + j];
664 const int y = spy[iwy + j];658 const int z = spd[iwd + j];
665 const int z = spd[iwd + j];659 const int pos = y * dlinesize + x;
666 const int pos = y * dlinesize + x;
667
668 if (z < tmin || z > tmax)
669 continue;
670
671 dpd[pos] = FFMIN(dpd[pos] + intensity, 255);
672 }
673 }
674 } else {
675 for (i = 0; i < h; i++) {
676 const int iwx = i * slinesizex;
677 const int iwy = i * slinesizey;
678 const int iwd = i * slinesized;
679 for (j = 0; j < w; j++) {
680 const int x = spx[iwx + j];
681 const int y = spy[iwy + j];
682 const int z = spd[iwd + j];
683 const int pos = y * dlinesize + x;
684 660
685 if (z < tmin || z > tmax)661 if (z < tmin || z > tmax)
686 continue;662 continue;
687 663
688 dst[0][pos] = FFMIN(dst[0][pos] + intensity, 255);664 dpd[pos] = FFMIN(dpd[pos] + intensity, 255);
689 dst[1][pos] = FFMIN(dst[1][pos] + intensity, 255);
690 dst[2][pos] = FFMIN(dst[2][pos] + intensity, 255);
691 }
692 }665 }
693 }666 }
694 break;667 break;
@@ -792,13 +765,24 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p · 97 unmodified lines
792 }765 }
793 }766 }
794 767
795 if (s->mode == TINT && (s->tint[0] != 128 ||768 if (s->mode == TINT && s->is_yuv &&
796 s->tint[1] != 128)) {769 (s->tint[0] != 128 || s->tint[1] != 128)) {
770 for (i = 0; i < out->height; i++) {
771 for (j = 0; j < out->width; j++) {
772 const int pos = i * dlinesize + j;
773 if (dpd[pos]) {
774 dp1[pos] = s->tint[0];
775 dp2[pos] = s->tint[1];
776 }
777 }
778 }
779 } else if (s->mode == TINT && !s->is_yuv) {
797 for (i = 0; i < out->height; i++) {780 for (i = 0; i < out->height; i++) {
798 for (j = 0; j < out->width; j++) {781 for (j = 0; j < out->width; j++) {
799 if (dpd[i * dlinesize + j]) {782 const int pos = i * dlinesize + j;
800 dst[1][i * dlinesize + j] = s->tint[0];783 if (dpd[pos]) {
801 dst[2][i * dlinesize + j] = s->tint[1];784 dpx[pos] = av_clip(dpd[pos] + dpd[pos] * s->ftint[0], 0, 255);
785 dpy[pos] = av_clip(dpd[pos] + dpd[pos] * s->ftint[1], 0, 255);
802 }786 }
803 }787 }
804 }788 }

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