Merge "third_party/libwebm: pull from upstream"
This commit is contained in:

committed by
Gerrit Code Review

commit
51a1cbfed1
2
third_party/libwebm/README.libvpx
vendored
2
third_party/libwebm/README.libvpx
vendored
@@ -1,5 +1,5 @@
|
|||||||
URL: https://chromium.googlesource.com/webm/libwebm
|
URL: https://chromium.googlesource.com/webm/libwebm
|
||||||
Version: a7118d8ec564e9db841da1eb01f547f3229f240a
|
Version: 249629d46c6e9391f25a90cff6d19075f47474cb
|
||||||
License: BSD
|
License: BSD
|
||||||
License File: LICENSE.txt
|
License File: LICENSE.txt
|
||||||
|
|
||||||
|
642
third_party/libwebm/mkvmuxer.cpp
vendored
642
third_party/libwebm/mkvmuxer.cpp
vendored
File diff suppressed because it is too large
Load Diff
161
third_party/libwebm/mkvmuxer.hpp
vendored
161
third_party/libwebm/mkvmuxer.hpp
vendored
@@ -15,7 +15,7 @@
|
|||||||
// http://www.webmproject.org/code/specs/container/.
|
// http://www.webmproject.org/code/specs/container/.
|
||||||
|
|
||||||
namespace mkvparser {
|
namespace mkvparser {
|
||||||
class IMkvReader;
|
class IMkvReader;
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
|
||||||
namespace mkvmuxer {
|
namespace mkvmuxer {
|
||||||
@@ -60,8 +60,8 @@ class IMkvWriter {
|
|||||||
bool WriteEbmlHeader(IMkvWriter* writer);
|
bool WriteEbmlHeader(IMkvWriter* writer);
|
||||||
|
|
||||||
// Copies in Chunk from source to destination between the given byte positions
|
// Copies in Chunk from source to destination between the given byte positions
|
||||||
bool ChunkedCopy(mkvparser::IMkvReader* source, IMkvWriter* dst,
|
bool ChunkedCopy(mkvparser::IMkvReader* source, IMkvWriter* dst, int64 start,
|
||||||
int64 start, int64 size);
|
int64 size);
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////
|
||||||
// Class to hold data the will be written to a block.
|
// Class to hold data the will be written to a block.
|
||||||
@@ -74,8 +74,7 @@ class Frame {
|
|||||||
bool Init(const uint8* frame, uint64 length);
|
bool Init(const uint8* frame, uint64 length);
|
||||||
|
|
||||||
// Copies |additional| data into |additional_|. Returns true on success.
|
// Copies |additional| data into |additional_|. Returns true on success.
|
||||||
bool AddAdditionalData(const uint8* additional, uint64 length,
|
bool AddAdditionalData(const uint8* additional, uint64 length, uint64 add_id);
|
||||||
uint64 add_id);
|
|
||||||
|
|
||||||
uint64 add_id() const { return add_id_; }
|
uint64 add_id() const { return add_id_; }
|
||||||
const uint8* additional() const { return additional_; }
|
const uint8* additional() const { return additional_; }
|
||||||
@@ -223,9 +222,7 @@ class Cues {
|
|||||||
// ContentEncAESSettings element
|
// ContentEncAESSettings element
|
||||||
class ContentEncAESSettings {
|
class ContentEncAESSettings {
|
||||||
public:
|
public:
|
||||||
enum {
|
enum { kCTR = 1 };
|
||||||
kCTR = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
ContentEncAESSettings();
|
ContentEncAESSettings();
|
||||||
~ContentEncAESSettings() {}
|
~ContentEncAESSettings() {}
|
||||||
@@ -353,6 +350,10 @@ class Track {
|
|||||||
seek_pre_roll_ = seek_pre_roll;
|
seek_pre_roll_ = seek_pre_roll;
|
||||||
}
|
}
|
||||||
uint64 seek_pre_roll() const { return seek_pre_roll_; }
|
uint64 seek_pre_roll() const { return seek_pre_roll_; }
|
||||||
|
void set_default_duration(uint64 default_duration) {
|
||||||
|
default_duration_ = default_duration;
|
||||||
|
}
|
||||||
|
uint64 default_duration() const { return default_duration_; }
|
||||||
|
|
||||||
uint64 codec_private_length() const { return codec_private_length_; }
|
uint64 codec_private_length() const { return codec_private_length_; }
|
||||||
uint32 content_encoding_entries_size() const {
|
uint32 content_encoding_entries_size() const {
|
||||||
@@ -360,7 +361,7 @@ class Track {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Track element names
|
// Track element names.
|
||||||
char* codec_id_;
|
char* codec_id_;
|
||||||
uint8* codec_private_;
|
uint8* codec_private_;
|
||||||
char* language_;
|
char* language_;
|
||||||
@@ -371,6 +372,7 @@ class Track {
|
|||||||
uint64 uid_;
|
uint64 uid_;
|
||||||
uint64 codec_delay_;
|
uint64 codec_delay_;
|
||||||
uint64 seek_pre_roll_;
|
uint64 seek_pre_roll_;
|
||||||
|
uint64 default_duration_;
|
||||||
|
|
||||||
// Size of the CodecPrivate data in bytes.
|
// Size of the CodecPrivate data in bytes.
|
||||||
uint64 codec_private_length_;
|
uint64 codec_private_length_;
|
||||||
@@ -397,10 +399,7 @@ class VideoTrack : public Track {
|
|||||||
kSideBySideRightIsFirst = 11
|
kSideBySideRightIsFirst = 11
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AlphaMode {
|
enum AlphaMode { kNoAlpha = 0, kAlpha = 1 };
|
||||||
kNoAlpha = 0,
|
|
||||||
kAlpha = 1
|
|
||||||
};
|
|
||||||
|
|
||||||
// The |seed| parameter is used to synthesize a UID for the track.
|
// The |seed| parameter is used to synthesize a UID for the track.
|
||||||
explicit VideoTrack(unsigned int* seed);
|
explicit VideoTrack(unsigned int* seed);
|
||||||
@@ -484,10 +483,7 @@ class AudioTrack : public Track {
|
|||||||
class Tracks {
|
class Tracks {
|
||||||
public:
|
public:
|
||||||
// Audio and video type defined by the Matroska specs.
|
// Audio and video type defined by the Matroska specs.
|
||||||
enum {
|
enum { kVideo = 0x1, kAudio = 0x2 };
|
||||||
kVideo = 0x1,
|
|
||||||
kAudio = 0x2
|
|
||||||
};
|
|
||||||
// Opus, Vorbis, VP8, and VP9 codec ids defined by the Matroska specs.
|
// Opus, Vorbis, VP8, and VP9 codec ids defined by the Matroska specs.
|
||||||
static const char kOpusCodecId[];
|
static const char kOpusCodecId[];
|
||||||
static const char kVorbisCodecId[];
|
static const char kVorbisCodecId[];
|
||||||
@@ -544,8 +540,7 @@ class Chapter {
|
|||||||
|
|
||||||
// Converts the nanosecond start and stop times of this chapter to
|
// Converts the nanosecond start and stop times of this chapter to
|
||||||
// their corresponding timecode values, and stores them that way.
|
// their corresponding timecode values, and stores them that way.
|
||||||
void set_time(const Segment& segment,
|
void set_time(const Segment& segment, uint64 start_time_ns,
|
||||||
uint64 start_time_ns,
|
|
||||||
uint64 end_time_ns);
|
uint64 end_time_ns);
|
||||||
|
|
||||||
// Sets the uid for this chapter. Primarily used to enable
|
// Sets the uid for this chapter. Primarily used to enable
|
||||||
@@ -568,9 +563,7 @@ class Chapter {
|
|||||||
// http://www.iana.org/domains/root/db/
|
// http://www.iana.org/domains/root/db/
|
||||||
//
|
//
|
||||||
// The function returns false if the string could not be allocated.
|
// The function returns false if the string could not be allocated.
|
||||||
bool add_string(const char* title,
|
bool add_string(const char* title, const char* language, const char* country);
|
||||||
const char* language,
|
|
||||||
const char* country);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class Chapters;
|
friend class Chapters;
|
||||||
@@ -724,9 +717,7 @@ class Cluster {
|
|||||||
// timecode: Absolute (not relative to cluster) timestamp of the
|
// timecode: Absolute (not relative to cluster) timestamp of the
|
||||||
// frame, expressed in timecode units.
|
// frame, expressed in timecode units.
|
||||||
// is_key: Flag telling whether or not this frame is a key frame.
|
// is_key: Flag telling whether or not this frame is a key frame.
|
||||||
bool AddFrame(const uint8* frame,
|
bool AddFrame(const uint8* frame, uint64 length, uint64 track_number,
|
||||||
uint64 length,
|
|
||||||
uint64 track_number,
|
|
||||||
uint64 timecode, // timecode units (absolute)
|
uint64 timecode, // timecode units (absolute)
|
||||||
bool is_key);
|
bool is_key);
|
||||||
|
|
||||||
@@ -743,14 +734,10 @@ class Cluster {
|
|||||||
// abs_timecode: Absolute (not relative to cluster) timestamp of the
|
// abs_timecode: Absolute (not relative to cluster) timestamp of the
|
||||||
// frame, expressed in timecode units.
|
// frame, expressed in timecode units.
|
||||||
// is_key: Flag telling whether or not this frame is a key frame.
|
// is_key: Flag telling whether or not this frame is a key frame.
|
||||||
bool AddFrameWithAdditional(const uint8* frame,
|
bool AddFrameWithAdditional(const uint8* frame, uint64 length,
|
||||||
uint64 length,
|
const uint8* additional, uint64 additional_length,
|
||||||
const uint8* additional,
|
uint64 add_id, uint64 track_number,
|
||||||
uint64 additional_length,
|
uint64 abs_timecode, bool is_key);
|
||||||
uint64 add_id,
|
|
||||||
uint64 track_number,
|
|
||||||
uint64 abs_timecode,
|
|
||||||
bool is_key);
|
|
||||||
|
|
||||||
// Adds a frame to be output in the file. The frame is written out through
|
// Adds a frame to be output in the file. The frame is written out through
|
||||||
// |writer_| if successful. Returns true on success.
|
// |writer_| if successful. Returns true on success.
|
||||||
@@ -763,12 +750,9 @@ class Cluster {
|
|||||||
// abs_timecode: Absolute (not relative to cluster) timestamp of the
|
// abs_timecode: Absolute (not relative to cluster) timestamp of the
|
||||||
// frame, expressed in timecode units.
|
// frame, expressed in timecode units.
|
||||||
// is_key: Flag telling whether or not this frame is a key frame.
|
// is_key: Flag telling whether or not this frame is a key frame.
|
||||||
bool AddFrameWithDiscardPadding(const uint8* frame,
|
bool AddFrameWithDiscardPadding(const uint8* frame, uint64 length,
|
||||||
uint64 length,
|
int64 discard_padding, uint64 track_number,
|
||||||
int64 discard_padding,
|
uint64 abs_timecode, bool is_key);
|
||||||
uint64 track_number,
|
|
||||||
uint64 abs_timecode,
|
|
||||||
bool is_key);
|
|
||||||
|
|
||||||
// Writes a frame of metadata to the output medium; returns true on
|
// Writes a frame of metadata to the output medium; returns true on
|
||||||
// success.
|
// success.
|
||||||
@@ -784,11 +768,8 @@ class Cluster {
|
|||||||
// The metadata frame is written as a block group, with a duration
|
// The metadata frame is written as a block group, with a duration
|
||||||
// sub-element but no reference time sub-elements (indicating that
|
// sub-element but no reference time sub-elements (indicating that
|
||||||
// it is considered a keyframe, per Matroska semantics).
|
// it is considered a keyframe, per Matroska semantics).
|
||||||
bool AddMetadata(const uint8* frame,
|
bool AddMetadata(const uint8* frame, uint64 length, uint64 track_number,
|
||||||
uint64 length,
|
uint64 timecode, uint64 duration);
|
||||||
uint64 track_number,
|
|
||||||
uint64 timecode, // timecode units (absolute)
|
|
||||||
uint64 duration); // timecode units
|
|
||||||
|
|
||||||
// Increments the size of the cluster's data in bytes.
|
// Increments the size of the cluster's data in bytes.
|
||||||
void AddPayloadSize(uint64 size);
|
void AddPayloadSize(uint64 size);
|
||||||
@@ -809,34 +790,26 @@ class Cluster {
|
|||||||
private:
|
private:
|
||||||
// Signature that matches either of WriteSimpleBlock or WriteMetadataBlock
|
// Signature that matches either of WriteSimpleBlock or WriteMetadataBlock
|
||||||
// in the muxer utilities package.
|
// in the muxer utilities package.
|
||||||
typedef uint64 (*WriteBlock)(IMkvWriter* writer,
|
typedef uint64 (*WriteBlock)(IMkvWriter* writer, const uint8* data,
|
||||||
const uint8* data,
|
uint64 length, uint64 track_number,
|
||||||
uint64 length,
|
int64 timecode, uint64 generic_arg);
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 generic_arg);
|
|
||||||
|
|
||||||
// Signature that matches WriteBlockWithAdditional
|
// Signature that matches WriteBlockWithAdditional
|
||||||
// in the muxer utilities package.
|
// in the muxer utilities package.
|
||||||
typedef uint64 (*WriteBlockAdditional)(IMkvWriter* writer,
|
typedef uint64 (*WriteBlockAdditional)(IMkvWriter* writer, const uint8* data,
|
||||||
const uint8* data,
|
uint64 length, const uint8* additional,
|
||||||
uint64 length,
|
|
||||||
const uint8* additional,
|
|
||||||
uint64 add_id,
|
uint64 add_id,
|
||||||
uint64 additional_length,
|
uint64 additional_length,
|
||||||
uint64 track_number,
|
uint64 track_number, int64 timecode,
|
||||||
int64 timecode,
|
|
||||||
uint64 is_key);
|
uint64 is_key);
|
||||||
|
|
||||||
// Signature that matches WriteBlockWithDiscardPadding
|
// Signature that matches WriteBlockWithDiscardPadding
|
||||||
// in the muxer utilities package.
|
// in the muxer utilities package.
|
||||||
typedef uint64 (*WriteBlockDiscardPadding)(IMkvWriter* writer,
|
typedef uint64 (*WriteBlockDiscardPadding)(IMkvWriter* writer,
|
||||||
const uint8* data,
|
const uint8* data, uint64 length,
|
||||||
uint64 length,
|
|
||||||
int64 discard_padding,
|
int64 discard_padding,
|
||||||
uint64 track_number,
|
uint64 track_number,
|
||||||
int64 timecode,
|
int64 timecode, uint64 is_key);
|
||||||
uint64 is_key);
|
|
||||||
|
|
||||||
// Utility method that confirms that blocks can still be added, and that the
|
// Utility method that confirms that blocks can still be added, and that the
|
||||||
// cluster header has been written. Used by |DoWriteBlock*|. Returns true
|
// cluster header has been written. Used by |DoWriteBlock*|. Returns true
|
||||||
@@ -858,27 +831,20 @@ class Cluster {
|
|||||||
int64 GetRelativeTimecode(int64 abs_timecode) const;
|
int64 GetRelativeTimecode(int64 abs_timecode) const;
|
||||||
|
|
||||||
// Used to implement AddFrame and AddMetadata.
|
// Used to implement AddFrame and AddMetadata.
|
||||||
bool DoWriteBlock(const uint8* frame,
|
bool DoWriteBlock(const uint8* frame, uint64 length, uint64 track_number,
|
||||||
uint64 length,
|
uint64 absolute_timecode, uint64 generic_arg,
|
||||||
uint64 track_number,
|
|
||||||
uint64 absolute_timecode,
|
|
||||||
uint64 generic_arg,
|
|
||||||
WriteBlock write_block);
|
WriteBlock write_block);
|
||||||
|
|
||||||
// Used to implement AddFrameWithAdditional
|
// Used to implement AddFrameWithAdditional
|
||||||
bool DoWriteBlockWithAdditional(const uint8* frame,
|
bool DoWriteBlockWithAdditional(const uint8* frame, uint64 length,
|
||||||
uint64 length,
|
|
||||||
const uint8* additional,
|
const uint8* additional,
|
||||||
uint64 additional_length,
|
uint64 additional_length, uint64 add_id,
|
||||||
uint64 add_id,
|
uint64 track_number, uint64 absolute_timecode,
|
||||||
uint64 track_number,
|
|
||||||
uint64 absolute_timecode,
|
|
||||||
uint64 generic_arg,
|
uint64 generic_arg,
|
||||||
WriteBlockAdditional write_block);
|
WriteBlockAdditional write_block);
|
||||||
|
|
||||||
// Used to implement AddFrameWithDiscardPadding
|
// Used to implement AddFrameWithDiscardPadding
|
||||||
bool DoWriteBlockWithDiscardPadding(const uint8* frame,
|
bool DoWriteBlockWithDiscardPadding(const uint8* frame, uint64 length,
|
||||||
uint64 length,
|
|
||||||
int64 discard_padding,
|
int64 discard_padding,
|
||||||
uint64 track_number,
|
uint64 track_number,
|
||||||
uint64 absolute_timecode,
|
uint64 absolute_timecode,
|
||||||
@@ -993,6 +959,8 @@ class SegmentInfo {
|
|||||||
uint64 timecode_scale() const { return timecode_scale_; }
|
uint64 timecode_scale() const { return timecode_scale_; }
|
||||||
void set_writing_app(const char* app);
|
void set_writing_app(const char* app);
|
||||||
const char* writing_app() const { return writing_app_; }
|
const char* writing_app() const { return writing_app_; }
|
||||||
|
void set_date_utc(int64 date_utc) { date_utc_ = date_utc; }
|
||||||
|
int64 date_utc() const { return date_utc_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Segment Information element names.
|
// Segment Information element names.
|
||||||
@@ -1004,6 +972,8 @@ class SegmentInfo {
|
|||||||
uint64 timecode_scale_;
|
uint64 timecode_scale_;
|
||||||
// Initially set to libwebm-%d.%d.%d.%d, major, minor, build, revision.
|
// Initially set to libwebm-%d.%d.%d.%d, major, minor, build, revision.
|
||||||
char* writing_app_;
|
char* writing_app_;
|
||||||
|
// LLONG_MIN when DateUTC is not set.
|
||||||
|
int64 date_utc_;
|
||||||
|
|
||||||
// The file position of the duration element.
|
// The file position of the duration element.
|
||||||
int64 duration_pos_;
|
int64 duration_pos_;
|
||||||
@@ -1019,10 +989,7 @@ class SegmentInfo {
|
|||||||
// |Init| must be called before any other method in this class.
|
// |Init| must be called before any other method in this class.
|
||||||
class Segment {
|
class Segment {
|
||||||
public:
|
public:
|
||||||
enum Mode {
|
enum Mode { kLive = 0x1, kFile = 0x2 };
|
||||||
kLive = 0x1,
|
|
||||||
kFile = 0x2
|
|
||||||
};
|
|
||||||
|
|
||||||
enum CuesPosition {
|
enum CuesPosition {
|
||||||
kAfterClusters = 0x0, // Position Cues after Clusters - Default
|
kAfterClusters = 0x0, // Position Cues after Clusters - Default
|
||||||
@@ -1070,11 +1037,8 @@ class Segment {
|
|||||||
// functions.
|
// functions.
|
||||||
// timestamp: Timestamp of the frame in nanoseconds from 0.
|
// timestamp: Timestamp of the frame in nanoseconds from 0.
|
||||||
// is_key: Flag telling whether or not this frame is a key frame.
|
// is_key: Flag telling whether or not this frame is a key frame.
|
||||||
bool AddFrame(const uint8* frame,
|
bool AddFrame(const uint8* frame, uint64 length, uint64 track_number,
|
||||||
uint64 length,
|
uint64 timestamp_ns, bool is_key);
|
||||||
uint64 track_number,
|
|
||||||
uint64 timestamp_ns,
|
|
||||||
bool is_key);
|
|
||||||
|
|
||||||
// Writes a frame of metadata to the output medium; returns true on
|
// Writes a frame of metadata to the output medium; returns true on
|
||||||
// success.
|
// success.
|
||||||
@@ -1090,11 +1054,8 @@ class Segment {
|
|||||||
// The metadata frame is written as a block group, with a duration
|
// The metadata frame is written as a block group, with a duration
|
||||||
// sub-element but no reference time sub-elements (indicating that
|
// sub-element but no reference time sub-elements (indicating that
|
||||||
// it is considered a keyframe, per Matroska semantics).
|
// it is considered a keyframe, per Matroska semantics).
|
||||||
bool AddMetadata(const uint8* frame,
|
bool AddMetadata(const uint8* frame, uint64 length, uint64 track_number,
|
||||||
uint64 length,
|
uint64 timestamp_ns, uint64 duration_ns);
|
||||||
uint64 track_number,
|
|
||||||
uint64 timestamp_ns,
|
|
||||||
uint64 duration_ns);
|
|
||||||
|
|
||||||
// Writes a frame with additional data to the output medium; returns true on
|
// Writes a frame with additional data to the output medium; returns true on
|
||||||
// success.
|
// success.
|
||||||
@@ -1109,14 +1070,10 @@ class Segment {
|
|||||||
// timestamp: Absolute timestamp of the frame, expressed in nanosecond
|
// timestamp: Absolute timestamp of the frame, expressed in nanosecond
|
||||||
// units.
|
// units.
|
||||||
// is_key: Flag telling whether or not this frame is a key frame.
|
// is_key: Flag telling whether or not this frame is a key frame.
|
||||||
bool AddFrameWithAdditional(const uint8* frame,
|
bool AddFrameWithAdditional(const uint8* frame, uint64 length,
|
||||||
uint64 length,
|
const uint8* additional, uint64 additional_length,
|
||||||
const uint8* additional,
|
uint64 add_id, uint64 track_number,
|
||||||
uint64 additional_length,
|
uint64 timestamp, bool is_key);
|
||||||
uint64 add_id,
|
|
||||||
uint64 track_number,
|
|
||||||
uint64 timestamp,
|
|
||||||
bool is_key);
|
|
||||||
|
|
||||||
// Writes a frame with DiscardPadding to the output medium; returns true on
|
// Writes a frame with DiscardPadding to the output medium; returns true on
|
||||||
// success.
|
// success.
|
||||||
@@ -1129,12 +1086,9 @@ class Segment {
|
|||||||
// timestamp: Absolute timestamp of the frame, expressed in nanosecond
|
// timestamp: Absolute timestamp of the frame, expressed in nanosecond
|
||||||
// units.
|
// units.
|
||||||
// is_key: Flag telling whether or not this frame is a key frame.
|
// is_key: Flag telling whether or not this frame is a key frame.
|
||||||
bool AddFrameWithDiscardPadding(const uint8* frame,
|
bool AddFrameWithDiscardPadding(const uint8* frame, uint64 length,
|
||||||
uint64 length,
|
int64 discard_padding, uint64 track_number,
|
||||||
int64 discard_padding,
|
uint64 timestamp, bool is_key);
|
||||||
uint64 track_number,
|
|
||||||
uint64 timestamp,
|
|
||||||
bool is_key);
|
|
||||||
|
|
||||||
// Writes a Frame to the output medium. Chooses the correct way of writing
|
// Writes a Frame to the output medium. Chooses the correct way of writing
|
||||||
// the frame (Block vs SimpleBlock) based on the parameters passed.
|
// the frame (Block vs SimpleBlock) based on the parameters passed.
|
||||||
@@ -1268,7 +1222,6 @@ class Segment {
|
|||||||
// was necessary but creation was not successful.
|
// was necessary but creation was not successful.
|
||||||
bool DoNewClusterProcessing(uint64 track_num, uint64 timestamp_ns, bool key);
|
bool DoNewClusterProcessing(uint64 track_num, uint64 timestamp_ns, bool key);
|
||||||
|
|
||||||
|
|
||||||
// Adjusts Cue Point values (to place Cues before Clusters) so that they
|
// Adjusts Cue Point values (to place Cues before Clusters) so that they
|
||||||
// reflect the correct offsets.
|
// reflect the correct offsets.
|
||||||
void MoveCuesBeforeClusters();
|
void MoveCuesBeforeClusters();
|
||||||
@@ -1398,6 +1351,6 @@ class Segment {
|
|||||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Segment);
|
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(Segment);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //end namespace mkvmuxer
|
} // end namespace mkvmuxer
|
||||||
|
|
||||||
#endif //MKVMUXER_HPP
|
#endif // MKVMUXER_HPP
|
||||||
|
2
third_party/libwebm/mkvmuxertypes.hpp
vendored
2
third_party/libwebm/mkvmuxertypes.hpp
vendored
@@ -25,6 +25,6 @@ typedef unsigned int uint32;
|
|||||||
typedef long long int64;
|
typedef long long int64;
|
||||||
typedef unsigned long long uint64;
|
typedef unsigned long long uint64;
|
||||||
|
|
||||||
} //end namespace mkvmuxer
|
} // end namespace mkvmuxer
|
||||||
|
|
||||||
#endif // MKVMUXERTYPES_HPP
|
#endif // MKVMUXERTYPES_HPP
|
||||||
|
147
third_party/libwebm/mkvmuxerutil.cpp
vendored
147
third_party/libwebm/mkvmuxerutil.cpp
vendored
@@ -29,6 +29,13 @@
|
|||||||
|
|
||||||
namespace mkvmuxer {
|
namespace mkvmuxer {
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
// Date elements are always 8 octets in size.
|
||||||
|
const int kDateElementSize = 8;
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
int32 GetCodedUIntSize(uint64 value) {
|
int32 GetCodedUIntSize(uint64 value) {
|
||||||
if (value < 0x000000000000007FULL)
|
if (value < 0x000000000000007FULL)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -92,7 +99,7 @@ uint64 EbmlElementSize(uint64 type, uint64 value) {
|
|||||||
return ebml_size;
|
return ebml_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 EbmlElementSize(uint64 type, float /* value */ ) {
|
uint64 EbmlElementSize(uint64 type, float /* value */) {
|
||||||
// Size of EBML ID
|
// Size of EBML ID
|
||||||
uint64 ebml_size = GetUIntSize(type);
|
uint64 ebml_size = GetUIntSize(type);
|
||||||
|
|
||||||
@@ -137,6 +144,19 @@ uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size) {
|
|||||||
return ebml_size;
|
return ebml_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64 EbmlDateElementSize(uint64 type, int64 value) {
|
||||||
|
// Size of EBML ID
|
||||||
|
uint64 ebml_size = GetUIntSize(type);
|
||||||
|
|
||||||
|
// Datasize
|
||||||
|
ebml_size += kDateElementSize;
|
||||||
|
|
||||||
|
// Size of Datasize
|
||||||
|
ebml_size++;
|
||||||
|
|
||||||
|
return ebml_size;
|
||||||
|
}
|
||||||
|
|
||||||
int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size) {
|
int32 SerializeInt(IMkvWriter* writer, int64 value, int32 size) {
|
||||||
if (!writer || size < 1 || size > 8)
|
if (!writer || size < 1 || size > 8)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -302,9 +322,7 @@ bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteEbmlElement(IMkvWriter* writer,
|
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
|
||||||
uint64 type,
|
|
||||||
const uint8* value,
|
|
||||||
uint64 size) {
|
uint64 size) {
|
||||||
if (!writer || !value || size < 1)
|
if (!writer || !value || size < 1)
|
||||||
return false;
|
return false;
|
||||||
@@ -321,12 +339,24 @@ bool WriteEbmlElement(IMkvWriter* writer,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 WriteSimpleBlock(IMkvWriter* writer,
|
bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value) {
|
||||||
const uint8* data,
|
if (!writer)
|
||||||
uint64 length,
|
return false;
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
if (WriteID(writer, type))
|
||||||
uint64 is_key) {
|
return false;
|
||||||
|
|
||||||
|
if (WriteUInt(writer, kDateElementSize))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (SerializeInt(writer, value, kDateElementSize))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64 WriteSimpleBlock(IMkvWriter* writer, const uint8* data, uint64 length,
|
||||||
|
uint64 track_number, int64 timecode, uint64 is_key) {
|
||||||
if (!writer)
|
if (!writer)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -391,11 +421,8 @@ uint64 WriteSimpleBlock(IMkvWriter* writer,
|
|||||||
// Duration size
|
// Duration size
|
||||||
// (duration payload)
|
// (duration payload)
|
||||||
//
|
//
|
||||||
uint64 WriteMetadataBlock(IMkvWriter* writer,
|
uint64 WriteMetadataBlock(IMkvWriter* writer, const uint8* data, uint64 length,
|
||||||
const uint8* data,
|
uint64 track_number, int64 timecode,
|
||||||
uint64 length,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 duration) {
|
uint64 duration) {
|
||||||
// We don't backtrack when writing to the stream, so we must
|
// We don't backtrack when writing to the stream, so we must
|
||||||
// pre-compute the BlockGroup size, by summing the sizes of each
|
// pre-compute the BlockGroup size, by summing the sizes of each
|
||||||
@@ -487,47 +514,37 @@ uint64 WriteMetadataBlock(IMkvWriter* writer,
|
|||||||
// 1 (Denotes Alpha)
|
// 1 (Denotes Alpha)
|
||||||
// BlockAdditional
|
// BlockAdditional
|
||||||
// Data
|
// Data
|
||||||
uint64 WriteBlockWithAdditional(IMkvWriter* writer,
|
uint64 WriteBlockWithAdditional(IMkvWriter* writer, const uint8* data,
|
||||||
const uint8* data,
|
uint64 length, const uint8* additional,
|
||||||
uint64 length,
|
uint64 additional_length, uint64 add_id,
|
||||||
const uint8* additional,
|
uint64 track_number, int64 timecode,
|
||||||
uint64 additional_length,
|
|
||||||
uint64 add_id,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 is_key) {
|
uint64 is_key) {
|
||||||
if (!data || !additional || length < 1 || additional_length < 1)
|
if (!data || !additional || length < 1 || additional_length < 1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const uint64 block_payload_size = 4 + length;
|
const uint64 block_payload_size = 4 + length;
|
||||||
const uint64 block_elem_size = EbmlMasterElementSize(kMkvBlock,
|
const uint64 block_elem_size =
|
||||||
block_payload_size) +
|
EbmlMasterElementSize(kMkvBlock, block_payload_size) + block_payload_size;
|
||||||
block_payload_size;
|
const uint64 block_additional_elem_size =
|
||||||
const uint64 block_additional_elem_size = EbmlElementSize(kMkvBlockAdditional,
|
EbmlElementSize(kMkvBlockAdditional, additional, additional_length);
|
||||||
additional,
|
|
||||||
additional_length);
|
|
||||||
const uint64 block_addid_elem_size = EbmlElementSize(kMkvBlockAddID, add_id);
|
const uint64 block_addid_elem_size = EbmlElementSize(kMkvBlockAddID, add_id);
|
||||||
|
|
||||||
const uint64 block_more_payload_size = block_addid_elem_size +
|
const uint64 block_more_payload_size =
|
||||||
block_additional_elem_size;
|
block_addid_elem_size + block_additional_elem_size;
|
||||||
const uint64 block_more_elem_size = EbmlMasterElementSize(
|
const uint64 block_more_elem_size =
|
||||||
kMkvBlockMore,
|
EbmlMasterElementSize(kMkvBlockMore, block_more_payload_size) +
|
||||||
block_more_payload_size) +
|
|
||||||
block_more_payload_size;
|
block_more_payload_size;
|
||||||
const uint64 block_additions_payload_size = block_more_elem_size;
|
const uint64 block_additions_payload_size = block_more_elem_size;
|
||||||
const uint64 block_additions_elem_size = EbmlMasterElementSize(
|
const uint64 block_additions_elem_size =
|
||||||
kMkvBlockAdditions,
|
EbmlMasterElementSize(kMkvBlockAdditions, block_additions_payload_size) +
|
||||||
block_additions_payload_size) +
|
|
||||||
block_additions_payload_size;
|
block_additions_payload_size;
|
||||||
const uint64 block_group_payload_size = block_elem_size +
|
const uint64 block_group_payload_size =
|
||||||
block_additions_elem_size;
|
block_elem_size + block_additions_elem_size;
|
||||||
const uint64 block_group_elem_size = EbmlMasterElementSize(
|
const uint64 block_group_elem_size =
|
||||||
kMkvBlockGroup,
|
EbmlMasterElementSize(kMkvBlockGroup, block_group_payload_size) +
|
||||||
block_group_payload_size) +
|
|
||||||
block_group_payload_size;
|
block_group_payload_size;
|
||||||
|
|
||||||
if (!WriteEbmlMasterElement(writer, kMkvBlockGroup,
|
if (!WriteEbmlMasterElement(writer, kMkvBlockGroup, block_group_payload_size))
|
||||||
block_group_payload_size))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!WriteEbmlMasterElement(writer, kMkvBlock, block_payload_size))
|
if (!WriteEbmlMasterElement(writer, kMkvBlock, block_payload_size))
|
||||||
@@ -558,8 +575,8 @@ uint64 WriteBlockWithAdditional(IMkvWriter* writer,
|
|||||||
if (!WriteEbmlElement(writer, kMkvBlockAddID, add_id))
|
if (!WriteEbmlElement(writer, kMkvBlockAddID, add_id))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!WriteEbmlElement(writer, kMkvBlockAdditional,
|
if (!WriteEbmlElement(writer, kMkvBlockAdditional, additional,
|
||||||
additional, additional_length))
|
additional_length))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return block_group_elem_size;
|
return block_group_elem_size;
|
||||||
@@ -571,31 +588,25 @@ uint64 WriteBlockWithAdditional(IMkvWriter* writer,
|
|||||||
// Block
|
// Block
|
||||||
// Data
|
// Data
|
||||||
// DiscardPadding
|
// DiscardPadding
|
||||||
uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer,
|
uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, const uint8* data,
|
||||||
const uint8* data,
|
uint64 length, int64 discard_padding,
|
||||||
uint64 length,
|
uint64 track_number, int64 timecode,
|
||||||
int64 discard_padding,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 is_key) {
|
uint64 is_key) {
|
||||||
if (!data || length < 1 || discard_padding <= 0)
|
if (!data || length < 1 || discard_padding <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const uint64 block_payload_size = 4 + length;
|
const uint64 block_payload_size = 4 + length;
|
||||||
const uint64 block_elem_size = EbmlMasterElementSize(kMkvBlock,
|
const uint64 block_elem_size =
|
||||||
block_payload_size) +
|
EbmlMasterElementSize(kMkvBlock, block_payload_size) + block_payload_size;
|
||||||
block_payload_size;
|
const uint64 discard_padding_elem_size =
|
||||||
const uint64 discard_padding_elem_size = EbmlElementSize(kMkvDiscardPadding,
|
EbmlElementSize(kMkvDiscardPadding, discard_padding);
|
||||||
discard_padding);
|
const uint64 block_group_payload_size =
|
||||||
const uint64 block_group_payload_size = block_elem_size +
|
block_elem_size + discard_padding_elem_size;
|
||||||
discard_padding_elem_size;
|
const uint64 block_group_elem_size =
|
||||||
const uint64 block_group_elem_size = EbmlMasterElementSize(
|
EbmlMasterElementSize(kMkvBlockGroup, block_group_payload_size) +
|
||||||
kMkvBlockGroup,
|
|
||||||
block_group_payload_size) +
|
|
||||||
block_group_payload_size;
|
block_group_payload_size;
|
||||||
|
|
||||||
if (!WriteEbmlMasterElement(writer, kMkvBlockGroup,
|
if (!WriteEbmlMasterElement(writer, kMkvBlockGroup, block_group_payload_size))
|
||||||
block_group_payload_size))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!WriteEbmlMasterElement(writer, kMkvBlock, block_payload_size))
|
if (!WriteEbmlMasterElement(writer, kMkvBlock, block_payload_size))
|
||||||
@@ -634,9 +645,9 @@ uint64 WriteVoidElement(IMkvWriter* writer, uint64 size) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Subtract one for the void ID and the coded size.
|
// Subtract one for the void ID and the coded size.
|
||||||
uint64 void_entry_size = size - 1 - GetCodedUIntSize(size-1);
|
uint64 void_entry_size = size - 1 - GetCodedUIntSize(size - 1);
|
||||||
uint64 void_size = EbmlMasterElementSize(kMkvVoid, void_entry_size) +
|
uint64 void_size =
|
||||||
void_entry_size;
|
EbmlMasterElementSize(kMkvVoid, void_entry_size) + void_entry_size;
|
||||||
|
|
||||||
if (void_size != size)
|
if (void_size != size)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -684,7 +695,7 @@ mkvmuxer::uint64 mkvmuxer::MakeUID(unsigned int* seed) {
|
|||||||
for (int i = 0; i < 7; ++i) { // avoid problems with 8-byte values
|
for (int i = 0; i < 7; ++i) { // avoid problems with 8-byte values
|
||||||
uid <<= 8;
|
uid <<= 8;
|
||||||
|
|
||||||
// TODO(fgalligan): Move random number generation to platform specific code.
|
// TODO(fgalligan): Move random number generation to platform specific code.
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
(void)seed;
|
(void)seed;
|
||||||
unsigned int random_value;
|
unsigned int random_value;
|
||||||
|
44
third_party/libwebm/mkvmuxerutil.hpp
vendored
44
third_party/libwebm/mkvmuxerutil.hpp
vendored
@@ -30,6 +30,7 @@ uint64 EbmlElementSize(uint64 type, uint64 value);
|
|||||||
uint64 EbmlElementSize(uint64 type, float value);
|
uint64 EbmlElementSize(uint64 type, float value);
|
||||||
uint64 EbmlElementSize(uint64 type, const char* value);
|
uint64 EbmlElementSize(uint64 type, const char* value);
|
||||||
uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size);
|
uint64 EbmlElementSize(uint64 type, const uint8* value, uint64 size);
|
||||||
|
uint64 EbmlDateElementSize(uint64 type, int64 value);
|
||||||
|
|
||||||
// Creates an EBML coded number from |value| and writes it out. The size of
|
// Creates an EBML coded number from |value| and writes it out. The size of
|
||||||
// the coded number is determined by the value of |value|. |value| must not
|
// the coded number is determined by the value of |value|. |value| must not
|
||||||
@@ -52,10 +53,9 @@ int32 WriteID(IMkvWriter* writer, uint64 type);
|
|||||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value);
|
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 value);
|
||||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value);
|
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, float value);
|
||||||
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value);
|
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value);
|
||||||
bool WriteEbmlElement(IMkvWriter* writer,
|
bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value,
|
||||||
uint64 type,
|
|
||||||
const uint8* value,
|
|
||||||
uint64 size);
|
uint64 size);
|
||||||
|
bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value);
|
||||||
|
|
||||||
// Output an Mkv Simple Block.
|
// Output an Mkv Simple Block.
|
||||||
// Inputs:
|
// Inputs:
|
||||||
@@ -67,12 +67,8 @@ bool WriteEbmlElement(IMkvWriter* writer,
|
|||||||
// timecode: Relative timecode of the Block. Only values in the
|
// timecode: Relative timecode of the Block. Only values in the
|
||||||
// range [0, 2^15) are permitted.
|
// range [0, 2^15) are permitted.
|
||||||
// is_key: Non-zero value specifies that frame is a key frame.
|
// is_key: Non-zero value specifies that frame is a key frame.
|
||||||
uint64 WriteSimpleBlock(IMkvWriter* writer,
|
uint64 WriteSimpleBlock(IMkvWriter* writer, const uint8* data, uint64 length,
|
||||||
const uint8* data,
|
uint64 track_number, int64 timecode, uint64 is_key);
|
||||||
uint64 length,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 is_key);
|
|
||||||
|
|
||||||
// Output a metadata keyframe, using a Block Group element.
|
// Output a metadata keyframe, using a Block Group element.
|
||||||
// Inputs:
|
// Inputs:
|
||||||
@@ -84,11 +80,8 @@ uint64 WriteSimpleBlock(IMkvWriter* writer,
|
|||||||
// timecode Timecode of frame, relative to cluster timecode. Only
|
// timecode Timecode of frame, relative to cluster timecode. Only
|
||||||
// values in the range [0, 2^15) are permitted.
|
// values in the range [0, 2^15) are permitted.
|
||||||
// duration_timecode Duration of frame, using timecode units.
|
// duration_timecode Duration of frame, using timecode units.
|
||||||
uint64 WriteMetadataBlock(IMkvWriter* writer,
|
uint64 WriteMetadataBlock(IMkvWriter* writer, const uint8* data, uint64 length,
|
||||||
const uint8* data,
|
uint64 track_number, int64 timecode,
|
||||||
uint64 length,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 duration_timecode);
|
uint64 duration_timecode);
|
||||||
|
|
||||||
// Output an Mkv Block with BlockAdditional data.
|
// Output an Mkv Block with BlockAdditional data.
|
||||||
@@ -104,14 +97,10 @@ uint64 WriteMetadataBlock(IMkvWriter* writer,
|
|||||||
// timecode: Relative timecode of the Block. Only values in the
|
// timecode: Relative timecode of the Block. Only values in the
|
||||||
// range [0, 2^15) are permitted.
|
// range [0, 2^15) are permitted.
|
||||||
// is_key: Non-zero value specifies that frame is a key frame.
|
// is_key: Non-zero value specifies that frame is a key frame.
|
||||||
uint64 WriteBlockWithAdditional(IMkvWriter* writer,
|
uint64 WriteBlockWithAdditional(IMkvWriter* writer, const uint8* data,
|
||||||
const uint8* data,
|
uint64 length, const uint8* additional,
|
||||||
uint64 length,
|
uint64 additional_length, uint64 add_id,
|
||||||
const uint8* additional,
|
uint64 track_number, int64 timecode,
|
||||||
uint64 additional_length,
|
|
||||||
uint64 add_id,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 is_key);
|
uint64 is_key);
|
||||||
|
|
||||||
// Output an Mkv Block with a DiscardPadding element.
|
// Output an Mkv Block with a DiscardPadding element.
|
||||||
@@ -125,12 +114,9 @@ uint64 WriteBlockWithAdditional(IMkvWriter* writer,
|
|||||||
// timecode: Relative timecode of the Block. Only values in the
|
// timecode: Relative timecode of the Block. Only values in the
|
||||||
// range [0, 2^15) are permitted.
|
// range [0, 2^15) are permitted.
|
||||||
// is_key: Non-zero value specifies that frame is a key frame.
|
// is_key: Non-zero value specifies that frame is a key frame.
|
||||||
uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer,
|
uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, const uint8* data,
|
||||||
const uint8* data,
|
uint64 length, int64 discard_padding,
|
||||||
uint64 length,
|
uint64 track_number, int64 timecode,
|
||||||
int64 discard_padding,
|
|
||||||
uint64 track_number,
|
|
||||||
int64 timecode,
|
|
||||||
uint64 is_key);
|
uint64 is_key);
|
||||||
|
|
||||||
// Output a void element. |size| must be the entire size in bytes that will be
|
// Output a void element. |size| must be the entire size in bytes that will be
|
||||||
@@ -146,6 +132,6 @@ void GetVersion(int32* major, int32* minor, int32* build, int32* revision);
|
|||||||
// the random-number generator (see POSIX rand_r() for semantics).
|
// the random-number generator (see POSIX rand_r() for semantics).
|
||||||
uint64 MakeUID(unsigned int* seed);
|
uint64 MakeUID(unsigned int* seed);
|
||||||
|
|
||||||
} //end namespace mkvmuxer
|
} // end namespace mkvmuxer
|
||||||
|
|
||||||
#endif // MKVMUXERUTIL_HPP
|
#endif // MKVMUXERUTIL_HPP
|
||||||
|
4149
third_party/libwebm/mkvparser.cpp
vendored
4149
third_party/libwebm/mkvparser.cpp
vendored
File diff suppressed because it is too large
Load Diff
504
third_party/libwebm/mkvparser.hpp
vendored
504
third_party/libwebm/mkvparser.hpp
vendored
File diff suppressed because it is too large
Load Diff
41
third_party/libwebm/mkvreader.cpp
vendored
41
third_party/libwebm/mkvreader.cpp
vendored
@@ -10,17 +10,11 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
namespace mkvparser
|
namespace mkvparser {
|
||||||
{
|
|
||||||
|
|
||||||
MkvReader::MkvReader() :
|
MkvReader::MkvReader() : m_file(NULL), reader_owns_file_(true) {}
|
||||||
m_file(NULL),
|
|
||||||
reader_owns_file_(true) {
|
|
||||||
}
|
|
||||||
|
|
||||||
MkvReader::MkvReader(FILE* fp) :
|
MkvReader::MkvReader(FILE* fp) : m_file(fp), reader_owns_file_(false) {
|
||||||
m_file(fp),
|
|
||||||
reader_owns_file_(false) {
|
|
||||||
GetFileSize();
|
GetFileSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,8 +24,7 @@ MkvReader::~MkvReader() {
|
|||||||
m_file = NULL;
|
m_file = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MkvReader::Open(const char* fileName)
|
int MkvReader::Open(const char* fileName) {
|
||||||
{
|
|
||||||
if (fileName == NULL)
|
if (fileName == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -42,7 +35,7 @@ int MkvReader::Open(const char* fileName)
|
|||||||
const errno_t e = fopen_s(&m_file, fileName, "rb");
|
const errno_t e = fopen_s(&m_file, fileName, "rb");
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
return -1; //error
|
return -1; // error
|
||||||
#else
|
#else
|
||||||
m_file = fopen(fileName, "rb");
|
m_file = fopen(fileName, "rb");
|
||||||
|
|
||||||
@@ -59,7 +52,7 @@ bool MkvReader::GetFileSize() {
|
|||||||
int status = _fseeki64(m_file, 0L, SEEK_END);
|
int status = _fseeki64(m_file, 0L, SEEK_END);
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
return false; //error
|
return false; // error
|
||||||
|
|
||||||
m_length = _ftelli64(m_file);
|
m_length = _ftelli64(m_file);
|
||||||
#else
|
#else
|
||||||
@@ -75,7 +68,7 @@ bool MkvReader::GetFileSize() {
|
|||||||
status = _fseeki64(m_file, 0L, SEEK_SET);
|
status = _fseeki64(m_file, 0L, SEEK_SET);
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
return false; //error
|
return false; // error
|
||||||
#else
|
#else
|
||||||
fseek(m_file, 0L, SEEK_SET);
|
fseek(m_file, 0L, SEEK_SET);
|
||||||
#endif
|
#endif
|
||||||
@@ -83,17 +76,14 @@ bool MkvReader::GetFileSize() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MkvReader::Close()
|
void MkvReader::Close() {
|
||||||
{
|
if (m_file != NULL) {
|
||||||
if (m_file != NULL)
|
|
||||||
{
|
|
||||||
fclose(m_file);
|
fclose(m_file);
|
||||||
m_file = NULL;
|
m_file = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MkvReader::Length(long long* total, long long* available)
|
int MkvReader::Length(long long* total, long long* available) {
|
||||||
{
|
|
||||||
if (m_file == NULL)
|
if (m_file == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -106,8 +96,7 @@ int MkvReader::Length(long long* total, long long* available)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MkvReader::Read(long long offset, long len, unsigned char* buffer)
|
int MkvReader::Read(long long offset, long len, unsigned char* buffer) {
|
||||||
{
|
|
||||||
if (m_file == NULL)
|
if (m_file == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@@ -127,7 +116,7 @@ int MkvReader::Read(long long offset, long len, unsigned char* buffer)
|
|||||||
const int status = _fseeki64(m_file, offset, SEEK_SET);
|
const int status = _fseeki64(m_file, offset, SEEK_SET);
|
||||||
|
|
||||||
if (status)
|
if (status)
|
||||||
return -1; //error
|
return -1; // error
|
||||||
#else
|
#else
|
||||||
fseek(m_file, offset, SEEK_SET);
|
fseek(m_file, offset, SEEK_SET);
|
||||||
#endif
|
#endif
|
||||||
@@ -135,9 +124,9 @@ int MkvReader::Read(long long offset, long len, unsigned char* buffer)
|
|||||||
const size_t size = fread(buffer, 1, len, m_file);
|
const size_t size = fread(buffer, 1, len, m_file);
|
||||||
|
|
||||||
if (size < size_t(len))
|
if (size < size_t(len))
|
||||||
return -1; //error
|
return -1; // error
|
||||||
|
|
||||||
return 0; //success
|
return 0; // success
|
||||||
}
|
}
|
||||||
|
|
||||||
} //end namespace mkvparser
|
} // end namespace mkvparser
|
||||||
|
21
third_party/libwebm/mkvreader.hpp
vendored
21
third_party/libwebm/mkvreader.hpp
vendored
@@ -12,16 +12,12 @@
|
|||||||
#include "mkvparser.hpp"
|
#include "mkvparser.hpp"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
namespace mkvparser
|
namespace mkvparser {
|
||||||
{
|
|
||||||
|
|
||||||
class MkvReader : public IMkvReader
|
class MkvReader : public IMkvReader {
|
||||||
{
|
public:
|
||||||
MkvReader(const MkvReader&);
|
|
||||||
MkvReader& operator=(const MkvReader&);
|
|
||||||
public:
|
|
||||||
MkvReader();
|
MkvReader();
|
||||||
MkvReader(FILE* fp);
|
explicit MkvReader(FILE* fp);
|
||||||
virtual ~MkvReader();
|
virtual ~MkvReader();
|
||||||
|
|
||||||
int Open(const char*);
|
int Open(const char*);
|
||||||
@@ -29,7 +25,10 @@ public:
|
|||||||
|
|
||||||
virtual int Read(long long position, long length, unsigned char* buffer);
|
virtual int Read(long long position, long length, unsigned char* buffer);
|
||||||
virtual int Length(long long* total, long long* available);
|
virtual int Length(long long* total, long long* available);
|
||||||
private:
|
|
||||||
|
private:
|
||||||
|
MkvReader(const MkvReader&);
|
||||||
|
MkvReader& operator=(const MkvReader&);
|
||||||
|
|
||||||
// Determines the size of the file. This is called either by the constructor
|
// Determines the size of the file. This is called either by the constructor
|
||||||
// or by the Open function depending on file ownership. Returns true on
|
// or by the Open function depending on file ownership. Returns true on
|
||||||
@@ -41,6 +40,6 @@ private:
|
|||||||
bool reader_owns_file_;
|
bool reader_owns_file_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} //end namespace mkvparser
|
} // end namespace mkvparser
|
||||||
|
|
||||||
#endif //MKVREADER_HPP
|
#endif // MKVREADER_HPP
|
||||||
|
17
third_party/libwebm/mkvwriter.cpp
vendored
17
third_party/libwebm/mkvwriter.cpp
vendored
@@ -16,15 +16,11 @@
|
|||||||
|
|
||||||
namespace mkvmuxer {
|
namespace mkvmuxer {
|
||||||
|
|
||||||
MkvWriter::MkvWriter() : file_(NULL), writer_owns_file_(true) {
|
MkvWriter::MkvWriter() : file_(NULL), writer_owns_file_(true) {}
|
||||||
}
|
|
||||||
|
|
||||||
MkvWriter::MkvWriter(FILE* fp): file_(fp), writer_owns_file_(false) {
|
MkvWriter::MkvWriter(FILE* fp) : file_(fp), writer_owns_file_(false) {}
|
||||||
}
|
|
||||||
|
|
||||||
MkvWriter::~MkvWriter() {
|
MkvWriter::~MkvWriter() { Close(); }
|
||||||
Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
int32 MkvWriter::Write(const void* buffer, uint32 length) {
|
int32 MkvWriter::Write(const void* buffer, uint32 length) {
|
||||||
if (!file_)
|
if (!file_)
|
||||||
@@ -87,11 +83,8 @@ int32 MkvWriter::Position(int64 position) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MkvWriter::Seekable() const {
|
bool MkvWriter::Seekable() const { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MkvWriter::ElementStartNotify(uint64, int64) {
|
void MkvWriter::ElementStartNotify(uint64, int64) {}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mkvmuxer
|
} // namespace mkvmuxer
|
||||||
|
4
third_party/libwebm/mkvwriter.hpp
vendored
4
third_party/libwebm/mkvwriter.hpp
vendored
@@ -20,7 +20,7 @@ namespace mkvmuxer {
|
|||||||
class MkvWriter : public IMkvWriter {
|
class MkvWriter : public IMkvWriter {
|
||||||
public:
|
public:
|
||||||
MkvWriter();
|
MkvWriter();
|
||||||
MkvWriter(FILE* fp);
|
explicit MkvWriter(FILE* fp);
|
||||||
virtual ~MkvWriter();
|
virtual ~MkvWriter();
|
||||||
|
|
||||||
// IMkvWriter interface
|
// IMkvWriter interface
|
||||||
@@ -46,6 +46,6 @@ class MkvWriter : public IMkvWriter {
|
|||||||
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(MkvWriter);
|
LIBWEBM_DISALLOW_COPY_AND_ASSIGN(MkvWriter);
|
||||||
};
|
};
|
||||||
|
|
||||||
} //end namespace mkvmuxer
|
} // end namespace mkvmuxer
|
||||||
|
|
||||||
#endif // MKVWRITER_HPP
|
#endif // MKVWRITER_HPP
|
||||||
|
26
third_party/libwebm/webmids.hpp
vendored
26
third_party/libwebm/webmids.hpp
vendored
@@ -29,21 +29,21 @@ enum MkvId {
|
|||||||
kMkvSignatureElements = 0x7E5B,
|
kMkvSignatureElements = 0x7E5B,
|
||||||
kMkvSignatureElementList = 0x7E7B,
|
kMkvSignatureElementList = 0x7E7B,
|
||||||
kMkvSignedElement = 0x6532,
|
kMkvSignedElement = 0x6532,
|
||||||
//segment
|
// segment
|
||||||
kMkvSegment = 0x18538067,
|
kMkvSegment = 0x18538067,
|
||||||
//Meta Seek Information
|
// Meta Seek Information
|
||||||
kMkvSeekHead = 0x114D9B74,
|
kMkvSeekHead = 0x114D9B74,
|
||||||
kMkvSeek = 0x4DBB,
|
kMkvSeek = 0x4DBB,
|
||||||
kMkvSeekID = 0x53AB,
|
kMkvSeekID = 0x53AB,
|
||||||
kMkvSeekPosition = 0x53AC,
|
kMkvSeekPosition = 0x53AC,
|
||||||
//Segment Information
|
// Segment Information
|
||||||
kMkvInfo = 0x1549A966,
|
kMkvInfo = 0x1549A966,
|
||||||
kMkvTimecodeScale = 0x2AD7B1,
|
kMkvTimecodeScale = 0x2AD7B1,
|
||||||
kMkvDuration = 0x4489,
|
kMkvDuration = 0x4489,
|
||||||
kMkvDateUTC = 0x4461,
|
kMkvDateUTC = 0x4461,
|
||||||
kMkvMuxingApp = 0x4D80,
|
kMkvMuxingApp = 0x4D80,
|
||||||
kMkvWritingApp = 0x5741,
|
kMkvWritingApp = 0x5741,
|
||||||
//Cluster
|
// Cluster
|
||||||
kMkvCluster = 0x1F43B675,
|
kMkvCluster = 0x1F43B675,
|
||||||
kMkvTimecode = 0xE7,
|
kMkvTimecode = 0xE7,
|
||||||
kMkvPrevSize = 0xAB,
|
kMkvPrevSize = 0xAB,
|
||||||
@@ -58,7 +58,7 @@ enum MkvId {
|
|||||||
kMkvBlockAddID = 0xEE,
|
kMkvBlockAddID = 0xEE,
|
||||||
kMkvBlockAdditional = 0xA5,
|
kMkvBlockAdditional = 0xA5,
|
||||||
kMkvDiscardPadding = 0x75A2,
|
kMkvDiscardPadding = 0x75A2,
|
||||||
//Track
|
// Track
|
||||||
kMkvTracks = 0x1654AE6B,
|
kMkvTracks = 0x1654AE6B,
|
||||||
kMkvTrackEntry = 0xAE,
|
kMkvTrackEntry = 0xAE,
|
||||||
kMkvTrackNumber = 0xD7,
|
kMkvTrackNumber = 0xD7,
|
||||||
@@ -77,7 +77,7 @@ enum MkvId {
|
|||||||
kMkvCodecName = 0x258688,
|
kMkvCodecName = 0x258688,
|
||||||
kMkvCodecDelay = 0x56AA,
|
kMkvCodecDelay = 0x56AA,
|
||||||
kMkvSeekPreRoll = 0x56BB,
|
kMkvSeekPreRoll = 0x56BB,
|
||||||
//video
|
// video
|
||||||
kMkvVideo = 0xE0,
|
kMkvVideo = 0xE0,
|
||||||
kMkvFlagInterlaced = 0x9A,
|
kMkvFlagInterlaced = 0x9A,
|
||||||
kMkvStereoMode = 0x53B8,
|
kMkvStereoMode = 0x53B8,
|
||||||
@@ -93,15 +93,15 @@ enum MkvId {
|
|||||||
kMkvDisplayUnit = 0x54B2,
|
kMkvDisplayUnit = 0x54B2,
|
||||||
kMkvAspectRatioType = 0x54B3,
|
kMkvAspectRatioType = 0x54B3,
|
||||||
kMkvFrameRate = 0x2383E3,
|
kMkvFrameRate = 0x2383E3,
|
||||||
//end video
|
// end video
|
||||||
//audio
|
// audio
|
||||||
kMkvAudio = 0xE1,
|
kMkvAudio = 0xE1,
|
||||||
kMkvSamplingFrequency = 0xB5,
|
kMkvSamplingFrequency = 0xB5,
|
||||||
kMkvOutputSamplingFrequency = 0x78B5,
|
kMkvOutputSamplingFrequency = 0x78B5,
|
||||||
kMkvChannels = 0x9F,
|
kMkvChannels = 0x9F,
|
||||||
kMkvBitDepth = 0x6264,
|
kMkvBitDepth = 0x6264,
|
||||||
//end audio
|
// end audio
|
||||||
//ContentEncodings
|
// ContentEncodings
|
||||||
kMkvContentEncodings = 0x6D80,
|
kMkvContentEncodings = 0x6D80,
|
||||||
kMkvContentEncoding = 0x6240,
|
kMkvContentEncoding = 0x6240,
|
||||||
kMkvContentEncodingOrder = 0x5031,
|
kMkvContentEncodingOrder = 0x5031,
|
||||||
@@ -113,8 +113,8 @@ enum MkvId {
|
|||||||
kMkvContentEncAESSettings = 0x47E7,
|
kMkvContentEncAESSettings = 0x47E7,
|
||||||
kMkvAESSettingsCipherMode = 0x47E8,
|
kMkvAESSettingsCipherMode = 0x47E8,
|
||||||
kMkvAESSettingsCipherInitData = 0x47E9,
|
kMkvAESSettingsCipherInitData = 0x47E9,
|
||||||
//end ContentEncodings
|
// end ContentEncodings
|
||||||
//Cueing Data
|
// Cueing Data
|
||||||
kMkvCues = 0x1C53BB6B,
|
kMkvCues = 0x1C53BB6B,
|
||||||
kMkvCuePoint = 0xBB,
|
kMkvCuePoint = 0xBB,
|
||||||
kMkvCueTime = 0xB3,
|
kMkvCueTime = 0xB3,
|
||||||
@@ -122,7 +122,7 @@ enum MkvId {
|
|||||||
kMkvCueTrack = 0xF7,
|
kMkvCueTrack = 0xF7,
|
||||||
kMkvCueClusterPosition = 0xF1,
|
kMkvCueClusterPosition = 0xF1,
|
||||||
kMkvCueBlockNumber = 0x5378,
|
kMkvCueBlockNumber = 0x5378,
|
||||||
//Chapters
|
// Chapters
|
||||||
kMkvChapters = 0x1043A770,
|
kMkvChapters = 0x1043A770,
|
||||||
kMkvEditionEntry = 0x45B9,
|
kMkvEditionEntry = 0x45B9,
|
||||||
kMkvChapterAtom = 0xB6,
|
kMkvChapterAtom = 0xB6,
|
||||||
|
Reference in New Issue
Block a user