summaryrefslogtreecommitdiff
path: root/misc/xine-logoconv.c
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2002-05-01 20:38:19 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2002-05-01 20:38:19 +0000
commit07a2e66440b57a0d7edd71ed82afce9b2f68f5fe (patch)
treeaa0f1b2485ceec09d125ba60cb2e3157504d97d0 /misc/xine-logoconv.c
parentf5ef61ef9364a04765b71d80ea19675a80616f40 (diff)
downloadxine-lib-07a2e66440b57a0d7edd71ed82afce9b2f68f5fe.tar.gz
xine-lib-07a2e66440b57a0d7edd71ed82afce9b2f68f5fe.tar.bz2
planar yv12 logo format
CVS patchset: 1825 CVS date: 2002/05/01 20:38:19
Diffstat (limited to 'misc/xine-logoconv.c')
-rw-r--r--misc/xine-logoconv.c78
1 files changed, 71 insertions, 7 deletions
diff --git a/misc/xine-logoconv.c b/misc/xine-logoconv.c
index 8f0d31e88..9965f7b5f 100644
--- a/misc/xine-logoconv.c
+++ b/misc/xine-logoconv.c
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 the xine project
*
- * This file is part of xine, a unix video player.
+ * This file is part of xine, a free video player.
*
* xine is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -75,7 +75,7 @@ static void save_image (char *oldname, ImlibImage *img) {
if (extension)
*extension = 0;
- snprintf (filename, 1023, "%s.zyuy2", oldname);
+ snprintf (filename, 1023, "%s.yv12.gz", oldname);
if (!(fp = gzopen (filename ,"w"))) {
printf ("failed to create file '%s'\n", filename);
@@ -89,7 +89,7 @@ static void save_image (char *oldname, ImlibImage *img) {
wr16 (fp, h);
/*
- * convert yuv to yuy2
+ * convert yuv to yv12
*/
for (py=0; py<h; py++) {
@@ -121,10 +121,38 @@ static void save_image (char *oldname, ImlibImage *img) {
cv = v + 128.0;
gzwrite (fp, &cy, 1);
- if ((px-1) % 2)
- gzwrite (fp, &cv, 1);
- else
- gzwrite (fp, &cu, 1);
+ }
+ }
+
+ for (py=0; py<h; py+=2) {
+ printf (".");
+ for (px=0; px<w; px+=2) {
+
+ double r, g, b;
+ double y, u, v;
+ unsigned char cy,cu,cv;
+
+#ifdef WORDS_BIGENDIAN
+ r = img->rgb_data[(px+py*w)*3];
+ g = img->rgb_data[(px+py*w)*3+1];
+ b = img->rgb_data[(px+py*w)*3+2];
+#else
+ r = img->rgb_data[(px+py*w)*3+2];
+ g = img->rgb_data[(px+py*w)*3+1];
+ b = img->rgb_data[(px+py*w)*3];
+#endif
+
+ y = (LUMARED*r) + (LUMAGREEN*g) + (LUMABLUE*b);
+ // u = (b-y) / (2 - 2*LUMABLUE);
+ // v = (r-y) / (2 - 2*LUMABLUE);
+ u = (b-y) / (2 - 2*LUMABLUE);
+ v = (r-y) / (2 - 2*LUMABLUE);
+
+ cy = y;
+ cu = u + 128.0;
+ cv = v + 128.0;
+
+ gzwrite (fp, &cu, 1);
/*
printf ("%f %f %f => %f %f %f\n",r,g,b,y,u,v);
@@ -133,6 +161,42 @@ static void save_image (char *oldname, ImlibImage *img) {
}
}
+ for (py=0; py<h; py+=2) {
+ printf (".");
+ for (px=0; px<w; px+=2) {
+
+ double r, g, b;
+ double y, u, v;
+ unsigned char cy,cu,cv;
+
+#ifdef WORDS_BIGENDIAN
+ r = img->rgb_data[(px+py*w)*3];
+ g = img->rgb_data[(px+py*w)*3+1];
+ b = img->rgb_data[(px+py*w)*3+2];
+#else
+ r = img->rgb_data[(px+py*w)*3+2];
+ g = img->rgb_data[(px+py*w)*3+1];
+ b = img->rgb_data[(px+py*w)*3];
+#endif
+
+ y = (LUMARED*r) + (LUMAGREEN*g) + (LUMABLUE*b);
+ // u = (b-y) / (2 - 2*LUMABLUE);
+ // v = (r-y) / (2 - 2*LUMABLUE);
+ u = (b-y) / (2 - 2*LUMABLUE);
+ v = (r-y) / (2 - 2*LUMABLUE);
+
+ cy = y;
+ cu = u + 128.0;
+ cv = v + 128.0;
+
+ gzwrite (fp, &cv, 1);
+
+ /*
+ printf ("%f %f %f => %f %f %f\n",r,g,b,y,u,v);
+ */
+
+ }
+ }
printf ("\ndone.\n");
gzclose(fp);
}