mkvmuxer: Add support for writing CodecDelay and SeekPreRoll elements.
Change-Id: Iad8c671b76c4b97abad58946df7f3c0ebe6cb01b
This commit is contained in:
21
mkvmuxer.cpp
21
mkvmuxer.cpp
@@ -514,6 +514,8 @@ Track::Track(unsigned int* seed)
|
||||
number_(0),
|
||||
type_(0),
|
||||
uid_(MakeUID(seed)),
|
||||
codec_delay_(0),
|
||||
seek_pre_roll_(0),
|
||||
codec_private_length_(0),
|
||||
content_encoding_entries_(NULL),
|
||||
content_encoding_entries_size_(0) {
|
||||
@@ -635,6 +637,11 @@ bool Track::Write(IMkvWriter* writer) const {
|
||||
size += EbmlElementSize(kMkvName, name_);
|
||||
if (max_block_additional_id_)
|
||||
size += EbmlElementSize(kMkvMaxBlockAdditionID, max_block_additional_id_);
|
||||
if (codec_delay_)
|
||||
size += EbmlElementSize(kMkvCodecDelay, codec_delay_);
|
||||
if (seek_pre_roll_)
|
||||
size += EbmlElementSize(kMkvSeekPreRoll, seek_pre_roll_);
|
||||
|
||||
|
||||
const int64 payload_position = writer->Position();
|
||||
if (payload_position < 0)
|
||||
@@ -646,11 +653,21 @@ bool Track::Write(IMkvWriter* writer) const {
|
||||
return false;
|
||||
if (!WriteEbmlElement(writer, kMkvTrackType, type_))
|
||||
return false;
|
||||
if (max_block_additional_id_)
|
||||
if (max_block_additional_id_) {
|
||||
if (!WriteEbmlElement(writer,
|
||||
kMkvMaxBlockAdditionID,
|
||||
max_block_additional_id_))
|
||||
max_block_additional_id_)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (codec_delay_) {
|
||||
if (!WriteEbmlElement(writer, kMkvCodecDelay, codec_delay_))
|
||||
return false;
|
||||
}
|
||||
if (seek_pre_roll_) {
|
||||
if (!WriteEbmlElement(writer, kMkvSeekPreRoll, seek_pre_roll_))
|
||||
return false;
|
||||
}
|
||||
if (codec_id_) {
|
||||
if (!WriteEbmlElement(writer, kMkvCodecID, codec_id_))
|
||||
return false;
|
||||
|
||||
@@ -340,6 +340,12 @@ class Track {
|
||||
uint64 type() const { return type_; }
|
||||
void set_uid(uint64 uid) { uid_ = uid; }
|
||||
uint64 uid() const { return uid_; }
|
||||
void set_codec_delay(uint64 codec_delay) { codec_delay_ = codec_delay; }
|
||||
uint64 codec_delay() const { return codec_delay_; }
|
||||
void set_seek_pre_roll(uint64 seek_pre_roll) {
|
||||
seek_pre_roll_ = seek_pre_roll;
|
||||
}
|
||||
uint64 seek_pre_roll() const { return seek_pre_roll_; }
|
||||
|
||||
uint64 codec_private_length() const { return codec_private_length_; }
|
||||
uint32 content_encoding_entries_size() const {
|
||||
@@ -356,6 +362,8 @@ class Track {
|
||||
uint64 number_;
|
||||
uint64 type_;
|
||||
uint64 uid_;
|
||||
uint64 codec_delay_;
|
||||
uint64 seek_pre_roll_;
|
||||
|
||||
// Size of the CodecPrivate data in bytes.
|
||||
uint64 codec_private_length_;
|
||||
|
||||
@@ -398,6 +398,11 @@ int main(int argc, char* argv[]) {
|
||||
const long long bit_depth = pAudioTrack->GetBitDepth();
|
||||
if (bit_depth > 0)
|
||||
audio->set_bit_depth(bit_depth);
|
||||
|
||||
if (pAudioTrack->GetCodecDelay())
|
||||
audio->set_codec_delay(pAudioTrack->GetCodecDelay());
|
||||
if (pAudioTrack->GetSeekPreRoll())
|
||||
audio->set_seek_pre_roll(pAudioTrack->GetSeekPreRoll());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,6 +74,8 @@ enum MkvId {
|
||||
kMkvCodecPrivate = 0x63A2,
|
||||
kMkvCodecName = 0x258688,
|
||||
kMkvMaxBlockAdditionID = 0x55EE,
|
||||
kMkvCodecDelay = 0x56AA,
|
||||
kMkvSeekPreRoll = 0x56BB,
|
||||
//video
|
||||
kMkvVideo = 0xE0,
|
||||
kMkvFlagInterlaced = 0x9A,
|
||||
|
||||
Reference in New Issue
Block a user