chromium/third_party/libaom/source/libaom/third_party/libwebm/mkvparser/mkvparser.cc

// Copyright (c) 2012 The WebM project authors. All Rights Reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree. An additional intellectual property rights grant can be found
// in the file PATENTS.  All contributing project authors may
// be found in the AUTHORS file in the root of the source tree.
#include "mkvparser/mkvparser.h"

#if defined(_MSC_VER) && _MSC_VER < 1800
#include <float.h>  // _isnan() / _finite()
#define MSC_COMPAT
#endif

#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <memory>
#include <new>

#include "common/webmids.h"

namespace mkvparser {
const long long kStringElementSizeLimit =;
const float MasteringMetadata::kValueNotPresent =;
const long long Colour::kValueNotPresent =;
const float Projection::kValueNotPresent =;

#ifdef MSC_COMPAT
inline bool isnan(double val) { return !!_isnan(val); }
inline bool isinf(double val) { return !_finite(val); }
#else
inline bool isnan(double val) {}
inline bool isinf(double val) {}
#endif  // MSC_COMPAT

template <typename Type>
Type* SafeArrayAlloc(unsigned long long num_elements,
                     unsigned long long element_size) {}

void GetVersion(int& major, int& minor, int& build, int& revision) {}

long long ReadUInt(IMkvReader* pReader, long long pos, long& len) {}

// Reads an EBML ID and returns it.
// An ID must at least 1 byte long, cannot exceed 4, and its value must be
// greater than 0.
// See known EBML values and EBMLMaxIDLength:
// http://www.matroska.org/technical/specs/index.html
// Returns the ID, or a value less than 0 to report an error while reading the
// ID.
long long ReadID(IMkvReader* pReader, long long pos, long& len) {}

long long GetUIntLength(IMkvReader* pReader, long long pos, long& len) {}

// TODO(vigneshv): This function assumes that unsigned values never have their
// high bit set.
long long UnserializeUInt(IMkvReader* pReader, long long pos, long long size) {}

long UnserializeFloat(IMkvReader* pReader, long long pos, long long size_,
                      double& result) {}

long UnserializeInt(IMkvReader* pReader, long long pos, long long size,
                    long long& result_ref) {}

long UnserializeString(IMkvReader* pReader, long long pos, long long size,
                       char*& str) {}

long ParseElementHeader(IMkvReader* pReader, long long& pos, long long stop,
                        long long& id, long long& size) {}

bool Match(IMkvReader* pReader, long long& pos, unsigned long expected_id,
           long long& val) {}

bool Match(IMkvReader* pReader, long long& pos, unsigned long expected_id,
           unsigned char*& buf, size_t& buflen) {}

EBMLHeader::EBMLHeader() :{}

EBMLHeader::~EBMLHeader() {}

void EBMLHeader::Init() {}

long long EBMLHeader::Parse(IMkvReader* pReader, long long& pos) {}

Segment::Segment(IMkvReader* pReader, long long elem_start,
                 // long long elem_size,
                 long long start, long long size)
    :{}

Segment::~Segment() {}

long long Segment::CreateInstance(IMkvReader* pReader, long long pos,
                                  Segment*& pSegment) {}

long long Segment::ParseHeaders() {}

long Segment::LoadCluster(long long& pos, long& len) {}

long Segment::DoLoadCluster(long long& pos, long& len) {}

long Segment::DoLoadClusterUnknownSize(long long& pos, long& len) {}

bool Segment::AppendCluster(Cluster* pCluster) {}

bool Segment::PreloadCluster(Cluster* pCluster, ptrdiff_t idx) {}

long Segment::Load() {}

SeekHead::Entry::Entry() :{}

SeekHead::SeekHead(Segment* pSegment, long long start, long long size_,
                   long long element_start, long long element_size)
    :{}

SeekHead::~SeekHead() {}

long SeekHead::Parse() {}

int SeekHead::GetCount() const {}

const SeekHead::Entry* SeekHead::GetEntry(int idx) const {}

int SeekHead::GetVoidElementCount() const {}

const SeekHead::VoidElement* SeekHead::GetVoidElement(int idx) const {}

long Segment::ParseCues(long long off, long long& pos, long& len) {}

bool SeekHead::ParseEntry(IMkvReader* pReader, long long start, long long size_,
                          Entry* pEntry) {}

Cues::Cues(Segment* pSegment, long long start_, long long size_,
           long long element_start, long long element_size)
    :{}

Cues::~Cues() {}

long Cues::GetCount() const {}

bool Cues::DoneParsing() const {}

bool Cues::Init() const {}

bool Cues::PreloadCuePoint(long& cue_points_size, long long pos) const {}

bool Cues::LoadCuePoint() const {}

bool Cues::Find(long long time_ns, const Track* pTrack, const CuePoint*& pCP,
                const CuePoint::TrackPosition*& pTP) const {}

const CuePoint* Cues::GetFirst() const {}

const CuePoint* Cues::GetLast() const {}

const CuePoint* Cues::GetNext(const CuePoint* pCurr) const {}

const BlockEntry* Cues::GetBlock(const CuePoint* pCP,
                                 const CuePoint::TrackPosition* pTP) const {}

const BlockEntry* Segment::GetBlock(const CuePoint& cp,
                                    const CuePoint::TrackPosition& tp) {}

const Cluster* Segment::FindOrPreloadCluster(long long requested_pos) {}

CuePoint::CuePoint(long idx, long long pos)
    :{}

CuePoint::~CuePoint() {}

bool CuePoint::Load(IMkvReader* pReader) {}

bool CuePoint::TrackPosition::Parse(IMkvReader* pReader, long long start_,
                                    long long size_) {}

const CuePoint::TrackPosition* CuePoint::Find(const Track* pTrack) const {}

long long CuePoint::GetTimeCode() const {}

long long CuePoint::GetTime(const Segment* pSegment) const {}

bool Segment::DoneParsing() const {}

const Cluster* Segment::GetFirst() const {}

const Cluster* Segment::GetLast() const {}

unsigned long Segment::GetCount() const {}

const Cluster* Segment::GetNext(const Cluster* pCurr) {}

long Segment::ParseNext(const Cluster* pCurr, const Cluster*& pResult,
                        long long& pos, long& len) {}

long Segment::DoParseNext(const Cluster*& pResult, long long& pos, long& len) {}

const Cluster* Segment::FindCluster(long long time_ns) const {}

const Tracks* Segment::GetTracks() const {}
const SegmentInfo* Segment::GetInfo() const {}
const Cues* Segment::GetCues() const {}
const Chapters* Segment::GetChapters() const {}
const Tags* Segment::GetTags() const {}
const SeekHead* Segment::GetSeekHead() const {}

long long Segment::GetDuration() const {}

Chapters::Chapters(Segment* pSegment, long long payload_start,
                   long long payload_size, long long element_start,
                   long long element_size)
    :{}

Chapters::~Chapters() {}

long Chapters::Parse() {}

int Chapters::GetEditionCount() const {}

const Chapters::Edition* Chapters::GetEdition(int idx) const {}

bool Chapters::ExpandEditionsArray() {}

long Chapters::ParseEdition(long long pos, long long size) {}

Chapters::Edition::Edition() {}

Chapters::Edition::~Edition() {}

int Chapters::Edition::GetAtomCount() const {}

const Chapters::Atom* Chapters::Edition::GetAtom(int index) const {}

void Chapters::Edition::Init() {}

void Chapters::Edition::ShallowCopy(Edition& rhs) const {}

void Chapters::Edition::Clear() {}

long Chapters::Edition::Parse(IMkvReader* pReader, long long pos,
                              long long size) {}

long Chapters::Edition::ParseAtom(IMkvReader* pReader, long long pos,
                                  long long size) {}

bool Chapters::Edition::ExpandAtomsArray() {}

Chapters::Atom::Atom() {}

Chapters::Atom::~Atom() {}

unsigned long long Chapters::Atom::GetUID() const {}

const char* Chapters::Atom::GetStringUID() const {}

long long Chapters::Atom::GetStartTimecode() const {}

long long Chapters::Atom::GetStopTimecode() const {}

long long Chapters::Atom::GetStartTime(const Chapters* pChapters) const {}

long long Chapters::Atom::GetStopTime(const Chapters* pChapters) const {}

int Chapters::Atom::GetDisplayCount() const {}

const Chapters::Display* Chapters::Atom::GetDisplay(int index) const {}

void Chapters::Atom::Init() {}

void Chapters::Atom::ShallowCopy(Atom& rhs) const {}

void Chapters::Atom::Clear() {}

long Chapters::Atom::Parse(IMkvReader* pReader, long long pos, long long size) {}

long long Chapters::Atom::GetTime(const Chapters* pChapters,
                                  long long timecode) {}

long Chapters::Atom::ParseDisplay(IMkvReader* pReader, long long pos,
                                  long long size) {}

bool Chapters::Atom::ExpandDisplaysArray() {}

Chapters::Display::Display() {}

Chapters::Display::~Display() {}

const char* Chapters::Display::GetString() const {}

const char* Chapters::Display::GetLanguage() const {}

const char* Chapters::Display::GetCountry() const {}

void Chapters::Display::Init() {}

void Chapters::Display::ShallowCopy(Display& rhs) const {}

void Chapters::Display::Clear() {}

long Chapters::Display::Parse(IMkvReader* pReader, long long pos,
                              long long size) {}

Tags::Tags(Segment* pSegment, long long payload_start, long long payload_size,
           long long element_start, long long element_size)
    :{}

Tags::~Tags() {}

long Tags::Parse() {}

int Tags::GetTagCount() const {}

const Tags::Tag* Tags::GetTag(int idx) const {}

bool Tags::ExpandTagsArray() {}

long Tags::ParseTag(long long pos, long long size) {}

Tags::Tag::Tag() {}

Tags::Tag::~Tag() {}

int Tags::Tag::GetSimpleTagCount() const {}

const Tags::SimpleTag* Tags::Tag::GetSimpleTag(int index) const {}

void Tags::Tag::Init() {}

void Tags::Tag::ShallowCopy(Tag& rhs) const {}

void Tags::Tag::Clear() {}

long Tags::Tag::Parse(IMkvReader* pReader, long long pos, long long size) {}

long Tags::Tag::ParseSimpleTag(IMkvReader* pReader, long long pos,
                               long long size) {}

bool Tags::Tag::ExpandSimpleTagsArray() {}

Tags::SimpleTag::SimpleTag() {}

Tags::SimpleTag::~SimpleTag() {}

const char* Tags::SimpleTag::GetTagName() const {}

const char* Tags::SimpleTag::GetTagString() const {}

void Tags::SimpleTag::Init() {}

void Tags::SimpleTag::ShallowCopy(SimpleTag& rhs) const {}

void Tags::SimpleTag::Clear() {}

long Tags::SimpleTag::Parse(IMkvReader* pReader, long long pos,
                            long long size) {}

SegmentInfo::SegmentInfo(Segment* pSegment, long long start, long long size_,
                         long long element_start, long long element_size)
    :{}

SegmentInfo::~SegmentInfo() {}

long SegmentInfo::Parse() {}

long long SegmentInfo::GetTimeCodeScale() const {}

long long SegmentInfo::GetDuration() const {}

const char* SegmentInfo::GetMuxingAppAsUTF8() const {}

const char* SegmentInfo::GetWritingAppAsUTF8() const {}

const char* SegmentInfo::GetTitleAsUTF8() const {}

///////////////////////////////////////////////////////////////
// ContentEncoding element
ContentEncoding::ContentCompression::ContentCompression()
    :{}

ContentEncoding::ContentCompression::~ContentCompression() {}

ContentEncoding::ContentEncryption::ContentEncryption()
    :{}

ContentEncoding::ContentEncryption::~ContentEncryption() {}

ContentEncoding::ContentEncoding()
    :{}

ContentEncoding::~ContentEncoding() {}

const ContentEncoding::ContentCompression*
ContentEncoding::GetCompressionByIndex(unsigned long idx) const {}

unsigned long ContentEncoding::GetCompressionCount() const {}

const ContentEncoding::ContentEncryption* ContentEncoding::GetEncryptionByIndex(
    unsigned long idx) const {}

unsigned long ContentEncoding::GetEncryptionCount() const {}

long ContentEncoding::ParseContentEncAESSettingsEntry(
    long long start, long long size, IMkvReader* pReader,
    ContentEncAESSettings* aes) {}

long ContentEncoding::ParseContentEncodingEntry(long long start, long long size,
                                                IMkvReader* pReader) {}

long ContentEncoding::ParseCompressionEntry(long long start, long long size,
                                            IMkvReader* pReader,
                                            ContentCompression* compression) {}

long ContentEncoding::ParseEncryptionEntry(long long start, long long size,
                                           IMkvReader* pReader,
                                           ContentEncryption* encryption) {}

Track::Track(Segment* pSegment, long long element_start, long long element_size)
    :{}

Track::~Track() {}

long Track::Create(Segment* pSegment, const Info& info, long long element_start,
                   long long element_size, Track*& pResult) {}

Track::Info::Info()
    :{}

Track::Info::~Info() {}

void Track::Info::Clear() {}

int Track::Info::CopyStr(char* Info::*str, Info& dst_) const {}

int Track::Info::Copy(Info& dst) const {}

const BlockEntry* Track::GetEOS() const {}

long Track::GetType() const {}

long Track::GetNumber() const {}

unsigned long long Track::GetUid() const {}

const char* Track::GetNameAsUTF8() const {}

const char* Track::GetLanguage() const {}

const char* Track::GetCodecNameAsUTF8() const {}

const char* Track::GetCodecId() const {}

const unsigned char* Track::GetCodecPrivate(size_t& size) const {}

bool Track::GetLacing() const {}

unsigned long long Track::GetDefaultDuration() const {}

unsigned long long Track::GetCodecDelay() const {}

unsigned long long Track::GetSeekPreRoll() const {}

long Track::GetFirst(const BlockEntry*& pBlockEntry) const {}

long Track::GetNext(const BlockEntry* pCurrEntry,
                    const BlockEntry*& pNextEntry) const {}

bool Track::VetEntry(const BlockEntry* pBlockEntry) const {}

long Track::Seek(long long time_ns, const BlockEntry*& pResult) const {}

const ContentEncoding* Track::GetContentEncodingByIndex(
    unsigned long idx) const {}

unsigned long Track::GetContentEncodingCount() const {}

long Track::ParseContentEncodingsEntry(long long start, long long size) {}

Track::EOSBlock::EOSBlock() :{}

BlockEntry::Kind Track::EOSBlock::GetKind() const {}

const Block* Track::EOSBlock::GetBlock() const {}

bool PrimaryChromaticity::Parse(IMkvReader* reader, long long read_pos,
                                long long value_size, bool is_x,
                                PrimaryChromaticity** chromaticity) {}

bool MasteringMetadata::Parse(IMkvReader* reader, long long mm_start,
                              long long mm_size, MasteringMetadata** mm) {}

bool Colour::Parse(IMkvReader* reader, long long colour_start,
                   long long colour_size, Colour** colour) {}

bool Projection::Parse(IMkvReader* reader, long long start, long long size,
                       Projection** projection) {}

VideoTrack::VideoTrack(Segment* pSegment, long long element_start,
                       long long element_size)
    :{}

VideoTrack::~VideoTrack() {}

long VideoTrack::Parse(Segment* pSegment, const Info& info,
                       long long element_start, long long element_size,
                       VideoTrack*& pResult) {}

bool VideoTrack::VetEntry(const BlockEntry* pBlockEntry) const {}

long VideoTrack::Seek(long long time_ns, const BlockEntry*& pResult) const {}

Colour* VideoTrack::GetColour() const {}

Projection* VideoTrack::GetProjection() const {}

long long VideoTrack::GetWidth() const {}

long long VideoTrack::GetHeight() const {}

long long VideoTrack::GetDisplayWidth() const {}

long long VideoTrack::GetDisplayHeight() const {}

long long VideoTrack::GetDisplayUnit() const {}

long long VideoTrack::GetStereoMode() const {}

double VideoTrack::GetFrameRate() const {}

AudioTrack::AudioTrack(Segment* pSegment, long long element_start,
                       long long element_size)
    :{}

long AudioTrack::Parse(Segment* pSegment, const Info& info,
                       long long element_start, long long element_size,
                       AudioTrack*& pResult) {}

double AudioTrack::GetSamplingRate() const {}

long long AudioTrack::GetChannels() const {}

long long AudioTrack::GetBitDepth() const {}

Tracks::Tracks(Segment* pSegment, long long start, long long size_,
               long long element_start, long long element_size)
    :{}

long Tracks::Parse() {}

unsigned long Tracks::GetTracksCount() const {}

long Tracks::ParseTrackEntry(long long track_start, long long track_size,
                             long long element_start, long long element_size,
                             Track*& pResult) const {}

Tracks::~Tracks() {}

const Track* Tracks::GetTrackByNumber(long tn) const {}

const Track* Tracks::GetTrackByIndex(unsigned long idx) const {}

long Cluster::Load(long long& pos, long& len) const {}

long Cluster::Parse(long long& pos, long& len) const {}

long Cluster::ParseSimpleBlock(long long block_size, long long& pos,
                               long& len) {}

long Cluster::ParseBlockGroup(long long payload_size, long long& pos,
                              long& len) {}

long Cluster::GetEntry(long index, const mkvparser::BlockEntry*& pEntry) const {}

Cluster* Cluster::Create(Segment* pSegment, long idx, long long off) {}

Cluster::Cluster()
    :{}

Cluster::Cluster(Segment* pSegment, long idx, long long element_start
                 /* long long element_size */)
    :{}

Cluster::~Cluster() {}

bool Cluster::EOS() const {}

long Cluster::GetIndex() const {}

long long Cluster::GetPosition() const {}

long long Cluster::GetElementSize() const {}

long Cluster::HasBlockEntries(
    const Segment* pSegment,
    long long off,  // relative to start of segment payload
    long long& pos, long& len) {}

long long Cluster::GetTimeCode() const {}

long long Cluster::GetTime() const {}

long long Cluster::GetFirstTime() const {}

long long Cluster::GetLastTime() const {}

long Cluster::CreateBlock(long long id,
                          long long pos,  // absolute pos of payload
                          long long size, long long discard_padding) {}

long Cluster::CreateBlockGroup(long long start_offset, long long size,
                               long long discard_padding) {}

long Cluster::CreateSimpleBlock(long long st, long long sz) {}

long Cluster::GetFirst(const BlockEntry*& pFirst) const {}

long Cluster::GetLast(const BlockEntry*& pLast) const {}

long Cluster::GetNext(const BlockEntry* pCurr, const BlockEntry*& pNext) const {}

long Cluster::GetEntryCount() const {}

const BlockEntry* Cluster::GetEntry(const Track* pTrack,
                                    long long time_ns) const {}

const BlockEntry* Cluster::GetEntry(const CuePoint& cp,
                                    const CuePoint::TrackPosition& tp) const {}

BlockEntry::BlockEntry(Cluster* p, long idx) :{}
BlockEntry::~BlockEntry() {}
const Cluster* BlockEntry::GetCluster() const {}
long BlockEntry::GetIndex() const {}

SimpleBlock::SimpleBlock(Cluster* pCluster, long idx, long long start,
                         long long size)
    :{}

long SimpleBlock::Parse() {}
BlockEntry::Kind SimpleBlock::GetKind() const {}
const Block* SimpleBlock::GetBlock() const {}

BlockGroup::BlockGroup(Cluster* pCluster, long idx, long long block_start,
                       long long block_size, long long prev, long long next,
                       long long duration, long long discard_padding)
    :{}

long BlockGroup::Parse() {}

BlockEntry::Kind BlockGroup::GetKind() const {}
const Block* BlockGroup::GetBlock() const {}
long long BlockGroup::GetPrevTimeCode() const {}
long long BlockGroup::GetNextTimeCode() const {}
long long BlockGroup::GetDurationTimeCode() const {}

Block::Block(long long start, long long size_, long long discard_padding)
    :{}

Block::~Block() {}

long Block::Parse(const Cluster* pCluster) {}

long long Block::GetTimeCode(const Cluster* pCluster) const {}

long long Block::GetTime(const Cluster* pCluster) const {}

long long Block::GetTrackNumber() const {}

bool Block::IsKey() const {}

void Block::SetKey(bool bKey) {}

bool Block::IsInvisible() const {}

Block::Lacing Block::GetLacing() const {}

int Block::GetFrameCount() const {}

const Block::Frame& Block::GetFrame(int idx) const {}

long Block::Frame::Read(IMkvReader* pReader, unsigned char* buf) const {}

long long Block::GetDiscardPadding() const {}

}  // namespace mkvparser