[xiph-commits] r16626 - trunk/theora/examples
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Thu Oct 8 18:41:16 PDT 2009
Author: tterribe
Date: 2009-10-08 18:41:16 -0700 (Thu, 08 Oct 2009)
New Revision: 16626
Modified:
trunk/theora/examples/png2theora.c
Log:
Slightly better RGB->Y'CbCr conversion (no floating point, correct offsets and
extents).
This still does not account for gamma or RGB primaries/whitepoint, and is not
fast.
Modified: trunk/theora/examples/png2theora.c
===================================================================
--- trunk/theora/examples/png2theora.c 2009-10-09 01:25:06 UTC (rev 16625)
+++ trunk/theora/examples/png2theora.c 2009-10-09 01:41:16 UTC (rev 16626)
@@ -365,19 +365,15 @@
g = png[y][3 * x + 1];
b = png[y][3 * x + 2];
- /* XXX: Cringe. */
+ /*This ignores gamma and RGB primary/whitepoint differences.
+ It also isn't terribly fast (though a decent compiler will
+ strength-reduce the division to a multiplication).*/
yuv[3 * (x + w * y) + 0] = clamp(
- 0.299 * r
- + 0.587 * g
- + 0.114 * b);
- yuv[3 * (x + w * y) + 1] = clamp((0.436 * 255
- - 0.14713 * r
- - 0.28886 * g
- + 0.436 * b) / 0.872);
- yuv[3 * (x + w * y) + 2] = clamp((0.615 * 255
- + 0.615 * r
- - 0.51499 * g
- - 0.10001 * b) / 1.230);
+ (65481*r+128553*g+24966*b+4207500)/255000);
+ yuv[3 * (x + w * y) + 1] = clamp(
+ (-33488*r-65744*g+99232*b+29032005)/225930);
+ yuv[3 * (x + w * y) + 2] = clamp(
+ (157024*r-131488*g-25536*b+45940035)/357510);
}
}
}
More information about the commits
mailing list