| 2467 | } |
| 2468 | |
| 2469 | static int wavpack_encode_block(WavPackEncodeContext *s, |
| 2470 | int32_t *samples_l, int32_t *samples_r, |
| 2471 | uint8_t *out, int out_size) |
| 2472 | { |
| 2473 | int block_size, start, end, data_size, tcount, temp, m = 0; |
| 2474 | int i, j, ret = 0, got_extra = 0, nb_samples = s->block_samples; |
| 2475 | uint32_t crc = 0xffffffffu; |
| 2476 | struct Decorr *dpp; |
| 2477 | PutByteContext pb; |
| 2478 | |
| 2479 | if (s->flags & WV_MONO_DATA) { |
| 2480 | CLEAR(s->w); |
| 2481 | } |
| 2482 | if (!(s->flags & WV_MONO) && s->optimize_mono) { |
| 2483 | int32_t lor = 0, diff = 0; |
| 2484 | |
| 2485 | for (i = 0; i < nb_samples; i++) { |
| 2486 | lor |= samples_l[i] | samples_r[i]; |
| 2487 | diff |= samples_l[i] - samples_r[i]; |
| 2488 | |
| 2489 | if (lor && diff) |
| 2490 | break; |
| 2491 | } |
| 2492 | |
| 2493 | if (i == nb_samples && lor && !diff) { |
| 2494 | s->flags &= ~(WV_JOINT_STEREO | WV_CROSS_DECORR); |
| 2495 | s->flags |= WV_FALSE_STEREO; |
| 2496 | |
| 2497 | if (!s->false_stereo) { |
| 2498 | s->false_stereo = 1; |
| 2499 | s->num_terms = 0; |
| 2500 | CLEAR(s->w); |
| 2501 | } |
| 2502 | } else if (s->false_stereo) { |
| 2503 | s->false_stereo = 0; |
| 2504 | s->num_terms = 0; |
| 2505 | CLEAR(s->w); |
| 2506 | } |
| 2507 | } |
| 2508 | |
| 2509 | if (s->flags & SHIFT_MASK) { |
| 2510 | int shift = (s->flags & SHIFT_MASK) >> SHIFT_LSB; |
| 2511 | int mag = (s->flags & MAG_MASK) >> MAG_LSB; |
| 2512 | |
| 2513 | if (s->flags & WV_MONO_DATA) |
| 2514 | shift_mono(samples_l, nb_samples, shift); |
| 2515 | else |
| 2516 | shift_stereo(samples_l, samples_r, nb_samples, shift); |
| 2517 | |
| 2518 | if ((mag -= shift) < 0) |
| 2519 | s->flags &= ~MAG_MASK; |
| 2520 | else |
| 2521 | s->flags -= (1 << MAG_LSB) * shift; |
| 2522 | } |
| 2523 | |
| 2524 | if ((s->flags & WV_FLOAT_DATA) || (s->flags & MAG_MASK) >> MAG_LSB >= 24) { |
| 2525 | av_fast_padded_malloc(&s->orig_l, &s->orig_l_size, sizeof(int32_t) * nb_samples); |
| 2526 | memcpy(s->orig_l, samples_l, sizeof(int32_t) * nb_samples); |
no test coverage detected