ref: 8e8866ed91937b607b7cfce0ac7f220ecadb458f
parent: e8b3be757e42a5e54aa2ab524c95087f5a160b05
author: lieff <lieff@users.noreply.github.com>
date: Tue Feb 4 13:57:04 EST 2020
mp3dec_ex: add id3v1/2 to test
--- a/minimp3_ex.h
+++ b/minimp3_ex.h
@@ -50,7 +50,7 @@
mp3dec_t mp3d;
mp3dec_map_info_t file;
mp3dec_index_t index;
- uint64_t offset, samples, start_offset;
+ uint64_t offset, samples, start_offset, end_offset;
mp3dec_frame_info_t info;
mp3d_sample_t buffer[MINIMP3_MAX_SAMPLES_PER_FRAME];
#ifndef MINIMP3_NO_STDIO
@@ -250,6 +250,7 @@
int i;
dec->info = *info;
dec->start_offset = offset;
+ dec->end_offset = offset + buf_size;
dec->free_format_bytes = free_format_bytes; /* should not change */
for (i = 5; i < frame_size - 12; i++)
{
@@ -404,6 +405,7 @@
size_t mp3dec_ex_read(mp3dec_ex_t *dec, mp3d_sample_t *buf, size_t samples)
{
+ uint64_t end_offset = dec->end_offset ? dec->end_offset : dec->file.size;
size_t samples_requested = samples;
mp3dec_frame_info_t frame_info;
memset(&frame_info, 0, sizeof(frame_info));
@@ -418,10 +420,10 @@
while (samples)
{
const uint8_t *dec_buf = dec->file.buffer + dec->offset;
- size_t buf_size = dec->file.size - dec->offset;
+ uint64_t buf_size = end_offset - dec->offset;
if (!buf_size)
break;
- dec->buffer_samples = mp3dec_decode_frame(&dec->mp3d, dec_buf, MINIMP3_MIN(buf_size, (size_t)INT_MAX), dec->buffer, &frame_info);
+ dec->buffer_samples = mp3dec_decode_frame(&dec->mp3d, dec_buf, MINIMP3_MIN(buf_size, (uint64_t)INT_MAX), dec->buffer, &frame_info);
dec->buffer_consumed = 0;
if (dec->buffer_samples)
{
--- a/scripts/test_mode.sh
+++ b/scripts/test_mode.sh
@@ -13,7 +13,7 @@
vectors/l3-hecommon.bit vectors/l3-he_mode.bit vectors/l3-si.bit vectors/l3-si_block.bit vectors/l3-si_huff.bit \
vectors/l3-sin1k0db.bit vectors/l3-test45.bit vectors/l3-test46.bit vectors/M2L3_bitrate_16_all.bit \
vectors/M2L3_bitrate_22_all.bit vectors/M2L3_bitrate_24_all.bit vectors/M2L3_compl24.bit vectors/M2L3_noise.bit \
-vectors/l1-fl1.bit vectors/l2-fl10.bit; do
+vectors/l3-nonstandard-id3v1.bit vectors/l3-nonstandard-id3v2.bit vectors/l1-fl1.bit vectors/l2-fl10.bit; do
$APP -m $MODE -s $POSITION $i ${i%.*}.pcm
retval=$?
echo -m $MODE -s $POSITION $i exited with code=$retval
binary files a/vectors/l3-id3v1.bit /dev/null differ
binary files a/vectors/l3-id3v1.pcm /dev/null differ
binary files a/vectors/l3-id3v2.bit /dev/null differ
binary files a/vectors/l3-id3v2.pcm /dev/null differ
binary files /dev/null b/vectors/l3-nonstandard-id3v1.bit differ
binary files /dev/null b/vectors/l3-nonstandard-id3v1.pcm differ
binary files /dev/null b/vectors/l3-nonstandard-id3v2.bit differ
binary files /dev/null b/vectors/l3-nonstandard-id3v2.pcm differ