Commit 667ab1c7 authored by Vignesh Venkatasubramanian's avatar Vignesh Venkatasubramanian Committed by Gerrit Code Review
Browse files

Merge "third_party/libwebm: Pull from upstream"

parents 5ed83c32 91955369
URL: https://chromium.googlesource.com/webm/libwebm
Version: 630a0e3c338e1b32bddf513a2dad807908d2976a
Version: a7118d8ec564e9db841da1eb01f547f3229f240a
License: BSD
License File: LICENSE.txt
......
......@@ -292,11 +292,11 @@ bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value) {
if (WriteID(writer, type))
return false;
const int32 length = strlen(value);
const uint64 length = strlen(value);
if (WriteUInt(writer, length))
return false;
if (writer->Write(value, length))
if (writer->Write(value, static_cast<const uint32>(length)))
return false;
return true;
......
......@@ -14,13 +14,20 @@ namespace mkvparser
{
MkvReader::MkvReader() :
m_file(NULL)
{
m_file(NULL),
reader_owns_file_(true) {
}
MkvReader::~MkvReader()
{
MkvReader::MkvReader(FILE* fp) :
m_file(fp),
reader_owns_file_(false) {
GetFileSize();
}
MkvReader::~MkvReader() {
if (reader_owns_file_)
Close();
m_file = NULL;
}
int MkvReader::Open(const char* fileName)
......@@ -42,12 +49,17 @@ int MkvReader::Open(const char* fileName)
if (m_file == NULL)
return -1;
#endif
return !GetFileSize();
}
bool MkvReader::GetFileSize() {
if (m_file == NULL)
return false;
#ifdef _MSC_VER
int status = _fseeki64(m_file, 0L, SEEK_END);
if (status)
return -1; //error
return false; //error
m_length = _ftelli64(m_file);
#else
......@@ -56,16 +68,19 @@ int MkvReader::Open(const char* fileName)
#endif
assert(m_length >= 0);
if (m_length < 0)
return false;
#ifdef _MSC_VER
status = _fseeki64(m_file, 0L, SEEK_SET);
if (status)
return -1; //error
return false; //error
#else
fseek(m_file, 0L, SEEK_SET);
#endif
return 0;
return true;
}
void MkvReader::Close()
......
......@@ -21,6 +21,7 @@ class MkvReader : public IMkvReader
MkvReader& operator=(const MkvReader&);
public:
MkvReader();
MkvReader(FILE* fp);
virtual ~MkvReader();
int Open(const char*);
......@@ -29,8 +30,15 @@ public:
virtual int Read(long long position, long length, unsigned char* buffer);
virtual int Length(long long* total, long long* available);
private:
// Determines the size of the file. This is called either by the constructor
// or by the Open function depending on file ownership. Returns true on
// success.
bool GetFileSize();
long long m_length;
FILE* m_file;
bool reader_owns_file_;
};
} //end namespace mkvparser
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment