Skip to content

Commit 497f0b4

Browse files
committed
mr: Fix issue with playing small MP3 files
See lieff#125
1 parent afb604c commit 497f0b4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

minimp3.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,21 @@ static void mp3d_synth_granule(float *qmf_state, float *grbuf, int nbands, int n
16541654
}
16551655
}
16561656

1657+
static int hdr_is_tag(const uint8_t* hdr)
1658+
{
1659+
return hdr[0] == 'T' && hdr[1] == 'A' && hdr[2] == 'G' && hdr[3] == '\0';
1660+
}
1661+
1662+
static int hdr_is_null(const uint8_t* hdr)
1663+
{
1664+
return hdr[0] == '\0' && hdr[1] == '\0' && hdr[2] == '\0' && hdr[3] == '\0';
1665+
}
1666+
1667+
static int hdr_is_null_or_tag(const uint8_t* hdr)
1668+
{
1669+
return hdr_is_tag(hdr) > 0 || hdr_is_null(hdr) > 0;
1670+
}
1671+
16571672
static int mp3d_match_frame(const uint8_t *hdr, int mp3_bytes, int frame_bytes)
16581673
{
16591674
int i, nmatch;
@@ -1662,6 +1677,8 @@ static int mp3d_match_frame(const uint8_t *hdr, int mp3_bytes, int frame_bytes)
16621677
i += hdr_frame_bytes(hdr + i, frame_bytes) + hdr_padding(hdr + i);
16631678
if (i + HDR_SIZE > mp3_bytes)
16641679
return nmatch > 0;
1680+
if (hdr_is_null_or_tag(hdr + i))
1681+
return nmatch > 0;
16651682
if (!hdr_compare(hdr, hdr + i))
16661683
return 0;
16671684
}

0 commit comments

Comments
 (0)