Fix some AIX with many segments [Sega Ages 2500 Vol 28 (PS2)]

This commit is contained in:
bnnm 2020-05-23 23:01:26 +02:00
parent 9da8b93f56
commit f65c2b5c00

View File

@ -3,13 +3,15 @@
#include "aix_streamfile.h"
#define MAX_SEGMENTS 50 /* usually segment0=intro, segment1=loop/main, sometimes ~5, rarely ~40 */
/* usually segment0=intro, segment1=loop/main, sometimes ~5, rarely ~40~115
* as pseudo dynamic/multi-song container [Sega Ages 2500 Vol 28 Tetris Collection (PS2)] */
#define MAX_SEGMENTS 120
static VGMSTREAM *build_segmented_vgmstream(STREAMFILE *streamFile, off_t *segment_offsets, size_t *segment_sizes, int32_t *segment_samples, int segment_count, int layer_count);
static VGMSTREAM* build_segmented_vgmstream(STREAMFILE* sf, off_t* segment_offsets, size_t* segment_sizes, int32_t* segment_samples, int segment_count, int layer_count);
/* AIX - N segments with M layers (2ch ADX) inside [SoulCalibur IV (PS3), Dragon Ball Z: Burst Limit (PS3)] */
VGMSTREAM * init_vgmstream_aix(STREAMFILE *sf) {
VGMSTREAM * vgmstream = NULL;
VGMSTREAM* init_vgmstream_aix(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t segment_offsets[MAX_SEGMENTS] = {0};
size_t segment_sizes[MAX_SEGMENTS] = {0};
@ -106,8 +108,8 @@ fail:
return NULL;
}
static VGMSTREAM *build_layered_vgmstream(STREAMFILE *streamFile, off_t segment_offset, size_t segment_size, int layer_count) {
VGMSTREAM *vgmstream = NULL;
static VGMSTREAM *build_layered_vgmstream(STREAMFILE* sf, off_t segment_offset, size_t segment_size, int layer_count) {
VGMSTREAM* vgmstream = NULL;
layered_layout_data* data = NULL;
int i;
STREAMFILE* temp_sf = NULL;
@ -119,7 +121,7 @@ static VGMSTREAM *build_layered_vgmstream(STREAMFILE *streamFile, off_t segment_
for (i = 0; i < layer_count; i++) {
/* build the layer STREAMFILE */
temp_sf = setup_aix_streamfile(streamFile, segment_offset, segment_size, i, "adx");
temp_sf = setup_aix_streamfile(sf, segment_offset, segment_size, i, "adx");
if (!temp_sf) goto fail;
/* build the sub-VGMSTREAM */
@ -149,9 +151,9 @@ fail:
return NULL;
}
static VGMSTREAM *build_segmented_vgmstream(STREAMFILE *streamFile, off_t *segment_offsets, size_t *segment_sizes, int32_t *segment_samples, int segment_count, int layer_count) {
VGMSTREAM *vgmstream = NULL;
segmented_layout_data *data = NULL;
static VGMSTREAM *build_segmented_vgmstream(STREAMFILE* sf, off_t* segment_offsets, size_t* segment_sizes, int32_t* segment_samples, int segment_count, int layer_count) {
VGMSTREAM* vgmstream = NULL;
segmented_layout_data* data = NULL;
int i, loop_flag, loop_start_segment, loop_end_segment;
@ -161,7 +163,7 @@ static VGMSTREAM *build_segmented_vgmstream(STREAMFILE *streamFile, off_t *segme
for (i = 0; i < segment_count; i++) {
/* build the layered sub-VGMSTREAM */
data->segments[i] = build_layered_vgmstream(streamFile, segment_offsets[i], segment_sizes[i], layer_count);
data->segments[i] = build_layered_vgmstream(sf, segment_offsets[i], segment_sizes[i], layer_count);
if (!data->segments[i]) goto fail;
data->segments[i]->num_samples = segment_samples[i]; /* just in case */
@ -177,7 +179,7 @@ static VGMSTREAM *build_segmented_vgmstream(STREAMFILE *streamFile, off_t *segme
* - 2 segments: intro + loop [SoulCalibur IV (PS3)]
* - 3 segments: intro + loop + end [Dragon Ball Z: Burst Limit (PS3), Metroid: Other M (Wii)]
* - 4/5 segments: intros + loop + ends [Danball Senki (PSP)]
* - 39 segments: no loops but multiple segments for dynamic parts? [Tetris Collection (PS2)] */
* - +39 segments: no loops but multiple segments for dynamic parts? [Tetris Collection (PS2)] */
loop_flag = (segment_count > 0 && segment_count <= 5);
loop_start_segment = (segment_count > 3) ? 2 : 1;
loop_end_segment = (segment_count > 3) ? (segment_count - 2) : 1;