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
312312 frame_info.bitrate_kbps = hdr_bitrate_kbps(hdr);
313313 frame_info.frame_bytes = frame_size;
314314 samples = hdr_frame_samples(hdr)*frame_info.channels;
315+ if (3 != frame_info.layer)
316+ break;
315317 int ret = mp3dec_check_vbrtag(hdr, frame_size, &frames, &delay, &padding);
316318 if (ret > 0)
317319 {
@@ -560,23 +562,26 @@ static int mp3dec_load_index(void *user_data, const uint8_t *frame, int frame_si · 242 unmodified lines
560562 dec->start_offset = dec->offset = offset;
561563 dec->end_offset = offset + buf_size;
562564 dec->free_format_bytes = free_format_bytes; /* should not change */
563− int ret = mp3dec_check_vbrtag(frame, frame_size, &frames, &delay, &padding);
564− if (ret)
565− dec->start_offset = dec->offset = offset + frame_size;
566− if (ret > 0)
565+ if (3 == dec->info.layer)
567566 {
568− padding *= info->channels;
569− dec->start_delay = dec->to_skip = delay*info->channels;
570− dec->samples = hdr_frame_samples(frame)*info->channels*(uint64_t)frames;
571− if (dec->samples >= (uint64_t)dec->start_delay)
572− dec->samples -= dec->start_delay;
573− if (padding > 0 && dec->samples >= (uint64_t)padding)
574− dec->samples -= padding;
575− dec->detected_samples = dec->samples;
576− dec->vbr_tag_found = 1;
577− return MP3D_E_USER;
578− } else if (ret < 0)
579− return 0;
567+ int ret = mp3dec_check_vbrtag(frame, frame_size, &frames, &delay, &padding);
568+ if (ret)
569+ dec->start_offset = dec->offset = offset + frame_size;
570+ if (ret > 0)
571+ {
572+ padding *= info->channels;
573+ dec->start_delay = dec->to_skip = delay*info->channels;
574+ dec->samples = hdr_frame_samples(frame)*info->channels*(uint64_t)frames;
575+ if (dec->samples >= (uint64_t)dec->start_delay)
576+ dec->samples -= dec->start_delay;
577+ if (padding > 0 && dec->samples >= (uint64_t)padding)
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+ }
580585 }
581586 if (dec->index.num_frames + 1 > dec->index.capacity)
582587 {
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