Don't let the MKV parser crash on certain MKV's for which it cannot determine the filesize by itself. (Adaption of Myrsloik's similar fix for FFMS2.)

Originally committed to SVN as r2891.
This commit is contained in:
Karl Blomster 2009-05-02 19:40:55 +00:00
parent 94cf1e4c22
commit 04e4249219
1 changed files with 11 additions and 0 deletions

View File

@ -568,6 +568,16 @@ int StdIoProgress(InputStream *_st, ulonglong cur, ulonglong max) {
return 1;
}
longlong StdIoGetFileSize(InputStream *_st) {
MkvStdIO *st = (MkvStdIO *) _st;
longlong epos = 0;
longlong cpos = _ftelli64(st->fp);
_fseeki64(st->fp, 0, SEEK_END);
epos = _ftelli64(st->fp);
_fseeki64(st->fp, cpos, SEEK_SET);
return epos;
}
MkvStdIO::MkvStdIO(wxString filename) {
read = StdIoRead;
scan = StdIoScan;
@ -577,6 +587,7 @@ MkvStdIO::MkvStdIO(wxString filename) {
memrealloc = StdIoRealloc;
memfree = StdIoFree;
progress = StdIoProgress;
getfilesize = StdIoGetFileSize;
wxFileName fname(filename);
fp = fopen(fname.GetShortPath().mb_str(wxConvUTF8),"rb");
if (fp) {