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
433433 uint16_t *dpx = dst[px];
434434 uint16_t *dpy = dst[py];
435435 uint16_t *dpd = dst[pd];
436+ uint16_t *dp1 = dst[1];
437+ uint16_t *dp2 = dst[2];
436438 const int max = s->size - 1;
437439 const int mid = s->size / 2;
438440 const int tmin = s->tmin;
@@ -450,41 +452,20 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int · 11 unmodified lines
450452 case COLOR:
451453 case COLOR5:
452454 case TINT:
453− if (s->is_yuv) {
454− for (i = 0; i < h; i++) {
455− const int iwx = i * slinesizex;
456− const int iwy = i * slinesizey;
457− const int iwd = i * slinesized;
458− for (j = 0; j < w; j++) {
459− const int x = FFMIN(spx[iwx + j], max);
460− const int y = FFMIN(spy[iwy + j], max);
461− const int z = spd[iwd + j];
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;
455+ for (i = 0; i < h; i++) {
456+ const int iwx = i * slinesizex;
457+ const int iwy = i * slinesizey;
458+ const int iwd = i * slinesized;
459+ for (j = 0; j < w; j++) {
460+ const int x = FFMIN(spx[iwx + j], max);
461+ const int y = FFMIN(spy[iwy + j], max);
462+ const int z = spd[iwd + j];
463+ const int pos = y * dlinesize + x;
480464
481− if (z < tmin || z > tmax)
482− continue;
465+ if (z < tmin || z > tmax)
466+ continue;
483467
484− dst[0][pos] = FFMIN(dst[0][pos] + intensity, max);
485− dst[1][pos] = FFMIN(dst[1][pos] + intensity, max);
486− dst[2][pos] = FFMIN(dst[2][pos] + intensity, max);
487− }
468+ dpd[pos] = FFMIN(dpd[pos] + intensity, max);
488469 }
489470 }
490471 break;
@@ -588,13 +569,24 @@ static void vectorscope16(VectorscopeContext *s, AVFrame *in, AVFrame *out, int · 97 unmodified lines
588569 }
589570 }
590571
591− if (s->mode == TINT && (s->tint[0] != mid ||
592− s->tint[1] != mid)) {
572+ if (s->mode == TINT && s->is_yuv &&
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) {
593584 for (i = 0; i < out->height; i++) {
594585 for (j = 0; j < out->width; j++) {
595− if (dpd[i * dlinesize + j]) {
596− dst[1][i * dlinesize + j] = s->tint[0];
597− dst[2][i * dlinesize + j] = s->tint[1];
586+ const int pos = i * dlinesize + j;
587+ if (dpd[pos]) {
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);
598590 }
599591 }
600592 }
@@ -641,6 +633,8 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p · 40 unmodified lines
641633 uint8_t *dpx = dst[px];
642634 uint8_t *dpy = dst[py];
643635 uint8_t *dpd = dst[pd];
636+ uint8_t *dp1 = dst[1];
637+ uint8_t *dp2 = dst[2];
644638 const int tmin = s->tmin;
645639 const int tmax = s->tmax;
646640 int i, j, k;
@@ -654,41 +648,20 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p · 7 unmodified lines
654648 case COLOR5:
655649 case COLOR:
656650 case TINT:
657− if (s->is_yuv) {
658− for (i = 0; i < h; i++) {
659− const int iwx = i * slinesizex;
660− const int iwy = i * slinesizey;
661− const int iwd = i * slinesized;
662− for (j = 0; j < w; j++) {
663− const int x = spx[iwx + j];
664− const int y = spy[iwy + j];
665− const int z = spd[iwd + j];
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;
651+ for (i = 0; i < h; i++) {
652+ const int iwx = i * slinesizex;
653+ const int iwy = i * slinesizey;
654+ const int iwd = i * slinesized;
655+ for (j = 0; j < w; j++) {
656+ const int x = spx[iwx + j];
657+ const int y = spy[iwy + j];
658+ const int z = spd[iwd + j];
659+ const int pos = y * dlinesize + x;
684660
685− if (z < tmin || z > tmax)
686− continue;
661+ if (z < tmin || z > tmax)
662+ continue;
687663
688− dst[0][pos] = FFMIN(dst[0][pos] + intensity, 255);
689− dst[1][pos] = FFMIN(dst[1][pos] + intensity, 255);
690− dst[2][pos] = FFMIN(dst[2][pos] + intensity, 255);
691− }
664+ dpd[pos] = FFMIN(dpd[pos] + intensity, 255);
692665 }
693666 }
694667 break;
@@ -792,13 +765,24 @@ static void vectorscope8(VectorscopeContext *s, AVFrame *in, AVFrame *out, int p · 97 unmodified lines
792765 }
793766 }
794767
795− if (s->mode == TINT && (s->tint[0] != 128 ||
796− s->tint[1] != 128)) {
768+ if (s->mode == TINT && s->is_yuv &&
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) {
797780 for (i = 0; i < out->height; i++) {
798781 for (j = 0; j < out->width; j++) {
799− if (dpd[i * dlinesize + j]) {
800− dst[1][i * dlinesize + j] = s->tint[0];
801− dst[2][i * dlinesize + j] = s->tint[1];
782+ const int pos = i * dlinesize + j;
783+ if (dpd[pos]) {
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);
802786 }
803787 }
804788 }

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