| 224 | #define get_sign(f) (((f) >> 31) & 0x1) |
| 225 | |
| 226 | static void process_float(WavPackEncodeContext *s, int32_t *sample) |
| 227 | { |
| 228 | int32_t shift_count, value, f = *sample; |
| 229 | |
| 230 | if (get_exponent(f) == 255) { |
| 231 | s->float_flags |= FLOAT_EXCEPTIONS; |
| 232 | value = 0x1000000; |
| 233 | shift_count = 0; |
| 234 | } else if (get_exponent(f)) { |
| 235 | shift_count = s->max_exp - get_exponent(f); |
| 236 | value = 0x800000 + get_mantissa(f); |
| 237 | } else { |
| 238 | shift_count = s->max_exp ? s->max_exp - 1 : 0; |
| 239 | value = get_mantissa(f); |
| 240 | } |
| 241 | |
| 242 | if (shift_count < 25) |
| 243 | value >>= shift_count; |
| 244 | else |
| 245 | value = 0; |
| 246 | |
| 247 | if (!value) { |
| 248 | if (get_exponent(f) || get_mantissa(f)) |
| 249 | s->false_zeros++; |
| 250 | else if (get_sign(f)) |
| 251 | s->neg_zeros++; |
| 252 | } else if (shift_count) { |
| 253 | int32_t mask = (1 << shift_count) - 1; |
| 254 | |
| 255 | if (!(get_mantissa(f) & mask)) |
| 256 | s->shifted_zeros++; |
| 257 | else if ((get_mantissa(f) & mask) == mask) |
| 258 | s->shifted_ones++; |
| 259 | else |
| 260 | s->shifted_both++; |
| 261 | } |
| 262 | |
| 263 | s->ordata |= value; |
| 264 | *sample = get_sign(f) ? -value : value; |
| 265 | } |
| 266 | |
| 267 | static int scan_float(WavPackEncodeContext *s, |
| 268 | int32_t *samples_l, int32_t *samples_r, |