mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 16:08:40 +01:00
blocked: add sample count util
This commit is contained in:
parent
f9ef1f2d89
commit
af2bb05fdb
@ -1,6 +1,7 @@
|
||||
#include "layout.h"
|
||||
#include "../vgmstream.h"
|
||||
#include "../decode.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* Decodes samples for blocked streams.
|
||||
@ -90,7 +91,7 @@ void render_vgmstream_blocked(sample_t* buffer, int32_t sample_count, VGMSTREAM*
|
||||
}
|
||||
|
||||
/* helper functions to parse new block */
|
||||
void block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
void block_update(off_t block_offset, VGMSTREAM* vgmstream) {
|
||||
switch (vgmstream->layout_type) {
|
||||
case layout_blocked_ast:
|
||||
block_update_ast(block_offset,vgmstream);
|
||||
@ -216,3 +217,38 @@ void block_update(off_t block_offset, VGMSTREAM * vgmstream) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void blocked_count_samples(VGMSTREAM* vgmstream, STREAMFILE* sf, off_t offset) {
|
||||
int block_samples;
|
||||
off_t max_offset = get_streamfile_size(sf);
|
||||
|
||||
vgmstream->next_block_offset = offset;
|
||||
do {
|
||||
block_update(vgmstream->next_block_offset, vgmstream);
|
||||
|
||||
if (vgmstream->current_block_samples < 0 || vgmstream->current_block_size == 0xFFFFFFFF)
|
||||
break;
|
||||
|
||||
if (vgmstream->current_block_samples) {
|
||||
block_samples = vgmstream->current_block_samples;
|
||||
}
|
||||
else {
|
||||
switch(vgmstream->coding_type) {
|
||||
case coding_PCM16_int: block_samples = pcm16_bytes_to_samples(vgmstream->current_block_size, 1); break;
|
||||
case coding_PCM8_int:
|
||||
case coding_PCM8_U_int: block_samples = pcm8_bytes_to_samples(vgmstream->current_block_size, 1); break;
|
||||
case coding_XBOX_IMA: block_samples = xbox_ima_bytes_to_samples(vgmstream->current_block_size, 1); break;
|
||||
case coding_NGC_DSP: block_samples = dsp_bytes_to_samples(vgmstream->current_block_size, 1); break;
|
||||
case coding_PSX: block_samples = ps_bytes_to_samples(vgmstream->current_block_size,1); break;
|
||||
default:
|
||||
VGM_LOG("BLOCKED: missing codec\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
vgmstream->num_samples += block_samples;
|
||||
}
|
||||
while (vgmstream->next_block_offset < max_offset);
|
||||
|
||||
block_update(offset, vgmstream); /* reset */
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
/* blocked layouts */
|
||||
void render_vgmstream_blocked(sample_t* buffer, int32_t sample_count, VGMSTREAM* vgmstream);
|
||||
void block_update(off_t block_offset, VGMSTREAM* vgmstream);
|
||||
void blocked_count_samples(VGMSTREAM* vgmstream, STREAMFILE* sf, off_t offset);
|
||||
|
||||
void block_update_ast(off_t block_ofset, VGMSTREAM* vgmstream);
|
||||
void block_update_mxch(off_t block_ofset, VGMSTREAM* vgmstream);
|
||||
|
Loading…
x
Reference in New Issue
Block a user