mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 09:40:51 +01:00
Find loop_segment automatically in segmented_layout + remove from metas
This commit is contained in:
parent
c9dc0917ff
commit
ee03726bbc
@ -16,10 +16,27 @@ void render_vgmstream_segmented(sample * buffer, int32_t sample_count, VGMSTREAM
|
||||
|
||||
|
||||
if (vgmstream->loop_flag && vgmstream_do_loop(vgmstream)) {
|
||||
/* handle looping, moving to loop segment */
|
||||
//todo can only loop in a segment start
|
||||
// (for arbitrary values find loop segment from loop_start_sample, and skip N samples until loop start)
|
||||
data->current_segment = data->loop_segment;
|
||||
/* handle looping, finding loop segment */
|
||||
int loop_segment = 0, samples = 0, loop_samples_skip = 0;
|
||||
while (samples < vgmstream->num_samples) {
|
||||
int32_t segment_samples = data->segments[loop_segment]->num_samples;
|
||||
if (vgmstream->loop_start_sample >= samples && vgmstream->loop_start_sample < samples + segment_samples) {
|
||||
loop_samples_skip = vgmstream->loop_start_sample - samples;
|
||||
break; /* loop_start falls within loop_segment's samples */
|
||||
}
|
||||
samples += segment_samples;
|
||||
loop_segment++;
|
||||
}
|
||||
if (loop_segment == data->segment_count) {
|
||||
VGM_LOG("segmented_layout: can't find loop segment\n");
|
||||
loop_segment = 0;
|
||||
}
|
||||
if (loop_samples_skip > 0) {
|
||||
VGM_LOG("segmented_layout: loop starts after %i samples\n", loop_samples_skip);
|
||||
//todo skip/fix, but probably won't happen
|
||||
}
|
||||
|
||||
data->current_segment = loop_segment;
|
||||
reset_vgmstream(data->segments[data->current_segment]);
|
||||
vgmstream->samples_into_block = 0;
|
||||
continue;
|
||||
|
@ -15,7 +15,7 @@ VGMSTREAM * init_vgmstream_aax(STREAMFILE *streamFile) {
|
||||
|
||||
int loop_flag = 0, channel_count = 0;
|
||||
int32_t sample_count, loop_start_sample = 0, loop_end_sample = 0;
|
||||
int segment_count, loop_segment = 0;
|
||||
int segment_count;
|
||||
|
||||
segmented_layout_data *data = NULL;
|
||||
int table_error = 0;
|
||||
@ -102,7 +102,6 @@ VGMSTREAM * init_vgmstream_aax(STREAMFILE *streamFile) {
|
||||
|
||||
if (!loop_flag && segment_loop_flag) {
|
||||
loop_start_sample = sample_count;
|
||||
loop_segment = i;
|
||||
}
|
||||
|
||||
sample_count += data->segments[i]->num_samples;
|
||||
@ -130,7 +129,6 @@ VGMSTREAM * init_vgmstream_aax(STREAMFILE *streamFile) {
|
||||
vgmstream->layout_type = layout_segmented;
|
||||
|
||||
vgmstream->layout_data = data;
|
||||
data->loop_segment = loop_segment;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
|
@ -755,8 +755,6 @@ static segmented_layout_data* build_segmented_eaaudiocore_looping(STREAMFILE *st
|
||||
/* setup segmented VGMSTREAMs */
|
||||
if (!setup_layout_segmented(data))
|
||||
goto fail;
|
||||
data->loop_segment = 1;
|
||||
|
||||
return data;
|
||||
|
||||
fail:
|
||||
|
@ -95,9 +95,7 @@ VGMSTREAM * init_vgmstream_mus_acm(STREAMFILE *streamFile) {
|
||||
vgmstream->meta_type = meta_MUS_ACM;
|
||||
vgmstream->coding_type = data->segments[0]->coding_type;
|
||||
vgmstream->layout_type = layout_segmented;
|
||||
|
||||
vgmstream->layout_data = data;
|
||||
data->loop_segment = loop_start_index;
|
||||
|
||||
clean_mus(mus_filenames, segment_count);
|
||||
return vgmstream;
|
||||
|
@ -84,9 +84,7 @@ VGMSTREAM * init_vgmstream_opus_ppp(STREAMFILE *streamFile) {
|
||||
vgmstream->meta_type = meta_OPUS_PPP;
|
||||
vgmstream->coding_type = data->segments[0]->coding_type;
|
||||
vgmstream->layout_type = layout_segmented;
|
||||
|
||||
vgmstream->layout_data = data;
|
||||
data->loop_segment = loop_start_segment;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
|
@ -180,10 +180,7 @@ VGMSTREAM * init_vgmstream_txtp(STREAMFILE *streamFile) {
|
||||
vgmstream->meta_type = meta_TXTP;
|
||||
vgmstream->coding_type = data_s->segments[0]->coding_type;
|
||||
vgmstream->layout_type = layout_segmented;
|
||||
|
||||
vgmstream->layout_data = data_s;
|
||||
if (loop_flag)
|
||||
data_s->loop_segment = txtp->loop_start_segment-1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -207,10 +207,7 @@ VGMSTREAM * init_vgmstream_wave_segmented(STREAMFILE *streamFile) {
|
||||
/* .wave can mix codecs, usually first segment is a small ADPCM section) */
|
||||
vgmstream->coding_type = (segment_count == 1 ? data->segments[0]->coding_type : data->segments[1]->coding_type);
|
||||
vgmstream->layout_type = layout_segmented;
|
||||
|
||||
vgmstream->layout_data = data;
|
||||
if (loop_flag)
|
||||
data->loop_segment = (loop_start_segment);
|
||||
|
||||
return vgmstream;
|
||||
|
||||
|
@ -1057,7 +1057,6 @@ typedef struct {
|
||||
int segment_count;
|
||||
VGMSTREAM **segments;
|
||||
int current_segment;
|
||||
int loop_segment;
|
||||
} segmented_layout_data;
|
||||
|
||||
/* for files made of "horizontal" layers, one per group of channels (using a complete sub-VGMSTREAM) */
|
||||
|
Loading…
Reference in New Issue
Block a user