use 64-bit math for MxSt stuff that can overflow 32-bit

(namely conversion from samples to milliseconds by
samples * 1000 / sample_rate)


git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@701 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
halleyscometsw 2009-09-18 05:28:24 +00:00
parent 2ade0dfb62
commit de6446c0c3

View File

@ -14,7 +14,7 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
long sample_count; long sample_count;
int i; int i;
off_t file_size; off_t file_size;
off_t chunk_list_size; off_t chunk_list_size=-1;
off_t start_offset; off_t start_offset;
/* check extension, case insensitive */ /* check extension, case insensitive */
@ -77,7 +77,7 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
if (chunk_offset > file_size) goto fail; if (chunk_offset > file_size) goto fail;
} }
if (MxDa == -1 || MxCh == -1) goto fail; if (MxDa == -1 || MxCh == -1 || chunk_list_size == -1) goto fail;
/* parse MxDa */ /* parse MxDa */
{ {
@ -130,7 +130,7 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
split_frames_seen ++; split_frames_seen ++;
if (split_frames_seen == 1) if (split_frames_seen == 1)
{ {
if (read_32bitLE(MxCh_offset+8+6,streamFile)!=(samples*1000l+sample_rate-1)/sample_rate) if (read_32bitLE(MxCh_offset+8+6,streamFile)!=(samples*UINT64_C(1000)+sample_rate-1)/sample_rate)
goto fail; goto fail;
} }
else if (split_frames_seen == 2) else if (split_frames_seen == 2)
@ -148,7 +148,7 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
{ {
goto fail; goto fail;
} }
if (read_32bitLE(MxCh_offset+8+6,streamFile)!=(samples*1000l+sample_rate-1)/sample_rate) if (read_32bitLE(MxCh_offset+8+6,streamFile)!=(samples*UINT64_C(1000)+sample_rate-1)/sample_rate)
goto fail; goto fail;
if ( read_32bitLE(MxCh_offset+8+0xa,streamFile)!= if ( read_32bitLE(MxCh_offset+8+0xa,streamFile)!=