Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions stb_vorbis.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
// github:audinowho Dougall Johnson David Reid
// github:Clownacy Pedro J. Estebanez Remi Verschelde
// AnthoFoxo github:morlat Gabriel Ravier
// github:lassade
//
// Partial history:
// 1.23 - 2021-07-11 - various small fixes
// 1.22 - 2021-07-11 - various small fixes
// 1.21 - 2021-07-02 - fix bug for files with no comments
// 1.20 - 2020-07-11 - several small fixes
Expand Down Expand Up @@ -719,9 +721,9 @@ typedef struct
uint8 class_subclasses[16]; // varies
uint8 class_masterbooks[16]; // varies
int16 subclass_books[16][8]; // varies
uint16 Xlist[31*8+2]; // varies
uint8 sorted_order[31*8+2];
uint8 neighbors[31*8+2][2];
uint16 Xlist[65]; // varies
uint8 sorted_order[65];
uint8 neighbors[65][2];
Comment on lines +724 to +726

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opportunity to document why this is 65, or use something like VIF_POSIT+2?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why but it is in the spec in at the last paragraph it says "Vector [floor1_x_list] is limited to a maximum length of 65 elements;"

uint8 floor1_multiplier;
uint8 rangebits;
int values;
Expand Down Expand Up @@ -1401,7 +1403,7 @@ static int set_file_offset(stb_vorbis *f, unsigned int loc)
#endif
f->eof = 0;
if (USE_MEMORY(f)) {
if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
if (f->stream_start + loc >= f->stream_end) {
f->stream = f->stream_end;
f->eof = 1;
return 0;
Expand Down Expand Up @@ -3181,8 +3183,8 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start,
{
Mapping *map;
int i,j,k,n,n2;
int zero_channel[256];
int really_zero_channel[256];
int zero_channel[STB_VORBIS_MAX_CHANNELS];
int really_zero_channel[STB_VORBIS_MAX_CHANNELS];

// WINDOWING

Expand Down Expand Up @@ -3304,7 +3306,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start,
for (i=0; i < map->submaps; ++i) {
float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
int r;
uint8 do_not_decode[256];
uint8 do_not_decode[STB_VORBIS_MAX_CHANNELS];
int ch = 0;
for (j=0; j < f->channels; ++j) {
if (map->chan[j].mux == i) {
Expand Down Expand Up @@ -3951,7 +3953,7 @@ static int start_decoder(vorb *f)
g->book_list[j] = get_bits(f,8);
return error(f, VORBIS_feature_not_supported);
} else {
stbv__floor_ordering p[31*8+2];
stbv__floor_ordering p[65];
Floor1 *g = &f->floor_config[i].floor1;
int max_class = -1;
g->partitions = get_bits(f, 5);
Expand Down Expand Up @@ -4161,7 +4163,7 @@ static int start_decoder(vorb *f)
int i,max_part_read=0;
for (i=0; i < f->residue_count; ++i) {
Residue *r = f->residue_config + i;
unsigned int actual_size = f->blocksize_1 / 2;
unsigned int actual_size = f->blocksize_1;
Comment on lines -4164 to +4166

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate of #1487

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this loop looks for the maximum ammount of memory needed, in my test data I don't have a single vorbis file that doesn't have a residue type 2 so using blocksize_1 is good enough

unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size;
int n_read = limit_r_end - limit_r_begin;
Expand Down