shithub: mp3dec

Download patch

ref: 7a6445efbd8d941987bdb5682b670eff100bfd9a
parent: 337b25296f47adac154ed65ea07149c7d9747013
author: Martin Fiedler <keyj@emphy.de>
date: Sat Jul 28 14:30:56 EDT 2018

added option to decode headers only
If the 'pcm' parameter to mp3dec_decode_frame()
is set to NULL, all bitstream and audio decoding
is skipped, but the header is still decoded and
frame info is still generated.
This is useful for quickly scanning an MP3 file,
e.g. to determine the duration or generate a
VBR seek index.

--- a/minimp3.h
+++ b/minimp3.h
@@ -1645,6 +1645,11 @@
     info->layer = 4 - HDR_GET_LAYER(hdr);
     info->bitrate_kbps = hdr_bitrate_kbps(hdr);
 
+    if (!pcm)
+    {
+        return hdr_frame_samples(hdr);
+    }
+
     bs_init(bs_frame, hdr + HDR_SIZE, frame_size - HDR_SIZE);
     if (HDR_IS_CRC(hdr))
     {