3311{
3312
3314 int32_t len,i,j,k, max_submaps = 0;
3316
3317
3319
3320
3322
3326
3329
3331 getn(f, header, 6) &&
3332 header[0] == 'f' &&
3333 header[1] == 'i' &&
3334 header[2] == 's' &&
3335 header[3] == 'h' &&
3336 header[4] == 'e' &&
3337 header[5] == 'a' &&
3340 else
3342 }
3343
3344
3345
3349
3358 {
3367 }
3368
3369
3372
3373
3374
3375
3376
3378
3380
3382
3386
3390 for(i=0; i < len; ++i) {
3392 }
3393 f->
vendor[len] = (char)
'\0';
3394
3398 {
3401 }
3402
3407
3408 for(j=0; j < len; ++j) {
3410 }
3412 }
3413
3414
3417
3420
3421 do {
3425 } while (len);
3426
3427
3428
3430
3431 #ifndef FL_STB_VORBIS_NO_PUSHDATA_API
3434
3437 return false;
3438 }
3439 }
3440 #endif
3441
3443
3447
3448
3449
3450
3452
3457
3459 int32_t ordered, sorted_count;
3464
3468
3470 c->dimensions = (
get_bits(f, 8)<<8) +
x;
3473 c->entries = (
get_bits(f, 8)<<16) + (
y<<8) +
x;
3475 c->sparse = ordered ? 0 :
get_bits(f,1);
3476
3477
3479
3480 if (c->sparse)
3482 else
3484
3486
3487 if (ordered) {
3488
3492 while (current_entry < c->entries) {
3493 if (++loop_counter > 100000) {
3494
3496 }
3497 int32_t limit = c->entries - current_entry;
3502 current_entry += n;
3503 ++current_length;
3504 }
3505
3506 } else {
3507
3508 for (j=0; j < c->entries; ++j) {
3510 if (present) {
3512 ++total;
3515 } else {
3517 }
3518 }
3519
3520 }
3521
3522 if (c->sparse && total >= c->entries >> 2) {
3523
3526
3531 lengths = c->codeword_lengths;
3532 c->sparse = 0;
3533 }
3534
3535
3536 if (c->sparse) {
3537 sorted_count = total;
3538 } else {
3539 sorted_count = 0;
3540 #ifndef FL_STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
3541 for (j=0; j < c->entries; ++j)
3543 ++sorted_count;
3544 #endif
3545 }
3546
3547 c->sorted_entries = sorted_count;
3548 values = nullptr;
3549
3551 if (!c->sparse) {
3554 } else {
3556 if (c->sorted_entries) {
3563 }
3564 size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
3567 }
3568
3569
3573 }
3574
3575
3576 if (c->sorted_entries) {
3577
3578
3579 c->sorted_codewords = (
uint32 *)
setup_malloc(f,
sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
3581
3582
3583 c->sorted_values = (
int32_t *)
setup_malloc(f,
sizeof(*c->sorted_values ) * (c->sorted_entries+1));
3585 ++c->sorted_values;
3586 c->sorted_values[-1] = -1;
3587
3589
3590 }
3591
3592 if (c->sparse) {
3594 setup_temp_free(f, c->codewords,
sizeof(*c->codewords)*c->sorted_entries);
3596 c->codewords = nullptr;
3597 }
3598
3599
3601
3602
3606 if (c->lookup_type > 0) {
3612 if (c->lookup_type == 1) {
3615 c->lookup_values = (
uint32) values;
3616 } else {
3617 c->lookup_values = c->entries * c->dimensions;
3618 }
3622 for (j=0; j < (
int32_t) c->lookup_values; ++j) {
3625 mults[j] = q;
3626 }
3627
3628#ifndef FL_STB_VORBIS_DIVIDES_IN_CODEBOOK
3629 if (c->lookup_type == 1) {
3630 int32_t len, sparse = c->sparse;
3631 float last=0;
3632
3633 if (sparse) {
3634 if (c->sorted_entries == 0)
goto skip;
3635 c->multiplicands = (
codetype *)
setup_malloc(f,
sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
3636 } else
3637 c->multiplicands = (
codetype *)
setup_malloc(f,
sizeof(c->multiplicands[0]) * c->entries * c->dimensions);
3639 len = sparse ? c->sorted_entries : c->entries;
3640 for (j=0; j < len; ++j) {
3641 uint32_t z = sparse ? c->sorted_values[j] : j;
3643 for (k=0; k < c->dimensions; ++k) {
3644 int32_t off = (
z / div) % c->lookup_values;
3645 float val = mults[off]*c->delta_value + c->minimum_value + last;
3646 c->multiplicands[j*c->dimensions + k] = val;
3647 if (c->sequence_p)
3648 last = val;
3649 if (k+1 < c->dimensions) {
3653 }
3654 div *= c->lookup_values;
3655 }
3656 }
3657 }
3658 c->lookup_type = 2;
3659 }
3660 else
3661#endif
3662 {
3663 float last=0;
3665 c->multiplicands = (
codetype *)
setup_malloc(f,
sizeof(c->multiplicands[0]) * c->lookup_values);
3667 for (j=0; j < (
int32_t) c->lookup_values; ++j) {
3668 float val = mults[j] * c->delta_value + c->minimum_value + last;
3669 c->multiplicands[j] = val;
3670 if (c->sequence_p)
3671 last = val;
3672 }
3673 }
3674#ifndef FL_STB_VORBIS_DIVIDES_IN_CODEBOOK
3676#endif
3678
3680 }
3682 }
3683
3684
3685
3687 for (i=0; i <
x; ++i) {
3690 }
3691
3692
3705 g->amplitude_offset =
get_bits(f,8);
3706 g->number_of_books =
get_bits(f,4) + 1;
3707 for (j=0; j < g->number_of_books; ++j)
3710 } else {
3715 for (j=0; j < g->partitions; ++j) {
3716 g->partition_class_list[j] =
get_bits(f, 4);
3717 if (g->partition_class_list[j] > max_class)
3718 max_class = g->partition_class_list[j];
3719 }
3720 for (j=0; j <= max_class; ++j) {
3721 g->class_dimensions[j] =
get_bits(f, 3)+1;
3722 g->class_subclasses[j] =
get_bits(f, 2);
3723 if (g->class_subclasses[j]) {
3724 g->class_masterbooks[j] =
get_bits(f, 8);
3726 }
3727 for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
3730 }
3731 }
3732 g->floor1_multiplier =
get_bits(f,2)+1;
3734 g->Xlist[0] = 0;
3735 g->Xlist[1] = 1 << g->rangebits;
3736 g->values = 2;
3737 for (j=0; j < g->partitions; ++j) {
3738 int32_t c = g->partition_class_list[j];
3739 for (k=0; k < g->class_dimensions[c]; ++k) {
3740 g->Xlist[g->values] =
get_bits(f, g->rangebits);
3741 ++g->values;
3742 }
3743 }
3744
3745 for (j=0; j < g->values; ++j) {
3746 p[j].x = g->Xlist[j];
3747 p[j].id = j;
3748 }
3750 for (j=0; j < g->values-1; ++j)
3751 if (p[j].
x == p[j+1].
x)
3753 for (j=0; j < g->values; ++j)
3754 g->sorted_order[j] = (
uint8) p[j].id;
3755
3756 for (j=2; j < g->values; ++j) {
3759 g->neighbors[j][0] = low;
3760 g->neighbors[j][1] = hi;
3761 }
3762
3763 if (g->values > longest_floorlist)
3764 longest_floorlist = g->values;
3765 }
3766 }
3767
3768
3774 uint8 residue_cascade[64];
3782 r->classifications =
get_bits(f,6)+1;
3785 for (j=0; j < r->classifications; ++j) {
3790 residue_cascade[j] = high_bits*8 + low_bits;
3791 }
3792 r->residue_books = (short (*)[8])
setup_malloc(f,
sizeof(r->residue_books[0]) * r->classifications);
3794 for (j=0; j < r->classifications; ++j) {
3795 for (k=0; k < 8; ++k) {
3796 if (residue_cascade[j] & (1 << k)) {
3797 r->residue_books[j][k] =
get_bits(f, 8);
3799 } else {
3800 r->residue_books[j][k] = -1;
3801 }
3802 }
3803 }
3804
3805
3812 r->classdata[j] = (
uint8 *)
setup_malloc(f,
sizeof(r->classdata[j][0]) * classwords);
3814 for (k=classwords-1; k >= 0; --k) {
3815 r->classdata[j][k] = temp % r->classifications;
3816 temp /= r->classifications;
3817 }
3818 }
3819 }
3820
3833 else
3834 m->submaps = 1;
3835 if (m->submaps > max_submaps)
3836 max_submaps = m->submaps;
3838 m->coupling_steps =
get_bits(f,8)+1;
3840 for (k=0; k < m->coupling_steps; ++k) {
3846 }
3847 } else
3848 m->coupling_steps = 0;
3849
3850
3852 if (m->submaps > 1) {
3856 }
3857 } else
3858
3860 m->chan[j].mux = 0;
3861
3862 for (j=0; j < m->submaps; ++j) {
3864 m->submap_floor[j] =
get_bits(f,8);
3865 m->submap_residue[j] =
get_bits(f,8);
3868 }
3869 }
3870
3871
3882 }
3883
3885
3887
3894 #ifdef FL_STB_VORBIS_NO_DEFER_FLOOR
3897 #endif
3898 }
3899
3904
3905#ifdef FL_STB_VORBIS_DIVIDE_TABLE
3910#endif
3911
3912
3913
3914
3915 {
3922 uint32_t limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
3923 uint32_t limit_r_end = r->end < actual_size ? r->end : actual_size;
3924 int32_t n_read = limit_r_end - limit_r_begin;
3925 int32_t part_read = n_read / r->part_size;
3926 if (part_read > max_part_read)
3927 max_part_read = part_read;
3928 }
3929 #ifndef FL_STB_VORBIS_DIVIDES_IN_RESIDUE
3930 classify_mem = f->
channels * (
sizeof(
void*) + max_part_read *
sizeof(
uint8 *));
3931 #else
3932 classify_mem = f->
channels * (
sizeof(
void*) + max_part_read *
sizeof(
int32_t*));
3933 #endif
3934
3935
3936
3940 }
3941
3942
3945
3948 }
3949
3950
3951
3952
3953
3954
3955
3958 } else {
3960 }
3961
3962
3963 return true;
3964}
#define FL_ASSERT(x, MSG)
void * memcpy(void *dest, const void *src, size_t n) FL_NOEXCEPT
static void flush_packet(vorb *f) FL_NOEXCEPT
static int32_t start_page(vorb *f) FL_NOEXCEPT
static int32_t ilog(int32 n) FL_NOEXCEPT
static int32_t error(vorb *f, enum STBVorbisError e) FL_NOEXCEPT
int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]
static constexpr uint8_t NO_CODE
static int32_t init_blocksize(vorb *f, int32_t b, int32_t n) FL_NOEXCEPT
static void setup_temp_free(vorb *f, void *p, int32_t sz) FL_NOEXCEPT
static int32_t is_whole_packet_present(stb_vorbis *f) FL_NOEXCEPT
static constexpr uint8_t PAGEFLAG_last_page
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
static void skip(vorb *z, int32_t n) FL_NOEXCEPT
static constexpr int32_t EOP
static float float32_unpack(uint32 x) FL_NOEXCEPT
static constexpr uint8_t PAGEFLAG_continued_packet
static int32_t vorbis_validate(uint8 *data) FL_NOEXCEPT
static constexpr int32_t DIVTAB_DENOM
static void crc32_init(void) FL_NOEXCEPT
@ VORBIS_too_many_channels
@ VORBIS_ogg_skeleton_not_supported
@ VORBIS_feature_not_supported
@ VORBIS_invalid_first_page
static constexpr int32_t DIVTAB_NUMER
static int32_t getn(vorb *z, uint8 *data, int32_t n) FL_NOEXCEPT
static uint8 get8(vorb *z) FL_NOEXCEPT
static void * setup_malloc(vorb *f, int32_t sz) FL_NOEXCEPT
uint32_t stb_vorbis_get_file_offset(stb_vorbis *f) FL_NOEXCEPT
static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) FL_NOEXCEPT
static int32_t lookup1_values(int32_t entries, int32_t dim) FL_NOEXCEPT
static int32_t compute_codewords(Codebook *c, uint8 *len, int32_t n, uint32 *values) FL_NOEXCEPT
static int32_t start_packet(vorb *f) FL_NOEXCEPT
static void neighbors(uint16 *x, int32_t n, int32_t *plow, int32_t *phigh) FL_NOEXCEPT
static void * setup_temp_malloc(vorb *f, int32_t sz) FL_NOEXCEPT
static int32_t get32_packet(vorb *f) FL_NOEXCEPT
static int point_compare(const void *p, const void *q) FL_NOEXCEPT
static constexpr uint8_t PAGEFLAG_first_page
static uint32 get32(vorb *f) FL_NOEXCEPT
static uint32 get_bits(vorb *f, int32_t n) FL_NOEXCEPT
static void compute_accelerated_huffman(Codebook *c) FL_NOEXCEPT
static int32_t get8_packet(vorb *f) FL_NOEXCEPT
static int32_t next_segment(vorb *f) FL_NOEXCEPT
int32_t alloc_buffer_length_in_bytes
uint32 first_audio_page_offset
enum STBVorbisError error
uint32_t setup_temp_memory_required
float * previous_window[FL_STB_VORBIS_MAX_CHANNELS]
int32_t comment_list_length
uint32_t temp_memory_required
int16 * finalY[FL_STB_VORBIS_MAX_CHANNELS]
float * channel_buffers[FL_STB_VORBIS_MAX_CHANNELS]
void qsort(void *base, size_t nmemb, size_t size, qsort_compare_fn compar)
#define FL_STB_VORBIS_MAX_CHANNELS
#define FL_STB_VORBIS_FAST_HUFFMAN_LENGTH
#define FL_STBV_IS_PUSH_MODE(f)
static constexpr T max() FL_NOEXCEPT