#include "mkvmuxer/mkvmuxer.h"
#include <stdint.h>
#include <cfloat>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <memory>
#include <new>
#include <string>
#include <vector>
#include "common/webmids.h"
#include "mkvmuxer/mkvmuxerutil.h"
#include "mkvmuxer/mkvwriter.h"
#include "mkvparser/mkvparser.h"
namespace mkvmuxer {
const float PrimaryChromaticity::kChromaticityMin = …;
const float PrimaryChromaticity::kChromaticityMax = …;
const float MasteringMetadata::kMinLuminance = …;
const float MasteringMetadata::kMinLuminanceMax = …;
const float MasteringMetadata::kMaxLuminanceMax = …;
const float MasteringMetadata::kValueNotPresent = …;
const uint64_t Colour::kValueNotPresent = …;
namespace {
const char kDocTypeWebm[] = …;
const char kDocTypeMatroska[] = …;
bool StrCpy(const char* src, char** dst_ptr) { … }
PrimaryChromaticityPtr;
bool CopyChromaticity(const PrimaryChromaticity* src,
PrimaryChromaticityPtr* dst) { … }
}
IMkvWriter::IMkvWriter() { … }
IMkvWriter::~IMkvWriter() { … }
bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version,
const char* const doc_type) { … }
bool WriteEbmlHeader(IMkvWriter* writer, uint64_t doc_type_version) { … }
bool WriteEbmlHeader(IMkvWriter* writer) { … }
bool ChunkedCopy(mkvparser::IMkvReader* source, mkvmuxer::IMkvWriter* dst,
int64_t start, int64_t size) { … }
Frame::Frame()
: … { … }
Frame::~Frame() { … }
bool Frame::CopyFrom(const Frame& frame) { … }
bool Frame::Init(const uint8_t* frame, uint64_t length) { … }
bool Frame::AddAdditionalData(const uint8_t* additional, uint64_t length,
uint64_t add_id) { … }
bool Frame::IsValid() const { … }
bool Frame::CanBeSimpleBlock() const { … }
void Frame::set_duration(uint64_t duration) { … }
void Frame::set_reference_block_timestamp(int64_t reference_block_timestamp) { … }
CuePoint::CuePoint()
: … { … }
CuePoint::~CuePoint() { … }
bool CuePoint::Write(IMkvWriter* writer) const { … }
uint64_t CuePoint::PayloadSize() const { … }
uint64_t CuePoint::Size() const { … }
Cues::Cues()
: … { … }
Cues::~Cues() { … }
bool Cues::AddCue(CuePoint* cue) { … }
CuePoint* Cues::GetCueByIndex(int32_t index) const { … }
uint64_t Cues::Size() { … }
bool Cues::Write(IMkvWriter* writer) const { … }
ContentEncAESSettings::ContentEncAESSettings() : … { … }
uint64_t ContentEncAESSettings::Size() const { … }
bool ContentEncAESSettings::Write(IMkvWriter* writer) const { … }
uint64_t ContentEncAESSettings::PayloadSize() const { … }
ContentEncoding::ContentEncoding()
: … { … }
ContentEncoding::~ContentEncoding() { … }
bool ContentEncoding::SetEncryptionID(const uint8_t* id, uint64_t length) { … }
uint64_t ContentEncoding::Size() const { … }
bool ContentEncoding::Write(IMkvWriter* writer) const { … }
uint64_t ContentEncoding::EncodingSize(uint64_t compression_size,
uint64_t encryption_size) const { … }
uint64_t ContentEncoding::EncryptionSize() const { … }
Track::Track(unsigned int* seed)
: … { … }
Track::~Track() { … }
bool Track::AddContentEncoding() { … }
ContentEncoding* Track::GetContentEncodingByIndex(uint32_t index) const { … }
uint64_t Track::PayloadSize() const { … }
uint64_t Track::Size() const { … }
bool Track::Write(IMkvWriter* writer) const { … }
bool Track::SetCodecPrivate(const uint8_t* codec_private, uint64_t length) { … }
void Track::set_codec_id(const char* codec_id) { … }
void Track::set_language(const char* language) { … }
void Track::set_name(const char* name) { … }
uint64_t PrimaryChromaticity::PrimaryChromaticitySize(
libwebm::MkvId x_id, libwebm::MkvId y_id) const { … }
bool PrimaryChromaticity::Write(IMkvWriter* writer, libwebm::MkvId x_id,
libwebm::MkvId y_id) const { … }
bool PrimaryChromaticity::Valid() const { … }
uint64_t MasteringMetadata::MasteringMetadataSize() const { … }
bool MasteringMetadata::Valid() const { … }
bool MasteringMetadata::Write(IMkvWriter* writer) const { … }
bool MasteringMetadata::SetChromaticity(
const PrimaryChromaticity* r, const PrimaryChromaticity* g,
const PrimaryChromaticity* b, const PrimaryChromaticity* white_point) { … }
uint64_t MasteringMetadata::PayloadSize() const { … }
uint64_t Colour::ColourSize() const { … }
bool Colour::Valid() const { … }
bool Colour::Write(IMkvWriter* writer) const { … }
bool Colour::SetMasteringMetadata(const MasteringMetadata& mastering_metadata) { … }
uint64_t Colour::PayloadSize() const { … }
uint64_t Projection::ProjectionSize() const { … }
bool Projection::Write(IMkvWriter* writer) const { … }
bool Projection::SetProjectionPrivate(const uint8_t* data,
uint64_t data_length) { … }
uint64_t Projection::PayloadSize() const { … }
VideoTrack::VideoTrack(unsigned int* seed)
: … { … }
VideoTrack::~VideoTrack() { … }
bool VideoTrack::SetStereoMode(uint64_t stereo_mode) { … }
bool VideoTrack::SetAlphaMode(uint64_t alpha_mode) { … }
uint64_t VideoTrack::PayloadSize() const { … }
bool VideoTrack::Write(IMkvWriter* writer) const { … }
void VideoTrack::set_colour_space(const char* colour_space) { … }
bool VideoTrack::SetColour(const Colour& colour) { … }
bool VideoTrack::SetProjection(const Projection& projection) { … }
uint64_t VideoTrack::VideoPayloadSize() const { … }
AudioTrack::AudioTrack(unsigned int* seed)
: … { … }
AudioTrack::~AudioTrack() { … }
uint64_t AudioTrack::PayloadSize() const { … }
bool AudioTrack::Write(IMkvWriter* writer) const { … }
const char Tracks::kOpusCodecId[] = …;
const char Tracks::kVorbisCodecId[] = …;
const char Tracks::kAv1CodecId[] = …;
const char Tracks::kVp8CodecId[] = …;
const char Tracks::kVp9CodecId[] = …;
const char Tracks::kWebVttCaptionsId[] = …;
const char Tracks::kWebVttDescriptionsId[] = …;
const char Tracks::kWebVttMetadataId[] = …;
const char Tracks::kWebVttSubtitlesId[] = …;
Tracks::Tracks()
: … { … }
Tracks::~Tracks() { … }
bool Tracks::AddTrack(Track* track, int32_t number) { … }
const Track* Tracks::GetTrackByIndex(uint32_t index) const { … }
Track* Tracks::GetTrackByNumber(uint64_t track_number) const { … }
bool Tracks::TrackIsAudio(uint64_t track_number) const { … }
bool Tracks::TrackIsVideo(uint64_t track_number) const { … }
bool Tracks::Write(IMkvWriter* writer) const { … }
bool Chapter::set_id(const char* id) { … }
void Chapter::set_time(const Segment& segment, uint64_t start_ns,
uint64_t end_ns) { … }
bool Chapter::add_string(const char* title, const char* language,
const char* country) { … }
Chapter::Chapter() { … }
Chapter::~Chapter() { … }
void Chapter::Init(unsigned int* seed) { … }
void Chapter::ShallowCopy(Chapter* dst) const { … }
void Chapter::Clear() { … }
bool Chapter::ExpandDisplaysArray() { … }
uint64_t Chapter::WriteAtom(IMkvWriter* writer) const { … }
void Chapter::Display::Init() { … }
void Chapter::Display::Clear() { … }
bool Chapter::Display::set_title(const char* title) { … }
bool Chapter::Display::set_language(const char* language) { … }
bool Chapter::Display::set_country(const char* country) { … }
uint64_t Chapter::Display::WriteDisplay(IMkvWriter* writer) const { … }
Chapters::Chapters() : … { … }
Chapters::~Chapters() { … }
int Chapters::Count() const { … }
Chapter* Chapters::AddChapter(unsigned int* seed) { … }
bool Chapters::Write(IMkvWriter* writer) const { … }
bool Chapters::ExpandChaptersArray() { … }
uint64_t Chapters::WriteEdition(IMkvWriter* writer) const { … }
bool Tag::add_simple_tag(const char* tag_name, const char* tag_string) { … }
Tag::Tag() { … }
Tag::~Tag() { … }
void Tag::ShallowCopy(Tag* dst) const { … }
void Tag::Clear() { … }
bool Tag::ExpandSimpleTagsArray() { … }
uint64_t Tag::Write(IMkvWriter* writer) const { … }
void Tag::SimpleTag::Init() { … }
void Tag::SimpleTag::Clear() { … }
bool Tag::SimpleTag::set_tag_name(const char* tag_name) { … }
bool Tag::SimpleTag::set_tag_string(const char* tag_string) { … }
uint64_t Tag::SimpleTag::Write(IMkvWriter* writer) const { … }
Tags::Tags() : … { … }
Tags::~Tags() { … }
int Tags::Count() const { … }
Tag* Tags::AddTag() { … }
bool Tags::Write(IMkvWriter* writer) const { … }
bool Tags::ExpandTagsArray() { … }
Cluster::Cluster(uint64_t timecode, int64_t cues_pos, uint64_t timecode_scale,
bool write_last_frame_with_duration, bool fixed_size_timecode)
: … { … }
Cluster::~Cluster() { … }
bool Cluster::Init(IMkvWriter* ptr_writer) { … }
bool Cluster::AddFrame(const Frame* const frame) { … }
bool Cluster::AddFrame(const uint8_t* data, uint64_t length,
uint64_t track_number, uint64_t abs_timecode,
bool is_key) { … }
bool Cluster::AddFrameWithAdditional(const uint8_t* data, uint64_t length,
const uint8_t* additional,
uint64_t additional_length,
uint64_t add_id, uint64_t track_number,
uint64_t abs_timecode, bool is_key) { … }
bool Cluster::AddFrameWithDiscardPadding(const uint8_t* data, uint64_t length,
int64_t discard_padding,
uint64_t track_number,
uint64_t abs_timecode, bool is_key) { … }
bool Cluster::AddMetadata(const uint8_t* data, uint64_t length,
uint64_t track_number, uint64_t abs_timecode,
uint64_t duration_timecode) { … }
void Cluster::AddPayloadSize(uint64_t size) { … }
bool Cluster::Finalize() { … }
bool Cluster::Finalize(bool set_last_frame_duration, uint64_t duration) { … }
uint64_t Cluster::Size() const { … }
bool Cluster::PreWriteBlock() { … }
void Cluster::PostWriteBlock(uint64_t element_size) { … }
int64_t Cluster::GetRelativeTimecode(int64_t abs_timecode) const { … }
bool Cluster::DoWriteFrame(const Frame* const frame) { … }
bool Cluster::QueueOrWriteFrame(const Frame* const frame) { … }
bool Cluster::WriteClusterHeader() { … }
SeekHead::SeekHead() : … { … }
SeekHead::~SeekHead() { … }
bool SeekHead::Finalize(IMkvWriter* writer) const { … }
bool SeekHead::Write(IMkvWriter* writer) { … }
bool SeekHead::AddSeekEntry(uint32_t id, uint64_t pos) { … }
uint32_t SeekHead::GetId(int index) const { … }
uint64_t SeekHead::GetPosition(int index) const { … }
bool SeekHead::SetSeekEntry(int index, uint32_t id, uint64_t position) { … }
uint64_t SeekHead::MaxEntrySize() const { … }
SegmentInfo::SegmentInfo()
: … { … }
SegmentInfo::~SegmentInfo() { … }
bool SegmentInfo::Init() { … }
bool SegmentInfo::Finalize(IMkvWriter* writer) const { … }
bool SegmentInfo::Write(IMkvWriter* writer) { … }
void SegmentInfo::set_muxing_app(const char* app) { … }
void SegmentInfo::set_writing_app(const char* app) { … }
Segment::Segment()
: … { … }
Segment::~Segment() { … }
void Segment::MoveCuesBeforeClustersHelper(uint64_t diff, int32_t index,
uint64_t* cues_size) { … }
void Segment::MoveCuesBeforeClusters() { … }
bool Segment::Init(IMkvWriter* ptr_writer) { … }
bool Segment::CopyAndMoveCuesBeforeClusters(mkvparser::IMkvReader* reader,
IMkvWriter* writer) { … }
bool Segment::Finalize() { … }
Track* Segment::AddTrack(int32_t number) { … }
Chapter* Segment::AddChapter() { … }
Tag* Segment::AddTag() { … }
uint64_t Segment::AddVideoTrack(int32_t width, int32_t height, int32_t number) { … }
bool Segment::AddCuePoint(uint64_t timestamp, uint64_t track) { … }
uint64_t Segment::AddAudioTrack(int32_t sample_rate, int32_t channels,
int32_t number) { … }
bool Segment::AddFrame(const uint8_t* data, uint64_t length,
uint64_t track_number, uint64_t timestamp, bool is_key) { … }
bool Segment::AddFrameWithAdditional(const uint8_t* data, uint64_t length,
const uint8_t* additional,
uint64_t additional_length,
uint64_t add_id, uint64_t track_number,
uint64_t timestamp, bool is_key) { … }
bool Segment::AddFrameWithDiscardPadding(const uint8_t* data, uint64_t length,
int64_t discard_padding,
uint64_t track_number,
uint64_t timestamp, bool is_key) { … }
bool Segment::AddMetadata(const uint8_t* data, uint64_t length,
uint64_t track_number, uint64_t timestamp_ns,
uint64_t duration_ns) { … }
bool Segment::AddGenericFrame(const Frame* frame) { … }
void Segment::OutputCues(bool output_cues) { … }
void Segment::AccurateClusterDuration(bool accurate_cluster_duration) { … }
void Segment::UseFixedSizeClusterTimecode(bool fixed_size_cluster_timecode) { … }
bool Segment::SetChunking(bool chunking, const char* filename) { … }
bool Segment::CuesTrack(uint64_t track_number) { … }
void Segment::ForceNewClusterOnNextFrame() { … }
Track* Segment::GetTrackByNumber(uint64_t track_number) const { … }
bool Segment::WriteSegmentHeader() { … }
int Segment::TestFrame(uint64_t track_number, uint64_t frame_timestamp_ns,
bool is_key) const { … }
bool Segment::MakeNewCluster(uint64_t frame_timestamp_ns) { … }
bool Segment::DoNewClusterProcessing(uint64_t track_number,
uint64_t frame_timestamp_ns, bool is_key) { … }
bool Segment::CheckHeaderInfo() { … }
void Segment::UpdateDocTypeVersion() { … }
bool Segment::UpdateChunkName(const char* ext, char** name) const { … }
int64_t Segment::MaxOffset() { … }
bool Segment::QueueFrame(Frame* frame) { … }
int Segment::WriteFramesAll() { … }
bool Segment::WriteFramesLessThan(uint64_t timestamp) { … }
bool Segment::DocTypeIsWebm() const { … }
}