From 483e729ed289e94b5b00f0cac30ef6df1f358e79 Mon Sep 17 00:00:00 2001 From: zhangtl Date: Mon, 15 Nov 2021 17:46:25 +0800 Subject: [PATCH] get samples_per_frame from hdr_frame_samples Signed-off-by: zhangtl --- minimp3.h | 9 +-------- minimp3_ex.h | 6 +++--- 2 files changed, 4 insertions(+), 11 deletions(-) mode change 100644 => 100755 minimp3.h mode change 100644 => 100755 minimp3_ex.h diff --git a/minimp3.h b/minimp3.h old mode 100644 new mode 100755 index 3220ae1..41bd004 --- a/minimp3.h +++ b/minimp3.h @@ -12,7 +12,7 @@ typedef struct { - int frame_bytes, frame_offset, channels, hz, layer, bitrate_kbps; + int frame_bytes, frame_offset, channels, hz, layer, bitrate_kbps, samples_per_frame; } mp3dec_frame_info_t; typedef struct @@ -890,13 +890,6 @@ static void L3_midside_stereo(float *left, int n) VSTORE(left + i, VADD(vl, vr)); VSTORE(right + i, VSUB(vl, vr)); } -#ifdef __GNUC__ - /* Workaround for spurious -Waggressive-loop-optimizations warning from gcc. - * For more info see: https://github.com/lieff/minimp3/issues/88 - */ - if (__builtin_constant_p(n % 4 == 0) && n % 4 == 0) - return; -#endif } #endif /* HAVE_SIMD */ for (; i < n; i++) diff --git a/minimp3_ex.h b/minimp3_ex.h old mode 100644 new mode 100755 index e29dd15..36a1d97 --- a/minimp3_ex.h +++ b/minimp3_ex.h @@ -503,8 +503,6 @@ int mp3dec_iterate_buf(const uint8_t *buf, size_t buf_size, MP3D_ITERATE_CB call return MP3D_E_PARAM; /* skip id3 */ mp3dec_skip_id3(&buf, &buf_size); - if (!buf_size) - return 0; mp3dec_frame_info_t frame_info; memset(&frame_info, 0, sizeof(frame_info)); do @@ -523,11 +521,13 @@ int mp3dec_iterate_buf(const uint8_t *buf, size_t buf_size, MP3D_ITERATE_CB call frame_info.layer = 4 - HDR_GET_LAYER(hdr); frame_info.bitrate_kbps = hdr_bitrate_kbps(hdr); frame_info.frame_bytes = frame_size; + frame_info.samples_per_frame = hdr_frame_samples(hdr); if (callback) { - if ((ret = callback(user_data, hdr, frame_size, free_format_bytes, buf_size, hdr - orig_buf, &frame_info))) + if ((ret = callback(user_data, hdr, frame_size, free_format_bytes, buf_size, hdr - orig_buf, &frame_info))){ return ret; + } } buf += frame_size; buf_size -= frame_size;