mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 16:30:54 +01:00
commit
5cc8ae303c
@ -19,7 +19,7 @@
|
|||||||
* read num_bits (up to 25) from a bit offset.
|
* read num_bits (up to 25) from a bit offset.
|
||||||
* 25 since we read a 32 bit int, and need to adjust up to 7 bits from the byte-rounded fseek (32-7=25)
|
* 25 since we read a 32 bit int, and need to adjust up to 7 bits from the byte-rounded fseek (32-7=25)
|
||||||
*/
|
*/
|
||||||
static uint32_t read_bitsBE_b(off_t bit_offset, int num_bits, STREAMFILE *streamFile) {
|
static uint32_t read_bitsBE_b(int64_t bit_offset, int num_bits, STREAMFILE *streamFile) {
|
||||||
uint32_t num, mask;
|
uint32_t num, mask;
|
||||||
if (num_bits > 25) return -1; //???
|
if (num_bits > 25) return -1; //???
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ fail:
|
|||||||
/* XMA PARSING */
|
/* XMA PARSING */
|
||||||
/* ******************************************** */
|
/* ******************************************** */
|
||||||
|
|
||||||
static void ms_audio_parse_header(STREAMFILE *streamFile, int xma_version, off_t offset_b, int bits_frame_size, size_t *first_frame_b, size_t *packet_skip_count, size_t *header_size_b) {
|
static void ms_audio_parse_header(STREAMFILE *streamFile, int xma_version, int64_t offset_b, int bits_frame_size, size_t *first_frame_b, size_t *packet_skip_count, size_t *header_size_b) {
|
||||||
if (xma_version == 1) { /* XMA1 */
|
if (xma_version == 1) { /* XMA1 */
|
||||||
//packet_sequence = read_bitsBE_b(offset_b+0, 4, streamFile); /* numbered from 0 to N */
|
//packet_sequence = read_bitsBE_b(offset_b+0, 4, streamFile); /* numbered from 0 to N */
|
||||||
//unknown = read_bitsBE_b(offset_b+4, 2, streamFile); /* packet_metadata? (always 2) */
|
//unknown = read_bitsBE_b(offset_b+4, 2, streamFile); /* packet_metadata? (always 2) */
|
||||||
@ -431,11 +431,11 @@ static void ms_audio_parse_header(STREAMFILE *streamFile, int xma_version, off_t
|
|||||||
/* full packet skip, no new frames start in this packet (prev frames can end here)
|
/* full packet skip, no new frames start in this packet (prev frames can end here)
|
||||||
* standardized to some value */
|
* standardized to some value */
|
||||||
if (*packet_skip_count == 0x7FF) { /* XMA1, 11b */
|
if (*packet_skip_count == 0x7FF) { /* XMA1, 11b */
|
||||||
VGM_LOG("MS_SAMPLES: XMA1 full packet_skip at 0x%x\n", (uint32_t)offset_b/8);
|
VGM_LOG("MS_SAMPLES: XMA1 full packet_skip at %"PRIx64"\n", offset_b/8);
|
||||||
*packet_skip_count = 0x800;
|
*packet_skip_count = 0x800;
|
||||||
}
|
}
|
||||||
else if (*packet_skip_count == 0xFF) { /* XMA2, 8b*/
|
else if (*packet_skip_count == 0xFF) { /* XMA2, 8b*/
|
||||||
VGM_LOG("MS_SAMPLES: XMA2 full packet_skip at 0x%x\n", (uint32_t)offset_b/8);
|
VGM_LOG("MS_SAMPLES: XMA2 full packet_skip at %"PRIx64"\n", offset_b/8);
|
||||||
*packet_skip_count = 0x800;
|
*packet_skip_count = 0x800;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -458,7 +458,7 @@ static void ms_audio_get_samples(ms_sample_data * msd, STREAMFILE *streamFile, i
|
|||||||
int frames = 0, samples = 0, loop_start_frame = 0, loop_end_frame = 0;
|
int frames = 0, samples = 0, loop_start_frame = 0, loop_end_frame = 0;
|
||||||
|
|
||||||
size_t first_frame_b, packet_skip_count, header_size_b, frame_size_b;
|
size_t first_frame_b, packet_skip_count, header_size_b, frame_size_b;
|
||||||
off_t offset_b, packet_offset_b, frame_offset_b;
|
int64_t offset_b, packet_offset_b, frame_offset_b;
|
||||||
|
|
||||||
size_t packet_size = bytes_per_packet;
|
size_t packet_size = bytes_per_packet;
|
||||||
size_t packet_size_b = packet_size * 8;
|
size_t packet_size_b = packet_size * 8;
|
||||||
@ -535,11 +535,11 @@ static void ms_audio_get_skips(STREAMFILE *streamFile, int xma_version, off_t da
|
|||||||
int start_skip = 0, end_skip = 0;
|
int start_skip = 0, end_skip = 0;
|
||||||
|
|
||||||
size_t first_frame_b, packet_skip_count, header_size_b, frame_size_b;
|
size_t first_frame_b, packet_skip_count, header_size_b, frame_size_b;
|
||||||
off_t offset_b, packet_offset_b, frame_offset_b;
|
int64_t offset_b, packet_offset_b, frame_offset_b;
|
||||||
|
|
||||||
size_t packet_size = bytes_per_packet;
|
size_t packet_size = bytes_per_packet;
|
||||||
size_t packet_size_b = packet_size * 8;
|
size_t packet_size_b = packet_size * 8;
|
||||||
off_t offset = data_offset;
|
int64_t offset = data_offset;
|
||||||
|
|
||||||
/* read packet */
|
/* read packet */
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,8 @@ static size_t read_stdio(STDIO_STREAMFILE *streamfile, uint8_t *dst, off_t offse
|
|||||||
/* Workaround a bug that appears when compiling with MSVC (later versions).
|
/* Workaround a bug that appears when compiling with MSVC (later versions).
|
||||||
* This bug is deterministic and seemingly appears randomly after seeking.
|
* This bug is deterministic and seemingly appears randomly after seeking.
|
||||||
* It results in fread returning data from the wrong area of the file.
|
* It results in fread returning data from the wrong area of the file.
|
||||||
* HPS is one format that is almost always affected by this. */
|
* HPS is one format that is almost always affected by this.
|
||||||
|
* May be related/same as open_stdio's bug when using dup() */
|
||||||
fseek(streamfile->infile, ftell(streamfile->infile), SEEK_SET);
|
fseek(streamfile->infile, ftell(streamfile->infile), SEEK_SET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -132,7 +133,12 @@ static STREAMFILE* open_stdio(STDIO_STREAMFILE *streamfile, const char * const f
|
|||||||
if (!filename)
|
if (!filename)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if !defined (__ANDROID__)
|
#if !defined (__ANDROID__) && !defined (_MSC_VER)
|
||||||
|
/* when enabling this for MSVC it'll seemingly work, but there are issues possibly related to underlying
|
||||||
|
* IO buffers when using dup(), noticeable by re-opening the same streamfile with small buffer sizes
|
||||||
|
* (reads garbage). fseek bug in line 81 may be related/same thing and may be removed.
|
||||||
|
* this reportedly this causes issues in Android too */
|
||||||
|
|
||||||
/* if same name, duplicate the file descriptor we already have open */
|
/* if same name, duplicate the file descriptor we already have open */
|
||||||
if (streamfile->infile && !strcmp(streamfile->name,filename)) {
|
if (streamfile->infile && !strcmp(streamfile->name,filename)) {
|
||||||
int new_fd;
|
int new_fd;
|
||||||
|
Loading…
Reference in New Issue
Block a user