ref: 2b9a0237547ca5f6f98e28a850237cc68f560f7a
parent: c65e366f67e3975a2a0ea5f97af49511cfa6136b
author: lieff <[email protected]>
date: Mon Feb 24 12:11:19 EST 2020
mp3dec_ex: fix skip not decodable first frames on seek in callback mode + test
--- a/minimp3_ex.h
+++ b/minimp3_ex.h
@@ -731,7 +731,17 @@
dec->to_skip = position - dec->index.frames[i].sample;
while ((i + 1) < dec->index.num_frames && !dec->index.frames[i].sample && !dec->index.frames[i + 1].sample)
{ /* skip not decodable first frames */
- const uint8_t *hdr = dec->file.buffer + dec->index.frames[i].offset;
+ const uint8_t *hdr;
+ if (dec->io)
+ {
+ hdr = dec->file.buffer;
+ if (dec->io->seek(dec->index.frames[i].offset, dec->io->seek_data))
+ return MP3D_E_IOERROR;
+ size_t readed = dec->io->read((uint8_t *)hdr, HDR_SIZE, dec->io->read_data);
+ if (readed != HDR_SIZE)
+ return MP3D_E_IOERROR;
+ } else
+ hdr = dec->file.buffer + dec->index.frames[i].offset;
dec->to_skip += hdr_frame_samples(hdr)*dec->info.channels;
i++;
}
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -69,6 +69,10 @@
./minimp3 -m 6 -s 633 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db_ofs633.pcm
./minimp3 -m 8 -s 215 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
./minimp3 -m 8 -s 633 -b vectors/l3-sin1k0db.bit vectors/l3-sin1k0db_ofs633.pcm
+
+./minimp3 -m 6 -s 2304 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+./minimp3 -m 8 -s 2304 vectors/l3-sin1k0db.bit vectors/l3-sin1k0db.pcm
+
./minimp3 -t vectors/l3-sin1k0db.bit
gcov minimp3_test.c