aboutsummaryrefslogblamecommitdiffstats
path: root/libcolour.h
blob: 51dfaa82c8f66bb63a47a4fd566c0f7acbca0b6b (plain) (tree)


















                                                                                                        
                                                                                                            








                                                                                                                    
                                                                  



















                                                                                                                      
                                                                    



















                                                                                                                        
                                                                      




















                                                                                                                              
                                                                            



















                                                                                                                                
                                                                              



















                                                                                                                                  
                                                                                














































                                                                                                                                  















                                                 








                                           
                                                                     
                                       
                                                                     
                                        
                                                                       
                                      
                                                                     




                                                            
                                                                                                               
                                                      
                                                                                                   
                                                          
                                                                                                           
                                        
                                                                       
                                             
                                                                                 
                                             
                                                                                 
                                            
                                                                               
                                            
                                                                               
                                             
                                                                                 
                                           
                                                                             
                                                  
                                                                                           
                                              
                                                                                   
                                                  
                                                                                           
                                             
                                                                                 
                                           
                                                                             
                                              
                                                                                   
                                                  
                                                                                           
                                                         
                                                                                                         
                                                         
                                                                                                         
                                                
                                                                                       
                                                 
                                                                                         
                                                         
                                                                                                         
                                                         
                                                                                                         
                                                         
                                                                                                         
                                                          
                                                                                                           
                                                          
                                                                                                           
                                                          
                                                                                                           
                                                 
                                                                                         
                                            
                                                                               
                                                 
                                                                                         
                                                
                                                                                       
                                           
                                                                             
                                                  
                                                                                           
                                               
                                                                                     
                                                 
                                                                                           


                               















                                                                                     









































































































                                                    



















                                                        

























                                                                                                                       


                                                                                                                   
























                                                                   


                                                                                  













                                                                                                    








                                                                                               



                                                                                    
 




































                                                                                           








                                            
/* See LICENSE file for copyright and license details. */
#ifndef LIBCOLOUR_H
#define LIBCOLOUR_H

#include <stddef.h>


#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wpadded"
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wpadded"
#endif


#define LIBCOLOUR_ILL__(S, T, X_, Y_) (S){.model = LIBCOLOUR_CIEXYY, .x = (T)(X_), .y = (T)(Y_), .Y = 1}
#define LIBCOLOUR_F__(X_, Y_)         LIBCOLOUR_ILL__(libcolour_ciexyy_f_t, float, (X_), (Y_))
#define LIBCOLOUR_LF__(X_, Y_)        LIBCOLOUR_ILL__(libcolour_ciexyy_lf_t, double, (X_), (Y_))
#define LIBCOLOUR_LLF__(X_, Y_)       LIBCOLOUR_ILL__(libcolour_ciexyy_llf_t, long double, (X_##L), (Y_##L))

/* 2-degrees observer standard illuminants */
#define LIBCOLOUR_ILLUMINANT_A_F   LIBCOLOUR_F__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
#define LIBCOLOUR_ILLUMINANT_B_F   LIBCOLOUR_F__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
#define LIBCOLOUR_ILLUMINANT_C_F   LIBCOLOUR_F__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
#define LIBCOLOUR_ILLUMINANT_D50_F LIBCOLOUR_F__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
#define LIBCOLOUR_ILLUMINANT_D55_F LIBCOLOUR_F__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
#define LIBCOLOUR_ILLUMINANT_D65_F LIBCOLOUR_F__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
#define LIBCOLOUR_ILLUMINANT_D75_F LIBCOLOUR_F__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
#define LIBCOLOUR_ILLUMINANT_E_F   LIBCOLOUR_F__(1. / 3., 1. / 3.)
#define LIBCOLOUR_ILLUMINANT_F1_F  LIBCOLOUR_F__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
#define LIBCOLOUR_ILLUMINANT_F2_F  LIBCOLOUR_F__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
#define LIBCOLOUR_ILLUMINANT_F3_F  LIBCOLOUR_F__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
#define LIBCOLOUR_ILLUMINANT_F4_F  LIBCOLOUR_F__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
#define LIBCOLOUR_ILLUMINANT_F5_F  LIBCOLOUR_F__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
#define LIBCOLOUR_ILLUMINANT_F6_F  LIBCOLOUR_F__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
#define LIBCOLOUR_ILLUMINANT_F7_F  LIBCOLOUR_F__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
#define LIBCOLOUR_ILLUMINANT_F8_F  LIBCOLOUR_F__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
#define LIBCOLOUR_ILLUMINANT_F9_F  LIBCOLOUR_F__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
#define LIBCOLOUR_ILLUMINANT_F10_F LIBCOLOUR_F__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
#define LIBCOLOUR_ILLUMINANT_F11_F LIBCOLOUR_F__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
#define LIBCOLOUR_ILLUMINANT_F12_F LIBCOLOUR_F__(0.437023901312296902954557253906, 0.404214327891585678553809657387)

