mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-17 19:19:16 +01:00
Add .mp3 parser using mpg123 for consistency
This commit is contained in:
parent
484908c57e
commit
9b75cc6d83
@ -481,6 +481,18 @@ void free_mpeg(mpeg_codec_data* data);
|
||||
|
||||
int mpeg_get_sample_rate(mpeg_codec_data* data);
|
||||
long mpeg_bytes_to_samples(long bytes, const mpeg_codec_data* data);
|
||||
|
||||
typedef struct {
|
||||
int version;
|
||||
int layer;
|
||||
int bit_rate;
|
||||
int sample_rate;
|
||||
int frame_samples;
|
||||
int frame_size; /* bytes */
|
||||
int channels;
|
||||
} mpeg_frame_info;
|
||||
|
||||
int mpeg_get_frame_info(STREAMFILE* sf, off_t offset, mpeg_frame_info* info);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -75,16 +75,4 @@ int mpeg_custom_parse_frame_eamp3(VGMSTREAMCHANNEL* stream, mpeg_codec_data* dat
|
||||
#endif/* VGM_USE_MPEG */
|
||||
|
||||
|
||||
typedef struct {
|
||||
int version;
|
||||
int layer;
|
||||
int bit_rate;
|
||||
int sample_rate;
|
||||
int frame_samples;
|
||||
int frame_size; /* bytes */
|
||||
int channels;
|
||||
} mpeg_frame_info;
|
||||
|
||||
int mpeg_get_frame_info(STREAMFILE* sf, off_t offset, mpeg_frame_info* info);
|
||||
|
||||
#endif/*_MPEG_DECODER_H_ */
|
||||
|
@ -1382,6 +1382,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_WBK, "Treyarch WBK header"},
|
||||
{meta_WBK_NSLB, "Treyarch NSLB header"},
|
||||
{meta_DSP_APEX, "Koei Tecmo APEX header"},
|
||||
{meta_MPEG, "MPEG header"},
|
||||
};
|
||||
|
||||
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {
|
||||
|
@ -392,6 +392,7 @@
|
||||
<ClCompile Include="meta\maxis_xa.c" />
|
||||
<ClCompile Include="meta\mc3.c" />
|
||||
<ClCompile Include="meta\mca.c" />
|
||||
<ClCompile Include="meta\mpeg.c" />
|
||||
<ClCompile Include="meta\mus_vc.c" />
|
||||
<ClCompile Include="meta\mus_acm.c" />
|
||||
<ClCompile Include="meta\musc.c" />
|
||||
|
@ -652,6 +652,9 @@
|
||||
<ClCompile Include="meta\mca.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\mpeg.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\mus_acm.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
@ -974,4 +974,6 @@ VGMSTREAM* init_vgmstream_wbk_nslb(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_ubi_ckd_cwav(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_mpeg(STREAMFILE* sf);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
55
src/meta/mpeg.c
Normal file
55
src/meta/mpeg.c
Normal file
@ -0,0 +1,55 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* MPEG - standard MP1/2/3 audio MP3 */
|
||||
VGMSTREAM* init_vgmstream_mpeg(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
int loop_flag = 0;
|
||||
mpeg_frame_info info = {0};
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!mpeg_get_frame_info(sf, 0x00, &info))
|
||||
goto fail;
|
||||
|
||||
/* .mp3/mp2: standard (is .mp1 ever used in games?)
|
||||
* .lmp1/2/3: for plugins
|
||||
* .mus: Marc Ecko's Getting Up (PC) */
|
||||
if (!check_extensions(sf, "mp3,mp2,mp1,mus,lmp3,lmp2,lmp1"))
|
||||
goto fail;
|
||||
|
||||
loop_flag = 0;
|
||||
|
||||
|
||||
/* build VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(info.channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_MPEG;
|
||||
vgmstream->sample_rate = info.sample_rate;
|
||||
|
||||
#ifdef VGM_USE_MPEG
|
||||
/* more strict, use? */
|
||||
//mpeg_custom_config cfg = {0};
|
||||
//cfg.skip_samples = ...
|
||||
//vgmstream->codec_data = init_mpeg_custom(sf, start_offset, &vgmstream->coding_type, fmt.channels, MPEG_STANDARD, &cfg);
|
||||
|
||||
vgmstream->codec_data = init_mpeg(sf, 0x00, &vgmstream->coding_type, info.channels);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->layout_type = layout_none;
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
//vgmstream->num_samples = mpeg_bytes_to_samples(data_size, vgmstream->codec_data);
|
||||
vgmstream->num_samples = mpeg_get_samples(sf, 0x00, get_streamfile_size(sf));
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, 0x00))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -521,6 +521,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
||||
init_vgmstream_ubi_ckd_cwav,
|
||||
|
||||
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
|
||||
init_vgmstream_mpeg,
|
||||
init_vgmstream_agsc,
|
||||
init_vgmstream_dtk,
|
||||
init_vgmstream_rsf,
|
||||
|
@ -753,6 +753,7 @@ typedef enum {
|
||||
meta_WBK,
|
||||
meta_WBK_NSLB,
|
||||
meta_DSP_APEX,
|
||||
meta_MPEG,
|
||||
|
||||
} meta_t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user