|
Definition at line 263 of file lh_core/stdconv.c.
00264 {
00265 register unsigned short *v;
00266 long i;
00267 long lon_aOff, lon_bOff, lon_X, lon_Y, lon_Z;
00268 long fract, index, leftVal, rightVal;
00269
00270 #ifdef DEBUG_OUTPUT
00271 OSErr err= noErr;
00272 #endif
00273
00274 #ifdef SYM_C
00275 unsigned short Y2L[432];
00276 v = Y2L;
00277 *v++= 0; *v++= 1156; *v++= 2312; *v++= 3391; *v++= 4260; *v++= 4993; *v++= 5635; *v++= 6208;
00278 *v++= 6730; *v++= 7209; *v++= 7654; *v++= 8070; *v++= 8462; *v++= 8833; *v++= 9185; *v++= 9520;
00279 *v++= 9841; *v++=10149; *v++=10445; *v++=10731; *v++=11006; *v++=11273; *v++=11531; *v++=11781;
00280 *v++=12024; *v++=12261; *v++=12491; *v++=12716; *v++=12935; *v++=13149; *v++=13358; *v++=13562;
00281 *v++=13762; *v++=13958; *v++=14150; *v++=14338; *v++=14523; *v++=14704; *v++=14883; *v++=15058;
00282 *v++=15230; *v++=15399; *v++=15565; *v++=15729; *v++=15890; *v++=16049; *v++=16206; *v++=16360;
00283 *v++=16512; *v++=16662; *v++=16810; *v++=16957; *v++=17101; *v++=17243; *v++=17384; *v++=17522;
00284 *v++=17659; *v++=17795; *v++=17929; *v++=18061; *v++=18192; *v++=18322; *v++=18450; *v++=18577;
00285 *v++=18702; *v++=18826; *v++=18949; *v++=19070; *v++=19191; *v++=19310; *v++=19428; *v++=19545;
00286 *v++=19661; *v++=19775; *v++=19889; *v++=20002; *v++=20114; *v++=20224; *v++=20334; *v++=20443;
00287 *v++=20551; *v++=20658; *v++=20764; *v++=20869; *v++=20974; *v++=21077; *v++=21180; *v++=21282;
00288 *v++=21383; *v++=21484; *v++=21584; *v++=21683; *v++=21781; *v++=21878; *v++=21975; *v++=22072;
00289 *v++=22167; *v++=22262; *v++=22356; *v++=22450; *v++=22543; *v++=22635; *v++=22727; *v++=22818;
00290 *v++=22908; *v++=22998; *v++=23087; *v++=23176; *v++=23265; *v++=23352; *v++=23439; *v++=23526;
00291 *v++=23612; *v++=23698; *v++=23783; *v++=23868; *v++=23952; *v++=24035; *v++=24119; *v++=24201;
00292 *v++=24284; *v++=24365; *v++=24447; *v++=24528; *v++=24608; *v++=24688; *v++=24768; *v++=24847;
00293 *v++=24926; *v++=25004; *v++=25082; *v++=25159; *v++=25237; *v++=25313; *v++=25390; *v++=25466;
00294 *v++=25541; *v++=25617; *v++=25692; *v++=25766; *v++=25840; *v++=25914; *v++=25988; *v++=26061;
00295 *v++=26134; *v++=26206; *v++=26278; *v++=26350; *v++=26421; *v++=26493; *v++=26563; *v++=26634;
00296 *v++=26704; *v++=26774; *v++=26844; *v++=26913; *v++=26982; *v++=27051; *v++=27119; *v++=27187;
00297 *v++=27255; *v++=27323; *v++=27390; *v++=27457; *v++=27524; *v++=27590; *v++=27656; *v++=27722;
00298 *v++=27788; *v++=27853; *v++=27919; *v++=27983; *v++=28048; *v++=28112; *v++=28177; *v++=28241;
00299 *v++=28304; *v++=28368; *v++=28431; *v++=28494; *v++=28556; *v++=28619; *v++=28681; *v++=28743;
00300 *v++=28805; *v++=28867; *v++=28928; *v++=28989; *v++=29050; *v++=29111; *v++=29171; *v++=29231;
00301 *v++=29291; *v++=29351; *v++=29411; *v++=29470; *v++=29530; *v++=29589; *v++=29647; *v++=29706;
00302 *v++=29765; *v++=29823; *v++=29881; *v++=29939; *v++=29996; *v++=30054; *v++=30111; *v++=30168;
00303 *v++=30225; *v++=30282; *v++=30339; *v++=30395; *v++=30451; *v++=30507; *v++=30563; *v++=30619;
00304 *v++=30674; *v++=30730; *v++=30785; *v++=30840; *v++=30895; *v++=30949; *v++=31004; *v++=31058;
00305 *v++=31112; *v++=31166; *v++=31220; *v++=31274; *v++=31327; *v++=31381; *v++=31434; *v++=31487;
00306 *v++=31540; *v++=31593; *v++=31645; *v++=31698; *v++=31750; *v++=31802; *v++=31854; *v++=31906;
00307 *v++=31958; *v++=32010; *v++=32061; *v++=32112; *v++=32164; *v++=32215; *v++=32265; *v++=32316;
00308 *v++=32367; *v++=32417; *v++=32468; *v++=32518; *v++=32568; *v++=32618; *v++=32668; *v++=32717;
00309 *v++=32767; *v++=32816; *v++=32866; *v++=32915; *v++=32964; *v++=33013; *v++=33062; *v++=33110;
00310 *v++=33159; *v++=33207; *v++=33256; *v++=33304; *v++=33352; *v++=33400; *v++=33448; *v++=33495;
00311 *v++=33543; *v++=33590; *v++=33638; *v++=33685; *v++=33732; *v++=33779; *v++=33826; *v++=33873;
00312 *v++=33919; *v++=33966; *v++=34013; *v++=34059; *v++=34105; *v++=34151; *v++=34197; *v++=34243;
00313 *v++=34289; *v++=34335; *v++=34380; *v++=34426; *v++=34471; *v++=34516; *v++=34562; *v++=34607;
00314 *v++=34652; *v++=34697; *v++=34741; *v++=34786; *v++=34831; *v++=34875; *v++=34919; *v++=34964;
00315 *v++=35008; *v++=35052; *v++=35096; *v++=35140; *v++=35184; *v++=35227; *v++=35271; *v++=35314;
00316 *v++=35358; *v++=35401; *v++=35444; *v++=35488; *v++=35531; *v++=35574; *v++=35617; *v++=35659;
00317 *v++=35702; *v++=35745; *v++=35787; *v++=35830; *v++=35872; *v++=35914; *v++=35956; *v++=35998;
00318 *v++=36040; *v++=36082; *v++=36124; *v++=36166; *v++=36208; *v++=36249; *v++=36291; *v++=36332;
00319 *v++=36373; *v++=36415; *v++=36456; *v++=36497; *v++=36538; *v++=36579; *v++=36620; *v++=36660;
00320 *v++=36701; *v++=36742; *v++=36782; *v++=36823; *v++=36863; *v++=36903; *v++=36943; *v++=36984;
00321 *v++=37024; *v++=37064; *v++=37104; *v++=37143; *v++=37183; *v++=37223; *v++=37262; *v++=37302;
00322 *v++=37342; *v++=37381; *v++=37420; *v++=37459; *v++=37499; *v++=37538; *v++=37577; *v++=37616;
00323 *v++=37655; *v++=37693; *v++=37732; *v++=37771; *v++=37810; *v++=37848; *v++=37887; *v++=37925;
00324 *v++=37963; *v++=38002; *v++=38040; *v++=38078; *v++=38116; *v++=38154; *v++=38192; *v++=38230;
00325 *v++=38268; *v++=38305; *v++=38343; *v++=38381; *v++=38418; *v++=38456; *v++=38493; *v++=38530;
00326 *v++=38568; *v++=38605; *v++=38642; *v++=38679; *v++=38716; *v++=38753; *v++=38790; *v++=38827;
00327 *v++=38864; *v++=38900; *v++=38937; *v++=38974; *v++=39010; *v++=39047; *v++=39083; *v++=39119;
00328 *v++=39156; *v++=39192; *v++=39228; *v++=39264; *v++=39300; *v++=39336; *v++=39372; *v++=39408;
00329 *v++=39444; *v++=39480; *v++=39516; *v++=39551; *v++=39587; *v++=39622; *v++=39658; *v++=39693;
00330 *v++=39729; *v++=39764; *v++=39799; *v++=39835; *v++=39870; *v++=39905; *v++=39940; *v++=39975;
00331 #else
00332 static unsigned short Y2L[439] = {
00333 0, 1156, 2312, 3391, 4260, 4993, 5635, 6208,
00334 6730, 7209, 7654, 8070, 8462, 8833, 9185, 9520,
00335 9841, 10149, 10445, 10731, 11006, 11273, 11531, 11781,
00336 12024, 12261, 12491, 12716, 12935, 13149, 13358, 13562,
00337 13762, 13958, 14150, 14338, 14523, 14704, 14883, 15058,
00338 15230, 15399, 15565, 15729, 15890, 16049, 16206, 16360,
00339 16512, 16662, 16810, 16957, 17101, 17243, 17384, 17522,
00340 17659, 17795, 17929, 18061, 18192, 18322, 18450, 18577,
00341 18702, 18826, 18949, 19070, 19191, 19310, 19428, 19545,
00342 19661, 19775, 19889, 20002, 20114, 20224, 20334, 20443,
00343 20551, 20658, 20764, 20869, 20974, 21077, 21180, 21282,
00344 21383, 21484, 21584, 21683, 21781, 21878, 21975, 22072,
00345 22167, 22262, 22356, 22450, 22543, 22635, 22727, 22818,
00346 22908, 22998, 23087, 23176, 23265, 23352, 23439, 23526,
00347 23612, 23698, 23783, 23868, 23952, 24035, 24119, 24201,
00348 24284, 24365, 24447, 24528, 24608, 24688, 24768, 24847,
00349 24926, 25004, 25082, 25159, 25237, 25313, 25390, 25466,
00350 25541, 25617, 25692, 25766, 25840, 25914, 25988, 26061,
00351 26134, 26206, 26278, 26350, 26421, 26493, 26563, 26634,
00352 26704, 26774, 26844, 26913, 26982, 27051, 27119, 27187,
00353 27255, 27323, 27390, 27457, 27524, 27590, 27656, 27722,
00354 27788, 27853, 27919, 27983, 28048, 28112, 28177, 28241,
00355 28304, 28368, 28431, 28494, 28556, 28619, 28681, 28743,
00356 28805, 28867, 28928, 28989, 29050, 29111, 29171, 29231,
00357 29291, 29351, 29411, 29470, 29530, 29589, 29647, 29706,
00358 29765, 29823, 29881, 29939, 29996, 30054, 30111, 30168,
00359 30225, 30282, 30339, 30395, 30451, 30507, 30563, 30619,
00360 30674, 30730, 30785, 30840, 30895, 30949, 31004, 31058,
00361 31112, 31166, 31220, 31274, 31327, 31381, 31434, 31487,
00362 31540, 31593, 31645, 31698, 31750, 31802, 31854, 31906,
00363 31958, 32010, 32061, 32112, 32164, 32215, 32265, 32316,
00364 32367, 32417, 32468, 32518, 32568, 32618, 32668, 32717,
00365 32767, 32816, 32866, 32915, 32964, 33013, 33062, 33110,
00366 33159, 33207, 33256, 33304, 33352, 33400, 33448, 33495,
00367 33543, 33590, 33638, 33685, 33732, 33779, 33826, 33873,
00368 33919, 33966, 34013, 34059, 34105, 34151, 34197, 34243,
00369 34289, 34335, 34380, 34426, 34471, 34516, 34562, 34607,
00370 34652, 34697, 34741, 34786, 34831, 34875, 34919, 34964,
00371 35008, 35052, 35096, 35140, 35184, 35227, 35271, 35314,
00372 35358, 35401, 35444, 35488, 35531, 35574, 35617, 35659,
00373 35702, 35745, 35787, 35830, 35872, 35914, 35956, 35998,
00374 36040, 36082, 36124, 36166, 36208, 36249, 36291, 36332,
00375 36373, 36415, 36456, 36497, 36538, 36579, 36620, 36660,
00376 36701, 36742, 36782, 36823, 36863, 36903, 36943, 36984,
00377 37024, 37064, 37104, 37143, 37183, 37223, 37262, 37302,
00378 37342, 37381, 37420, 37459, 37499, 37538, 37577, 37616,
00379 37655, 37693, 37732, 37771, 37810, 37848, 37887, 37925,
00380 37963, 38002, 38040, 38078, 38116, 38154, 38192, 38230,
00381 38268, 38305, 38343, 38381, 38418, 38456, 38493, 38530,
00382 38568, 38605, 38642, 38679, 38716, 38753, 38790, 38827,
00383 38864, 38900, 38937, 38974, 39010, 39047, 39083, 39119,
00384 39156, 39192, 39228, 39264, 39300, 39336, 39372, 39409,
00385 39444, 39480, 39516, 39551, 39588, 39622, 39658, 39693,
00386 39729, 39764, 39799, 39835, 39870, 39905, 39940, 39975,
00387 27253, 29259, 25185, 25954, 26734, 25967, 29798 };
00388 #endif
00389
00390 LH_START_PROC( "XYZ2Lab_forCube16")
00391
00392 v = theCube;
00393
00394 for(i=0; i<count; i++)
00395 {
00396 lon_X = ( long)v[0];
00397 lon_Y = ( long)v[1];
00398 lon_Z = ( long)v[2];
00399
00400
00401
00402 index = lon_Y >> 7;
00403 fract = lon_Y & 0x7F;
00404 if(index < 431)
00405 {
00406 leftVal = Y2L[index];
00407 rightVal = Y2L[index + 1];
00408 lon_Y = leftVal + ((fract * (rightVal - leftVal) + 63) >> 7);
00409 }
00410 else
00411 lon_Y = Y2L[431];
00412
00413
00414
00415 lon_X = 531 * lon_X >> 4;
00416 index = lon_X >> 12;
00417 fract = lon_X & 0x0FFF;
00418 if(index < 431)
00419 {
00420 leftVal = Y2L[index];
00421 rightVal = Y2L[index + 1];
00422 lon_X = leftVal + ((fract * (rightVal - leftVal) + 2047) >> 12);
00423 }
00424 else
00425 lon_X = Y2L[431];
00426
00427 lon_Z = lon_Z * 9931 >> 8;
00428 index = lon_Z >> 12;
00429 fract = lon_Z & 0x0FFF;
00430 if(index < 431)
00431 {
00432 leftVal = Y2L[index];
00433 rightVal = Y2L[index + 1];
00434 lon_Z = leftVal + ((fract * (rightVal - leftVal) + 2047) >> 12);
00435 }
00436 else
00437 lon_Z = Y2L[431];
00438
00439
00440
00441
00442 lon_aOff = ((lon_X - lon_Y) * 431 + 4194368) >> 7;
00443 if(lon_aOff & 0xFFFF0000)
00444 {
00445 if(lon_aOff < 0)
00446 lon_aOff = 0;
00447 else if(lon_aOff > 65535)
00448 lon_aOff = 65535;
00449 }
00450
00451
00452 lon_bOff = ((lon_Y - lon_Z) * 11035 + 268439552) >> 13;
00453 if(lon_bOff & 0xFFFF0000)
00454 {
00455 if(lon_bOff < 0)
00456 lon_bOff = 0;
00457 else if(lon_bOff > 65535)
00458 lon_bOff = 65535;
00459 }
00460
00461 lon_Y <<= 1;
00462 if(lon_Y > 65535)
00463 lon_Y = 65535;
00464
00465 *v++ = ( unsigned short)lon_Y;
00466 *v++ = ( unsigned short)lon_aOff;
00467 *v++ = ( unsigned short)lon_bOff;
00468 }
00469 LH_END_PROC( "XYZ2Lab_forCube16")
00470 }
|