#define LIBCOLOUR_ILLUMINANT_A_LF   LIBCOLOUR_LF__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
#define LIBCOLOUR_ILLUMINANT_B_LF   LIBCOLOUR_LF__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
#define LIBCOLOUR_ILLUMINANT_C_LF   LIBCOLOUR_LF__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
#define LIBCOLOUR_ILLUMINANT_D50_LF LIBCOLOUR_LF__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
#define LIBCOLOUR_ILLUMINANT_D55_LF LIBCOLOUR_LF__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
#define LIBCOLOUR_ILLUMINANT_D65_LF LIBCOLOUR_LF__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
#define LIBCOLOUR_ILLUMINANT_D75_LF LIBCOLOUR_LF__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
#define LIBCOLOUR_ILLUMINANT_E_LF   LIBCOLOUR_LF__(1. / 3., 1. / 3.)
#define LIBCOLOUR_ILLUMINANT_F1_LF  LIBCOLOUR_LF__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
#define LIBCOLOUR_ILLUMINANT_F2_LF  LIBCOLOUR_LF__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
#define LIBCOLOUR_ILLUMINANT_F3_LF  LIBCOLOUR_LF__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
#define LIBCOLOUR_ILLUMINANT_F4_LF  LIBCOLOUR_LF__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
#define LIBCOLOUR_ILLUMINANT_F5_LF  LIBCOLOUR_LF__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
#define LIBCOLOUR_ILLUMINANT_F6_LF  LIBCOLOUR_LF__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
#define LIBCOLOUR_ILLUMINANT_F7_LF  LIBCOLOUR_LF__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
#define LIBCOLOUR_ILLUMINANT_F8_LF  LIBCOLOUR_LF__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
#define LIBCOLOUR_ILLUMINANT_F9_LF  LIBCOLOUR_LF__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
#define LIBCOLOUR_ILLUMINANT_F10_LF LIBCOLOUR_LF__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
#define LIBCOLOUR_ILLUMINANT_F11_LF LIBCOLOUR_LF__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
#define LIBCOLOUR_ILLUMINANT_F12_LF LIBCOLOUR_LF__(0.437023901312296902954557253906, 0.404214327891585678553809657387)

#define LIBCOLOUR_ILLUMINANT_A_LLF   LIBCOLOUR_LLF__(0.447573514098910552050369915378, 0.407439444306660847328060981454)
#define LIBCOLOUR_ILLUMINANT_B_LLF   LIBCOLOUR_LLF__(0.348407693041403399014654951316, 0.351617234807268863594487129376)
#define LIBCOLOUR_ILLUMINANT_C_LLF   LIBCOLOUR_LLF__(0.310058473730255412803558101587, 0.316149707523236456196968902077)
#define LIBCOLOUR_ILLUMINANT_D50_LLF LIBCOLOUR_LLF__(0.345668037029273123028616510055, 0.358496838937619077825047497754)
#define LIBCOLOUR_ILLUMINANT_D55_LLF LIBCOLOUR_LLF__(0.332424102468830251488896010414, 0.347428039087666229445261478759)
#define LIBCOLOUR_ILLUMINANT_D65_LLF LIBCOLOUR_LLF__(0.312726871026564878786047074755, 0.329023206641284038376227272238)
#define LIBCOLOUR_ILLUMINANT_D75_LLF LIBCOLOUR_LLF__(0.299022300412497055166483050925, 0.314852737888341893679466920730)
#define LIBCOLOUR_ILLUMINANT_E_LLF   LIBCOLOUR_LLF__(1. / 3., 1. / 3.)
#define LIBCOLOUR_ILLUMINANT_F1_LLF  LIBCOLOUR_LLF__(0.313062433035651010992950205036, 0.337106477918307445573731229160)
#define LIBCOLOUR_ILLUMINANT_F2_LLF  LIBCOLOUR_LLF__(0.372068154452825539113547392844, 0.375122558203110079144693145281)
#define LIBCOLOUR_ILLUMINANT_F3_LLF  LIBCOLOUR_LLF__(0.409090035308107391465171076561, 0.394117134255365986206243178458)
#define LIBCOLOUR_ILLUMINANT_F4_LLF  LIBCOLOUR_LLF__(0.440181095827666568620628595454, 0.403090691158138336724903183494)
#define LIBCOLOUR_ILLUMINANT_F5_LLF  LIBCOLOUR_LLF__(0.313756583095696484075887155996, 0.345160794752101929283583103825)
#define LIBCOLOUR_ILLUMINANT_F6_LLF  LIBCOLOUR_LLF__(0.377882361062687466279896852939, 0.388192885537868959122675960316)
#define LIBCOLOUR_ILLUMINANT_F7_LLF  LIBCOLOUR_LLF__(0.312852472915475354753311876266, 0.329174178033567632617462095368)
#define LIBCOLOUR_ILLUMINANT_F8_LLF  LIBCOLOUR_LLF__(0.345805753550315952971061506105, 0.358617583214377477762724311106)
#define LIBCOLOUR_ILLUMINANT_F9_LLF  LIBCOLOUR_LLF__(0.374105245592801061160770359493, 0.372672400924498159469067104510)
#define LIBCOLOUR_ILLUMINANT_F10_LLF LIBCOLOUR_LLF__(0.346086913993929323751785886998, 0.358751605952200347537939251197)
#define LIBCOLOUR_ILLUMINANT_F11_LLF LIBCOLOUR_LLF__(0.380537485483030235577928124258, 0.376915309293930078649026427229)
#define LIBCOLOUR_ILLUMINANT_F12_LLF LIBCOLOUR_LLF__(0.437023901312296902954557253906, 0.404214327891585678553809657387)

