History

mp3dec_ex: check vbrtag only for layer 3

lieff committed 6 years ago

Commit 728ff801 parent dc65e6d3 files · +20 −15Browse files

Unified · Split

3 files
  1. minimp3_ex.h +21 −16
  2. vectors/l3-nonstandard-vbrtag-corrupted.bit +0 −0
  3. vectors/l3-nonstandard-vbrtag-corrupted.pcm +0 −0
minimp3_ex.h+21−16
@@ -312,6 +312,8 @@ int mp3dec_load_cb(mp3dec_t *dec, mp3dec_io_t *io, uint8_t *buf, size_t buf_size · 311 unmodified lines
312 frame_info.bitrate_kbps = hdr_bitrate_kbps(hdr);312 frame_info.bitrate_kbps = hdr_bitrate_kbps(hdr);
313 frame_info.frame_bytes = frame_size;313 frame_info.frame_bytes = frame_size;
314 samples = hdr_frame_samples(hdr)*frame_info.channels;314 samples = hdr_frame_samples(hdr)*frame_info.channels;
315 if (3 != frame_info.layer)
316 break;
315 int ret = mp3dec_check_vbrtag(hdr, frame_size, &frames, &delay, &padding);317 int ret = mp3dec_check_vbrtag(hdr, frame_size, &frames, &delay, &padding);
316 if (ret > 0)318 if (ret > 0)
317 {319 {
@@ -560,23 +562,26 @@ static int mp3dec_load_index(void *user_data, const uint8_t *frame, int frame_si · 242 unmodified lines
560 dec->start_offset = dec->offset = offset;562 dec->start_offset = dec->offset = offset;
561 dec->end_offset = offset + buf_size;563 dec->end_offset = offset + buf_size;
562 dec->free_format_bytes = free_format_bytes; /* should not change */564 dec->free_format_bytes = free_format_bytes; /* should not change */
563 int ret = mp3dec_check_vbrtag(frame, frame_size, &frames, &delay, &padding);565 if (3 == dec->info.layer)
564 if (ret)
565 dec->start_offset = dec->offset = offset + frame_size;
566 if (ret > 0)
567 {566 {
568 padding *= info->channels;567 int ret = mp3dec_check_vbrtag(frame, frame_size, &frames, &delay, &padding);
569 dec->start_delay = dec->to_skip = delay*info->channels;568 if (ret)
570 dec->samples = hdr_frame_samples(frame)*info->channels*(uint64_t)frames;569 dec->start_offset = dec->offset = offset + frame_size;
571 if (dec->samples >= (uint64_t)dec->start_delay)570 if (ret > 0)
572 dec->samples -= dec->start_delay;571 {
573 if (padding > 0 && dec->samples >= (uint64_t)padding)572 padding *= info->channels;
574 dec->samples -= padding;573 dec->start_delay = dec->to_skip = delay*info->channels;
575 dec->detected_samples = dec->samples;574 dec->samples = hdr_frame_samples(frame)*info->channels*(uint64_t)frames;
576 dec->vbr_tag_found = 1;575 if (dec->samples >= (uint64_t)dec->start_delay)
577 return MP3D_E_USER;576 dec->samples -= dec->start_delay;
578 } else if (ret < 0)577 if (padding > 0 && dec->samples >= (uint64_t)padding)
579 return 0;578 dec->samples -= padding;
579 dec->detected_samples = dec->samples;
580 dec->vbr_tag_found = 1;
581 return MP3D_E_USER;
582 } else if (ret < 0)
583 return 0;
584 }
580 }585 }
581 if (dec->index.num_frames + 1 > dec->index.capacity)586 if (dec->index.num_frames + 1 > dec->index.capacity)
582 {587 {
vectors/l3-nonstandard-vbrtag-corrupted.bit+0−0

Binary file not shown.

vectors/l3-nonstandard-vbrtag-corrupted.pcm+0−0

Empty file added.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t