[xiph-cvs] cvs commit: w3d yuv.c
Kenneth C. Arnold
kcarnold at xiph.org
Tue Feb 13 07:38:06 PST 2001
kcarnold 01/02/13 07:38:06
Modified: . yuv.c
Log:
1. Cleaned up messiness in yuv code
2. Check for TARKIN_YUV_EXACT and use the exact YUV transform in that case.
The approximation is still broken, but it's easier for Holger to fix it
than it is for me to figure it out.
Revision Changes Path
1.2 +18 -12 w3d/yuv.c
Index: yuv.c
===================================================================
RCS file: /usr/local/cvsroot/w3d/yuv.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- yuv.c 2001/02/13 00:56:02 1.1
+++ yuv.c 2001/02/13 15:38:05 1.2
@@ -2,17 +2,20 @@
void rgb2yuv (uint8 *rgb, int16 *y, int16 *u, int16 *v, uint32 count, uint32 stride)
{
-/*
- for (; count; count--, rgb+=stride, y++, u++, v++) {
+ while (count) {
+ count--;
+ rgb += stride;
+ y++; u++; v++;
+
+#ifdef TARKIN_YUV_EXACT
*y = ((int16) 77 * rgb [0] + 150 * rgb [1] + 29 * rgb [2]) / 256;
*u = ((int16) -44 * rgb [0] - 87 * rgb [1] + 131 * rgb [2]) / 256;
*v = ((int16) 131 * rgb [0] - 110 * rgb [1] - 21 * rgb [2]) / 256;
- }
-*/
- for (; count; count--, rgb+=stride, y++, u++, v++) {
+#else
*u = rgb [0] - rgb [1];
- *v = rgb [1] - rgb [2];
+ *v = rgb [2] - rgb [1];
*y = rgb [1] + ((*u + *v) >> 2);
+#endif
}
}
@@ -24,17 +27,20 @@
void yuv2rgb (int16 *y, int16 *u, int16 *v, uint8 *rgb, uint32 count, uint32 stride)
{
-/*
- for (; count; count--, rgb+=stride, y++, u++, v++) {
+ while (count) {
+ count--;
+ rgb += stride;
+ y++; u++; v++;
+
+#ifdef TARKIN_YUV_EXACT
rgb [0] = CLAMP(*y + 1.371 * (*v));
rgb [1] = CLAMP(*y - 0.698 * (*v) - 0.336 * (*u));
rgb [2] = CLAMP(*y + 1.732 * (*u));
- }
-*/
- for (; count; count--, rgb+=stride, y++, u++, v++) {
+#else
rgb [1] = CLAMP(*y - ((*u + *v) >> 2));
- rgb [2] = CLAMP(rgb [1] - *v);
+ rgb [2] = CLAMP(*v + rgb [1]);
rgb [0] = CLAMP(*u + rgb [1]);
+#endif
}
}
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list