/* 10-degrees observer standard illuminants */
#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS_F   LIBCOLOUR_F__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS_F   LIBCOLOUR_F__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS_F   LIBCOLOUR_F__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS_F LIBCOLOUR_F__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS_F LIBCOLOUR_F__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS_F LIBCOLOUR_F__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS_F LIBCOLOUR_F__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS_F   LIBCOLOUR_F__(1. / 3., 1. / 3.)
#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS_F  LIBCOLOUR_F__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS_F  LIBCOLOUR_F__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS_F  LIBCOLOUR_F__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS_F  LIBCOLOUR_F__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS_F  LIBCOLOUR_F__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS_F  LIBCOLOUR_F__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS_F  LIBCOLOUR_F__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS_F  LIBCOLOUR_F__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS_F  LIBCOLOUR_F__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS_F LIBCOLOUR_F__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS_F LIBCOLOUR_F__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS_F LIBCOLOUR_F__(0.442654456042513022584472537346, 0.397060737666593277506166259627)

#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS_LF   LIBCOLOUR_LF__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS_LF   LIBCOLOUR_LF__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS_LF   LIBCOLOUR_LF__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS_LF LIBCOLOUR_LF__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS_LF LIBCOLOUR_LF__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS_LF LIBCOLOUR_LF__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS_LF LIBCOLOUR_LF__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS_LF   LIBCOLOUR_LF__(1. / 3., 1. / 3.)
#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS_LF  LIBCOLOUR_LF__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS_LF  LIBCOLOUR_LF__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS_LF  LIBCOLOUR_LF__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS_LF  LIBCOLOUR_LF__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS_LF  LIBCOLOUR_LF__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS_LF  LIBCOLOUR_LF__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS_LF  LIBCOLOUR_LF__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS_LF  LIBCOLOUR_LF__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS_LF  LIBCOLOUR_LF__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS_LF LIBCOLOUR_LF__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS_LF LIBCOLOUR_LF__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS_LF LIBCOLOUR_LF__(0.442654456042513022584472537346, 0.397060737666593277506166259627)

