2008-07-06 17:33:38 +02:00
|
|
|
#include "../vgmstream.h"
|
2008-06-09 02:20:08 +02:00
|
|
|
#include "meta.h"
|
2008-06-10 03:20:54 +02:00
|
|
|
#include "../layout/layout.h"
|
2008-06-09 02:20:08 +02:00
|
|
|
#include "../util.h"
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
#include <mpg123.h>
|
|
|
|
#endif
|
2008-06-09 02:20:08 +02:00
|
|
|
|
|
|
|
/* GENH is an artificial "generic" header for headerless streams */
|
|
|
|
|
2008-06-10 03:20:54 +02:00
|
|
|
VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
|
2008-06-09 02:20:08 +02:00
|
|
|
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
|
|
|
|
int32_t channel_count;
|
|
|
|
int32_t interleave;
|
|
|
|
int32_t sample_rate;
|
|
|
|
int32_t loop_start;
|
|
|
|
int32_t loop_end;
|
2008-06-13 01:33:07 +02:00
|
|
|
int32_t start_offset;
|
|
|
|
int32_t header_size;
|
2008-11-17 19:45:09 +01:00
|
|
|
int32_t coef[2];
|
2008-12-23 19:01:18 +01:00
|
|
|
int32_t coef_splitted[2];
|
2008-11-24 19:27:28 +01:00
|
|
|
int32_t dsp_interleave_type;
|
2008-12-23 19:01:18 +01:00
|
|
|
int32_t coef_type;
|
|
|
|
|
2008-06-09 02:20:08 +02:00
|
|
|
char filename[260];
|
2008-06-10 03:20:54 +02:00
|
|
|
int coding;
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
mpeg_codec_data *data = NULL;
|
|
|
|
#endif
|
2008-06-09 02:20:08 +02:00
|
|
|
|
|
|
|
/* check extension, case insensitive */
|
|
|
|
streamFile->get_name(streamFile,filename,sizeof(filename));
|
|
|
|
if (strcasecmp("genh",filename_extension(filename))) goto fail;
|
|
|
|
|
|
|
|
/* check header magic */
|
|
|
|
if (read_32bitBE(0x0,streamFile) != 0x47454e48) goto fail;
|
|
|
|
|
2008-06-13 01:50:45 +02:00
|
|
|
/* check channel count (needed for ADP/DTK check) */
|
|
|
|
channel_count = read_32bitLE(0x4,streamFile);
|
|
|
|
if (channel_count < 1) goto fail;
|
|
|
|
|
2008-06-10 03:20:54 +02:00
|
|
|
/* check format */
|
|
|
|
/* 0 = PSX ADPCM */
|
2008-06-13 01:33:07 +02:00
|
|
|
/* 1 = XBOX IMA ADPCM */
|
|
|
|
/* 2 = NGC ADP/DTK ADPCM */
|
2008-06-18 01:32:24 +02:00
|
|
|
/* 3 = 16bit big endian PCM */
|
|
|
|
/* 4 = 16bit little endian PCM */
|
2008-07-02 03:41:20 +02:00
|
|
|
/* 5 = 8bit PCM */
|
|
|
|
/* 6 = SDX2 */
|
|
|
|
/* 7 = DVI IMA */
|
2008-07-06 17:33:38 +02:00
|
|
|
/* 8 = MPEG-1 Layer III, possibly also the MPEG-2 and 2.5 extensions */
|
2008-07-18 07:25:05 +02:00
|
|
|
/* 9 = IMA */
|
2008-08-15 04:21:19 +02:00
|
|
|
/* 10 = AICA ADPCM */
|
2008-08-18 01:07:41 +02:00
|
|
|
/* 11 = MS ADPCM */
|
2008-11-17 19:28:14 +01:00
|
|
|
/* 12 = NGC DSP */
|
2008-11-24 19:27:28 +01:00
|
|
|
/* 13 = 8bit unsingned PCM */
|
2008-12-18 20:04:35 +01:00
|
|
|
/* 14 = PSX ADPCM (bad flagged) */
|
2008-06-10 03:20:54 +02:00
|
|
|
/* ... others to come */
|
|
|
|
switch (read_32bitLE(0x18,streamFile)) {
|
|
|
|
case 0:
|
|
|
|
coding = coding_PSX;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
coding = coding_XBOX;
|
|
|
|
break;
|
2008-06-13 01:33:07 +02:00
|
|
|
case 2:
|
|
|
|
coding = coding_NGC_DTK;
|
|
|
|
if (channel_count != 2) goto fail;
|
|
|
|
break;
|
2008-06-18 01:32:24 +02:00
|
|
|
case 3:
|
|
|
|
coding = coding_PCM16BE;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
coding = coding_PCM16LE;
|
|
|
|
break;
|
2008-07-01 05:19:02 +02:00
|
|
|
case 5:
|
|
|
|
coding = coding_PCM8;
|
|
|
|
break;
|
2008-07-01 18:10:18 +02:00
|
|
|
case 6:
|
|
|
|
coding = coding_SDX2;
|
|
|
|
break;
|
2008-07-02 03:41:20 +02:00
|
|
|
case 7:
|
|
|
|
coding = coding_DVI_IMA;
|
|
|
|
break;
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
case 8:
|
|
|
|
/* we say MPEG-1 L3 here, but later find out exactly which */
|
|
|
|
coding = coding_MPEG1_L3;
|
|
|
|
break;
|
|
|
|
#endif
|
2008-07-18 07:25:05 +02:00
|
|
|
case 9:
|
|
|
|
coding = coding_IMA;
|
|
|
|
break;
|
2008-08-15 04:21:19 +02:00
|
|
|
case 10:
|
|
|
|
coding = coding_AICA;
|
|
|
|
break;
|
2008-08-18 01:07:41 +02:00
|
|
|
case 11:
|
|
|
|
coding = coding_MSADPCM;
|
|
|
|
break;
|
2008-11-17 19:28:14 +01:00
|
|
|
case 12:
|
|
|
|
coding = coding_NGC_DSP;
|
|
|
|
break;
|
2008-12-18 20:04:35 +01:00
|
|
|
case 13:
|
2008-11-24 19:27:28 +01:00
|
|
|
coding = coding_PCM8_U_int;
|
2008-12-18 20:04:35 +01:00
|
|
|
break;
|
|
|
|
case 14:
|
|
|
|
coding = coding_PSX_badflags;
|
2008-11-24 19:27:28 +01:00
|
|
|
break;
|
2008-06-10 03:20:54 +02:00
|
|
|
default:
|
|
|
|
goto fail;
|
|
|
|
}
|
2008-06-09 02:20:08 +02:00
|
|
|
|
2008-11-17 19:28:14 +01:00
|
|
|
start_offset = read_32bitLE(0x1C,streamFile);
|
2008-06-13 01:50:45 +02:00
|
|
|
header_size = read_32bitLE(0x20,streamFile);
|
2008-06-13 01:33:07 +02:00
|
|
|
|
|
|
|
/* HACK to support old genh */
|
|
|
|
if (header_size == 0) {
|
|
|
|
start_offset = 0x800;
|
|
|
|
header_size = 0x800;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for audio data start past header end */
|
|
|
|
if (header_size > start_offset) goto fail;
|
|
|
|
|
2008-06-09 02:20:08 +02:00
|
|
|
interleave = read_32bitLE(0x8,streamFile);
|
|
|
|
sample_rate = read_32bitLE(0xc,streamFile);
|
|
|
|
loop_start = read_32bitLE(0x10,streamFile);
|
|
|
|
loop_end = read_32bitLE(0x14,streamFile);
|
2008-11-17 19:28:14 +01:00
|
|
|
|
2008-11-17 19:45:09 +01:00
|
|
|
coef[0] = read_32bitLE(0x24,streamFile);
|
|
|
|
coef[1] = read_32bitLE(0x28,streamFile);
|
2008-11-24 19:27:28 +01:00
|
|
|
dsp_interleave_type = read_32bitLE(0x2C,streamFile);
|
2008-12-23 19:01:18 +01:00
|
|
|
coef_type = read_32bitLE(0x30,streamFile); /* 0 - normal coefs
|
|
|
|
1 - splitted coefs (16byte rows) */
|
|
|
|
coef_splitted[0] = read_32bitLE(0x34,streamFile);
|
|
|
|
coef_splitted[1] = read_32bitLE(0x38,streamFile);
|
2008-11-17 19:45:09 +01:00
|
|
|
//if (coding == coding_XBOX && channel_count != 2) goto fail;
|
2008-06-10 03:20:54 +02:00
|
|
|
|
2008-06-09 02:20:08 +02:00
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,(loop_start!=-1));
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
/* fill in the vital information */
|
|
|
|
|
|
|
|
vgmstream->channels = channel_count;
|
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = loop_end;
|
|
|
|
vgmstream->loop_start_sample = loop_start;
|
|
|
|
vgmstream->loop_end_sample = loop_end;
|
|
|
|
vgmstream->loop_flag = (loop_start != -1);
|
|
|
|
|
2008-06-10 03:20:54 +02:00
|
|
|
switch (coding) {
|
2008-11-24 19:27:28 +01:00
|
|
|
case coding_PCM8_U_int:
|
|
|
|
vgmstream->layout_type=layout_none;
|
|
|
|
break;
|
|
|
|
case coding_PCM16LE:
|
2008-06-18 12:40:35 +02:00
|
|
|
case coding_PCM16BE:
|
2008-07-01 05:19:02 +02:00
|
|
|
case coding_PCM8:
|
2008-07-01 18:10:18 +02:00
|
|
|
case coding_SDX2:
|
2008-06-10 03:20:54 +02:00
|
|
|
case coding_PSX:
|
2008-12-18 20:04:35 +01:00
|
|
|
case coding_PSX_badflags:
|
2008-07-02 03:41:20 +02:00
|
|
|
case coding_DVI_IMA:
|
2008-07-18 07:25:05 +02:00
|
|
|
case coding_IMA:
|
2008-08-15 04:21:19 +02:00
|
|
|
case coding_AICA:
|
2008-06-10 03:20:54 +02:00
|
|
|
vgmstream->interleave_block_size = interleave;
|
|
|
|
if (channel_count > 1)
|
|
|
|
{
|
2008-07-14 22:42:49 +02:00
|
|
|
if (coding == coding_SDX2) {
|
|
|
|
coding = coding_SDX2_int;
|
|
|
|
vgmstream->coding_type = coding_SDX2_int;
|
|
|
|
}
|
2008-11-17 19:45:09 +01:00
|
|
|
if(vgmstream->interleave_block_size==0xffffffff)
|
|
|
|
vgmstream->layout_type=layout_none;
|
|
|
|
else {
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
if(coding==coding_DVI_IMA)
|
|
|
|
coding=coding_INT_DVI_IMA;
|
|
|
|
if(coding==coding_IMA)
|
|
|
|
coding=coding_INT_IMA;
|
|
|
|
}
|
2008-06-10 03:20:54 +02:00
|
|
|
} else {
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
}
|
|
|
|
break;
|
2008-08-18 01:21:12 +02:00
|
|
|
case coding_MSADPCM:
|
|
|
|
if (channel_count != 2) goto fail;
|
|
|
|
vgmstream->interleave_block_size = interleave;
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
break;
|
2008-06-10 03:20:54 +02:00
|
|
|
case coding_XBOX:
|
2008-08-10 22:08:03 +02:00
|
|
|
vgmstream->layout_type = layout_none;
|
2008-06-13 01:33:07 +02:00
|
|
|
break;
|
|
|
|
case coding_NGC_DTK:
|
|
|
|
vgmstream->layout_type = layout_dtk_interleave;
|
2008-06-10 03:20:54 +02:00
|
|
|
break;
|
2008-11-17 19:28:14 +01:00
|
|
|
case coding_NGC_DSP:
|
2008-11-24 19:27:28 +01:00
|
|
|
if (dsp_interleave_type == 0) {
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = interleave;
|
|
|
|
} else if (dsp_interleave_type == 1) {
|
|
|
|
vgmstream->layout_type = layout_interleave_byte;
|
|
|
|
vgmstream->interleave_block_size = interleave;
|
|
|
|
} else if (dsp_interleave_type == 2) {
|
|
|
|
vgmstream->layout_type = layout_none;
|
2008-11-19 21:32:56 +01:00
|
|
|
}
|
2008-11-17 19:28:14 +01:00
|
|
|
break;
|
|
|
|
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
case coding_MPEG1_L3:
|
|
|
|
vgmstream->layout_type = layout_mpeg;
|
|
|
|
break;
|
|
|
|
#endif
|
2008-06-09 12:26:17 +02:00
|
|
|
}
|
2008-06-09 02:20:08 +02:00
|
|
|
|
2008-11-17 19:45:09 +01:00
|
|
|
vgmstream->coding_type = coding;
|
2008-06-10 03:20:54 +02:00
|
|
|
vgmstream->meta_type = meta_GENH;
|
2008-06-09 02:20:08 +02:00
|
|
|
|
|
|
|
/* open the file for reading by each channel */
|
|
|
|
{
|
|
|
|
int i;
|
2008-11-17 19:28:14 +01:00
|
|
|
int j;
|
|
|
|
|
2008-06-13 01:33:07 +02:00
|
|
|
STREAMFILE * chstreamfile = NULL;
|
|
|
|
|
2008-06-09 02:20:08 +02:00
|
|
|
for (i=0;i<channel_count;i++) {
|
2008-06-13 01:33:07 +02:00
|
|
|
off_t chstart_offset = start_offset;
|
|
|
|
|
|
|
|
switch (coding) {
|
|
|
|
case coding_PSX:
|
2008-12-18 20:04:35 +01:00
|
|
|
case coding_PSX_badflags:
|
2008-06-18 01:32:24 +02:00
|
|
|
case coding_PCM16BE:
|
|
|
|
case coding_PCM16LE:
|
2008-07-01 18:10:18 +02:00
|
|
|
case coding_SDX2:
|
2008-07-14 22:42:49 +02:00
|
|
|
case coding_SDX2_int:
|
2008-07-02 03:41:20 +02:00
|
|
|
case coding_DVI_IMA:
|
2008-07-18 07:25:05 +02:00
|
|
|
case coding_IMA:
|
2008-07-01 05:19:02 +02:00
|
|
|
case coding_PCM8:
|
2008-11-24 19:27:28 +01:00
|
|
|
case coding_PCM8_U_int:
|
2008-08-15 04:21:19 +02:00
|
|
|
case coding_AICA:
|
2008-11-17 19:45:09 +01:00
|
|
|
case coding_INT_DVI_IMA:
|
|
|
|
case coding_INT_IMA:
|
2008-06-13 01:33:07 +02:00
|
|
|
if (vgmstream->layout_type == layout_interleave) {
|
2008-06-18 12:40:35 +02:00
|
|
|
if (interleave >= 512) {
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,interleave);
|
|
|
|
} else {
|
|
|
|
if (!chstreamfile)
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
}
|
2008-06-13 01:33:07 +02:00
|
|
|
chstart_offset =
|
|
|
|
start_offset+vgmstream->interleave_block_size*i;
|
|
|
|
} else {
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,
|
|
|
|
STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case coding_XBOX:
|
2008-08-18 01:07:41 +02:00
|
|
|
case coding_MSADPCM:
|
2008-06-13 01:33:07 +02:00
|
|
|
/* xbox's "interleave" is a lie, all channels start at same
|
|
|
|
* offset */
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,
|
|
|
|
STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
break;
|
|
|
|
case coding_NGC_DTK:
|
|
|
|
if (!chstreamfile)
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,32*0x400);
|
|
|
|
break;
|
2008-11-17 19:28:14 +01:00
|
|
|
case coding_NGC_DSP:
|
2008-11-17 19:45:09 +01:00
|
|
|
if (!chstreamfile)
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
|
|
|
2008-12-23 19:01:18 +01:00
|
|
|
if (coef_type == 0) {
|
|
|
|
for (j=0;j<16;j++) {
|
2008-11-17 19:45:09 +01:00
|
|
|
vgmstream->ch[i].adpcm_coef[j] = read_16bitBE(coef[i]+j*2,streamFile);
|
2008-12-23 19:01:18 +01:00
|
|
|
chstart_offset =start_offset+vgmstream->interleave_block_size*i;
|
|
|
|
}
|
|
|
|
} else if (coef_type == 1) {
|
|
|
|
for (j=0;j<8;j++) {
|
|
|
|
vgmstream->ch[0].adpcm_coef[j*2]=read_16bitBE(coef[0]+j*2,streamFile);
|
|
|
|
vgmstream->ch[0].adpcm_coef[j*2+1]=read_16bitBE(coef_splitted[0]+j*2,streamFile);
|
|
|
|
vgmstream->ch[1].adpcm_coef[j*2]=read_16bitBE(coef[1]+j*2,streamFile);
|
|
|
|
vgmstream->ch[1].adpcm_coef[j*2+1]=read_16bitBE(coef_splitted[1]+j*2,streamFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
chstart_offset =start_offset+vgmstream->interleave_block_size*i;
|
|
|
|
|
2008-11-17 19:45:09 +01:00
|
|
|
break;
|
2008-11-17 19:28:14 +01:00
|
|
|
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
case coding_MPEG1_L3:
|
|
|
|
if (!chstreamfile)
|
|
|
|
chstreamfile =
|
|
|
|
streamFile->open(streamFile,filename,MPEG_BUFFER_SIZE);
|
|
|
|
break;
|
|
|
|
#endif
|
2008-06-13 01:33:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!chstreamfile) goto fail;
|
2008-06-09 02:20:08 +02:00
|
|
|
|
2008-06-13 01:33:07 +02:00
|
|
|
vgmstream->ch[i].streamfile = chstreamfile;
|
2008-06-09 02:20:08 +02:00
|
|
|
|
|
|
|
vgmstream->ch[i].channel_start_offset=
|
2008-06-14 01:01:12 +02:00
|
|
|
vgmstream->ch[i].offset=chstart_offset;
|
2008-06-09 02:20:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
if (coding == coding_MPEG1_L3) {
|
|
|
|
int rc;
|
|
|
|
off_t read_offset;
|
|
|
|
data = calloc(1,sizeof(mpeg_codec_data));
|
|
|
|
if (!data) goto mpeg_fail;
|
|
|
|
|
|
|
|
data->m = mpg123_new(NULL,&rc);
|
|
|
|
if (rc==MPG123_NOT_INITIALIZED) {
|
|
|
|
if (mpg123_init()!=MPG123_OK) goto mpeg_fail;
|
|
|
|
data->m = mpg123_new(NULL,&rc);
|
|
|
|
if (rc!=MPG123_OK) goto mpeg_fail;
|
|
|
|
} else if (rc!=MPG123_OK) {
|
|
|
|
goto mpeg_fail;
|
|
|
|
}
|
|
|
|
|
2008-07-10 16:37:09 +02:00
|
|
|
mpg123_param(data->m,MPG123_REMOVE_FLAGS,MPG123_GAPLESS,0.0);
|
|
|
|
|
2008-07-06 17:33:38 +02:00
|
|
|
if (mpg123_open_feed(data->m)!=MPG123_OK) {
|
|
|
|
goto mpeg_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check format */
|
|
|
|
read_offset=0;
|
|
|
|
do {
|
|
|
|
size_t bytes_done;
|
|
|
|
if (read_streamfile(data->buffer, start_offset+read_offset,
|
|
|
|
MPEG_BUFFER_SIZE,vgmstream->ch[0].streamfile) !=
|
|
|
|
MPEG_BUFFER_SIZE) goto mpeg_fail;
|
|
|
|
read_offset+=1;
|
|
|
|
rc = mpg123_decode(data->m,data->buffer,MPEG_BUFFER_SIZE,
|
|
|
|
NULL,0,&bytes_done);
|
|
|
|
if (rc != MPG123_OK && rc != MPG123_NEW_FORMAT &&
|
|
|
|
rc != MPG123_NEED_MORE) goto mpeg_fail;
|
|
|
|
} while (rc != MPG123_NEW_FORMAT);
|
|
|
|
|
|
|
|
{
|
|
|
|
long rate;
|
|
|
|
int channels,encoding;
|
|
|
|
struct mpg123_frameinfo mi;
|
|
|
|
rc = mpg123_getformat(data->m,&rate,&channels,&encoding);
|
|
|
|
if (rc != MPG123_OK) goto mpeg_fail;
|
|
|
|
if (rate != vgmstream->sample_rate ||
|
|
|
|
channels != vgmstream->channels ||
|
|
|
|
encoding != MPG123_ENC_SIGNED_16) goto mpeg_fail;
|
|
|
|
mpg123_info(data->m,&mi);
|
|
|
|
if (mi.rate != vgmstream->sample_rate) goto mpeg_fail;
|
|
|
|
if (mi.version == MPG123_1_0 && mi.layer == 1)
|
|
|
|
vgmstream->coding_type = coding_MPEG1_L1;
|
|
|
|
else if (mi.version == MPG123_1_0 && mi.layer == 2)
|
|
|
|
vgmstream->coding_type = coding_MPEG1_L2;
|
|
|
|
else if (mi.version == MPG123_1_0 && mi.layer == 3)
|
|
|
|
vgmstream->coding_type = coding_MPEG1_L3;
|
|
|
|
else if (mi.version == MPG123_2_0 && mi.layer == 1)
|
|
|
|
vgmstream->coding_type = coding_MPEG2_L1;
|
|
|
|
else if (mi.version == MPG123_2_0 && mi.layer == 2)
|
|
|
|
vgmstream->coding_type = coding_MPEG2_L2;
|
|
|
|
else if (mi.version == MPG123_2_0 && mi.layer == 3)
|
|
|
|
vgmstream->coding_type = coding_MPEG2_L3;
|
|
|
|
else if (mi.version == MPG123_2_5 && mi.layer == 1)
|
|
|
|
vgmstream->coding_type = coding_MPEG25_L1;
|
|
|
|
else if (mi.version == MPG123_2_5 && mi.layer == 2)
|
|
|
|
vgmstream->coding_type = coding_MPEG25_L2;
|
|
|
|
else if (mi.version == MPG123_2_5 && mi.layer == 3)
|
|
|
|
vgmstream->coding_type = coding_MPEG25_L3;
|
|
|
|
else goto mpeg_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reinit, to ignore the reading we've done so far */
|
|
|
|
mpg123_open_feed(data->m);
|
|
|
|
|
|
|
|
vgmstream->codec_data = data;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-06-09 02:20:08 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
/* clean up anything we may have opened */
|
2008-07-06 17:33:38 +02:00
|
|
|
#ifdef VGM_USE_MPEG
|
|
|
|
mpeg_fail:
|
|
|
|
if (data) {
|
|
|
|
mpg123_delete(data->m);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
#endif
|
2008-06-09 02:20:08 +02:00
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|