forked from mia/Aegisub
Fixed loading of mkv files over 2 GB... hopefully, without destroying the posix ports.
Originally committed to SVN as r1652.
This commit is contained in:
parent
e9c894a2e0
commit
c57ab33467
1 changed files with 14 additions and 4 deletions
|
@ -484,16 +484,26 @@ void MatroskaWrapper::GetSubtitles(AssFile *target) {
|
||||||
|
|
||||||
////////////////////////////// LOTS OF HAALI C CODE DOWN HERE ///////////////////////////////////////
|
////////////////////////////// LOTS OF HAALI C CODE DOWN HERE ///////////////////////////////////////
|
||||||
|
|
||||||
|
#ifdef __VISUALC__
|
||||||
|
#define std_fread fread
|
||||||
|
#define std_fseek _fseeki64
|
||||||
|
#define std_ftell _ftelli64
|
||||||
|
#else
|
||||||
|
#define std_fread fread
|
||||||
|
#define std_fseek fseeko64
|
||||||
|
#define std_ftell ftello64
|
||||||
|
#endif
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// STDIO class
|
// STDIO class
|
||||||
int StdIoRead(InputStream *_st, ulonglong pos, void *buffer, int count) {
|
int StdIoRead(InputStream *_st, ulonglong pos, void *buffer, int count) {
|
||||||
MkvStdIO *st = (MkvStdIO *) _st;
|
MkvStdIO *st = (MkvStdIO *) _st;
|
||||||
size_t rd;
|
size_t rd;
|
||||||
if (fseek(st->fp, pos, SEEK_SET)) {
|
if (std_fseek(st->fp, pos, SEEK_SET)) {
|
||||||
st->error = errno;
|
st->error = errno;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
rd = fread(buffer, 1, count, st->fp);
|
rd = std_fread(buffer, 1, count, st->fp);
|
||||||
if (rd == 0) {
|
if (rd == 0) {
|
||||||
if (feof(st->fp))
|
if (feof(st->fp))
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -512,13 +522,13 @@ longlong StdIoScan(InputStream *_st, ulonglong start, unsigned signature) {
|
||||||
unsigned cmp = 0;
|
unsigned cmp = 0;
|
||||||
FILE *fp = st->fp;
|
FILE *fp = st->fp;
|
||||||
|
|
||||||
if (fseek(fp, start, SEEK_SET))
|
if (std_fseek(fp, start, SEEK_SET))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while ((c = getc(fp)) != EOF) {
|
while ((c = getc(fp)) != EOF) {
|
||||||
cmp = ((cmp << 8) | c) & 0xffffffff;
|
cmp = ((cmp << 8) | c) & 0xffffffff;
|
||||||
if (cmp == signature)
|
if (cmp == signature)
|
||||||
return ftell(fp) - 4;
|
return std_ftell(fp) - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Reference in a new issue