#define LIBCOLOUR_ILLUMINANT_A_10DEG_OBS_LLF   LIBCOLOUR_LLF__(0.451173939693730152722395132514, 0.405936604212625562482230634487)
#define LIBCOLOUR_ILLUMINANT_B_10DEG_OBS_LLF   LIBCOLOUR_LLF__(0.349819801494100579564161535018, 0.352687989927865819250740742063)
#define LIBCOLOUR_ILLUMINANT_C_10DEG_OBS_LLF   LIBCOLOUR_LLF__(0.310388663270034004248998371622, 0.319050711366790695766582075521)
#define LIBCOLOUR_ILLUMINANT_D50_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.347729429961154856698613002663, 0.359522508516545380441442603114)
#define LIBCOLOUR_ILLUMINANT_D55_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.334116336430253457745465084372, 0.348766090975953568786849245953)
#define LIBCOLOUR_ILLUMINANT_D65_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.313823646938709621689866935412, 0.330998985489933561510156323493)
#define LIBCOLOUR_ILLUMINANT_D75_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.299679971345752860223399238748, 0.317403239854836705102769656150)
#define LIBCOLOUR_ILLUMINANT_E_10DEG_OBS_LLF   LIBCOLOUR_LLF__(1. / 3., 1. / 3.)
#define LIBCOLOUR_ILLUMINANT_F1_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.318098801070991199502202562144, 0.335489451474129951602520804954)
#define LIBCOLOUR_ILLUMINANT_F2_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.379274832262508854174853922814, 0.367227934400669309145115448700)
#define LIBCOLOUR_ILLUMINANT_F3_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.417644682102624287267644831445, 0.383124504918675723441623404142)
#define LIBCOLOUR_ILLUMINANT_F4_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.449247699162001246087072559021, 0.390605475879083674506375700730)
#define LIBCOLOUR_ILLUMINANT_F5_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.319739939104951298443069163113, 0.342367055369128092667807550242)
#define LIBCOLOUR_ILLUMINANT_F6_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.386626908526034762658696308790, 0.378372201588893453116924092683)
#define LIBCOLOUR_ILLUMINANT_F7_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.315645637312390425766039925293, 0.329508145132134222521358424274)
#define LIBCOLOUR_ILLUMINANT_F8_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.348965563721531868424108324689, 0.359317299140994528272585739614)
#define LIBCOLOUR_ILLUMINANT_F9_10DEG_OBS_LLF  LIBCOLOUR_LLF__(0.378258900384649654480284652891, 0.370371375730762564248976786985)
#define LIBCOLOUR_ILLUMINANT_F10_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.350893389986753234666139178444, 0.354302210111646531665030579461)
#define LIBCOLOUR_ILLUMINANT_F11_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.385435391037903751776383387551, 0.371094786781121399599214782938)
#define LIBCOLOUR_ILLUMINANT_F12_10DEG_OBS_LLF LIBCOLOUR_LLF__(0.442654456042513022584472537346, 0.397060737666593277506166259627)


