Skip to content
Myr

Merge branch 'OggComment' of https://github.com/audinowho/stb into work2

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parents 49cbedf, 2a0cff1 · Browse files · 1 file+77 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+77 added−1 removed

  • other:+77 added−1 removed

1 file+77 added−1 removed

modified:stb_vorbis.c+77 added-1 removed
128 unmodified lines
129130 int max_frame_size;131} stb_vorbis_info;132133typedef struct134{135 char *vendor;136137 int comment_list_length;138 char **comment_list;139} stb_vorbis_comment;140141// get general information about the file142extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);143144// get ogg comments145extern stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f);146147// get the last error detected (clears it, too)148extern int stb_vorbis_get_error(stb_vorbis *f);149150// close an ogg vorbis file and free all memory in use
618 unmodified lines
769 unsigned int setup_memory_required;770 unsigned int temp_memory_required;771 unsigned int setup_temp_memory_required;772773 char *vendor;774 int comment_list_length;775 char **comment_list;776777 // input config778#ifndef STB_VORBIS_NO_STDIO779 FILE *f;780 uint32 f_start;
775 unmodified lines
1556 f->valid_bits = 0;1557 return x;1558}15591560static int get32_packet(vorb *f)1561{1562 uint32 x;1563 x = get8_packet(f);1564 x += get8_packet(f) << 8;1565 x += get8_packet(f) << 16;1566 x += (uint32) get8_packet(f) << 24;1567 return x;1568}15691570static void flush_packet(vorb *f)1571{1572 while (get8_packet_raw(f) != EOP);1573}
2041 unmodified lines
3615 if (!(x & 1)) return error(f, VORBIS_invalid_first_page);36163617 // second packet!3618 if (!start_page(f)) return FALSE;35943619 3620 if (!start_packet(f)) return FALSE;36213622 if (!next_segment(f)) return FALSE;36233624 if (get8_packet(f) != VORBIS_packet_comment) return error(f, VORBIS_invalid_setup);3625 for (i=0; i < 6; ++i) header[i] = get8_packet(f);3626 if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup);3627 //file vendor3628 len = get32_packet(f);3629 f->vendor = (char*)setup_malloc(f, sizeof(char) * (len+1));3630 for(i=0; i < len; ++i) {3631 f->vendor[i] = get8_packet(f);3632 }3633 f->vendor[len] = (char)NULL;3634 //user comments3635 f->comment_list_length = get32_packet(f);3636 f->comment_list = (char**)setup_malloc(f, sizeof(char*) * (f->comment_list_length));3637 3638 for(i=0; i < f->comment_list_length; ++i) {3639 len = get32_packet(f);3640 f->comment_list[i] = (char*)setup_malloc(f, sizeof(char) * (len+1));36413642 for(j=0; j < len; ++j) {3643 f->comment_list[i][j] = get8_packet(f);3644 }3645 f->comment_list[i][len] = (char)NULL;3646 }36473648 // framing_flag3649 x = get8_packet(f);3650 if (!(x & 1)) return error(f, VORBIS_invalid_setup);36513652 3653 skip(f, f->bytes_in_seg);3654 f->bytes_in_seg = 0;36553656 do {3657 len = next_segment(f);3658 skip(f, len);3659 f->bytes_in_seg = 0;
517 unmodified lines
41774178static void vorbis_deinit(stb_vorbis *p)4179{4180 int i,j;41814182 setup_free(p, p->vendor);4183 for (i=0; i < p->comment_list_length; ++i) {4184 setup_free(p, p->comment_list[i]);4185 }4186 setup_free(p, p->comment_list);41874188 if (p->residue_config) {4189 for (i=0; i < p->residue_count; ++i) {4190 Residue *r = p->residue_config+i;4191 if (r->classdata) {
91 unmodified lines
4283 d.max_frame_size = f->blocksize_1 >> 1;4284 return d;4285}42864287stb_vorbis_comment stb_vorbis_get_comment(stb_vorbis *f)4288{4289 stb_vorbis_comment d;4290 d.vendor = f->vendor;4291 d.comment_list_length = f->comment_list_length;4292 d.comment_list = f->comment_list;4293 return d;4294}42954296int stb_vorbis_get_error(stb_vorbis *f)4297{4298 int e = f->error;4299 f->error = VORBIS__no_error;
1253 unmodified lines