diff --git a/fb2k/version.h b/fb2k/version.h index e308d609..36467656 100755 --- a/fb2k/version.h +++ b/fb2k/version.h @@ -1 +1 @@ -#define VERSION "r873" +#define VERSION "r911" diff --git a/src/coding/coding.h b/src/coding/coding.h index d028c70d..16710ec9 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -80,7 +80,7 @@ void decode_ws(VGMSTREAM * vgmstream, int channel, sample * outbuf, int channels void decode_fake_mpeg2_l2(VGMSTREAMCHANNEL * stream, mpeg_codec_data * data, sample * outbuf, int32_t samples_to_do); -mpeg_codec_data *init_mpeg_codec_data(STREAMFILE *streamfile, off_t start_offset, long given_sample_rate, int given_channels, coding_t *coding_type); +mpeg_codec_data *init_mpeg_codec_data(STREAMFILE *streamfile, off_t start_offset, long given_sample_rate, int given_channels, coding_t *coding_type, int * actual_sample_rate, int * actual_channels); long mpeg_bytes_to_samples(long bytes, const struct mpg123_frameinfo *mi); void decode_mpeg(VGMSTREAMCHANNEL * stream, mpeg_codec_data * data, diff --git a/src/coding/mpeg_decoder.c b/src/coding/mpeg_decoder.c index 3fb659c3..921287b8 100644 --- a/src/coding/mpeg_decoder.c +++ b/src/coding/mpeg_decoder.c @@ -85,7 +85,7 @@ void decode_fake_mpeg2_l2(VGMSTREAMCHANNEL *stream, } } -mpeg_codec_data *init_mpeg_codec_data(STREAMFILE *streamfile, off_t start_offset, long given_sample_rate, int given_channels, coding_t *coding_type) { +mpeg_codec_data *init_mpeg_codec_data(STREAMFILE *streamfile, off_t start_offset, long given_sample_rate, int given_channels, coding_t *coding_type, int * actual_sample_rate, int * actual_channels) { int rc; off_t read_offset; mpeg_codec_data *data = NULL; @@ -157,6 +157,9 @@ mpeg_codec_data *init_mpeg_codec_data(STREAMFILE *streamfile, off_t start_offset else if (mi.version == MPG123_2_5 && mi.layer == 3) *coding_type = coding_MPEG25_L3; else goto mpeg_fail; + + if ( actual_sample_rate ) *actual_sample_rate = rate; + if ( actual_channels ) *actual_channels = channels; } /* reinit, to ignore the reading we've done so far */ @@ -187,6 +190,11 @@ void decode_mpeg(VGMSTREAMCHANNEL *stream, data->bytes_in_buffer = read_streamfile(data->buffer, stream->offset,MPEG_BUFFER_SIZE,stream->streamfile); + if (!data->bytes_in_buffer) { + memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * sizeof(sample)); + break; + } + data->buffer_full = 1; data->buffer_used = 0; diff --git a/src/meta/fsb.c b/src/meta/fsb.c index f3f6a975..e53bd1b9 100644 --- a/src/meta/fsb.c +++ b/src/meta/fsb.c @@ -430,10 +430,9 @@ VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE *streamFile) { num_samples = (read_32bitLE(0x5C,streamFile)); #ifdef VGM_USE_MPEG - mpeg_data = init_mpeg_codec_data(streamFile, start_offset, -1, -1, &mpeg_coding_type); // -1 to not check sample rate or channels + mpeg_data = init_mpeg_codec_data(streamFile, start_offset, -1, -1, &mpeg_coding_type, &rate, &channels); // -1 to not check sample rate or channels if (!mpeg_data) goto fail; - if (MPG123_OK != mpg123_getformat(mpeg_data->m,&rate,&channels,&encoding)) goto fail; channel_count = channels; sample_rate = rate; diff --git a/src/meta/genh.c b/src/meta/genh.c index ec51ee5b..960bc46d 100644 --- a/src/meta/genh.c +++ b/src/meta/genh.c @@ -323,7 +323,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { #ifdef VGM_USE_MPEG if (coding == coding_MPEG1_L3) { - vgmstream->codec_data = init_mpeg_codec_data(vgmstream->ch[0].streamfile, start_offset, vgmstream->sample_rate, vgmstream->channels, &(vgmstream->coding_type)); + vgmstream->codec_data = init_mpeg_codec_data(vgmstream->ch[0].streamfile, start_offset, vgmstream->sample_rate, vgmstream->channels, &(vgmstream->coding_type), NULL, NULL); if (!vgmstream->codec_data) goto fail; } #endif diff --git a/src/meta/ps3_msf.c b/src/meta/ps3_msf.c index 762de5a0..cf86c497 100644 --- a/src/meta/ps3_msf.c +++ b/src/meta/ps3_msf.c @@ -105,7 +105,7 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { struct mpg123_frameinfo mi; coding_t ct; - mpeg_data = init_mpeg_codec_data(streamFile, start_offset, vgmstream->sample_rate, vgmstream->channels, &ct); + mpeg_data = init_mpeg_codec_data(streamFile, start_offset, vgmstream->sample_rate, vgmstream->channels, &ct, NULL, NULL); if (!mpeg_data) goto fail; vgmstream->codec_data = mpeg_data; diff --git a/src/meta/ps3_xvag.c b/src/meta/ps3_xvag.c index 9d385b62..9467dfe3 100644 --- a/src/meta/ps3_xvag.c +++ b/src/meta/ps3_xvag.c @@ -73,10 +73,9 @@ VGMSTREAM * init_vgmstream_ps3_xvag(STREAMFILE *streamFile) { long rate; int channels,encoding; - mpeg_data = init_mpeg_codec_data(streamFile, start_offset, -1, -1, &mpeg_coding_type); // -1 to not check sample rate or channels + mpeg_data = init_mpeg_codec_data(streamFile, start_offset, -1, -1, &mpeg_coding_type, &rate, &channels); // -1 to not check sample rate or channels if (!mpeg_data) goto fail; - if (MPG123_OK != mpg123_getformat(mpeg_data->m,&rate,&channels,&encoding)) goto fail; channel_count = channels; sample_rate = rate; diff --git a/src/meta/se_scd.c b/src/meta/se_scd.c index 05de6ba0..d33fcc9d 100644 --- a/src/meta/se_scd.c +++ b/src/meta/se_scd.c @@ -88,7 +88,7 @@ VGMSTREAM * init_vgmstream_se_scd(STREAMFILE *streamFile) { struct mpg123_frameinfo mi; coding_t ct; - mpeg_data = init_mpeg_codec_data(streamFile, start_offset, vgmstream->sample_rate, vgmstream->channels, &ct); + mpeg_data = init_mpeg_codec_data(streamFile, start_offset, vgmstream->sample_rate, vgmstream->channels, &ct, NULL, NULL); if (!mpeg_data) goto fail; vgmstream->codec_data = mpeg_data;