mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-18 00:49:19 +02:00
mantenance: stb_vorbis update to v1.16
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
// Ogg Vorbis audio decoder - v1.14 - public domain
|
// Ogg Vorbis audio decoder - v1.16 - public domain
|
||||||
// http://nothings.org/stb_vorbis/
|
// http://nothings.org/stb_vorbis/
|
||||||
//
|
//
|
||||||
// Original version written by Sean Barrett in 2007.
|
// Original version written by Sean Barrett in 2007.
|
||||||
@@ -33,6 +33,8 @@
|
|||||||
// Timur Gagiev
|
// Timur Gagiev
|
||||||
//
|
//
|
||||||
// Partial history:
|
// Partial history:
|
||||||
|
// 1.16 - 2019-03-04 - fix warnings
|
||||||
|
// 1.15 - 2019-02-07 - explicit failure if Ogg Skeleton data is found
|
||||||
// 1.14 - 2018-02-11 - delete bogus dealloca usage
|
// 1.14 - 2018-02-11 - delete bogus dealloca usage
|
||||||
// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
|
// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
|
||||||
// 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
|
// 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
|
||||||
@@ -253,7 +255,7 @@ extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
|
|||||||
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
|
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
|
||||||
// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
|
// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
|
||||||
// note that stb_vorbis must "own" this stream; if you seek it in between
|
// note that stb_vorbis must "own" this stream; if you seek it in between
|
||||||
// calls to stb_vorbis, it will become confused. Morever, if you attempt to
|
// calls to stb_vorbis, it will become confused. Moreover, if you attempt to
|
||||||
// perform stb_vorbis_seek_*() operations on this file, it will assume it
|
// perform stb_vorbis_seek_*() operations on this file, it will assume it
|
||||||
// owns the _entire_ rest of the file after the start point. Use the next
|
// owns the _entire_ rest of the file after the start point. Use the next
|
||||||
// function, stb_vorbis_open_file_section(), to limit it.
|
// function, stb_vorbis_open_file_section(), to limit it.
|
||||||
@@ -374,7 +376,8 @@ enum STBVorbisError
|
|||||||
VORBIS_invalid_first_page,
|
VORBIS_invalid_first_page,
|
||||||
VORBIS_bad_packet_type,
|
VORBIS_bad_packet_type,
|
||||||
VORBIS_cant_find_last_page,
|
VORBIS_cant_find_last_page,
|
||||||
VORBIS_seek_failed
|
VORBIS_seek_failed,
|
||||||
|
VORBIS_ogg_skeleton_not_supported
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1073,7 +1076,7 @@ static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values)
|
|||||||
assert(z >= 0 && z < 32);
|
assert(z >= 0 && z < 32);
|
||||||
available[z] = 0;
|
available[z] = 0;
|
||||||
add_entry(c, bit_reverse(res), i, m++, len[i], values);
|
add_entry(c, bit_reverse(res), i, m++, len[i], values);
|
||||||
// propogate availability up the tree
|
// propagate availability up the tree
|
||||||
if (z != len[i]) {
|
if (z != len[i]) {
|
||||||
assert(len[i] >= 0 && len[i] < 32);
|
assert(len[i] >= 0 && len[i] < 32);
|
||||||
for (y=len[i]; y > z; --y) {
|
for (y=len[i]; y > z; --y) {
|
||||||
@@ -2637,7 +2640,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
|
|||||||
// once I combined the passes.
|
// once I combined the passes.
|
||||||
|
|
||||||
// so there's a missing 'times 2' here (for adding X to itself).
|
// so there's a missing 'times 2' here (for adding X to itself).
|
||||||
// this propogates through linearly to the end, where the numbers
|
// this propagates through linearly to the end, where the numbers
|
||||||
// are 1/2 too small, and need to be compensated for.
|
// are 1/2 too small, and need to be compensated for.
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -3578,7 +3581,22 @@ static int start_decoder(vorb *f)
|
|||||||
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
|
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
|
||||||
// check for expected packet length
|
// check for expected packet length
|
||||||
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
|
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
|
||||||
if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page);
|
if (f->segments[0] != 30) {
|
||||||
|
// check for the Ogg skeleton fishead identifying header to refine our error
|
||||||
|
if (f->segments[0] == 64 &&
|
||||||
|
getn(f, header, 6) &&
|
||||||
|
header[0] == 'f' &&
|
||||||
|
header[1] == 'i' &&
|
||||||
|
header[2] == 's' &&
|
||||||
|
header[3] == 'h' &&
|
||||||
|
header[4] == 'e' &&
|
||||||
|
header[5] == 'a' &&
|
||||||
|
get8(f) == 'd' &&
|
||||||
|
get8(f) == '\0') return error(f, VORBIS_ogg_skeleton_not_supported);
|
||||||
|
else
|
||||||
|
return error(f, VORBIS_invalid_first_page);
|
||||||
|
}
|
||||||
|
|
||||||
// read packet
|
// read packet
|
||||||
// check packet header
|
// check packet header
|
||||||
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
|
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
|
||||||
@@ -4566,7 +4584,7 @@ static int get_seek_page_info(stb_vorbis *f, ProbedPage *z)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rarely used function to seek back to the preceeding page while finding the
|
// rarely used function to seek back to the preceding page while finding the
|
||||||
// start of a packet
|
// start of a packet
|
||||||
static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
|
static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
|
||||||
{
|
{
|
||||||
@@ -4973,7 +4991,13 @@ stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, con
|
|||||||
|
|
||||||
stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
|
stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(filename, "rb");
|
FILE *f;
|
||||||
|
#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__)
|
||||||
|
if (0 != fopen_s(&f, filename, "rb"))
|
||||||
|
f = NULL;
|
||||||
|
#else
|
||||||
|
f = fopen(filename, "rb");
|
||||||
|
#endif
|
||||||
if (f)
|
if (f)
|
||||||
return stb_vorbis_open_file(f, TRUE, error, alloc);
|
return stb_vorbis_open_file(f, TRUE, error, alloc);
|
||||||
if (error) *error = VORBIS_file_open_failure;
|
if (error) *error = VORBIS_file_open_failure;
|
||||||
@@ -5459,4 +5483,4 @@ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|||||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user