mirror of
https://github.com/nothings/stb
synced 2024-12-16 04:42:42 +03:00
Add detection for Ogg skeleton metadata
This commit is contained in:
parent
38f86fc461
commit
604b9367ee
15
stb_vorbis.c
15
stb_vorbis.c
@ -374,7 +374,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
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -3579,6 +3580,18 @@ static int start_decoder(vorb *f)
|
|||||||
// 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) return error(f, VORBIS_invalid_first_page);
|
||||||
|
// 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') 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);
|
||||||
|
Loading…
Reference in New Issue
Block a user