MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / start_decoder

Function start_decoder

extlibs/soloud/src/audiosource/wav/stb_vorbis.c:3568–4121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3566#endif // !STB_VORBIS_NO_PUSHDATA_API
3567
3568static int start_decoder(vorb *f)
3569{
3570 uint8 header[6], x,y;
3571 int len,i,j,k, max_submaps = 0;
3572 int longest_floorlist=0;
3573
3574 // first page, first packet
3575
3576 if (!start_page(f)) return FALSE;
3577 // validate page flag
3578 if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page);
3579 if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page);
3580 if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
3581 // check for expected packet length
3582 if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
3583 if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page);
3584 // read packet
3585 // check packet header
3586 if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
3587 if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof);
3588 if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page);
3589 // vorbis_version
3590 if (get32(f) != 0) return error(f, VORBIS_invalid_first_page);
3591 f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page);
3592 if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels);
3593 f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page);
3594 get32(f); // bitrate_maximum
3595 get32(f); // bitrate_nominal
3596 get32(f); // bitrate_minimum
3597 x = get8(f);
3598 {
3599 int log0,log1;
3600 log0 = x & 15;
3601 log1 = x >> 4;
3602 f->blocksize_0 = 1 << log0;
3603 f->blocksize_1 = 1 << log1;
3604 if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup);
3605 if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup);
3606 if (log0 > log1) return error(f, VORBIS_invalid_setup);
3607 }
3608
3609 // framing_flag
3610 x = get8(f);
3611 if (!(x & 1)) return error(f, VORBIS_invalid_first_page);
3612
3613 // second packet!
3614 if (!start_page(f)) return FALSE;
3615
3616 if (!start_packet(f)) return FALSE;
3617 do {
3618 len = next_segment(f);
3619 skip(f, len);
3620 f->bytes_in_seg = 0;
3621 } while (len);
3622
3623 // third packet!
3624 if (!start_packet(f)) return FALSE;
3625

Callers 3

stb_vorbis_open_pushdataFunction · 0.85
stb_vorbis_open_memoryFunction · 0.85

Calls 15

start_pageFunction · 0.85
get8Function · 0.85
getnFunction · 0.85
vorbis_validateFunction · 0.85
get32Function · 0.85
start_packetFunction · 0.85
next_segmentFunction · 0.85
skipFunction · 0.85
is_whole_packet_presentFunction · 0.85
crc32_initFunction · 0.85
get8_packetFunction · 0.85
get_bitsFunction · 0.85

Tested by

no test coverage detected