Bladeren bron

Clamp Y to 16 - 235, as the MPEG standard uses.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@4699 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 14 jaren geleden
bovenliggende
commit
e88e7d9e4d
1 gewijzigde bestanden met toevoegingen van 11 en 8 verwijderingen
  1. +11
    -8
      pipi/filter/yuv.c

+ 11
- 8
pipi/filter/yuv.c Bestand weergeven

@@ -31,7 +31,7 @@ pipi_image_t *pipi_rgb2yuv(pipi_image_t *src)
pipi_image_t *dst;
pipi_pixels_t *srcp, *dstp;
float *srcdata, *dstdata;
int x, y, w, h, gray;
int x, y, w, h;

w = src->w;
h = src->h;
@@ -56,16 +56,19 @@ pipi_image_t *pipi_rgb2yuv(pipi_image_t *src)
a = srcdata[d + 3];

yp = 0.299 * r + 0.587 * g + 0.114 * b;
yp = (yp * 220.0 + 16.0) / 255.0;

u = 0.5 - 0.14713 * r - 0.28886 * g + 0.436 * b;
if (u < 0.0) u = 0.0;
if (u > 1.0) u = 1.0;

v = 0.5 + 0.615 * r - 0.51499 * g - 0.10001 * b;
if (v < 0.0) v = 0.0;
if (v > 1.0) v = 1.0;

dstdata[d] = v;
dstdata[d + 1] = yp;
dstdata[d + 2] = u;
dstdata[d] = yp;
dstdata[d + 1] = u;
dstdata[d + 2] = v;
dstdata[d + 3] = a;
}
}
@@ -78,7 +81,7 @@ pipi_image_t *pipi_yuv2rgb(pipi_image_t *src)
pipi_image_t *dst;
pipi_pixels_t *srcp, *dstp;
float *srcdata, *dstdata;
int x, y, w, h, gray;
int x, y, w, h;

w = src->w;
h = src->h;
@@ -97,9 +100,9 @@ pipi_image_t *pipi_yuv2rgb(pipi_image_t *src)
double r, g, b, a, yp, u, v;
int d = 4 * (y * w + x);

v = srcdata[d] - 0.5;
yp = srcdata[d + 1];
u = srcdata[d + 2] - 0.5;
yp = (srcdata[d] * 255.0 - 16.0) / 220.0;
u = srcdata[d + 1] - 0.5;
v = srcdata[d + 2] - 0.5;
a = srcdata[d + 3];

r = yp + 1.13983 * v;


Laden…
Annuleren
Opslaan