00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include <string.h>
00025 #include <math.h>
00026 #include <flgrCoreDispatch.h>
00027 #include <flgrCoreIO.h>
00028 #include <flgrCoreMalloc.h>
00029 #include <flgrCoreArithDef.h>
00030 #include "flgrArithShift.h"
00031 #include "flgrArithShiftFast.h"
00032
00042 #define FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(dtype,operator) \
00043 int j,k; \
00044 int spp = datdest->spp; \
00045 int sfsize = spp*right_shift_size; \
00046 dtype *psrc1 = (dtype*) data1->array; \
00047 dtype *pdest = (dtype*) datdest->array; \
00048 int length = datdest->length*spp; \
00049 dtype v1; \
00050 dtype v2; \
00051 dtype result; \
00052 \
00053 \
00054 \
00055 for(j=0 ; j<sfsize ; j++) { \
00056 result = flgr_get_array_##dtype(psrc1,j); \
00057 flgr_set_array_##dtype(pdest,j,result); \
00058 } \
00059 \
00060 for(j=sfsize,k=0 ; j<length ; j++,k++) { \
00061 v1 = flgr_get_array_##dtype(psrc1,j); \
00062 v2 = flgr_get_array_##dtype(psrc1,k); \
00063 result = operator(v1,v2); \
00064 flgr_set_array_##dtype(pdest,j,result); \
00065 } \
00066 \
00067 return
00068
00069
00070 #define FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(dtype,operator) \
00071 int j,k; \
00072 int spp = datdest->spp; \
00073 int sfsize = spp*left_shift_size; \
00074 dtype *psrc1 = (dtype*) data1->array; \
00075 dtype *pdest = (dtype*) datdest->array; \
00076 int length = datdest->length*spp; \
00077 dtype v1; \
00078 dtype v2; \
00079 dtype result; \
00080 \
00081 \
00082 \
00083 for(j=0,k=sfsize ; j<length-sfsize ; j++,k++) { \
00084 v1 = flgr_get_array_##dtype(psrc1,j); \
00085 v2 = flgr_get_array_##dtype(psrc1,k); \
00086 result = operator(v1,v2); \
00087 flgr_set_array_##dtype(pdest,j,result); \
00088 } \
00089 \
00090 for(j=length-sfsize ; j<length ; j++) { \
00091 result = flgr_get_array_##dtype(psrc1,j); \
00092 flgr_set_array_##dtype(pdest,j,result); \
00093 } \
00094 \
00095 return
00096
00097
00098
00099
00100 void flgr1d_arith_sup_shift_right_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00101 if((right_shift_size==1) &&(datdest->spp==1)) {
00102 flgr1d_arith_sup_shift_1_right_fast_fgBIT(datdest,data1);
00103 }else {
00104 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgBIT,flgr_defop_sup_fgBIT);
00105 }
00106 }
00107 void flgr1d_arith_sup_shift_right_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00108 #if defined(__SSE2__) || defined(SSE)
00109 flgr1d_arith_sup_shift_right_fast_fgUINT8(datdest,data1,right_shift_size);
00110 #else
00111 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgUINT8,flgr_defop_sup_fgUINT8);
00112 #endif
00113 }
00114 void flgr1d_arith_sup_shift_right_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00115 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgUINT16,flgr_defop_sup_fgUINT16);
00116 }
00117 void flgr1d_arith_sup_shift_right_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00118 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgUINT32,flgr_defop_sup_fgUINT32);
00119 }
00120 void flgr1d_arith_sup_shift_right_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00121 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgINT8,flgr_defop_sup_fgINT8);
00122 }
00123 void flgr1d_arith_sup_shift_right_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00124 #if defined(__SSE2__) || defined(SSE)
00125 flgr1d_arith_sup_shift_right_fast_fgINT16(datdest,data1,right_shift_size);
00126 #else
00127 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgINT16,flgr_defop_sup_fgINT16);
00128 #endif
00129 }
00130 void flgr1d_arith_sup_shift_right_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00131 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgINT32,flgr_defop_sup_fgINT32);
00132 }
00133 void flgr1d_arith_sup_shift_right_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00134 #if defined(SSE)
00135 flgr1d_arith_sup_shift_right_fast_fgFLOAT32(datdest,data1,right_shift_size);
00136 #else
00137 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgFLOAT32,flgr_defop_sup_fgFLOAT32);
00138 #endif
00139 }
00140 void flgr1d_arith_sup_shift_right_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00141 #if defined(__SSE2__)
00142 flgr1d_arith_sup_shift_right_fast_fgFLOAT64(datdest,data1,right_shift_size);
00143 #else
00144 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgFLOAT64,flgr_defop_sup_fgFLOAT64);
00145 #endif
00146 }
00147
00149
00155
00156 FLGR_Ret flgr1d_arith_sup_shift_right(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00157 FLGR_Ret ret;
00158
00159
00160
00161 if((datdest==NULL) || (data1==NULL)) {
00162 POST_ERROR("Null objects!\n");
00163 return FLGR_RET_NULL_OBJECT;
00164 }
00165
00166 if(right_shift_size<0) {
00167 POST_ERROR("shift size must be > 0\n");
00168 return FLGR_RET_PARAM_ERROR;
00169 }
00170
00171 if((ret = flgr1d_is_data_same_attributes(datdest,data1,__FUNCTION__)) != FLGR_RET_OK) return ret;
00172
00173 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_arith_sup_shift_right,datdest,data1,right_shift_size);
00174
00175 }
00176
00177
00178
00179
00180
00181 void flgr1d_arith_sup_shift_left_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00182 if((left_shift_size==1) &&(datdest->spp==1)) {
00183 flgr1d_arith_sup_shift_1_left_fast_fgBIT(datdest,data1);
00184 }else {
00185 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgBIT,flgr_defop_sup_fgBIT);
00186 }
00187 }
00188 void flgr1d_arith_sup_shift_left_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00189 #if defined(__SSE2__) || defined(SSE)
00190 flgr1d_arith_sup_shift_left_fast_fgUINT8(datdest,data1,left_shift_size);
00191 #else
00192 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgUINT8,flgr_defop_sup_fgUINT8);
00193 #endif
00194 }
00195 void flgr1d_arith_sup_shift_left_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00196 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgUINT16,flgr_defop_sup_fgUINT16);
00197 }
00198 void flgr1d_arith_sup_shift_left_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00199 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgUINT32,flgr_defop_sup_fgUINT32);
00200 }
00201 void flgr1d_arith_sup_shift_left_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00202 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgINT8,flgr_defop_sup_fgINT8);
00203 }
00204 void flgr1d_arith_sup_shift_left_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00205 #if defined(__SSE2__) || defined(SSE)
00206 flgr1d_arith_sup_shift_left_fast_fgINT16(datdest,data1,left_shift_size);
00207 #else
00208 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgINT16,flgr_defop_sup_fgINT16);
00209 #endif
00210 }
00211 void flgr1d_arith_sup_shift_left_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00212 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgINT32,flgr_defop_sup_fgINT32);
00213 }
00214 void flgr1d_arith_sup_shift_left_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00215 #if defined(SSE)
00216 flgr1d_arith_sup_shift_left_fast_fgFLOAT32(datdest,data1,left_shift_size);
00217 #else
00218 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgFLOAT32,flgr_defop_sup_fgFLOAT32);
00219 #endif
00220 }
00221 void flgr1d_arith_sup_shift_left_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00222 #if defined(__SSE2__)
00223 flgr1d_arith_sup_shift_left_fast_fgFLOAT64(datdest,data1,left_shift_size);
00224 #else
00225 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgFLOAT64,flgr_defop_sup_fgFLOAT64);
00226 #endif
00227 }
00229
00235
00236 FLGR_Ret flgr1d_arith_sup_shift_left(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00237 FLGR_Ret ret;
00238
00239
00240
00241 if((datdest==NULL) || (data1==NULL)) {
00242 POST_ERROR("Null objects!\n");
00243 return FLGR_RET_NULL_OBJECT;
00244 }
00245
00246 if(left_shift_size<0) {
00247 POST_ERROR("shift size must be > 0\n");
00248 return FLGR_RET_PARAM_ERROR;
00249 }
00250
00251 if((ret = flgr1d_is_data_same_attributes(datdest,data1,__FUNCTION__)) != FLGR_RET_OK) return ret;
00252
00253 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_arith_sup_shift_left,datdest,data1,left_shift_size);
00254
00255 }
00256
00257
00258
00259
00260
00261
00262 void flgr1d_arith_inf_shift_right_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00263 if((right_shift_size==1) &&(datdest->spp==1)) {
00264 flgr1d_arith_inf_shift_1_right_fast_fgBIT(datdest,data1);
00265 }else {
00266 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgBIT,flgr_defop_inf_fgBIT);
00267 }
00268 }
00269 void flgr1d_arith_inf_shift_right_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00270 #if defined(__SSE2__) || defined(__SSE__)
00271 flgr1d_arith_inf_shift_right_fast_fgUINT8(datdest,data1,right_shift_size);
00272 #else
00273 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgUINT8,flgr_defop_inf_fgUINT8);
00274 #endif
00275 }
00276 void flgr1d_arith_inf_shift_right_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00277 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgUINT16,flgr_defop_inf_fgUINT16);
00278 }
00279 void flgr1d_arith_inf_shift_right_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00280 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgUINT32,flgr_defop_inf_fgUINT32);
00281 }
00282 void flgr1d_arith_inf_shift_right_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00283 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgINT8,flgr_defop_inf_fgINT8);
00284 }
00285 void flgr1d_arith_inf_shift_right_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00286 #if defined(__SSE2__) || defined(__SSE__)
00287 flgr1d_arith_inf_shift_right_fast_fgINT16(datdest,data1,right_shift_size);
00288 #else
00289 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgINT16,flgr_defop_inf_fgINT16);
00290 #endif
00291 }
00292 void flgr1d_arith_inf_shift_right_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00293 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgINT32,flgr_defop_inf_fgINT32);
00294 }
00295 void flgr1d_arith_inf_shift_right_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00296 #if defined(__SSE__)
00297 flgr1d_arith_inf_shift_right_fast_fgFLOAT32(datdest,data1,right_shift_size);
00298 #else
00299 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgFLOAT32,flgr_defop_inf_fgFLOAT32);
00300 #endif
00301 }
00302 void flgr1d_arith_inf_shift_right_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00303 #if defined(__SSE2__)
00304 flgr1d_arith_inf_shift_right_fast_fgFLOAT64(datdest,data1,right_shift_size);
00305 #else
00306 FLGR_MACRO_1D_ARITH_OP_SHIFT_RIGHT(fgFLOAT64,flgr_defop_inf_fgFLOAT64);
00307 #endif
00308 }
00309
00311
00317
00318 FLGR_Ret flgr1d_arith_inf_shift_right(FLGR_Data1D *datdest, FLGR_Data1D *data1, int right_shift_size) {
00319 FLGR_Ret ret;
00320
00321
00322
00323 if((datdest==NULL) || (data1==NULL)) {
00324 POST_ERROR("Null objects!\n");
00325 return FLGR_RET_NULL_OBJECT;
00326 }
00327
00328 if(right_shift_size<0) {
00329 POST_ERROR("shift size must be > 0\n");
00330 return FLGR_RET_PARAM_ERROR;
00331 }
00332
00333 if((ret = flgr1d_is_data_same_attributes(datdest,data1,__FUNCTION__)) != FLGR_RET_OK) return ret;
00334
00335 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_arith_inf_shift_right,datdest,data1,right_shift_size);
00336
00337 }
00338
00339
00340
00341
00342
00343 void flgr1d_arith_inf_shift_left_fgBIT(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00344 if((left_shift_size==1) && (datdest->spp==1)) {
00345 flgr1d_arith_inf_shift_1_left_fast_fgBIT(datdest,data1);
00346 }else {
00347 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgBIT,flgr_defop_inf_fgBIT);
00348 }
00349 }
00350 void flgr1d_arith_inf_shift_left_fgUINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00351 #if defined(__SSE2__) || defined(__SSE__)
00352 flgr1d_arith_inf_shift_left_fast_fgUINT8(datdest,data1,left_shift_size);
00353 #else
00354 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgUINT8,flgr_defop_inf_fgUINT8);
00355 #endif
00356 }
00357 void flgr1d_arith_inf_shift_left_fgUINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00358 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgUINT16,flgr_defop_inf_fgUINT16);
00359 }
00360 void flgr1d_arith_inf_shift_left_fgUINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00361 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgUINT32,flgr_defop_inf_fgUINT32);
00362 }
00363 void flgr1d_arith_inf_shift_left_fgINT8(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00364 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgINT8,flgr_defop_inf_fgINT8);
00365 }
00366 void flgr1d_arith_inf_shift_left_fgINT16(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00367 #if defined(__SSE2__) || defined(__SSE__)
00368 flgr1d_arith_inf_shift_left_fast_fgINT16(datdest,data1,left_shift_size);
00369 #else
00370 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgINT16,flgr_defop_inf_fgINT16);
00371 #endif
00372 }
00373 void flgr1d_arith_inf_shift_left_fgINT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00374 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgINT32,flgr_defop_inf_fgINT32);
00375 }
00376 void flgr1d_arith_inf_shift_left_fgFLOAT32(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00377 #if defined(__SSE__)
00378 flgr1d_arith_inf_shift_left_fast_fgFLOAT32(datdest,data1,left_shift_size);
00379 #else
00380 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgFLOAT32,flgr_defop_inf_fgFLOAT32);
00381 #endif
00382 }
00383 void flgr1d_arith_inf_shift_left_fgFLOAT64(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00384 #if defined(__SSE2__)
00385 flgr1d_arith_inf_shift_left_fast_fgFLOAT64(datdest,data1,left_shift_size);
00386 #else
00387 FLGR_MACRO_1D_ARITH_OP_SHIFT_LEFT(fgFLOAT64,flgr_defop_inf_fgFLOAT64);
00388 #endif
00389 }
00391
00397
00398 FLGR_Ret flgr1d_arith_inf_shift_left(FLGR_Data1D *datdest, FLGR_Data1D *data1, int left_shift_size) {
00399 FLGR_Ret ret;
00400
00401
00402
00403 if((datdest==NULL) || (data1==NULL)) {
00404 POST_ERROR("Null objects!\n");
00405 return FLGR_RET_NULL_OBJECT;
00406 }
00407
00408 if(left_shift_size<0) {
00409 POST_ERROR("shift size must be > 0\n");
00410 return FLGR_RET_PARAM_ERROR;
00411 }
00412
00413 if((ret = flgr1d_is_data_same_attributes(datdest,data1,__FUNCTION__)) != FLGR_RET_OK) return ret;
00414
00415 FLGR_DISPATCH_PROCEDURE(datdest->type,flgr1d_arith_inf_shift_left,datdest,data1,left_shift_size);
00416
00417 }
00418