/* * libnogg: a decoder library for Ogg Vorbis streams * Copyright (c) 2014-2024 Andrew Church * * This software may be copied and redistributed under certain conditions; * see the file "COPYING" in the source code distribution for details. * NO WARRANTY is provided with this software. */ #include "include/nogg.h" #include "tests/common.h" #include "tests/data/6-mode-bits_last10_float.h" // Defines expected_pcm[]. int main(void) { FILE *f; uint8_t *data; long size; EXPECT(f = fopen("tests/data/6-mode-bits-multipage.ogg", "rb")); EXPECT_EQ(fseek(f, 0, SEEK_END), 0); EXPECT_EQ(size = ftell(f), 0xE9B); EXPECT_EQ(fseek(f, 0, SEEK_SET), 0); EXPECT(data = malloc(size)); EXPECT_EQ(fread(data, 1, size, f), size); fclose(f); MODIFY(data[0xE0F], 0x21, 0xD5); MODIFY(data[0xE10], 0xFD, 0x0E); MODIFY(data[0xE11], 0xFB, 0x9C); MODIFY(data[0xE12], 0x9F, 0xA4); MODIFY(data[0xE1E], 0x00, 0x44); vorbis_t *vorbis; EXPECT(vorbis = vorbis_open_buffer(data, size, 0, NULL)); EXPECT(vorbis_seek(vorbis, 882)); float pcm[611]; vorbis_error_t error = (vorbis_error_t)-1; EXPECT_EQ(vorbis_read_float(vorbis, pcm, 611, &error), 206); EXPECT_EQ(error, VORBIS_ERROR_DECODE_RECOVERED); EXPECT_EQ(vorbis_read_float(vorbis, pcm, 611, &error), 610-206); EXPECT_EQ(error, VORBIS_ERROR_STREAM_END); COMPARE_PCM_FLOAT(&pcm[600-206], expected_pcm, 10); vorbis_close(vorbis); free(data); return EXIT_SUCCESS; }