| 1 |
|
| |
| 2 |
|
| #line 453 "lib/PDL/PP.pm" |
| 3 |
|
| /* |
| 4 |
|
| * THIS FILE WAS GENERATED BY PDL::PP from lib/PDL/Image2D.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_Image2D |
| 21 |
|
| extern Core* PDL; /* Structure hold core C functions */ |
| 22 |
|
| #line 23 "lib/PDL/Image2D-pp-rot2d.c" |
| 23 |
|
| |
| 24 |
|
| /* Fast Modulus with proper negative behaviour */ |
| 25 |
|
| |
| 26 |
|
| #define REALMOD(a,b) {while ((a)>=(b)) (a) -= (b); while ((a)<0) (a) += (b);} |
| 27 |
|
| |
| 28 |
|
| #define X(symbol, ctype, ppsym, ...) \ |
| 29 |
|
| ctype quick_select_ ## ppsym(ctype arr[], int n); |
| 30 |
|
| PDL_TYPELIST_REAL(X) |
| 31 |
|
| #undef X |
| 32 |
|
| #define EZ(x) ez ? 0 : (x) |
| 33 |
|
| int getnewsize(PDL_Indx cols, PDL_Indx rows, float fangle, PDL_Indx *newcols, PDL_Indx *newrows); |
| 34 |
|
| typedef unsigned char imT; /* image type */ |
| 35 |
|
| int rotate(imT *im, imT *out, int cols, int rows, int nc, int nr, |
| 36 |
|
| float fangle, imT bgval, int antialias); |
| 37 |
|
| |
| 38 |
|
| #line 1888 "lib/PDL/PP.pm" |
| 39 |
|
| pdl_error pdl_rot2d_redodims(pdl_trans *__privtrans) { |
| 40 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 41 |
|
| #line 42 "lib/PDL/Image2D-pp-rot2d.c" |
| 42 |
|
| #ifndef PDL_DECLARE_PARAMS_rot2d_0 |
| 43 |
|
| #define PDL_DECLARE_PARAMS_rot2d_0(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_angle,PDL_PPSYM_PARAM_angle,PDL_TYPE_PARAM_aa,PDL_PPSYM_PARAM_aa) \ |
| 44 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, im, (__privtrans->pdls[0]), 0, PDL_PPSYM_OP) \ |
| 45 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_angle, angle, (__privtrans->pdls[1]), 0, PDL_PPSYM_PARAM_angle) \ |
| 46 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, bg, (__privtrans->pdls[2]), 0, PDL_PPSYM_OP) \ |
| 47 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_aa, aa, (__privtrans->pdls[3]), 0, PDL_PPSYM_PARAM_aa) \ |
| 48 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, om, (__privtrans->pdls[4]), 0, PDL_PPSYM_OP) |
| 49 |
|
| #endif |
| 50 |
|
| #define PDL_IF_BAD(t,f) f |
| 51 |
0 |
▶ | switch (__privtrans->__datatype) { /* Start generic switch */ |
Branch: 1 branch
| Branch | True | False | Total |
| switch (__privtrans->__datatype) { /* Start generic switch */ |
0 |
0 |
0 |
|
| 52 |
0 |
| case PDL_B: { |
| 53 |
0 |
▶ | PDL_DECLARE_PARAMS_rot2d_0(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
Branch: 5 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_rot2d_0(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_0(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_0(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_0(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_0(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
|
| 54 |
|
| { |
| 55 |
0 |
▶ | if (getnewsize(__privtrans->ind_sizes[0],__privtrans->ind_sizes[1], |
Branch: 1 branch
| Branch | True | False | Total |
| if (getnewsize(__privtrans->ind_sizes[0],__privtrans->ind_sizes[1], |
0 |
0 |
0 |
|
| 56 |
0 |
| (angle_datap)[0], &__privtrans->ind_sizes[2], |
| 57 |
0 |
| &__privtrans->ind_sizes[3]) != 0) |
| 58 |
0 |
| return PDL->make_error(PDL_EUSERERROR, "Error in rot2d:" "error during rotate, wrong angle"); |
| 59 |
|
| /* printf("o: %d, p: %d\n",ncols,nrows); */ |
| 60 |
|
| } |
| 61 |
0 |
| } break; |
| 62 |
0 |
| default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rot2d: unhandled datatype(%d), only handles (B)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
| 63 |
|
| } |
| 64 |
|
| #undef PDL_IF_BAD |
| 65 |
|
| |
| 66 |
0 |
▶ | PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->redodims_default(__privtrans)); |
0 |
0 |
0 |
|
| 67 |
0 |
| return PDL_err; |
| 68 |
|
| } |
| 69 |
|
| |
| 70 |
|
| |
| 71 |
|
| #line 1888 "lib/PDL/PP.pm" |
| 72 |
|
| pdl_error pdl_rot2d_readdata(pdl_trans *__privtrans) { |
| 73 |
|
| pdl_error PDL_err = {0, NULL, 0}; |
| 74 |
|
| #line 75 "lib/PDL/Image2D-pp-rot2d.c" |
| 75 |
0 |
▶ | if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in rot2d:" "broadcast.incs NULL"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!__privtrans->broadcast.incs) return PDL->make_error(PDL_EUSERERROR, "Error in rot2d:" "broadcast.incs NULL"); |
0 |
0 |
0 |
|
| 76 |
|
| /* broadcastloop declarations */ |
| 77 |
|
| int __brcloopval; |
| 78 |
|
| register PDL_Indx __tind0,__tind1; /* counters along dim */ |
| 79 |
0 |
| register PDL_Indx __tnpdls = __privtrans->broadcast.npdls; |
| 80 |
|
| /* dims here are how many steps along those dims */ |
| 81 |
0 |
| register PDL_Indx __tinc0_im = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,0); |
| 82 |
0 |
| register PDL_Indx __tinc0_angle = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,0); |
| 83 |
0 |
| register PDL_Indx __tinc0_bg = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,0); |
| 84 |
0 |
| register PDL_Indx __tinc0_aa = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,0); |
| 85 |
0 |
| register PDL_Indx __tinc0_om = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,0); |
| 86 |
0 |
| register PDL_Indx __tinc1_im = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,0,1); |
| 87 |
0 |
| register PDL_Indx __tinc1_angle = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,1,1); |
| 88 |
0 |
| register PDL_Indx __tinc1_bg = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,2,1); |
| 89 |
0 |
| register PDL_Indx __tinc1_aa = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,3,1); |
| 90 |
0 |
| register PDL_Indx __tinc1_om = PDL_BRC_INC(__privtrans->broadcast.incs,__tnpdls,4,1); |
| 91 |
|
| #define PDL_BROADCASTLOOP_START_rot2d_readdata PDL_BROADCASTLOOP_START( \ |
| 92 |
|
| readdata, \ |
| 93 |
|
| __privtrans->broadcast, \ |
| 94 |
|
| __privtrans->vtable, \ |
| 95 |
|
| im_datap += __offsp[0]; \ |
| 96 |
|
| angle_datap += __offsp[1]; \ |
| 97 |
|
| bg_datap += __offsp[2]; \ |
| 98 |
|
| aa_datap += __offsp[3]; \ |
| 99 |
|
| om_datap += __offsp[4]; \ |
| 100 |
|
| , \ |
| 101 |
|
| ( ,im_datap += __tinc1_im - __tinc0_im * __tdims0 \ |
| 102 |
|
| ,angle_datap += __tinc1_angle - __tinc0_angle * __tdims0 \ |
| 103 |
|
| ,bg_datap += __tinc1_bg - __tinc0_bg * __tdims0 \ |
| 104 |
|
| ,aa_datap += __tinc1_aa - __tinc0_aa * __tdims0 \ |
| 105 |
|
| ,om_datap += __tinc1_om - __tinc0_om * __tdims0 \ |
| 106 |
|
| ), \ |
| 107 |
|
| ( ,im_datap += __tinc0_im \ |
| 108 |
|
| ,angle_datap += __tinc0_angle \ |
| 109 |
|
| ,bg_datap += __tinc0_bg \ |
| 110 |
|
| ,aa_datap += __tinc0_aa \ |
| 111 |
|
| ,om_datap += __tinc0_om \ |
| 112 |
|
| ) \ |
| 113 |
|
| ) |
| 114 |
|
| #define PDL_BROADCASTLOOP_END_rot2d_readdata PDL_BROADCASTLOOP_END( \ |
| 115 |
|
| __privtrans->broadcast, \ |
| 116 |
|
| im_datap -= __tinc1_im * __tdims1 + __offsp[0]; \ |
| 117 |
|
| angle_datap -= __tinc1_angle * __tdims1 + __offsp[1]; \ |
| 118 |
|
| bg_datap -= __tinc1_bg * __tdims1 + __offsp[2]; \ |
| 119 |
|
| aa_datap -= __tinc1_aa * __tdims1 + __offsp[3]; \ |
| 120 |
|
| om_datap -= __tinc1_om * __tdims1 + __offsp[4]; \ |
| 121 |
|
| ) |
| 122 |
0 |
| register PDL_Indx __inc_im_m = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,0)]; (void)__inc_im_m;register PDL_Indx __inc_im_n = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,0,1)]; (void)__inc_im_n; |
| 123 |
0 |
| register PDL_Indx __inc_om_p = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,4,0)]; (void)__inc_om_p;register PDL_Indx __inc_om_q = __privtrans->inc_sizes[PDL_INC_ID(__privtrans->vtable,4,1)]; (void)__inc_om_q; |
| 124 |
|
| #ifndef PDL_DECLARE_PARAMS_rot2d_1 |
| 125 |
|
| #define PDL_DECLARE_PARAMS_rot2d_1(PDL_TYPE_OP,PDL_PPSYM_OP,PDL_TYPE_PARAM_angle,PDL_PPSYM_PARAM_angle,PDL_TYPE_PARAM_aa,PDL_PPSYM_PARAM_aa) \ |
| 126 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, im, (__privtrans->pdls[0]), 1, PDL_PPSYM_OP) \ |
| 127 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_angle, angle, (__privtrans->pdls[1]), 1, PDL_PPSYM_PARAM_angle) \ |
| 128 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, bg, (__privtrans->pdls[2]), 1, PDL_PPSYM_OP) \ |
| 129 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_PARAM_aa, aa, (__privtrans->pdls[3]), 1, PDL_PPSYM_PARAM_aa) \ |
| 130 |
|
| PDL_DECLARE_PARAMETER(PDL_TYPE_OP, om, (__privtrans->pdls[4]), 1, PDL_PPSYM_OP) |
| 131 |
|
| #endif |
| 132 |
|
| #define PDL_IF_BAD(t,f) f |
| 133 |
0 |
▶ | switch (__privtrans->__datatype) { /* Start generic switch */ |
Branch: 1 branch
| Branch | True | False | Total |
| switch (__privtrans->__datatype) { /* Start generic switch */ |
0 |
0 |
0 |
|
| 134 |
0 |
| case PDL_B: { |
| 135 |
0 |
▶ | PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
Branch: 15 branches
| Branch | True | False | Total |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
| PDL_DECLARE_PARAMS_rot2d_1(PDL_Byte,B,PDL_Float,F,PDL_Long,L) |
0 |
0 |
0 |
|
| 136 |
0 |
▶ | PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
Branch: 7 branches
| Branch | True | False | Total |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
| PDL_BROADCASTLOOP_START_rot2d_readdata {int ierr; |
0 |
0 |
0 |
|
| 137 |
0 |
▶ | if ((ierr = rotate(im_datap,om_datap,__privtrans->ind_sizes[0],__privtrans->ind_sizes[1],__privtrans->ind_sizes[2], |
Branch: 1 branch
| Branch | True | False | Total |
| if ((ierr = rotate(im_datap,om_datap,__privtrans->ind_sizes[0],__privtrans->ind_sizes[1],__privtrans->ind_sizes[2], |
0 |
0 |
0 |
|
| 138 |
0 |
| __privtrans->ind_sizes[3],(angle_datap)[0],(bg_datap)[0],(aa_datap)[0])) != 0) { |
| 139 |
0 |
▶ | if (ierr == -1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (ierr == -1) |
0 |
0 |
0 |
|
| 140 |
0 |
| return PDL->make_error(PDL_EUSERERROR, "Error in rot2d:" "error during rotate, wrong angle"); |
| 141 |
|
| else |
| 142 |
0 |
| return PDL->make_error(PDL_EUSERERROR, "Error in rot2d:" "wrong output dims, did you set them?"); |
| 143 |
0 |
▶ | }}PDL_BROADCASTLOOP_END_rot2d_readdata |
Branch: 2 branches
| Branch | True | False | Total |
| }}PDL_BROADCASTLOOP_END_rot2d_readdata |
0 |
0 |
0 |
| }}PDL_BROADCASTLOOP_END_rot2d_readdata |
0 |
0 |
0 |
|
| 144 |
0 |
| } break; |
| 145 |
0 |
| default: return PDL->make_error(PDL_EUSERERROR, "PP INTERNAL ERROR in rot2d: unhandled datatype(%d), only handles (B)! PLEASE MAKE A BUG REPORT\n", __privtrans->__datatype); |
| 146 |
|
| } |
| 147 |
|
| #undef PDL_IF_BAD |
| 148 |
0 |
| return PDL_err; |
| 149 |
|
| } |
| 150 |
|
| |
| 151 |
|
| static pdl_datatypes pdl_rot2d_vtable_gentypes[] = { PDL_B, -1 }; |
| 152 |
|
| static PDL_Indx pdl_rot2d_vtable_realdims[] = { 2, 0, 0, 0, 2 }; |
| 153 |
|
| static char *pdl_rot2d_vtable_parnames[] = { "im","angle","bg","aa","om" }; |
| 154 |
|
| static short pdl_rot2d_vtable_parflags[] = { |
| 155 |
|
| PDL_PARAM_ISPHYS, |
| 156 |
|
| PDL_PARAM_ISTYPED, |
| 157 |
|
| 0, |
| 158 |
|
| PDL_PARAM_ISTYPED, |
| 159 |
|
| PDL_PARAM_ISCREAT|PDL_PARAM_ISOUT|PDL_PARAM_ISPHYS|PDL_PARAM_ISWRITE |
| 160 |
|
| }; |
| 161 |
|
| static pdl_datatypes pdl_rot2d_vtable_partypes[] = { -1, PDL_F, -1, PDL_L, -1 }; |
| 162 |
|
| static PDL_Indx pdl_rot2d_vtable_realdims_starts[] = { 0, 2, 2, 2, 2 }; |
| 163 |
|
| static PDL_Indx pdl_rot2d_vtable_realdims_ind_ids[] = { 0, 1, 2, 3 }; |
| 164 |
|
| static char *pdl_rot2d_vtable_indnames[] = { "m","n","p","q" }; |
| 165 |
|
| pdl_transvtable pdl_rot2d_vtable = { |
| 166 |
|
| PDL_TRANS_DO_BROADCAST|PDL_TRANS_BADIGNORE, 0, pdl_rot2d_vtable_gentypes, 4, 5, NULL /*CORE21*/, |
| 167 |
|
| pdl_rot2d_vtable_realdims, pdl_rot2d_vtable_parnames, |
| 168 |
|
| pdl_rot2d_vtable_parflags, pdl_rot2d_vtable_partypes, |
| 169 |
|
| pdl_rot2d_vtable_realdims_starts, pdl_rot2d_vtable_realdims_ind_ids, 4, |
| 170 |
|
| 4, pdl_rot2d_vtable_indnames, |
| 171 |
|
| pdl_rot2d_redodims, pdl_rot2d_readdata, NULL, |
| 172 |
|
| NULL, |
| 173 |
|
| 0,"PDL::Image2D::rot2d" |
| 174 |
|
| }; |
| 175 |
|
| |
| 176 |
|
| |
| 177 |
0 |
| pdl_error pdl_run_rot2d(pdl *im,pdl *angle,pdl *bg,pdl *aa,pdl *om) { |
| 178 |
0 |
| pdl_error PDL_err = {0, NULL, 0}; |
| 179 |
0 |
▶ | if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
Branch: 1 branch
| Branch | True | False | Total |
| if (!PDL) return (pdl_error){PDL_EFATAL, "PDL core struct is NULL, can't continue",0}; |
0 |
0 |
0 |
|
| 180 |
0 |
| pdl_trans *__privtrans = PDL->create_trans(&pdl_rot2d_vtable); |
| 181 |
0 |
▶ | if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!__privtrans) return PDL->make_error_simple(PDL_EFATAL, "Couldn't create trans"); |
0 |
0 |
0 |
|
| 182 |
0 |
| __privtrans->pdls[0] = im; |
| 183 |
0 |
| __privtrans->pdls[1] = angle; |
| 184 |
0 |
| __privtrans->pdls[2] = bg; |
| 185 |
0 |
| __privtrans->pdls[3] = aa; |
| 186 |
0 |
| __privtrans->pdls[4] = om; |
| 187 |
0 |
▶ | PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->type_coerce(__privtrans)); |
0 |
0 |
0 |
|
| 188 |
0 |
▶ | PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
Branch: 1 branch
| Branch | True | False | Total |
| PDL_RETERROR(PDL_err, PDL->make_trans_mutual(__privtrans)); |
0 |
0 |
0 |
|
| 189 |
0 |
| return PDL_err; |
| 190 |
|
| } |