File Coverage

pp-_xyz_to_lab.c
Criterion Covered Total %
statement 48 50 96.0
branch 65 122 53.2
condition n/a
subroutine n/a
pod n/a
total 113 172 65.7


line stmt bran cond sub pod time code
1              
2             #line 453 "lib/PDL/PP.pm"
3             /*
4             * THIS FILE WAS GENERATED BY PDL::PP from color_space.pd! Do not modify!
5             */
6              
7             #define PDL_FREE_CODE(trans, destroy, comp_free_code, ntpriv_free_code) \
8             if (destroy) { \
9             comp_free_code \
10             } \
11             if ((trans)->dims_redone) { \
12             ntpriv_free_code \
13             }
14              
15             #include "EXTERN.h"
16             #include "perl.h"
17             #include "XSUB.h"
18             #include "pdl.h"
19             #include "pdlcore.h"
20             #define PDL PDL_Graphics_ColorSpace
21             extern Core* PDL; /* Structure hold core C functions */
22             #line 23 "pp-_xyz_to_lab.c"
23              
24             #include
25             #include "color_space.h" /* Local decs */
26              
27             #line 1857 "lib/PDL/PP.pm"
28             pdl_error pdl__xyz_to_lab_redodims(pdl_trans *__privtrans) {
29             pdl_error PDL_err = {0, NULL, 0};
30             #line 31 "pp-_xyz_to_lab.c"
31 8           __privtrans->ind_sizes[0] = 3;
32 8           __privtrans->ind_sizes[1] = 2;
33 8 50         PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans));
34 8           return PDL_err;
35             }
36              
37              
38             #line 1857 "lib/PDL/PP.pm"
39             pdl_error pdl__xyz_to_lab_readdata(pdl_trans *__privtrans) {
40             pdl_error PDL_err = {0, NULL, 0};
41             #line 42 "pp-_xyz_to_lab.c"
42 8           register PDL_Indx __c_size = __privtrans->ind_sizes[0];
43 8 50         if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in _xyz_to_lab:" "broadcast.incs NULL");
44             /* broadcastloop declarations */
45             int __brcloopval;
46             register PDL_Indx __tind0,__tind1; /* counters along dim */
47 8           register PDL_Indx __tnpdls = __privtrans->broadcast.npdls;
48             /* dims here are how many steps along those dims */
49 8           register PDL_Indx __tinc0_xyz = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0);
50 8           register PDL_Indx __tinc0_w = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0);
51 8           register PDL_Indx __tinc0_lab = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0);
52 8           register PDL_Indx __tinc1_xyz = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1);
53 8           register PDL_Indx __tinc1_w = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1);
54 8           register PDL_Indx __tinc1_lab = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1);
55             #define PDL_BROADCASTLOOP_START__xyz_to_lab_readdata PDL_BROADCASTLOOP_START( \
56             readdata, \
57             __privtrans->broadcast, \
58             __privtrans->vtable, \
59             xyz_datap += __offsp[0]; \
60             w_datap += __offsp[1]; \
61             lab_datap += __offsp[2]; \
62             , \
63             ( ,xyz_datap += __tinc1_xyz - __tinc0_xyz * __tdims0 \
64             ,w_datap += __tinc1_w - __tinc0_w * __tdims0 \
65             ,lab_datap += __tinc1_lab - __tinc0_lab * __tdims0 \
66             ), \
67             ( ,xyz_datap += __tinc0_xyz \
68             ,w_datap += __tinc0_w \
69             ,lab_datap += __tinc0_lab \
70             ) \
71             )
72             #define PDL_BROADCASTLOOP_END__xyz_to_lab_readdata PDL_BROADCASTLOOP_END( \
73             __privtrans->broadcast, \
74             xyz_datap -= __tinc1_xyz * __tdims1 + __offsp[0]; \
75             w_datap -= __tinc1_w * __tdims1 + __offsp[1]; \
76             lab_datap -= __tinc1_lab * __tdims1 + __offsp[2]; \
77             )
78 8           register PDL_Indx __inc_lab_c = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,2,0)]; (void)__inc_lab_c;
79 8           register PDL_Indx __inc_w_d = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,1,0)]; (void)__inc_w_d;
80 8           register PDL_Indx __inc_xyz_c = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_xyz_c;
81             #ifndef PDL_DECLARE_PARAMS__xyz_to_lab_1
82             #define PDL_DECLARE_PARAMS__xyz_to_lab_1(PDL_TYPE_OP,PDL_PPSYM_OP) \
83             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, xyz, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \
84             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, w, (__privtrans->pdls[1]), 1, PDL_PPSYM_OP) \
85             PDL_DECLARE_PARAMETER_BADVAL(PDL_TYPE_OP, lab, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP)
86             #endif
87 8 100         if ( __privtrans->bvalflag ) { /* ** do 'bad' Code ** */
88             #define PDL_BAD_CODE
89             #define PDL_IF_BAD(t,f) t
90 3 50         switch (__privtrans->__datatype) { /* Start generic switch */
91 3           case PDL_D: {
92 3 50         PDL_DECLARE_PARAMS__xyz_to_lab_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
93             {
94             /* construct white point */
95 3           double xyY[3] = { (w_datap)[0+(__inc_w_d*(0))], (w_datap)[0+(__inc_w_d*(1))], 1.0 };
96             double xyz_white[3];
97 3           xyY2xyz( &xyY[0], &xyz_white[0] );
98              
99 15 50         PDL_BROADCASTLOOP_START__xyz_to_lab_readdata
    50          
    50          
    50          
    50          
    100          
    100          
100             /* First check for bad values */
101 15 50         PDL_IF_BAD(if (PDL_ISBAD2((xyz_datap)[0+(__inc_xyz_c*(0))],xyz_badval,D,xyz_badval_isnan) || PDL_ISBAD2((xyz_datap)[0+(__inc_xyz_c*(1))],xyz_badval,D,xyz_badval_isnan) || PDL_ISBAD2((xyz_datap)[0+(__inc_xyz_c*(2))],xyz_badval,D,xyz_badval_isnan)) {
    0          
    100          
    50          
    0          
    50          
    50          
    0          
    50          
    100          
102             {/* Open c */ PDL_EXPAND2(register PDL_Indx c=0, __c_stop=(__c_size)); for(; c<__c_stop; c+=1) {
103             (lab_datap)[0+(__inc_lab_c*(c))]=lab_badval;
104             }} /* Close c */
105             /* skip to the next xyz triple */
106             }
107             else,) {
108 3           xyz2lab( xyz_datap, &xyz_white[0], lab_datap );
109             }
110 3 50         PDL_BROADCASTLOOP_END__xyz_to_lab_readdata
    50          
111             }
112 3           } break;
113 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in _xyz_to_lab: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
114             }
115             #undef PDL_BAD_CODE
116             #undef PDL_IF_BAD
117             } else { /* ** else do 'good' Code ** */
118             #define PDL_IF_BAD(t,f) f
119 5 50         switch (__privtrans->__datatype) { /* Start generic switch */
120 5           case PDL_D: {
121 5 50         PDL_DECLARE_PARAMS__xyz_to_lab_1(PDL_Double,D)
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
    50          
122             {
123             /* construct white point */
124 5           double xyY[3] = { (w_datap)[0+(__inc_w_d*(0))], (w_datap)[0+(__inc_w_d*(1))], 1.0 };
125             double xyz_white[3];
126 5           xyY2xyz( &xyY[0], &xyz_white[0] );
127              
128 25 50         PDL_BROADCASTLOOP_START__xyz_to_lab_readdata
    50          
    50          
    50          
    50          
    100          
    100          
129             /* First check for bad values */
130             PDL_IF_BAD(if (PDL_ISBAD2((xyz_datap)[0+(__inc_xyz_c*(0))],xyz_badval,D,xyz_badval_isnan) || PDL_ISBAD2((xyz_datap)[0+(__inc_xyz_c*(1))],xyz_badval,D,xyz_badval_isnan) || PDL_ISBAD2((xyz_datap)[0+(__inc_xyz_c*(2))],xyz_badval,D,xyz_badval_isnan)) {
131             {/* Open c */ PDL_EXPAND2(register PDL_Indx c=0, __c_stop=(__c_size)); for(; c<__c_stop; c+=1) {
132             (lab_datap)[0+(__inc_lab_c*(c))]=lab_badval;
133             }} /* Close c */
134             /* skip to the next xyz triple */
135             }
136             else,) {
137 10           xyz2lab( xyz_datap, &xyz_white[0], lab_datap );
138             }
139 5 50         PDL_BROADCASTLOOP_END__xyz_to_lab_readdata
    50          
140             }
141 5           } break;
142 0           default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in _xyz_to_lab: unhandled datatype(%d), only handles (D)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype);
143             }
144             #undef PDL_IF_BAD
145             }
146 8           return PDL_err;
147             }
148              
149             static pdl_datatypes pdl__xyz_to_lab_vtable_gentypes[] = { PDL_D, -1 };
150             static PDL_Indx pdl__xyz_to_lab_vtable_realdims[] = { 1, 1, 1 };
151             static char *pdl__xyz_to_lab_vtable_parnames[] = { "xyz","w","lab" };
152             static short pdl__xyz_to_lab_vtable_parflags[] = {
153             PDL_PARAM_ISPHYS,
154             0,
155             PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE
156             };
157             static pdl_datatypes pdl__xyz_to_lab_vtable_partypes[] = { -1, -1, -1 };
158             static PDL_Indx pdl__xyz_to_lab_vtable_realdims_starts[] = { 0, 1, 2 };
159             static PDL_Indx pdl__xyz_to_lab_vtable_realdims_ind_ids[] = { 0, 1, 0 };
160             static char *pdl__xyz_to_lab_vtable_indnames[] = { "c","d" };
161             pdl_transvtable pdl__xyz_to_lab_vtable = {
162             PDL_TRANS_DO_BROADCAST|PDL_TRANS_BADPROCESS, 0, pdl__xyz_to_lab_vtable_gentypes, 2, 3, NULL /*CORE21*/,
163             pdl__xyz_to_lab_vtable_realdims, pdl__xyz_to_lab_vtable_parnames,
164             pdl__xyz_to_lab_vtable_parflags, pdl__xyz_to_lab_vtable_partypes,
165             pdl__xyz_to_lab_vtable_realdims_starts, pdl__xyz_to_lab_vtable_realdims_ind_ids, 3,
166             2, pdl__xyz_to_lab_vtable_indnames,
167             pdl__xyz_to_lab_redodims, pdl__xyz_to_lab_readdata, NULL,
168             NULL,
169             0,"PDL::Graphics::ColorSpace::_xyz_to_lab"
170             };
171              
172              
173 8           pdl_error pdl_run__xyz_to_lab(pdl *xyz,pdl *w,pdl *lab) {
174 8           pdl_error PDL_err = {0, NULL, 0};
175 8 50         if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0};
176 8           pdl_trans *__privtrans = PDL->create_trans(&pdl__xyz_to_lab_vtable);
177 8 50         if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans");
178 8           __privtrans->pdls[0] = xyz;
179 8           __privtrans->pdls[1] = w;
180 8           __privtrans->pdls[2] = lab;
181 8 50         PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans));
182 8 50         PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans));
183 8           return PDL_err;
184             }