#define LIBCOLOUR_LIST_MODELS_N(_, RES, ...)\
	_(LIBCOLOUR_RGB,        libcolour_rgb_##RES##_t,        rgb,        __VA_ARGS__)\
	_(LIBCOLOUR_SRGB,       libcolour_srgb_##RES##_t,       srgb,       __VA_ARGS__)\
	_(LIBCOLOUR_CIEXYY,     libcolour_ciexyy_##RES##_t,     ciexyy,     __VA_ARGS__)\
	_(LIBCOLOUR_CIEXYZ,     libcolour_ciexyz_##RES##_t,     ciexyz,     __VA_ARGS__)\
	_(LIBCOLOUR_CIELAB,     libcolour_cielab_##RES##_t,     cielab,     __VA_ARGS__)\
	_(LIBCOLOUR_CIELUV,     libcolour_cieluv_##RES##_t,     cieluv,     __VA_ARGS__)\
	_(LIBCOLOUR_CIELCHUV,   libcolour_cielchuv_##RES##_t,   cielchuv,   __VA_ARGS__)\
	_(LIBCOLOUR_YIQ,        libcolour_yiq_##RES##_t,        yiq,        __VA_ARGS__)\
	_(LIBCOLOUR_YDBDR,      libcolour_ydbdr_##RES##_t,      ydbdr,      __VA_ARGS__)\
	_(LIBCOLOUR_YUV,        libcolour_yuv_##RES##_t,        yuv,        __VA_ARGS__)\
	_(LIBCOLOUR_YPBPR,      libcolour_ypbpr_##RES##_t,      ypbpr,      __VA_ARGS__)\
	_(LIBCOLOUR_YCGCO,      libcolour_ycgco_##RES##_t,      ycgco,      __VA_ARGS__)\
	_(LIBCOLOUR_CIE1960UCS, libcolour_cie1960ucs_##RES##_t, cie1960ucs, __VA_ARGS__)\
	_(LIBCOLOUR_CIEUVW,     libcolour_cieuvw_##RES##_t,     cieuvw,     __VA_ARGS__)

#define LIBCOLOUR_LIST_MODELS(_, RES)\
	_(LIBCOLOUR_RGB,        libcolour_rgb_##RES##_t,        rgb)\
	_(LIBCOLOUR_SRGB,       libcolour_srgb_##RES##_t,       srgb)\
	_(LIBCOLOUR_CIEXYY,     libcolour_ciexyy_##RES##_t,     ciexyy)\
	_(LIBCOLOUR_CIEXYZ,     libcolour_ciexyz_##RES##_t,     ciexyz)\
	_(LIBCOLOUR_CIELAB,     libcolour_cielab_##RES##_t,     cielab)\
	_(LIBCOLOUR_CIELUV,     libcolour_cieluv_##RES##_t,     cieluv)\
	_(LIBCOLOUR_CIELCHUV,   libcolour_cielchuv_##RES##_t,   cielchuv)\
	_(LIBCOLOUR_YIQ,        libcolour_yiq_##RES##_t,        yiq)\
	_(LIBCOLOUR_YDBDR,      libcolour_ydbdr_##RES##_t,      ydbdr)\
	_(LIBCOLOUR_YUV,        libcolour_yuv_##RES##_t,        yuv)\
	_(LIBCOLOUR_YPBPR,      libcolour_ypbpr_##RES##_t,      ypbpr)\
	_(LIBCOLOUR_YCGCO,      libcolour_ycgco_##RES##_t,      ycgco)\
	_(LIBCOLOUR_CIE1960UCS, libcolour_cie1960ucs_##RES##_t, cie1960ucs)\
	_(LIBCOLOUR_CIEUVW,     libcolour_cieuvw_##RES##_t,     cieuvw)


#define LIBCOLOUR_RGB LIBCOLOUR_RGB
#define LIBCOLOUR_SRGB LIBCOLOUR_SRGB
#define LIBCOLOUR_CIEXYY LIBCOLOUR_CIEXYY
#define LIBCOLOUR_CIEXYZ LIBCOLOUR_CIEXYZ
#define LIBCOLOUR_CIELAB LIBCOLOUR_CIELAB
#define LIBCOLOUR_CIELUV LIBCOLOUR_CIELUV
#define LIBCOLOUR_CIELCHUV LIBCOLOUR_CIELCHUV
#define LIBCOLOUR_YIQ LIBCOLOUR_YIQ
#define LIBCOLOUR_YDBDR LIBCOLOUR_YDBDR
#define LIBCOLOUR_YUV LIBCOLOUR_YUV
#define LIBCOLOUR_YPBPR LIBCOLOUR_YPBPR
#define LIBCOLOUR_YCGCO LIBCOLOUR_YCGCO
#define LIBCOLOUR_CIE1960UCS LIBCOLOUR_CIE1960UCS
#define LIBCOLOUR_CIEUVW LIBCOLOUR_CIEUVW


typedef enum libcolour_model {
#define LIBCOLOUR_X(C, T, N) C,
	LIBCOLOUR_LIST_MODELS(LIBCOLOUR_X,)
#undef LIBCOLOUR_X
} libcolour_model_t;


typedef enum libcolour_encoding_type {
	LIBCOLOUR_ENCODING_TYPE_LINEAR,
#define LIBCOLOUR_ENCODING_TYPE_LINEAR LIBCOLOUR_ENCODING_TYPE_LINEAR
	LIBCOLOUR_ENCODING_TYPE_SIMPLE,
#define LIBCOLOUR_ENCODING_TYPE_SIMPLE LIBCOLOUR_ENCODING_TYPE_SIMPLE
	LIBCOLOUR_ENCODING_TYPE_REGULAR,
#define LIBCOLOUR_ENCODING_TYPE_REGULAR LIBCOLOUR_ENCODING_TYPE_REGULAR
	LIBCOLOUR_ENCODING_TYPE_CUSTOM
#define LIBCOLOUR_ENCODING_TYPE_CUSTOM LIBCOLOUR_ENCODING_TYPE_CUSTOM
} libcolour_encoding_type_t;


typedef enum libcolour_rgb_colour_space {
	LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS,
#define LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MEASUREMENTS
	LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX,
#define LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_MATRIX
	LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX,
#define LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX LIBCOLOUR_RGB_COLOUR_SPACE_CUSTOM_FROM_INV_MATRIX
	LIBCOLOUR_RGB_COLOUR_SPACE_SRGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_SRGB LIBCOLOUR_RGB_COLOUR_SPACE_SRGB
	LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB LIBCOLOUR_RGB_COLOUR_SPACE_ADOBE_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB LIBCOLOUR_RGB_COLOUR_SPACE_APPLE_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB LIBCOLOUR_RGB_COLOUR_SPACE_BEST_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB LIBCOLOUR_RGB_COLOUR_SPACE_BETA_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB LIBCOLOUR_RGB_COLOUR_SPACE_BRUCE_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB LIBCOLOUR_RGB_COLOUR_SPACE_CIE_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB LIBCOLOUR_RGB_COLOUR_SPACE_COLORMATCH_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65,
#define LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65 LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_D65
	LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER,
#define LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER LIBCOLOUR_RGB_COLOUR_SPACE_DCI_P3_THEATER
	LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4,
#define LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4 LIBCOLOUR_RGB_COLOUR_SPACE_DON_RGB_4
	LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2 LIBCOLOUR_RGB_COLOUR_SPACE_ECI_RGB_V2
	LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5,
#define LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5 LIBCOLOUR_RGB_COLOUR_SPACE_EKTA_SPACE_PS5
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_625_LINE
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_601_525_LINE
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709 LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_709
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020 LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2020
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_PQ
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_PQ
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_PQ
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_EOTF_HLG
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OOTF_HLG
	LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG,
#define LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG LIBCOLOUR_RGB_COLOUR_SPACE_ITU_R_BT_2100_OETF_HLG
	LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB LIBCOLOUR_RGB_COLOUR_SPACE_LIGHTROOM_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB LIBCOLOUR_RGB_COLOUR_SPACE_NTSC_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB LIBCOLOUR_RGB_COLOUR_SPACE_PAL_SECAM_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB LIBCOLOUR_RGB_COLOUR_SPACE_PROPHOTO_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB LIBCOLOUR_RGB_COLOUR_SPACE_SGI_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_240M_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB,
#define LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB LIBCOLOUR_RGB_COLOUR_SPACE_SMPTE_C_RGB
	LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB
#define LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB LIBCOLOUR_RGB_COLOUR_SPACE_WIDE_GAMUT_RGB
} libcolour_rgb_colour_space_t;


typedef enum libcolour_convert_en_masse_mode {
	LIBCOLOUR_CONVERT_EN_MASSE_NO_ALPHA    = 0x0000,
#define LIBCOLOUR_CONVERT_EN_MASSE_NO_ALPHA LIBCOLOUR_CONVERT_EN_MASSE_NO_ALPHA
	LIBCOLOUR_CONVERT_EN_MASSE_ALPHA_FIRST = 0x0001,
#define LIBCOLOUR_CONVERT_EN_MASSE_ALPHA_FIRST LIBCOLOUR_CONVERT_EN_MASSE_ALPHA_FIRST
	LIBCOLOUR_CONVERT_EN_MASSE_ALPHA_LAST  = 0x0002,
#define LIBCOLOUR_CONVERT_EN_MASSE_ALPHA_LAST LIBCOLOUR_CONVERT_EN_MASSE_ALPHA_LAST
	LIBCOLOUR_CONVERT_EN_MASSE_SEPARATED   = 0x0003,
#define LIBCOLOUR_CONVERT_EN_MASSE_SEPARATED LIBCOLOUR_CONVERT_EN_MASSE_SEPARATED
	LIBCOLOUR_CONVERT_EN_MASSE_ON_CPU      = 0x0004,
#define LIBCOLOUR_CONVERT_EN_MASSE_ON_CPU LIBCOLOUR_CONVERT_EN_MASSE_ON_CPU
	LIBCOLOUR_CONVERT_EN_MASSE_NO_OVERRIDE = 0x0008
#define LIBCOLOUR_CONVERT_EN_MASSE_NO_OVERRIDE LIBCOLOUR_CONVERT_EN_MASSE_NO_OVERRIDE
} libcolour_convert_en_masse_mode_t;


#define LIBCOLOUR_X(C, T, N) T N;
#define LIBCOLOUR_DEF(TYPE, RES) \
typedef struct libcolour_srgb_##RES {\
	enum libcolour_model model;\
	TYPE R;\
	TYPE G;\
	TYPE B;\
	int with_transfer;\
} libcolour_srgb_##RES##_t;\
\
typedef struct libcolour_ciexyy_##RES {\
	enum libcolour_model model;\
	TYPE x;\
	TYPE y;\
	TYPE Y;\
} libcolour_ciexyy_##RES##_t;\
\
typedef struct libcolour_ciexyz_##RES {\
	enum libcolour_model model;\
	TYPE X;\
	TYPE Y;\
	TYPE Z;\
} libcolour_ciexyz_##RES##_t;\
\
typedef struct libcolour_cielab_##RES {\
	enum libcolour_model model;\
	TYPE L;\
	TYPE a;\
	TYPE b;\
} libcolour_cielab_##RES##_t;\
\
typedef struct libcolour_yiq_##RES {\
	enum libcolour_model model;\
	TYPE Y;\
	TYPE I;\
	TYPE Q;\
} libcolour_yiq_##RES##_t;\
\
typedef struct libcolour_ydbdr_##RES {\
	enum libcolour_model model;\
	TYPE Y;\
	TYPE Db;\
	TYPE Dr;\
} libcolour_ydbdr_##RES##_t;\
\
typedef struct libcolour_yuv_##RES {\
	enum libcolour_model model;\
	TYPE Y;\
	TYPE U;\
	TYPE V;\
} libcolour_yuv_##RES##_t;\
\
typedef struct libcolour_ypbpr_##RES {\
	enum libcolour_model model;\
	TYPE Y;\
	TYPE Pb;\
	TYPE Pr;\
} libcolour_ypbpr_##RES##_t;\
\
typedef struct libcolour_ycgco_##RES {\
	enum libcolour_model model;\
	TYPE Y;\
	TYPE Cg;\
	TYPE Co;\
} libcolour_ycgco_##RES##_t;\
\
typedef struct libcolour_cie1960ucs_##RES {\
	enum libcolour_model model;\
	TYPE u;\
	TYPE v;\
	TYPE Y;\
} libcolour_cie1960ucs_##RES##_t;\
\
typedef struct libcolour_cieuvw_##RES {\
	enum libcolour_model model;\
	TYPE U;\
	TYPE V;\
	TYPE W;\
	TYPE u0;\
	TYPE v0;\
} libcolour_cieuvw_##RES##_t;\
\
typedef struct libcolour_cieluv_##RES {\
	enum libcolour_model model;\
	TYPE L;\
	TYPE u;\
	TYPE v;\
	struct libcolour_ciexyz_##RES white;\
} libcolour_cieluv_##RES##_t;\
\
typedef struct libcolour_cielchuv_##RES {\
	enum libcolour_model model;\
	TYPE L;\
	TYPE C;\
	TYPE h;\
	struct libcolour_ciexyz_##RES white;\
	TYPE one_revolution;\
} libcolour_cielchuv_##RES##_t;\
\
typedef struct libcolour_rgb_##RES {\
	enum libcolour_model model;\
	TYPE R;\
	TYPE G;\
	TYPE B;\
	int with_transfer;\
	enum libcolour_encoding_type encoding_type;\
	union {\
		struct {\
			TYPE gamma;\
		} simple;\
		struct {\
			TYPE gamma;\
			TYPE offset;\
			TYPE slope;\
			TYPE transition;\
			TYPE transitioninv;\
		} regular;\
		struct {\
			TYPE (*to_encoded_red)(TYPE);\
			TYPE (*to_decoded_red)(TYPE);\
			TYPE (*to_encoded_green)(TYPE);\
			TYPE (*to_decoded_green)(TYPE);\
			TYPE (*to_encoded_blue)(TYPE);\
			TYPE (*to_decoded_blue)(TYPE);\
		} custom;\
	} transfer;\
	struct libcolour_ciexyy_##RES red;\
	struct libcolour_ciexyy_##RES green;\
	struct libcolour_ciexyy_##RES blue;\
	struct libcolour_ciexyy_##RES white;\
	TYPE white_r;\
	TYPE white_g;\
	TYPE white_b;\
	TYPE M[3][3];\
	TYPE Minv[3][3];\
	enum libcolour_rgb_colour_space colour_space;\
} libcolour_rgb_##RES##_t;\
\
\
typedef union libcolour_colour_##RES {\
	enum libcolour_model model;\
	LIBCOLOUR_LIST_MODELS(LIBCOLOUR_X, RES)\
} libcolour_colour_##RES##_t;\
\
\
int libcolour_convert_##RES(const libcolour_colour_##RES##_t *restrict from, libcolour_colour_##RES##_t *restrict to);\
TYPE libcolour_srgb_encode_##RES(TYPE);\
TYPE libcolour_srgb_decode_##RES(TYPE);\
int libcolour_delta_e_##RES(const libcolour_colour_##RES##_t *, const libcolour_colour_##RES##_t *, TYPE *);\
int libcolour_proper_##RES(libcolour_colour_##RES##_t *);\
int libcolour_get_rgb_colour_space_##RES(libcolour_rgb_##RES##_t *, libcolour_rgb_colour_space_t);\
size_t libcolour_marshal_##RES(const libcolour_colour_##RES##_t *, void *);\
size_t libcolour_unmarshal_##RES(libcolour_colour_##RES##_t *, const void *);\
int libcolour_convert_en_masse_##RES(const libcolour_colour_##RES##_t *from, const libcolour_colour_##RES##_t *to,\
                                     libcolour_convert_en_masse_mode_t mode, size_t n, ...);

LIBCOLOUR_DEF(float, f)
LIBCOLOUR_DEF(double, lf)
LIBCOLOUR_DEF(long double, llf)

#undef LIBCOLOUR_DEF
#undef LIBCOLOUR_X



#define LIBCOLOUR_GENERIC___(C, TYPE, N, CALL)\
	TYPE *:       (CALL),\
	const TYPE *: (CALL),

#define LIBCOLOUR_GENERIC__(TYPE, RES, CALL)\
	LIBCOLOUR_LIST_MODELS_N(LIBCOLOUR_GENERIC___, RES, (CALL))\
        TYPE:                               (CALL),\
	TYPE *:                             (CALL),\
	const TYPE:                         (CALL),\
	const TYPE *:                       (CALL),\
	libcolour_colour_##RES##_t *:       (CALL),\
	const libcolour_colour_##RES##_t *: (CALL)

#define LIBCOLOUR_GENERIC(FUNC, REF, ...)\
	(_Generic((REF),\
	          LIBCOLOUR_GENERIC__(long double, llf, FUNC##_llf(__VA_ARGS__)),\
	          LIBCOLOUR_GENERIC__(double,      lf,  FUNC##_lf(__VA_ARGS__)),\
	          LIBCOLOUR_GENERIC__(float,       f,   FUNC##_f(__VA_ARGS__))))


#define libcolour_convert(FROM, TO)\
	LIBCOLOUR_GENERIC(libcolour_convert, (FROM), (const void *)(FROM), (void *)(TO))

#define libcolour_srgb_encode(VALUE)\
	LIBCOLOUR_GENERIC(libcolour_srgb_encode, (VALUE), (VALUE))

#define libcolour_srgb_decode(VALUE)\
	LIBCOLOUR_GENERIC(libcolour_srgb_decode, (VALUE), (VALUE))

#define libcolour_delta_e(A, B, E)\
	LIBCOLOUR_GENERIC(libcolour_delta_e, (A), (const void *)(A), (const void *)(B), (void *)(E))

#define libcolour_get_rgb_colour_space(CS, SPACE)\
	LIBCOLOUR_GENERIC(libcolour_get_rgb_colour_space, (CS), (void *)(CS), (SPACE))

#define libcolour_marshal(COLOUR, BUF)\
	LIBCOLOUR_GENERIC(libcolour_marshal, (COLOUR), (const void *)(COLOUR), (void *)(BUF))

#define libcolour_unmarshal(COLOUR, BUF)\
	LIBCOLOUR_GENERIC(libcolour_unmarshal, (COLOUR), (void *)(COLOUR), (const void *)(BUF))

#define libcolour_convert_en_masse(FROM, TO, MODE, N, ...)\
	LIBCOLOUR_GENERIC(libcolour_convert_en_masse, (FROM), (const void *)(FROM),\
			  (const void *)(TO), (MODE), (N), __VA_ARGS__)


static inline int
libcolour_proper_f__(union libcolour_colour_f *colour, enum libcolour_model model)
{
	colour->model = model;
	return libcolour_proper_f(colour);
}

static inline int
libcolour_proper_lf__(union libcolour_colour_lf *colour, enum libcolour_model model)
{
	colour->model = model;
	return libcolour_proper_lf(colour);
}

static inline int
libcolour_proper_llf__(union libcolour_colour_llf *colour, enum libcolour_model model)
{
	colour->model = model;
	return libcolour_proper_llf(colour);
}

#define LIBCOLOUR_F(C, T, N, COLOUR) T *: libcolour_proper_f__((void *)(COLOUR), (C))),
#define LIBCOLOUR_LF(C, T, N, COLOUR) T *: libcolour_proper_lf__((void *)(COLOUR), (C))),
#define LIBCOLOUR_LLF(C, T, N, COLOUR) T *: libcolour_proper_llf__((void *)(COLOUR), (C))),
#define libcolour_proper(COLOUR)\
	(_Generic((COLOUR),\
	          LIBCOLOUR_LIST_MODELS_N(LIBCOLOUR_F, f, (COLOUR))\
	          LIBCOLOUR_LIST_MODELS_N(LIBCOLOUR_LF, lf, (COLOUR))\
	          LIBCOLOUR_LIST_MODELS_N(LIBCOLOUR_LLF, llf, (COLOUR))\
	          union libcolour_colour_f *: libcolour_proper_f((void *)(COLOUR)),\
	          union libcolour_colour_lf *: libcolour_proper_lf((void *)(COLOUR)),\
	          union libcolour_colour_llf *: libcolour_proper_llf((void *)(COLOUR))))
#undef LIBCOLOUR_F
#undef LIBCOLOUR_LF
#undef LIBCOLOUR_LLF



#if defined(__GNUC__) && !defined(__clang__)
# pragma GCC diagnostic pop
#elif defined(__clang__)
# pragma clang diagnostic pop
#endif


#endif