| 319 | } |
| 320 | |
| 321 | static float wv_get_value_float(WavpackFrameContext *s, uint32_t *crc, int S) |
| 322 | { |
| 323 | union { |
| 324 | float f; |
| 325 | uint32_t u; |
| 326 | } value; |
| 327 | |
| 328 | unsigned int sign; |
| 329 | int exp = s->float_max_exp; |
| 330 | |
| 331 | if (s->got_extra_bits) { |
| 332 | const int max_bits = 1 + 23 + 8 + 1; |
| 333 | const int left_bits = get_bits_left(&s->gb_extra_bits); |
| 334 | |
| 335 | if (left_bits + 8 * AV_INPUT_BUFFER_PADDING_SIZE < max_bits) |
| 336 | return 0.0; |
| 337 | } |
| 338 | |
| 339 | if (S) { |
| 340 | S *= 1U << s->float_shift; |
| 341 | sign = S < 0; |
| 342 | if (sign) |
| 343 | S = -(unsigned)S; |
| 344 | if (S >= 0x1000000U) { |
| 345 | if (s->got_extra_bits && get_bits1(&s->gb_extra_bits)) |
| 346 | S = get_bits(&s->gb_extra_bits, 23); |
| 347 | else |
| 348 | S = 0; |
| 349 | exp = 255; |
| 350 | } else if (exp) { |
| 351 | int shift = 23 - av_log2(S); |
| 352 | exp = s->float_max_exp; |
| 353 | if (exp <= shift) |
| 354 | shift = --exp; |
| 355 | exp -= shift; |
| 356 | |
| 357 | if (shift) { |
| 358 | S <<= shift; |
| 359 | if ((s->float_flag & WV_FLT_SHIFT_ONES) || |
| 360 | (s->got_extra_bits && |
| 361 | (s->float_flag & WV_FLT_SHIFT_SAME) && |
| 362 | get_bits1(&s->gb_extra_bits))) { |
| 363 | S |= (1 << shift) - 1; |
| 364 | } else if (s->got_extra_bits && |
| 365 | (s->float_flag & WV_FLT_SHIFT_SENT)) { |
| 366 | S |= get_bits(&s->gb_extra_bits, shift); |
| 367 | } |
| 368 | } |
| 369 | } else { |
| 370 | exp = s->float_max_exp; |
| 371 | } |
| 372 | S &= 0x7fffff; |
| 373 | } else { |
| 374 | sign = 0; |
| 375 | exp = 0; |
| 376 | if (s->got_extra_bits && (s->float_flag & WV_FLT_ZERO_SENT)) { |
| 377 | if (get_bits1(&s->gb_extra_bits)) { |
| 378 | S = get_bits(&s->gb_extra_bits, 23); |
no test coverage detected