Revision 8a98d689 host/lib/convert/convert_common.hpp

b/host/lib/convert/convert_common.hpp
194 194
 * Convert complex char to items32 sc8 buffer
195 195
 **********************************************************************/
196 196
static UHD_INLINE item32_t sc8_to_item32_sc8(sc8_t in0, sc8_t in1, double){
197
    boost::uint8_t real0 = boost::int8_t(in0.real());
198
    boost::uint8_t imag0 = boost::int8_t(in0.imag());
199
    boost::uint8_t real1 = boost::int8_t(in1.real());
200
    boost::uint8_t imag1 = boost::int8_t(in1.imag());
197 201
    return
198
        (item32_t(boost::uint8_t(in0.real())) << 8) |
199
        (item32_t(boost::uint8_t(in0.imag())) << 0) |
200
        (item32_t(boost::uint8_t(in1.real())) << 24) |
201
        (item32_t(boost::uint8_t(in1.imag())) << 16)
202
        (item32_t(real0) << 8) | (item32_t(imag0) << 0) |
203
        (item32_t(real1) << 24) | (item32_t(imag1) << 16)
202 204
    ;
203 205
}
204 206

  
......
206 208
 * Convert complex short to items32 sc8 buffer
207 209
 **********************************************************************/
208 210
static UHD_INLINE item32_t sc16_to_item32_sc8(sc16_t in0, sc16_t in1, double){
211
    boost::uint8_t real0 = boost::int8_t(in0.real());
212
    boost::uint8_t imag0 = boost::int8_t(in0.imag());
213
    boost::uint8_t real1 = boost::int8_t(in1.real());
214
    boost::uint8_t imag1 = boost::int8_t(in1.imag());
209 215
    return
210
        (item32_t(boost::uint8_t(in0.real())) << 8) |
211
        (item32_t(boost::uint8_t(in0.imag())) << 0) |
212
        (item32_t(boost::uint8_t(in1.real())) << 24) |
213
        (item32_t(boost::uint8_t(in1.imag())) << 16)
216
        (item32_t(real0) << 8) | (item32_t(imag0) << 0) |
217
        (item32_t(real1) << 24) | (item32_t(imag1) << 16)
214 218
    ;
215 219
}
216 220

  
......
218 222
 * Convert complex float to items32 sc8 buffer
219 223
 **********************************************************************/
220 224
static UHD_INLINE item32_t fc32_to_item32_sc8(fc32_t in0, fc32_t in1, double scale_factor){
225
    boost::uint8_t real0 = boost::int8_t(in0.real()*float(scale_factor));
226
    boost::uint8_t imag0 = boost::int8_t(in0.imag()*float(scale_factor));
227
    boost::uint8_t real1 = boost::int8_t(in1.real()*float(scale_factor));
228
    boost::uint8_t imag1 = boost::int8_t(in1.imag()*float(scale_factor));
221 229
    return
222
        (item32_t(boost::uint8_t(in0.real()*float(scale_factor))) << 8) |
223
        (item32_t(boost::uint8_t(in0.imag()*float(scale_factor))) << 0) |
224
        (item32_t(boost::uint8_t(in1.real()*float(scale_factor))) << 24) |
225
        (item32_t(boost::uint8_t(in1.imag()*float(scale_factor))) << 16)
230
        (item32_t(real0) << 8) | (item32_t(imag0) << 0) |
231
        (item32_t(real1) << 24) | (item32_t(imag1) << 16)
226 232
    ;
227 233
}
228 234

  
......
230 236
 * Convert complex double to items32 sc8 buffer
231 237
 **********************************************************************/
232 238
static UHD_INLINE item32_t fc64_to_item32_sc8(fc64_t in0, fc64_t in1, double scale_factor){
239
    boost::uint8_t real0 = boost::int8_t(in0.real()*(scale_factor));
240
    boost::uint8_t imag0 = boost::int8_t(in0.imag()*(scale_factor));
241
    boost::uint8_t real1 = boost::int8_t(in1.real()*(scale_factor));
242
    boost::uint8_t imag1 = boost::int8_t(in1.imag()*(scale_factor));
233 243
    return
234
        (item32_t(boost::uint8_t(in0.real()*(scale_factor))) << 8) |
235
        (item32_t(boost::uint8_t(in0.imag()*(scale_factor))) << 0) |
236
        (item32_t(boost::uint8_t(in1.real()*(scale_factor))) << 24) |
237
        (item32_t(boost::uint8_t(in1.imag()*(scale_factor))) << 16)
244
        (item32_t(real0) << 8) | (item32_t(imag0) << 0) |
245
        (item32_t(real1) << 24) | (item32_t(imag1) << 16)
238 246
    ;
239 247
}
240 248

  

Also available in: Unified diff