Fix ParseElementHeader to support 0 payload elements

Cherry-pick'ing Change 5c83bbec9a5f6f00a349674ddad85b753d2ea219
from upstream. This fixes regression in some edge cases for mkv
playback.

BUG=26499283

Change-Id: I88de03219a3d941b6b2f251d384e29c36bdd4d9b

long long ReadUInt(IMkvReader* pReader, long long pos, long& len) {
 if (!pReader || pos < 0)
 return E_FILE_FORMAT_INVALID;

  len = 1;
 unsigned char b;
 int status = pReader->Read(pos, 1, &b);

 if (status < 0) // error or underflow
 return status;

 if (status > 0) // interpreted as "underflow"
 return E_BUFFER_NOT_FULL;

 if (b == 0) // we can't handle u-int values larger than 8 bytes
 return E_FILE_FORMAT_INVALID;

 unsigned char m = 0x80;

 while (!(b & m)) {
    m >>= 1;
 ++len;
 }

 long long result = b & (~m);
 ++pos;

 for (int i = 1; i < len; ++i) {
    status = pReader->Read(pos, 1, &b);

 if (status < 0) {
      len = 1;
 return status;
 }

 if (status > 0) {
      len = 1;
 return E_BUFFER_NOT_FULL;
 }

    result <<= 8;
    result |= b;

 ++pos;
 }

 return result;
}

long long ReadUInt(IMkvReader* pReader, long long pos, long& len) {
 if (!pReader || pos < 0)
 return E_FILE_FORMAT_INVALID;

  len = 1;
 unsigned char b;
 int status = pReader->Read(pos, 1, &b);

 if (status < 0) // error or underflow
 return status;

 if (status > 0) // interpreted as "underflow"
 return E_BUFFER_NOT_FULL;

 if (b == 0) // we can't handle u-int values larger than 8 bytes
 return E_FILE_FORMAT_INVALID;

 unsigned char m = 0x80;

 while (!(b & m)) {
    m >>= 1;
 ++len;
 }

 long long result = b & (~m);
 ++pos;

 for (int i = 1; i < len; ++i) {
    status = pReader->Read(pos, 1, &b);

 if (status < 0) {
      len = 1;
 return status;
 }

 if (status > 0) {
      len = 1;
 return E_BUFFER_NOT_FULL;
 }

    result <<= 8;
    result |= b;

 ++pos;
 }

 return result;
}
