Bug 550969 - Fix white_point_from_temp to handle out of range input. r=jmuizelaar
authorYati Sagade <yati.sagade@gmail.com>
Fri, 14 Oct 2011 14:58:34 -0400
changeset 78798 4aa4a5905d1aff085f00cc43da0f2e58606fed5e
parent 78797 68a211dccf2c43d972c970f112e71245d31a6f01
child 78799 ec435f2a60824639eea6ed213a4dd31c9fad5bf1
push id21335
push userbmo@edmorley.co.uk
push dateSat, 15 Oct 2011 11:21:12 +0000
treeherdermozilla-central@3b58a9df4c8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmuizelaar
bugs550969
milestone10.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 550969 - Fix white_point_from_temp to handle out of range input. r=jmuizelaar
gfx/qcms/iccread.c
--- a/gfx/qcms/iccread.c
+++ b/gfx/qcms/iccread.c
@@ -912,16 +912,18 @@ qcms_profile* qcms_profile_create_rgb_wi
 	profile->class = DISPLAY_DEVICE_PROFILE;
 	profile->rendering_intent = QCMS_INTENT_PERCEPTUAL;
 	profile->color_space = RGB_SIGNATURE;
 	return profile;
 }
 
 /* from lcms: cmsWhitePointFromTemp */
 /* tempK must be >= 4000. and <= 25000.
+ * Invalid values of tempK will return
+ * (x,y,Y) = (-1.0, -1.0, -1.0)
  * similar to argyll: icx_DTEMP2XYZ() */
 static qcms_CIE_xyY white_point_from_temp(int temp_K)
 {
 	qcms_CIE_xyY white_point;
 	double x, y;
 	double T, T2, T3;
 	// double M1, M2;
 
@@ -933,17 +935,24 @@ static qcms_CIE_xyY white_point_from_tem
 	// For correlated color temperature (T) between 4000K and 7000K:
 	if (T >= 4000. && T <= 7000.) {
 		x = -4.6070*(1E9/T3) + 2.9678*(1E6/T2) + 0.09911*(1E3/T) + 0.244063;
 	} else {
 		// or for correlated color temperature (T) between 7000K and 25000K:
 		if (T > 7000.0 && T <= 25000.0) {
 			x = -2.0064*(1E9/T3) + 1.9018*(1E6/T2) + 0.24748*(1E3/T) + 0.237040;
 		} else {
+			// Invalid tempK
+			white_point.x = -1.0;
+			white_point.y = -1.0;
+			white_point.Y = -1.0;
+
 			assert(0 && "invalid temp");
+
+			return white_point;
 		}
 	}
 
 	// Obtain y(x)
 
 	y = -3.000*(x*x) + 2.870*x - 0.275;
 
 	// wave factors (not used, but here for futures extensions)