OLD | NEW |
(Empty) | |
| 1 #include "qcms.h" |
| 2 #include "qcmstypes.h" |
| 3 |
| 4 /* used as a lookup table for the output transformation. |
| 5 * we refcount them so we only need to have one around per output |
| 6 * profile, instead of duplicating them per transform */ |
| 7 struct precache_output |
| 8 { |
| 9 int ref_count; |
| 10 /* We previously used a count of 65536 here but that seems like more |
| 11 * precision than we actually need. By reducing the size we can |
| 12 * improve startup performance and reduce memory usage. ColorSync on |
| 13 * 10.5 uses 4097 which is perhaps because they use a fixed point |
| 14 * representation where 1. is represented by 0x1000. */ |
| 15 #define PRECACHE_OUTPUT_SIZE 8192 |
| 16 #define PRECACHE_OUTPUT_MAX (PRECACHE_OUTPUT_SIZE-1) |
| 17 uint8_t data[PRECACHE_OUTPUT_SIZE]; |
| 18 }; |
| 19 |
| 20 #ifdef _MSC_VER |
| 21 #define ALIGN __declspec(align(16)) |
| 22 #else |
| 23 #define ALIGN __attribute__(( aligned (16) )) |
| 24 #endif |
| 25 |
| 26 struct _qcms_transform { |
| 27 float ALIGN matrix[3][4]; |
| 28 float *input_gamma_table_r; |
| 29 float *input_gamma_table_g; |
| 30 float *input_gamma_table_b; |
| 31 |
| 32 float *input_gamma_table_gray; |
| 33 |
| 34 float out_gamma_r; |
| 35 float out_gamma_g; |
| 36 float out_gamma_b; |
| 37 |
| 38 float out_gamma_gray; |
| 39 |
| 40 uint16_t *output_gamma_lut_r; |
| 41 uint16_t *output_gamma_lut_g; |
| 42 uint16_t *output_gamma_lut_b; |
| 43 |
| 44 uint16_t *output_gamma_lut_gray; |
| 45 |
| 46 size_t output_gamma_lut_r_length; |
| 47 size_t output_gamma_lut_g_length; |
| 48 size_t output_gamma_lut_b_length; |
| 49 |
| 50 size_t output_gamma_lut_gray_length; |
| 51 |
| 52 struct precache_output *output_table_r; |
| 53 struct precache_output *output_table_g; |
| 54 struct precache_output *output_table_b; |
| 55 |
| 56 void (*transform_fn)(struct _qcms_transform *transform, unsigned char *s
rc, unsigned char *dest, size_t length); |
| 57 }; |
| 58 |
| 59 typedef int32_t s15Fixed16Number; |
| 60 typedef uint16_t uInt16Number; |
| 61 |
| 62 struct XYZNumber { |
| 63 s15Fixed16Number X; |
| 64 s15Fixed16Number Y; |
| 65 s15Fixed16Number Z; |
| 66 }; |
| 67 |
| 68 struct curveType { |
| 69 uint32_t count; |
| 70 /* Using the C99 flexible array member syntax with IBM compiler */ |
| 71 #if defined (__IBMC__) || defined (__IBMCPP__) |
| 72 uInt16Number data[]; |
| 73 #else |
| 74 uInt16Number data[0]; |
| 75 #endif |
| 76 }; |
| 77 |
| 78 struct lutType { |
| 79 uint8_t num_input_channels; |
| 80 uint8_t num_output_channels; |
| 81 uint8_t num_clut_grid_points; |
| 82 |
| 83 s15Fixed16Number e00; |
| 84 s15Fixed16Number e01; |
| 85 s15Fixed16Number e02; |
| 86 s15Fixed16Number e10; |
| 87 s15Fixed16Number e11; |
| 88 s15Fixed16Number e12; |
| 89 s15Fixed16Number e20; |
| 90 s15Fixed16Number e21; |
| 91 s15Fixed16Number e22; |
| 92 |
| 93 uint16_t num_input_table_entries; |
| 94 uint16_t num_output_table_entries; |
| 95 |
| 96 uint16_t *input_table; |
| 97 uint16_t *clut_table; |
| 98 uint16_t *output_table; |
| 99 }; |
| 100 #if 0 |
| 101 /* this is from an intial idea of having the struct correspond to the data in |
| 102 * the file. I decided that it wasn't a good idea. |
| 103 */ |
| 104 struct tag_value { |
| 105 uint32_t type; |
| 106 union { |
| 107 struct { |
| 108 uint32_t reserved; |
| 109 struct { |
| 110 s15Fixed16Number X; |
| 111 s15Fixed16Number Y; |
| 112 s15Fixed16Number Z; |
| 113 } XYZNumber; |
| 114 } XYZType; |
| 115 }; |
| 116 }; // I guess we need to pack this? |
| 117 #endif |
| 118 |
| 119 #define RGB_SIGNATURE 0x52474220 |
| 120 #define GRAY_SIGNATURE 0x47524159 |
| 121 |
| 122 struct _qcms_profile { |
| 123 uint32_t class; |
| 124 uint32_t color_space; |
| 125 qcms_intent rendering_intent; |
| 126 struct XYZNumber redColorant; |
| 127 struct XYZNumber blueColorant; |
| 128 struct XYZNumber greenColorant; |
| 129 struct curveType *redTRC; |
| 130 struct curveType *blueTRC; |
| 131 struct curveType *greenTRC; |
| 132 struct curveType *grayTRC; |
| 133 struct lutType *A2B0; |
| 134 |
| 135 struct precache_output *output_table_r; |
| 136 struct precache_output *output_table_g; |
| 137 struct precache_output *output_table_b; |
| 138 }; |
| 139 |
| 140 #ifdef _MSC_VER |
| 141 #define inline _inline |
| 142 #endif |
| 143 |
| 144 static inline float s15Fixed16Number_to_float(s15Fixed16Number a) |
| 145 { |
| 146 return ((int32_t)a)/65536.; |
| 147 } |
| 148 |
| 149 static inline s15Fixed16Number double_to_s15Fixed16Number(double v) |
| 150 { |
| 151 return (int32_t)(v*65536); |
| 152 } |
| 153 |
| 154 void precache_release(struct precache_output *p); |
| 155 qcms_bool set_rgb_colorants(qcms_profile *profile, qcms_CIE_xyY white_point, qcm
s_CIE_xyYTRIPLE primaries); |
| 156 |
| 157 void qcms_transform_data_rgb_out_lut_sse2(qcms_transform *transform, |
| 158 unsigned char *src, |
| 159 unsigned char *dest, |
| 160 size_t length); |
| 161 void qcms_transform_data_rgba_out_lut_sse2(qcms_transform *transform, |
| 162 unsigned char *src, |
| 163 unsigned char *dest, |
| 164 size_t length); |
| 165 void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *transform, |
| 166 unsigned char *src, |
| 167 unsigned char *dest, |
| 168 size_t length); |
| 169 void qcms_transform_data_rgba_out_lut_sse1(qcms_transform *transform, |
| 170 unsigned char *src, |
| 171 unsigned char *dest, |
| 172 size_t length); |
OLD | NEW |