#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "media/formats/webm/webm_parser.h"
#include <stddef.h>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <limits>
#include "base/check_op.h"
#include "base/logging.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "media/formats/webm/webm_constants.h"
namespace media {
enum ElementType { … };
struct ElementIdInfo { … };
struct ListElementInfo { … };
static const ElementIdInfo kEBMLHeaderIds[] = …;
static const ElementIdInfo kSegmentIds[] = …;
static const ElementIdInfo kSeekHeadIds[] = …;
static const ElementIdInfo kSeekIds[] = …;
static const ElementIdInfo kInfoIds[] = …;
static const ElementIdInfo kChapterTranslateIds[] = …;
static const ElementIdInfo kClusterIds[] = …;
static const ElementIdInfo kSilentTracksIds[] = …;
static const ElementIdInfo kBlockGroupIds[] = …;
static const ElementIdInfo kBlockAdditionsIds[] = …;
static const ElementIdInfo kBlockMoreIds[] = …;
static const ElementIdInfo kSlicesIds[] = …;
static const ElementIdInfo kTimeSliceIds[] = …;
static const ElementIdInfo kTracksIds[] = …;
static const ElementIdInfo kTrackEntryIds[] = …;
static const ElementIdInfo kTrackTranslateIds[] = …;
static const ElementIdInfo kVideoIds[] = …;
static const ElementIdInfo kColourIds[] = …;
static const ElementIdInfo kColorVolumeMetadataIds[] = …;
static const ElementIdInfo kProjectionIds[]{ … };
static const ElementIdInfo kAudioIds[] = …;
static const ElementIdInfo kTrackOperationIds[] = …;
static const ElementIdInfo kTrackCombinePlanesIds[] = …;
static const ElementIdInfo kTrackPlaneIds[] = …;
static const ElementIdInfo kJoinBlocksIds[] = …;
static const ElementIdInfo kContentEncodingsIds[] = …;
static const ElementIdInfo kContentEncodingIds[] = …;
static const ElementIdInfo kContentCompressionIds[] = …;
static const ElementIdInfo kContentEncryptionIds[] = …;
static const ElementIdInfo kContentEncAESSettingsIds[] = …;
static const ElementIdInfo kCuesIds[] = …;
static const ElementIdInfo kCuePointIds[] = …;
static const ElementIdInfo kCueTrackPositionsIds[] = …;
static const ElementIdInfo kCueReferenceIds[] = …;
static const ElementIdInfo kAttachmentsIds[] = …;
static const ElementIdInfo kAttachedFileIds[] = …;
static const ElementIdInfo kChaptersIds[] = …;
static const ElementIdInfo kEditionEntryIds[] = …;
static const ElementIdInfo kChapterAtomIds[] = …;
static const ElementIdInfo kChapterTrackIds[] = …;
static const ElementIdInfo kChapterDisplayIds[] = …;
static const ElementIdInfo kChapProcessIds[] = …;
static const ElementIdInfo kChapProcessCommandIds[] = …;
static const ElementIdInfo kTagsIds[] = …;
static const ElementIdInfo kTagIds[] = …;
static const ElementIdInfo kTargetsIds[] = …;
static const ElementIdInfo kSimpleTagIds[] = …;
#define LIST_ELEMENT_INFO(id, level, id_info) …
static const ListElementInfo kListElementInfo[] = …;
static int ParseWebMElementHeaderField(const uint8_t* buf,
int size,
int max_bytes,
bool mask_first_byte,
int64_t* num) { … }
int WebMParseElementHeader(const uint8_t* buf,
int size,
int* id,
int64_t* element_size) { … }
static ElementType FindIdType(int id,
const ElementIdInfo* id_info,
int id_info_count) { … }
static const ListElementInfo* FindListInfo(int id) { … }
static int FindListLevel(int id) { … }
static int ParseUInt(const uint8_t* buf,
int size,
int id,
WebMParserClient* client) { … }
static int ParseFloat(const uint8_t* buf,
int size,
int id,
WebMParserClient* client) { … }
static int ParseBinary(const uint8_t* buf,
int size,
int id,
WebMParserClient* client) { … }
static int ParseString(const uint8_t* buf,
int size,
int id,
WebMParserClient* client) { … }
static int ParseNonListElement(ElementType type,
int id,
int64_t element_size,
const uint8_t* buf,
int size,
WebMParserClient* client) { … }
WebMParserClient::WebMParserClient() = default;
WebMParserClient::~WebMParserClient() = default;
WebMParserClient* WebMParserClient::OnListStart(int id) { … }
bool WebMParserClient::OnListEnd(int id) { … }
bool WebMParserClient::OnUInt(int id, int64_t val) { … }
bool WebMParserClient::OnFloat(int id, double val) { … }
bool WebMParserClient::OnBinary(int id, const uint8_t* data, int size) { … }
bool WebMParserClient::OnString(int id, const std::string& str) { … }
WebMListParser::WebMListParser(int id, WebMParserClient* client)
: … { … }
WebMListParser::~WebMListParser() = default;
void WebMListParser::Reset() { … }
int WebMListParser::Parse(const uint8_t* buf, int size) { … }
bool WebMListParser::IsParsingComplete() const { … }
void WebMListParser::ChangeState(State new_state) { … }
int WebMListParser::ParseListElement(int header_size,
int id,
int64_t element_size,
const uint8_t* data,
int size) { … }
bool WebMListParser::OnListStart(int id, int64_t size) { … }
bool WebMListParser::OnListEnd() { … }
bool WebMListParser::IsSiblingOrAncestor(int id_a, int id_b) const { … }
}