blob: 39cf46328b4326f26820d17fdfbf09e26ef36b2f [file] [log] [blame]
/*
* function: kernel_hdr_lab
* sample code of default kernel arguments
* input: image2d_t as read only
* output: image2d_t as write only
*/
"__constant float table[] = {4.3287616,5.9319224,7.1324205,8.1288157,8.9965763,9.7739191,10.483327,11.139331,11.751958,12.328467,12.874310,13.393700,13.889977,14.365837,14.823494,15.264792,15.691289,16.104307,16.504990,16.894327,17.273184,17.642323,18.002419,18.354071,18.697817,19.034143,19.363485,19.686239,20.002764,20.313389,20.618416,20.918123,21.212763,21.502573,21.787767,22.068552,22.345116,22.617630,22.886259,23.151157,23.412468,23.670324,23.924854,24.176174,24.424398,24.669630,24.911972,25.151518,25.388355,25.622572,25.854246,26.083458,26.310276,26.534771,26.757010,26.977057,27.194969,27.410807,27.624624,27.836473,28.046406,28.254467,28.254467,28.254467,28.254467,28.254467,28.254467,28.254467,28.254467,28.254467,28.377895,28.567524,28.755781,28.942692,29.128284,29.312582,29.495617,29.677410,29.857986,30.037369,30.215582,30.392645,30.568581,30.743410,30.917152,31.089828,31.261454,31.432049,31.601633,31.770222,31.937832,32.104481,32.270180,32.434952,32.598808,32.761761,32.923832,33.085026,33.245361,33.404850,33.563507,33.721340,33.878368,34.034599,34.190044,34.344715,34.498627,34.651783,34.804199,34.955887,35.106853,35.257107,35.406662,35.555523,35.703705,35.851208,35.998051,36.144238,36.289776,36.434673,36.578941,36.722588,36.865616,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.008038,37.013512,37.148350,37.282703,37.416573,37.549969,37.682888,37.815342,37.947330,38.078865,38.209946,38.340580,38.470768,38.600517,38.729836,38.858719,38.987175,39.115215,39.242832,39.370041,39.496838,39.623226,39.749214,39.874802,40,40.124805,40.249222,40.373260,40.496914,40.620193,40.743095,40.865631,40.987804,41.109608,41.231056,41.352146,41.472885,41.593269,41.713306,41.833000,41.952354,42.071369,42.190048,42.308392,42.426407,42.544094,42.661457,42.778500,42.895222,43.011627,43.127716,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.243496,43.315910,43.427536,43.538902,43.650013,43.760872,43.871479,43.981831,44.091938,44.201797,44.311413,44.420780,44.529911,44.638798,44.747448,44.855862,44.964039,45.071983,45.179695,45.287178,45.394428,45.501453,45.608253,45.714825,45.821178,45.927307,46.033215,46.138905,46.244377,46.349632,46.454674,46.559505,46.664120,46.768528,46.872723,46.976711,47.080494,47.184067,47.287441,47.390610,47.493576,47.596344,47.698910,47.801281,47.903454,48.005428,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.107212,48.116840,48.216503,48.316002,48.415333,48.514507,48.613514,48.712364,48.811050,48.909580,49.007950,49.106163,49.204220,49.302116,49.399860,49.497452,49.594887,49.692173,49.789303,49.886284,49.983109,50.079788,50.176319,50.272701,50.368935,50.465023,50.560966,50.656761,50.752411,50.847919,50.943279,51.038502,51.133583,51.228519,51.323318,51.417973,51.512493,51.606873,51.701115,51.795219,51.889191,51.983021,52.076717,52.170280,52.263706,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.357002,52.370274,52.462727,52.555069,52.647293,52.739407,52.831406,52.923294,53.015072,53.106739,53.198296,53.289738,53.381077,53.472301,53.563419,53.654430,53.745327,53.836124,53.926811,54.017391,54.107864,54.198231,54.288494,54.378651,54.468708,54.558655,54.648502,54.738243,54.827885,54.917419,55.006851,55.096188,55.185417,55.274551,55.363579,55.452511,55.541340,55.630070,55.718704,55.807240,55.895676,55.984013,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.072254,56.136337,56.224670,56.312920,56.401089,56.489174,56.577179,56.665100,56.752941,56.840698,56.928371,57.015968,57.103481,57.190918,57.278271,57.365547,57.452744,57.539856,57.626896,57.713852,57.800732,57.887531,57.974255,58.060902,58.147465,58.233959,58.320370,58.406708,58.492970,58.579155,58.665260,58.751289,58.837250,58.923130,59.008938,59.094666,59.180325,59.265907,59.351414,59.436852,59.522209,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.607498,59.676125,59.762394,59.848598,59.934742,60.020828,60.106846,60.192806,60.278702,60.364540,60.450314,60.536030,60.621685,60.707275,60.792812,60.878284,60.963699,61.049049,61.134342,61.219578,61.304752,61.389870,61.474926,61.559925,61.644867,61.729748,61.814568,61.899334,61.984039,62.068687,62.153282,62.237812,62.322292,62.406708,62.491070,62.575375,62.659622,62.743816,62.827950,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.912029,62.940441,63.026379,63.112267,63.198112,63.283909,63.369659,63.455360,63.541019,63.626637,63.712200,63.797718,63.883190,63.968624,64.054001,64.139343,64.224632,64.309875,64.395081,64.480240,64.565346,64.650414,64.735435,64.820412,64.905342,64.990234,65.075073,65.159874,65.244629,65.329346,65.414009,65.498634,65.583214,65.667747,65.752243,65.836693,65.921097,66.005463,66.089783,66.174057,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.258286,66.291786,66.378784,66.465752,66.552689,66.639587,66.726456,66.813293,66.900085,66.986855,67.073586,67.160286,67.246948,67.333572,67.420174,67.506737,67.593269,67.679764,67.766228,67.852654,67.939056,68.025421,68.111755,68.198051,68.284325,68.370560,68.456757,68.542923,68.629059,68.715164,68.801239,68.887276,68.973282,69.059258,69.145203,69.231110,69.316986,69.402832,69.488655,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.574432,69.659309,69.748878,69.838425,69.927956,70.017456,70.106934,70.196388,70.285820,70.375237,70.464622,70.553986,70.643333,70.732658,70.821953,70.911224,71.000481,71.089706,71.178917,71.268105,71.357262,71.446404,71.535530,71.624619,71.713692,71.802750,71.891777,71.980789,72.069771,72.158737,72.247673,72.336594,72.425499,72.514374,72.603226,72.692062,72.780876,72.869659,72.958427,73.047173,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.135902,73.151604,73.245392,73.339172,73.432938,73.526695,73.620430,73.714165,73.807884,73.901588,73.995285,74.088966,74.182640,74.276299,74.369942,74.463577,74.557198,74.650818,74.744415,74.838005,74.931580,75.025139,75.118698,75.212242,75.305771,75.399284,75.492798,75.586296,75.679771,75.773247,75.866707,75.960159,76.053596,76.147018,76.240433,76.333839,76.427231,76.520615,76.613983,76.707336,76.800690,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.894020,76.900002,77,77.100006,77.200005,77.300003,77.400002,77.500000,77.600006,77.700005,77.800003,77.900002,78,78.099998,78.199997,78.300003,78.400002,78.500000,78.599998,78.699997,78.799995,78.899994,79,79.099998,79.199997,79.299995,79.400002,79.500000,79.599998,79.699997,79.799995,79.900002,80,80.099998,80.199997,80.299995,80.400002,80.500000,80.599998,80.699997,80.800003,80.900002,81,81.099998,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.199997,81.299294,81.408134,81.516991,81.625862,81.734749,81.843643,81.952560,82.061493,82.170433,82.279388,82.388359,82.497353,82.606354,82.715363,82.824394,82.933441,83.042496,83.151573,83.260658,83.369759,83.478874,83.588005,83.697151,83.806305,83.915474,84.024666,84.133865,84.243080,84.352310,84.461555,84.570816,84.680084,84.789368,84.898666,85.007988,85.117310,85.226654,85.336006,85.445374,85.554764,85.664162,85.773575,85.882996,85.992439,86.101898,86.211365,86.320839,86.430336,86.539848,86.649376,86.758911,86.868454,86.978027,87.087608,87.197197,87.306801,87.416420,87.526054,87.635704,87.745361,87.855034,87.964722,88.074432,88.184143,88.293877,88.403618,88.513374,88.623146,88.732933,88.842728,88.952538,89.062363,89.172203,89.282051,89.391914,89.501793,89.611694,89.721596,89.831512,89.941444,90.051399,90.161354,90.271324,90.381310,90.491310,90.601326,90.711349,90.821388,90.931442,91.041512,91.151596,91.261681,91.371788,91.481911,91.592049,91.702187,91.812347,91.922516,92.032707,92.142906,92.253120,92.363342,92.473579,92.583839,92.694099,92.804375,92.914665,93.024971,93.135292,93.245621,93.355965,93.466316,93.576683,93.687073,93.797470,93.907875,94.018295,94.128731,94.239182,94.349640,94.460106,94.570595,94.681099,94.791611,94.902130,95.012665,95.123215,95.233788,95.344360,95.454948,95.565552,95.676170,95.786797,95.897430,96.008087,96.118752,96.229431,96.340126,96.450829,96.561539,96.672272,96.783012,96.893768,97.004532,97.115311,97.226112,97.336914,97.447731,97.558563,97.669403,97.780266,97.891129,98.002007,98.112900,98.223816,98.334732,98.445656,98.556602,98.667557,98.778526,98.889511,99.000504,99.111504,99.222519,99.333557,99.444603,99.555656,99.666718,99.777809,99.888893,100}; "
"static float fun(float in) "
"{ "
" if(in > 0.008856) "
" return pow(in,1.0/3); "
" else "
" return (float)(7.787*in + 16.0/116); "
"} "
"__kernel void kernel_hdr_lab (__read_only image2d_t input, __write_only image2d_t output) "
"{ "
" int x = get_global_id (0); "
" int y = get_global_id (1); "
" sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST; "
" float4 pixel_in,pixel_out; "
" unsigned int table_id;"
" pixel_in = read_imagef(input, sampler, (int2)(x,y)); "
" float X,Y,Z,L,a,b; "
" X = 0.412453*pixel_in.x + 0.357580*pixel_in.y + 0.180423*pixel_in.z; "
" Y = 0.212671*pixel_in.x + 0.715160*pixel_in.y + 0.072169*pixel_in.z; "
" Z = 0.019334*pixel_in.x + 0.119193*pixel_in.y + 0.950227*pixel_in.z; "
" if(Y > 0.008856) "
" L = 116.0*(pow(Y,1.0/3)) -16.0; "
" else "
" L = 903.3*Y; "
" a = 500*(fun(X) - fun(Y)); "
" b = 200*(fun(Y) - fun(Z)); "
" table_id = (unsigned int)(L*10) <1000 ? (unsigned int)(L*10) : 999; "
" L = table[table_id]; "
" float fX,fY,fZ; "
" Y = pow(L/116.0, 3.0); "
" if (Y < 0.008856) "
" Y = L/903.3; "
" if (Y > 0.008856) "
" fY = pow(Y, 1.0/3.0); "
" else "
" fY = 7.787*Y + 16.0/116.0; "
" fX = a / 500.0 + fY; "
" X = pow(fX, 3.0); "
" if(X < 0.008865) "
" X = (fX - 16.0/116.0) / 7.787; "
" fZ = fY - b /200.0; "
" Z = pow(fZ, 3.0); "
" if(Z < 0.008865) "
" Z = (fZ - 16.0/116.0) / 7.787; "
" pixel_out.x = 3.240479*X - 1.537150*Y - 0.498535*Z; "
" pixel_out.y = -0.969256*X + 1.875992*Y + 0.041556*Z; "
" pixel_out.z = 0.055648*X - 0.204043*Y + 1.204043*Z; "
" pixel_out.w = pixel_in.w; "
" write_imagef(output, (int2)(x,y), pixel_out); "
"} "