mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
Fix .sngw 5.1 channel order
This commit is contained in:
parent
8739631792
commit
9ac36892f6
@ -6,7 +6,7 @@
|
||||
#include <vorbis/vorbisfile.h>
|
||||
|
||||
|
||||
static void pcm_convert_float_to_16(int channels, sample_t * outbuf, int samples_to_do, float ** pcm);
|
||||
static void pcm_convert_float_to_16(int channels, sample_t * outbuf, int samples_to_do, float ** pcm, int disable_ordering);
|
||||
|
||||
|
||||
void decode_ogg_vorbis(ogg_vorbis_codec_data * data, sample_t * outbuf, int32_t samples_to_do, int channels) {
|
||||
@ -22,7 +22,7 @@ void decode_ogg_vorbis(ogg_vorbis_codec_data * data, sample_t * outbuf, int32_t
|
||||
&data->bitstream); /* bitstream*/
|
||||
if (rc <= 0) goto fail; /* rc is samples done */
|
||||
|
||||
pcm_convert_float_to_16(channels, outbuf, rc, pcm_channels);
|
||||
pcm_convert_float_to_16(channels, outbuf, rc, pcm_channels, data->disable_reordering);
|
||||
|
||||
outbuf += rc * channels;
|
||||
samples_done += rc;
|
||||
@ -69,7 +69,7 @@ static const int xiph_channel_map[8][8] = {
|
||||
};
|
||||
|
||||
/* converts from internal Vorbis format to standard PCM and remaps (mostly from Xiph's decoder_example.c) */
|
||||
static void pcm_convert_float_to_16(int channels, sample_t * outbuf, int samples_to_do, float ** pcm) {
|
||||
static void pcm_convert_float_to_16(int channels, sample_t * outbuf, int samples_to_do, float ** pcm, int disable_ordering) {
|
||||
int ch, s, ch_map;
|
||||
sample_t *ptr;
|
||||
float *channel;
|
||||
@ -77,7 +77,9 @@ static void pcm_convert_float_to_16(int channels, sample_t * outbuf, int samples
|
||||
/* convert float PCM (multichannel float array, with pcm[0]=ch0, pcm[1]=ch1, pcm[2]=ch0, etc)
|
||||
* to 16 bit signed PCM ints (host order) and interleave + fix clipping */
|
||||
for (ch = 0; ch < channels; ch++) {
|
||||
ch_map = (channels > 8) ? ch : xiph_channel_map[channels - 1][ch]; /* put Vorbis' ch to other outbuf's ch */
|
||||
ch_map = disable_ordering ?
|
||||
ch :
|
||||
(channels > 8) ? ch : xiph_channel_map[channels - 1][ch]; /* put Vorbis' ch to other outbuf's ch */
|
||||
ptr = outbuf + ch;
|
||||
channel = pcm[ch_map];
|
||||
for (s = 0; s < samples_to_do; s++) {
|
||||
|
@ -117,6 +117,7 @@ typedef struct {
|
||||
|
||||
off_t stream_size;
|
||||
int total_subsongs;
|
||||
int disable_reordering;
|
||||
|
||||
/* decryption setup */
|
||||
void (*decryption_callback)(void *ptr, size_t size, size_t nmemb, void *datasource);
|
||||
|
@ -381,6 +381,7 @@ VGMSTREAM * init_vgmstream_ogg_vorbis(STREAMFILE *streamFile) {
|
||||
ovmi.xor_value = read_32bitBE(0x00,streamFile);
|
||||
ovmi.decryption_callback = sngw_ogg_decryption_callback;
|
||||
}
|
||||
ovmi.disable_reordering = 1; /* must be an MT Framework thing */
|
||||
ovmi.meta_type = meta_OGG_encrypted;
|
||||
}
|
||||
|
||||
@ -530,6 +531,9 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb
|
||||
data->bitstream = OGG_DEFAULT_BITSTREAM;
|
||||
vi = ov_info(ovf,OGG_DEFAULT_BITSTREAM);
|
||||
|
||||
/* other settings */
|
||||
data->disable_reordering = ovmi->disable_reordering;
|
||||
|
||||
/* search for loop comments */
|
||||
{
|
||||
int i;
|
||||
|
@ -931,6 +931,7 @@ typedef struct {
|
||||
int bitstream;
|
||||
|
||||
ogg_vorbis_streamfile ov_streamfile;
|
||||
int disable_reordering; /* Xiph reorder channels on output, except for some devs */
|
||||
} ogg_vorbis_codec_data;
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user