vpxpes_parser: Read and store PTS when present.

Change-Id: I11acb45b26eeea6f5945c04bb447937ba2ffca9f
This commit is contained in:
Tom Finegan 2016-08-04 13:54:09 -07:00
parent 6cf0a0f400
commit 1b24a792e3
3 changed files with 13 additions and 0 deletions

View File

@ -83,4 +83,10 @@ bool WriteUint8(std::uint8_t val, std::FILE* fileptr) {
return (std::fputc(val, fileptr) == val);
}
std::uint16_t ReadUint16(const std::uint8_t* buf) {
if (buf == nullptr)
return 0;
return ((buf[0] << 8) | buf[1]);
}
} // namespace libwebm

View File

@ -54,6 +54,10 @@ bool ParseVP9SuperFrameIndex(const std::uint8_t* frame,
// Writes |val| to |fileptr| and returns true upon success.
bool WriteUint8(std::uint8_t val, std::FILE* fileptr);
// Reads 2 bytes from |buf| and returns them as a uint16_t. Returns 0 when |buf|
// is a nullptr.
std::uint16_t ReadUint16(const std::uint8_t* buf);
} // namespace libwebm
#endif // LIBWEBM_COMMON_LIBWEBM_UTIL_H_

View File

@ -189,6 +189,9 @@ bool VpxPesParser::ParsePesOptionalHeader(PesOptionalHeader* header) {
return false;
}
header->pts = (pes_file_data_[offset] & 0xe) << 29 |
((ReadUint16(&pes_file_data_[offset + 1]) & ~1) << 14) |
(ReadUint16(&pes_file_data_[offset + 3]) >> 1);
offset += 5;
bytes_left -= 5;
}