Revision 16b54d61 host/lib/convert/convert_common.hpp
| b/host/lib/convert/convert_common.hpp | ||
|---|---|---|
| 46 | 46 |
typedef std::complex<boost::int16_t> sc16_t; |
| 47 | 47 |
typedef std::complex<boost::int8_t> sc8_t; |
| 48 | 48 |
typedef boost::uint32_t item32_t; |
| 49 |
typedef boost::uint16_t item16_t; |
|
| 49 | 50 |
|
| 50 | 51 |
/*********************************************************************** |
| 51 | 52 |
* Convert complex short buffer to items32 |
| ... | ... | |
| 104 | 105 |
); |
| 105 | 106 |
} |
| 106 | 107 |
|
| 108 |
/*********************************************************************** |
|
| 109 |
* Convert complex short buffer to items32 |
|
| 110 |
**********************************************************************/ |
|
| 111 |
static UHD_INLINE item16_t sc16_to_item16(sc16_t num, double){
|
|
| 112 |
boost::uint16_t real = num.real(); |
|
| 113 |
boost::uint16_t imag = num.imag(); |
|
| 114 |
return (item16_t(real) << 8) | (item16_t(imag) << 0); |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
/*********************************************************************** |
|
| 118 |
* Convert items32 buffer to complex short |
|
| 119 |
**********************************************************************/ |
|
| 120 |
static UHD_INLINE sc16_t item16_to_sc16(item16_t item, double){
|
|
| 121 |
return sc16_t( |
|
| 122 |
boost::int16_t(item >> 8), |
|
| 123 |
boost::int16_t(item >> 0) |
|
| 124 |
); |
|
| 125 |
} |
|
| 126 |
|
|
| 127 |
/*********************************************************************** |
|
| 128 |
* Convert complex float buffer to items32 (no swap) |
|
| 129 |
**********************************************************************/ |
|
| 130 |
static UHD_INLINE item16_t fc32_to_item16(fc32_t num, float scale_factor){
|
|
| 131 |
boost::uint16_t real = boost::int16_t(num.real()*scale_factor); |
|
| 132 |
boost::uint16_t imag = boost::int16_t(num.imag()*scale_factor); |
|
| 133 |
return (item16_t(real) << 8) | (item16_t(imag) << 0); |
|
| 134 |
} |
|
| 135 |
|
|
| 136 |
/*********************************************************************** |
|
| 137 |
* Convert items32 buffer to complex float |
|
| 138 |
**********************************************************************/ |
|
| 139 |
static UHD_INLINE fc32_t item16_to_fc32(item16_t item, float scale_factor){
|
|
| 140 |
return fc32_t( |
|
| 141 |
float(boost::int16_t(item >> 8)*scale_factor), |
|
| 142 |
float(boost::int16_t(item >> 0)*scale_factor) |
|
| 143 |
); |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
/*********************************************************************** |
|
| 147 |
* Convert complex double buffer to items32 (no swap) |
|
| 148 |
**********************************************************************/ |
|
| 149 |
static UHD_INLINE item16_t fc64_to_item16(fc64_t num, double scale_factor){
|
|
| 150 |
boost::uint16_t real = boost::int16_t(num.real()*scale_factor); |
|
| 151 |
boost::uint16_t imag = boost::int16_t(num.imag()*scale_factor); |
|
| 152 |
return (item16_t(real) << 8) | (item16_t(imag) << 0); |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
/*********************************************************************** |
|
| 156 |
* Convert items32 buffer to complex double |
|
| 157 |
**********************************************************************/ |
|
| 158 |
static UHD_INLINE fc64_t item16_to_fc64(item16_t item, double scale_factor){
|
|
| 159 |
return fc64_t( |
|
| 160 |
float(boost::int16_t(item >> 8)*scale_factor), |
|
| 161 |
float(boost::int16_t(item >> 0)*scale_factor) |
|
| 162 |
); |
|
| 163 |
} |
|
| 164 |
|
|
| 107 | 165 |
#endif /* INCLUDED_LIBUHD_CONVERT_COMMON_HPP */ |
Also available in: Unified diff