ISIS Core Library 0.7.2 (api 3.0.0)
|
00001 /* 00002 <one line to give the program's name and a brief idea of what it does.> 00003 Copyright (C) <year> <name of author> 00004 00005 This program is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 00018 */ 00019 00020 #include "numeric_convert.hpp" 00021 00022 #ifdef ISIS_USE_LIBOIL 00023 extern "C" { 00024 #include <liboil/liboil.h> 00025 } 00026 00027 00028 namespace isis 00029 { 00030 namespace data 00031 { 00032 API_EXCLUDE_BEGIN 00033 namespace _internal 00034 { 00035 00038 #define IMPL_CONVERT(SRC,DST,SRC_KEY,DST_KEY) \ 00039 template<> void numeric_convert_impl<SRC,DST>( const SRC *src, DST *dst, size_t count ){\ 00040 LOG( Runtime, info ) \ 00041 << "using optimized convert " << ValueArray<SRC>::staticName() << " => " \ 00042 << ValueArray<DST>::staticName() << " without scaling"; \ 00043 oil_conv_ ## DST_KEY ## _ ## SRC_KEY (dst,sizeof(DST),src,sizeof(SRC),count); \ 00044 } 00045 00046 #define IMPL_SCALED_CONVERT(SRC,DST,SRC_KEY,DST_KEY) \ 00047 template<> void numeric_convert_impl<SRC,DST>( const SRC *src, DST *dst, size_t count, double scale, double offset ){ \ 00048 LOG( Runtime, info ) \ 00049 << "using optimized scaling convert " << ValueArray<SRC>::staticName() << "=>" << ValueArray<DST>::staticName()\ 00050 << " with scale/offset " << std::fixed << scale << "/" << offset; \ 00051 oil_scaleconv_ ## DST_KEY ## _ ## SRC_KEY (dst,src,count,&offset,&scale); \ 00052 } 00053 00054 //>>s32 00055 IMPL_CONVERT( float, int32_t, f32, s32 ) 00056 IMPL_CONVERT( double, int32_t, f64, s32 ) 00057 IMPL_CONVERT( uint32_t, int32_t, u32, s32 ) 00058 IMPL_CONVERT( int16_t, int32_t, s16, s32 ) 00059 IMPL_CONVERT( uint16_t, int32_t, u16, s32 ) 00060 IMPL_CONVERT( int8_t, int32_t, s8, s32 ) 00061 IMPL_CONVERT( uint8_t, int32_t, u8, s32 ) 00062 00063 //>>u32 00064 //IMPL_CONVERT(float,uint32_t,f32,u32) 00065 //IMPL_CONVERT(double,uint32_t,f64,u32) 00066 IMPL_CONVERT( int32_t, uint32_t, s32, u32 ) 00067 //IMPL_CONVERT(int16_t,uint32_t,s16,u32) ** Not available in liboil - but should be imho 00068 IMPL_CONVERT( uint16_t, uint32_t, u16, u32 ) 00069 //IMPL_CONVERT(int8_t,uint32_t,s8,u32) ** Not available in liboil - but should be imho 00070 IMPL_CONVERT( uint8_t, uint32_t, u8, u32 ) 00071 00072 //>>s16 00073 IMPL_CONVERT( float, int16_t, f32, s16 ) 00074 IMPL_CONVERT( double, int16_t, f64, s16 ) 00075 IMPL_CONVERT( int32_t, int16_t, s32, s16 ) 00076 IMPL_CONVERT( uint32_t, int16_t, u32, s16 ) 00077 IMPL_CONVERT( uint16_t, int16_t, u16, s16 ) 00078 IMPL_CONVERT( int8_t, int16_t, s8, s16 ) 00079 IMPL_CONVERT( uint8_t, int16_t, u8, s16 ) 00080 00081 //>>u16 00082 IMPL_CONVERT( float, uint16_t, f32, u16 ) 00083 IMPL_CONVERT( double, uint16_t, f64, u16 ) 00084 IMPL_CONVERT( int32_t, uint16_t, s32, u16 ) 00085 IMPL_CONVERT( uint32_t, uint16_t, u32, u16 ) 00086 IMPL_CONVERT( int16_t, uint16_t, s16, u16 ) 00087 //IMPL_CONVERT(int8_t,uint16_t,s8,u16) ** Not available in liboil - but should be imho 00088 IMPL_CONVERT( uint8_t, uint16_t, u8, u16 ) 00089 00090 //>>s8 00091 IMPL_CONVERT( float, int8_t, f32, s8 ) 00092 IMPL_CONVERT( double, int8_t, f64, s8 ) 00093 IMPL_CONVERT( int32_t, int8_t, s32, s8 ) 00094 IMPL_CONVERT( uint32_t, int8_t, u32, s8 ) 00095 IMPL_CONVERT( int16_t, int8_t, s16, s8 ) 00096 IMPL_CONVERT( uint16_t, int8_t, u16, s8 ) 00097 IMPL_CONVERT( uint8_t, int8_t, u8, s8 ) 00098 00099 //>>u8 00100 IMPL_CONVERT( float, uint8_t, f32, u8 ) 00101 IMPL_CONVERT( double, uint8_t, f64, u8 ) 00102 IMPL_CONVERT( int32_t, uint8_t, s32, u8 ) 00103 IMPL_CONVERT( uint32_t, uint8_t, u32, u8 ) 00104 IMPL_CONVERT( int16_t, uint8_t, s16, u8 ) 00105 IMPL_CONVERT( uint16_t, uint8_t, u16, u8 ) 00106 IMPL_CONVERT( int8_t, uint8_t, s8, u8 ) 00107 00108 //>>f32 00109 IMPL_CONVERT( double, float, f64, f32 ) 00110 IMPL_CONVERT( int32_t, float, s32, f32 ) 00111 IMPL_CONVERT( uint32_t, float, u32, f32 ) 00112 IMPL_CONVERT( int16_t, float, s16, f32 ) 00113 IMPL_CONVERT( uint16_t, float, u16, f32 ) 00114 IMPL_CONVERT( int8_t, float, s8, f32 ) 00115 IMPL_CONVERT( uint8_t, float, u8, f32 ) 00116 00117 //>>f64 00118 IMPL_CONVERT( float, double, f32, f64 ) 00119 IMPL_CONVERT( int32_t, double, s32, f64 ) 00120 IMPL_CONVERT( uint32_t, double, u32, f64 ) 00121 IMPL_CONVERT( int16_t, double, s16, f64 ) 00122 IMPL_CONVERT( uint16_t, double, u16, f64 ) 00123 IMPL_CONVERT( int8_t, double, s8, f64 ) 00124 IMPL_CONVERT( uint8_t, double, u8, f64 ) 00125 00126 00127 //scale>>s32 00128 IMPL_SCALED_CONVERT( float, int32_t, f32, s32 ) 00129 IMPL_SCALED_CONVERT( double, int32_t, f64, s32 ) 00130 00131 //scale>>u32 00132 //IMPL_SCALED_CONVERT(float,uint32_t,f32,u32) 00133 //IMPL_SCALED_CONVERT(double,uint32_t,f64,u32) 00134 00135 //scale>>s16 00136 IMPL_SCALED_CONVERT( float, int16_t, f32, s16 ) 00137 IMPL_SCALED_CONVERT( double, int16_t, f64, s16 ) 00138 00139 //scale>>u16 00140 IMPL_SCALED_CONVERT( float, uint16_t, f32, u16 ) 00141 IMPL_SCALED_CONVERT( double, uint16_t, f64, u16 ) 00142 00143 //scale>>s8 00144 IMPL_SCALED_CONVERT( float, int8_t, f32, s8 ) 00145 IMPL_SCALED_CONVERT( double, int8_t, f64, s8 ) 00146 00147 //scale>>u8 00148 IMPL_SCALED_CONVERT( float, uint8_t, f32, u8 ) 00149 IMPL_SCALED_CONVERT( double, uint8_t, f64, u8 ) 00150 00151 //scale>>f32 00152 IMPL_SCALED_CONVERT( int32_t, float, s32, f32 ) 00153 IMPL_SCALED_CONVERT( uint32_t, float, u32, f32 ) 00154 IMPL_SCALED_CONVERT( int16_t, float, s16, f32 ) 00155 IMPL_SCALED_CONVERT( uint16_t, float, u16, f32 ) 00156 IMPL_SCALED_CONVERT( int8_t, float, s8, f32 ) 00157 IMPL_SCALED_CONVERT( uint8_t, float, u8, f32 ) 00158 00159 //scale>>f64 00160 IMPL_SCALED_CONVERT( int32_t, double, s32, f64 ) 00161 IMPL_SCALED_CONVERT( uint32_t, double, u32, f64 ) 00162 IMPL_SCALED_CONVERT( int16_t, double, s16, f64 ) 00163 IMPL_SCALED_CONVERT( uint16_t, double, u16, f64 ) 00164 IMPL_SCALED_CONVERT( int8_t, double, s8, f64 ) 00165 IMPL_SCALED_CONVERT( uint8_t, double, u8, f64 ) 00166 00167 #undef IMPL_CONVERT 00168 #undef IMPL_SCALED_CONVERT 00169 } 00170 #pragma GCC visibility pop 00171 } 00172 } 00173 #endif //ISIS_USE_LIBOIL 00174