mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-12 00:53:05 +01:00
Fix silent downmixing in rare cases
This commit is contained in:
parent
c7eb984f6c
commit
6e86f78900
@ -157,7 +157,7 @@ static VGMSTREAM* init_vgmstream_ktsr_internal(STREAMFILE* sf, bool is_srsa) {
|
|||||||
const char* ext;
|
const char* ext;
|
||||||
switch(ktsr.codec) {
|
switch(ktsr.codec) {
|
||||||
case RIFF_ATRAC9: init_vgmstream = init_vgmstream_riff; ext = "at9"; break; // Nioh (PS4)
|
case RIFF_ATRAC9: init_vgmstream = init_vgmstream_riff; ext = "at9"; break; // Nioh (PS4)
|
||||||
case KOVS: init_vgmstream = init_vgmstream_ogg_vorbis; ext = "kvs"; break; // Nioh (PC)
|
case KOVS: init_vgmstream = init_vgmstream_ogg_vorbis; ext = "kvs"; break; // Nioh (PC), Fairy Tail 2 (PC)
|
||||||
case KTSS: init_vgmstream = init_vgmstream_ktss; ext = "ktss"; break; //
|
case KTSS: init_vgmstream = init_vgmstream_ktss; ext = "ktss"; break; //
|
||||||
case KTAC: init_vgmstream = init_vgmstream_ktac; ext = "ktac"; break; // Blue Reflection Tie (PS4)
|
case KTAC: init_vgmstream = init_vgmstream_ktac; ext = "ktac"; break; // Blue Reflection Tie (PS4)
|
||||||
case KA1A: init_vgmstream = init_vgmstream_ka1a; ext = "ka1a"; break; // Dynasty Warriors Origins (PC)
|
case KA1A: init_vgmstream = init_vgmstream_ka1a; ext = "ka1a"; break; // Dynasty Warriors Origins (PC)
|
||||||
@ -466,7 +466,7 @@ static bool parse_ktsr_subfile(ktsr_header* ktsr, STREAMFILE* sf, uint32_t offse
|
|||||||
* 18 num samples
|
* 18 num samples
|
||||||
* 1c null or 0x100?
|
* 1c null or 0x100?
|
||||||
* 20 loop start or -1 (loop end is num samples)
|
* 20 loop start or -1 (loop end is num samples)
|
||||||
* 24 channel layout or null
|
* 24 null or channel layout (for 1 track in case of multi-track streams))
|
||||||
* 28 header offset (within subfile)
|
* 28 header offset (within subfile)
|
||||||
* 2c header size [B, C]
|
* 2c header size [B, C]
|
||||||
* 30 offset to data start offset [A, C] or to data start+size [B]
|
* 30 offset to data start offset [A, C] or to data start+size [B]
|
||||||
|
@ -82,13 +82,12 @@ bool prepare_vgmstream(VGMSTREAM* vgmstream, STREAMFILE* sf) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* some players are picky with incorrect channel layouts */
|
/* some players are picky with incorrect channel layouts (also messes ups downmixing calcs) */
|
||||||
if (vgmstream->channel_layout > 0) {
|
if (vgmstream->channel_layout > 0) {
|
||||||
int output_channels = vgmstream->channels;
|
|
||||||
int count = 0, max_ch = 32;
|
int count = 0, max_ch = 32;
|
||||||
for (int ch = 0; ch < max_ch; ch++) {
|
for (int ch = 0; ch < max_ch; ch++) {
|
||||||
int bit = (vgmstream->channel_layout >> ch) & 1;
|
int bit = (vgmstream->channel_layout >> ch) & 1;
|
||||||
if (ch > 17 && bit) {
|
if (ch > 17 && bit) { // unknown past 16
|
||||||
VGM_LOG("VGMSTREAM: wrong bit %i in channel_layout %x\n", ch, vgmstream->channel_layout);
|
VGM_LOG("VGMSTREAM: wrong bit %i in channel_layout %x\n", ch, vgmstream->channel_layout);
|
||||||
vgmstream->channel_layout = 0;
|
vgmstream->channel_layout = 0;
|
||||||
break;
|
break;
|
||||||
@ -96,8 +95,8 @@ bool prepare_vgmstream(VGMSTREAM* vgmstream, STREAMFILE* sf) {
|
|||||||
count += bit;
|
count += bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > output_channels) {
|
if (count != vgmstream->channels) {
|
||||||
VGM_LOG("VGMSTREAM: wrong totals %i in channel_layout %x\n", count, vgmstream->channel_layout);
|
VGM_LOG("VGMSTREAM: ignored mismatched channel_layout %04x, uses %i vs %i channels\n", vgmstream->channel_layout, count, vgmstream->channels);
|
||||||
vgmstream->channel_layout = 0;
|
vgmstream->channel_layout = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user