mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
Fix TXTH XMA multichannel and num_samples
This commit is contained in:
parent
93e35d672b
commit
a975eff1a2
@ -190,7 +190,7 @@ int ffmpeg_make_riff_xma1(uint8_t * buf, size_t buf_size, size_t sample_count, s
|
|||||||
put_32bitLE(buf+off+0x08, 0); /* loop start */
|
put_32bitLE(buf+off+0x08, 0); /* loop start */
|
||||||
put_32bitLE(buf+off+0x0c, 0); /* loop end */
|
put_32bitLE(buf+off+0x0c, 0); /* loop end */
|
||||||
put_8bit (buf+off+0x10, 0); /* loop subframe */
|
put_8bit (buf+off+0x10, 0); /* loop subframe */
|
||||||
put_8bit (buf+off+0x11, channels);
|
put_8bit (buf+off+0x11, stream_channels);
|
||||||
put_16bitLE(buf+off+0x12, speakers);
|
put_16bitLE(buf+off+0x12, speakers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ typedef struct {
|
|||||||
uint32_t coef_big_endian;
|
uint32_t coef_big_endian;
|
||||||
uint32_t coef_mode;
|
uint32_t coef_mode;
|
||||||
|
|
||||||
|
int num_samples_data_size;
|
||||||
|
|
||||||
} txth_header;
|
} txth_header;
|
||||||
|
|
||||||
static STREAMFILE * open_txth(STREAMFILE * streamFile);
|
static STREAMFILE * open_txth(STREAMFILE * streamFile);
|
||||||
@ -343,25 +345,29 @@ VGMSTREAM * init_vgmstream_txth(STREAMFILE *streamFile) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VGM_USE_FFMPEG
|
#ifdef VGM_USE_FFMPEG
|
||||||
if (txth.sample_type_bytes && (txth.codec == XMA1 || txth.codec == XMA2)) {
|
if ((txth.sample_type_bytes || txth.num_samples_data_size) && (txth.codec == XMA1 || txth.codec == XMA2)) {
|
||||||
/* manually find sample offsets */
|
/* manually find sample offsets */
|
||||||
ms_sample_data msd;
|
ms_sample_data msd = {0};
|
||||||
memset(&msd,0,sizeof(ms_sample_data));
|
|
||||||
|
|
||||||
msd.xma_version = 1;
|
msd.xma_version = 1;
|
||||||
msd.channels = txth.channels;
|
msd.channels = txth.channels;
|
||||||
msd.data_offset = txth.start_offset;
|
msd.data_offset = txth.start_offset;
|
||||||
msd.data_size = txth.data_size;
|
msd.data_size = txth.data_size;
|
||||||
msd.loop_flag = txth.loop_flag;
|
if (txth.sample_type_bytes) {
|
||||||
msd.loop_start_b = txth.loop_start_sample;
|
msd.loop_flag = txth.loop_flag;
|
||||||
msd.loop_end_b = txth.loop_end_sample;
|
msd.loop_start_b = txth.loop_start_sample;
|
||||||
msd.loop_start_subframe = txth.loop_adjust & 0xF; /* lower 4b: subframe where the loop starts, 0..4 */
|
msd.loop_end_b = txth.loop_end_sample;
|
||||||
msd.loop_end_subframe = txth.loop_adjust >> 4; /* upper 4b: subframe where the loop ends, 0..3 */
|
msd.loop_start_subframe = txth.loop_adjust & 0xF; /* lower 4b: subframe where the loop starts, 0..4 */
|
||||||
|
msd.loop_end_subframe = txth.loop_adjust >> 4; /* upper 4b: subframe where the loop ends, 0..3 */
|
||||||
|
}
|
||||||
|
|
||||||
xma_get_samples(&msd, streamFile);
|
xma_get_samples(&msd, streamFile);
|
||||||
|
|
||||||
vgmstream->num_samples = msd.num_samples;
|
vgmstream->num_samples = msd.num_samples;
|
||||||
vgmstream->loop_start_sample = msd.loop_start_sample;
|
if (txth.sample_type_bytes) {
|
||||||
vgmstream->loop_end_sample = msd.loop_end_sample;
|
vgmstream->loop_start_sample = msd.loop_start_sample;
|
||||||
|
vgmstream->loop_end_sample = msd.loop_end_sample;
|
||||||
|
}
|
||||||
//skip_samples = msd.skip_samples; //todo add skip samples
|
//skip_samples = msd.skip_samples; //todo add skip samples
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -524,6 +530,7 @@ static int parse_keyval(STREAMFILE * streamFile, STREAMFILE * streamText, txth_h
|
|||||||
else if (0==strcmp(key,"num_samples")) {
|
else if (0==strcmp(key,"num_samples")) {
|
||||||
if (0==strcmp(val,"data_size")) {
|
if (0==strcmp(val,"data_size")) {
|
||||||
txth->num_samples = get_bytes_to_samples(txth, txth->data_size);
|
txth->num_samples = get_bytes_to_samples(txth, txth->data_size);
|
||||||
|
txth->num_samples_data_size = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!parse_num(streamFile,val, &txth->num_samples)) goto fail;
|
if (!parse_num(streamFile,val, &txth->num_samples)) goto fail;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user