webm2pes: Add start code emulation prevention.

- Make start codes reliable for VPx in PES.
- Stop setting the PES size field and stop splitting packets when
  larger than UINT16_MAX (always set 0; rely on start codes to find
  packet boundaries).

Change-Id: I402e91c26562e930f61543ca59223b83cc92be29
This commit is contained in:
Tom Finegan
2016-05-27 14:21:04 -07:00
parent 82903f36fa
commit 4b735452bb
5 changed files with 125 additions and 82 deletions

View File

@@ -20,8 +20,10 @@ namespace libwebm {
class VpxPesParser {
public:
typedef std::vector<std::uint8_t> PesFileData;
typedef std::vector<std::uint8_t> PacketData;
enum ParseState {
kFindStartCode,
kParsePesHeader,
kParsePesOptionalHeader,
kParseBcmvHeader,
@@ -137,10 +139,18 @@ class VpxPesParser {
// header.
bool ParseBcmvHeader(BcmvHeader* header);
// Returns true when a start code is found and sets |offset| to the position
// of the start code relative to |pes_file_data_[read_pos_]|.
// Does not set |offset| value if the end of |pes_file_data_| is reached
// without locating a start code.
// Note: A start code is the byte sequence 0x00 0x00 0x01.
bool FindStartCode(std::size_t origin, std::size_t* offset);
std::size_t pes_file_size_ = 0;
PacketData packet_data_;
PesFileData pes_file_data_;
std::size_t read_pos_ = 0;
ParseState parse_state_ = kParsePesHeader;
ParseState parse_state_ = kFindStartCode;
};
} // namespace libwebm