00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <flgrCoreData.h>
00023 #include <flgrCoreVector.h>
00024 #include <flgrCoreArithVector.h>
00025 #include <flgrCoreDispatch.h>
00026 #include <flgrCoreDataIO.h>
00027 #include "flgrCoreTranspose.h"
00028 #include "flgrCoreTransposeFast.h"
00029
00030
00032
00034 #define FLGR_MACRO_TRANSPOSE(dtype) \
00035 FLGR_Vector *vec = flgr_vector_create(datsrc->spp,datsrc->type); \
00036 int size_y, size_x; \
00037 int i,j; \
00038 \
00039 \
00040 \
00041 size_y=datsrc->size_y; \
00042 size_x=datsrc->size_x; \
00043 \
00044 for(i=0;i<size_y;i++) { \
00045 for(j=0;j<size_x;j++) { \
00046 flgr2d_get_data_vector_##dtype(datsrc,i,j,vec); \
00047 flgr2d_set_data_vector_##dtype(datdest,j,i,vec); \
00048 } \
00049 } \
00050 \
00051 flgr_vector_destroy(vec); \
00052 return
00053
00054
00055 void flgr2d_transpose_fgBIT(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00056 FLGR_MACRO_TRANSPOSE(fgBIT);
00057 }
00058
00059 void flgr2d_transpose_fgUINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00060 #ifdef __SSE2__
00061 if(datdest->spp==1) {
00062 flgr2d_transpose_fast_fgUINT8(datdest,datsrc);
00063
00064 }else if(datdest->spp==2) {
00065 flgr2d_transpose_fast_fgUINT16(datdest,datsrc);
00066
00067 }else if(datdest->spp==4) {
00068 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00069
00070 }else {
00071 FLGR_MACRO_TRANSPOSE(fgUINT8);
00072 }
00073 #else
00074 #ifdef __MMX__
00075 if(datdest->spp==1) {
00076 flgr2d_transpose_fast_fgUINT8(datdest,datsrc);
00077 }else {
00078 FLGR_MACRO_TRANSPOSE(fgUINT8);
00079 }
00080 #else
00081 FLGR_MACRO_TRANSPOSE(fgUINT8);
00082 #endif
00083 #endif
00084 }
00085
00086 void flgr2d_transpose_fgUINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00087 #ifdef __SSE2__
00088 if(datdest->spp==1) {
00089 flgr2d_transpose_fast_fgUINT16(datdest,datsrc);
00090 }else if(datdest->spp==2) {
00091 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00092 }else {
00093 FLGR_MACRO_TRANSPOSE(fgUINT16);
00094 }
00095 #else
00096 FLGR_MACRO_TRANSPOSE(fgUINT16);
00097 #endif
00098 }
00099
00100 void flgr2d_transpose_fgUINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00101 #ifdef __SSE2__
00102 if(datdest->spp==1) {
00103 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00104 }else {
00105 FLGR_MACRO_TRANSPOSE(fgUINT32);
00106 }
00107 #else
00108 FLGR_MACRO_TRANSPOSE(fgUINT32);
00109 #endif
00110 }
00111
00112 void flgr2d_transpose_fgINT8(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00113 #ifdef __SSE2__
00114 if(datdest->spp==1) {
00115 flgr2d_transpose_fast_fgUINT8(datdest,datsrc);
00116 }else if(datdest->spp==2) {
00117 flgr2d_transpose_fast_fgUINT16(datdest,datsrc);
00118 }else if(datdest->spp==4) {
00119 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00120 }else {
00121 FLGR_MACRO_TRANSPOSE(fgUINT8);
00122 }
00123 #else
00124 #ifdef __MMX__
00125 if(datdest->spp==1) {
00126 flgr2d_transpose_fast_fgUINT8(datdest,datsrc);
00127 }else {
00128 FLGR_MACRO_TRANSPOSE(fgUINT8);
00129 }
00130 #else
00131 FLGR_MACRO_TRANSPOSE(fgUINT8);
00132 #endif
00133 #endif
00134 }
00135
00136 void flgr2d_transpose_fgINT16(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00137 #ifdef __SSE2__
00138 if(datdest->spp==1) {
00139 flgr2d_transpose_fast_fgUINT16(datdest,datsrc);
00140 }else if(datdest->spp==2) {
00141 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00142 }else {
00143 FLGR_MACRO_TRANSPOSE(fgINT16);
00144 }
00145 #else
00146 FLGR_MACRO_TRANSPOSE(fgINT16);
00147 #endif
00148 }
00149
00150 void flgr2d_transpose_fgINT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00151 #ifdef __SSE2__
00152 if(datdest->spp==1) {
00153 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00154 }else {
00155 FLGR_MACRO_TRANSPOSE(fgINT32);
00156 }
00157 #else
00158 FLGR_MACRO_TRANSPOSE(fgINT32);
00159 #endif
00160 }
00161
00162 void flgr2d_transpose_fgFLOAT32(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00163 #ifdef __SSE2__
00164 if(datdest->spp==1) {
00165 flgr2d_transpose_fast_fgUINT32(datdest,datsrc);
00166 }else {
00167 FLGR_MACRO_TRANSPOSE(fgFLOAT32);
00168 }
00169 #else
00170 FLGR_MACRO_TRANSPOSE(fgFLOAT32);
00171 #endif
00172 }
00173
00174 void flgr2d_transpose_fgFLOAT64(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00175 FLGR_MACRO_TRANSPOSE(fgFLOAT64);
00176 }
00177
00178 FLGR_Ret flgr2d_transpose(FLGR_Data2D *datdest, FLGR_Data2D *datsrc) {
00179
00180
00181
00182 if((datdest==NULL) || (datsrc==NULL)){
00183 POST_ERROR("Null objects!\n");
00184 return FLGR_RET_NULL_OBJECT;
00185 }
00186
00187 if(flgr2d_is_data_same_type(datdest, datsrc)!=0) {
00188 POST_ERROR("src type and dest type different!\n");
00189 return FLGR_RET_TYPE_DIFFERENT;
00190 }
00191
00192 if(flgr2d_is_data_same_spp(datdest, datsrc)!=0) {
00193 POST_ERROR("src SPP and dest SPP different!\n");
00194 return FLGR_RET_UNDEFINED_ERROR;
00195 }
00196
00197 if((datdest->size_x!=datsrc->size_y)||(datdest->size_y!=datsrc->size_x)) {
00198 POST_ERROR("src size and dest size incompatible!\n");
00199 return FLGR_RET_SIZE_ERROR;
00200 }
00201
00202 FLGR_DISPATCH_PROCEDURE(datsrc->type,flgr2d_transpose,datdest, datsrc);
00203
00204 }
00205