From 9ead078aafb8e2bbf9a9a43f761a3a800358ff97 Mon Sep 17 00:00:00 2001 From: Vignesh Venkatasubramanian Date: Mon, 14 Apr 2014 10:28:59 -0700 Subject: [PATCH] clang-format on mkvmuxerutil.[ch]pp Conformance of mkvmuxerutil.[ch]pp to Google C++ style guide. Change-Id: Ib66b73adb2682cd5560f6f363fc04d75ab3815c6 --- mkvmuxerutil.cpp | 123 +++++++++++++++++++---------------------------- mkvmuxerutil.hpp | 44 ++++++----------- 2 files changed, 63 insertions(+), 104 deletions(-) diff --git a/mkvmuxerutil.cpp b/mkvmuxerutil.cpp index 2424da5..3fb9bc9 100644 --- a/mkvmuxerutil.cpp +++ b/mkvmuxerutil.cpp @@ -99,7 +99,7 @@ uint64 EbmlElementSize(uint64 type, uint64 value) { return ebml_size; } -uint64 EbmlElementSize(uint64 type, float /* value */ ) { +uint64 EbmlElementSize(uint64 type, float /* value */) { // Size of EBML ID uint64 ebml_size = GetUIntSize(type); @@ -322,9 +322,7 @@ bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const char* value) { return true; } -bool WriteEbmlElement(IMkvWriter* writer, - uint64 type, - const uint8* value, +bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value, uint64 size) { if (!writer || !value || size < 1) return false; @@ -357,12 +355,8 @@ bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value) { return true; } -uint64 WriteSimpleBlock(IMkvWriter* writer, - const uint8* data, - uint64 length, - uint64 track_number, - int64 timecode, - uint64 is_key) { +uint64 WriteSimpleBlock(IMkvWriter* writer, const uint8* data, uint64 length, + uint64 track_number, int64 timecode, uint64 is_key) { if (!writer) return false; @@ -408,7 +402,7 @@ uint64 WriteSimpleBlock(IMkvWriter* writer, return 0; const uint64 element_size = - GetUIntSize(kMkvSimpleBlock) + GetCodedUIntSize(size) + 4 + length; + GetUIntSize(kMkvSimpleBlock) + GetCodedUIntSize(size) + 4 + length; return element_size; } @@ -427,11 +421,8 @@ uint64 WriteSimpleBlock(IMkvWriter* writer, // Duration size // (duration payload) // -uint64 WriteMetadataBlock(IMkvWriter* writer, - const uint8* data, - uint64 length, - uint64 track_number, - int64 timecode, +uint64 WriteMetadataBlock(IMkvWriter* writer, const uint8* data, uint64 length, + uint64 track_number, int64 timecode, uint64 duration) { // We don't backtrack when writing to the stream, so we must // pre-compute the BlockGroup size, by summing the sizes of each @@ -523,47 +514,37 @@ uint64 WriteMetadataBlock(IMkvWriter* writer, // 1 (Denotes Alpha) // BlockAdditional // Data -uint64 WriteBlockWithAdditional(IMkvWriter* writer, - const uint8* data, - uint64 length, - const uint8* additional, - uint64 additional_length, - uint64 add_id, - uint64 track_number, - int64 timecode, +uint64 WriteBlockWithAdditional(IMkvWriter* writer, const uint8* data, + uint64 length, const uint8* additional, + uint64 additional_length, uint64 add_id, + uint64 track_number, int64 timecode, uint64 is_key) { if (!data || !additional || length < 1 || additional_length < 1) return 0; const uint64 block_payload_size = 4 + length; - const uint64 block_elem_size = EbmlMasterElementSize(kMkvBlock, - block_payload_size) + - block_payload_size; - const uint64 block_additional_elem_size = EbmlElementSize(kMkvBlockAdditional, - additional, - additional_length); + const uint64 block_elem_size = + EbmlMasterElementSize(kMkvBlock, block_payload_size) + block_payload_size; + const uint64 block_additional_elem_size = + EbmlElementSize(kMkvBlockAdditional, additional, additional_length); const uint64 block_addid_elem_size = EbmlElementSize(kMkvBlockAddID, add_id); - const uint64 block_more_payload_size = block_addid_elem_size + - block_additional_elem_size; - const uint64 block_more_elem_size = EbmlMasterElementSize( - kMkvBlockMore, - block_more_payload_size) + - block_more_payload_size; + const uint64 block_more_payload_size = + block_addid_elem_size + block_additional_elem_size; + const uint64 block_more_elem_size = + EbmlMasterElementSize(kMkvBlockMore, block_more_payload_size) + + block_more_payload_size; const uint64 block_additions_payload_size = block_more_elem_size; - const uint64 block_additions_elem_size = EbmlMasterElementSize( - kMkvBlockAdditions, - block_additions_payload_size) + - block_additions_payload_size; - const uint64 block_group_payload_size = block_elem_size + - block_additions_elem_size; - const uint64 block_group_elem_size = EbmlMasterElementSize( - kMkvBlockGroup, - block_group_payload_size) + - block_group_payload_size; + const uint64 block_additions_elem_size = + EbmlMasterElementSize(kMkvBlockAdditions, block_additions_payload_size) + + block_additions_payload_size; + const uint64 block_group_payload_size = + block_elem_size + block_additions_elem_size; + const uint64 block_group_elem_size = + EbmlMasterElementSize(kMkvBlockGroup, block_group_payload_size) + + block_group_payload_size; - if (!WriteEbmlMasterElement(writer, kMkvBlockGroup, - block_group_payload_size)) + if (!WriteEbmlMasterElement(writer, kMkvBlockGroup, block_group_payload_size)) return 0; if (!WriteEbmlMasterElement(writer, kMkvBlock, block_payload_size)) @@ -594,8 +575,8 @@ uint64 WriteBlockWithAdditional(IMkvWriter* writer, if (!WriteEbmlElement(writer, kMkvBlockAddID, add_id)) return 0; - if (!WriteEbmlElement(writer, kMkvBlockAdditional, - additional, additional_length)) + if (!WriteEbmlElement(writer, kMkvBlockAdditional, additional, + additional_length)) return 0; return block_group_elem_size; @@ -607,31 +588,25 @@ uint64 WriteBlockWithAdditional(IMkvWriter* writer, // Block // Data // DiscardPadding -uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, - const uint8* data, - uint64 length, - int64 discard_padding, - uint64 track_number, - int64 timecode, +uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, const uint8* data, + uint64 length, int64 discard_padding, + uint64 track_number, int64 timecode, uint64 is_key) { if (!data || length < 1 || discard_padding <= 0) return 0; const uint64 block_payload_size = 4 + length; - const uint64 block_elem_size = EbmlMasterElementSize(kMkvBlock, - block_payload_size) + - block_payload_size; - const uint64 discard_padding_elem_size = EbmlElementSize(kMkvDiscardPadding, - discard_padding); - const uint64 block_group_payload_size = block_elem_size + - discard_padding_elem_size; - const uint64 block_group_elem_size = EbmlMasterElementSize( - kMkvBlockGroup, - block_group_payload_size) + - block_group_payload_size; + const uint64 block_elem_size = + EbmlMasterElementSize(kMkvBlock, block_payload_size) + block_payload_size; + const uint64 discard_padding_elem_size = + EbmlElementSize(kMkvDiscardPadding, discard_padding); + const uint64 block_group_payload_size = + block_elem_size + discard_padding_elem_size; + const uint64 block_group_elem_size = + EbmlMasterElementSize(kMkvBlockGroup, block_group_payload_size) + + block_group_payload_size; - if (!WriteEbmlMasterElement(writer, kMkvBlockGroup, - block_group_payload_size)) + if (!WriteEbmlMasterElement(writer, kMkvBlockGroup, block_group_payload_size)) return 0; if (!WriteEbmlMasterElement(writer, kMkvBlock, block_payload_size)) @@ -670,9 +645,9 @@ uint64 WriteVoidElement(IMkvWriter* writer, uint64 size) { return false; // Subtract one for the void ID and the coded size. - uint64 void_entry_size = size - 1 - GetCodedUIntSize(size-1); - uint64 void_size = EbmlMasterElementSize(kMkvVoid, void_entry_size) + - void_entry_size; + uint64 void_entry_size = size - 1 - GetCodedUIntSize(size - 1); + uint64 void_size = + EbmlMasterElementSize(kMkvVoid, void_entry_size) + void_entry_size; if (void_size != size) return 0; @@ -720,13 +695,13 @@ mkvmuxer::uint64 mkvmuxer::MakeUID(unsigned int* seed) { for (int i = 0; i < 7; ++i) { // avoid problems with 8-byte values 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 (void)seed; unsigned int random_value; const errno_t e = rand_s(&random_value); (void)e; - const int32 nn = random_value; + const int32 nn = random_value; #elif __ANDROID__ int32 temp_num = 1; int fd = open("/dev/urandom", O_RDONLY); diff --git a/mkvmuxerutil.hpp b/mkvmuxerutil.hpp index 31532c4..a092abe 100644 --- a/mkvmuxerutil.hpp +++ b/mkvmuxerutil.hpp @@ -53,9 +53,7 @@ int32 WriteID(IMkvWriter* writer, uint64 type); bool WriteEbmlElement(IMkvWriter* writer, uint64 type, uint64 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 uint8* value, +bool WriteEbmlElement(IMkvWriter* writer, uint64 type, const uint8* value, uint64 size); bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value); @@ -69,12 +67,8 @@ bool WriteEbmlDateElement(IMkvWriter* writer, uint64 type, int64 value); // timecode: Relative timecode of the Block. Only values in the // range [0, 2^15) are permitted. // is_key: Non-zero value specifies that frame is a key frame. -uint64 WriteSimpleBlock(IMkvWriter* writer, - const uint8* data, - uint64 length, - uint64 track_number, - int64 timecode, - uint64 is_key); +uint64 WriteSimpleBlock(IMkvWriter* writer, const uint8* data, uint64 length, + uint64 track_number, int64 timecode, uint64 is_key); // Output a metadata keyframe, using a Block Group element. // Inputs: @@ -86,11 +80,8 @@ uint64 WriteSimpleBlock(IMkvWriter* writer, // timecode Timecode of frame, relative to cluster timecode. Only // values in the range [0, 2^15) are permitted. // duration_timecode Duration of frame, using timecode units. -uint64 WriteMetadataBlock(IMkvWriter* writer, - const uint8* data, - uint64 length, - uint64 track_number, - int64 timecode, +uint64 WriteMetadataBlock(IMkvWriter* writer, const uint8* data, uint64 length, + uint64 track_number, int64 timecode, uint64 duration_timecode); // Output an Mkv Block with BlockAdditional data. @@ -106,14 +97,10 @@ uint64 WriteMetadataBlock(IMkvWriter* writer, // timecode: Relative timecode of the Block. Only values in the // range [0, 2^15) are permitted. // is_key: Non-zero value specifies that frame is a key frame. -uint64 WriteBlockWithAdditional(IMkvWriter* writer, - const uint8* data, - uint64 length, - const uint8* additional, - uint64 additional_length, - uint64 add_id, - uint64 track_number, - int64 timecode, +uint64 WriteBlockWithAdditional(IMkvWriter* writer, const uint8* data, + uint64 length, const uint8* additional, + uint64 additional_length, uint64 add_id, + uint64 track_number, int64 timecode, uint64 is_key); // Output an Mkv Block with a DiscardPadding element. @@ -127,12 +114,9 @@ uint64 WriteBlockWithAdditional(IMkvWriter* writer, // timecode: Relative timecode of the Block. Only values in the // range [0, 2^15) are permitted. // is_key: Non-zero value specifies that frame is a key frame. -uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, - const uint8* data, - uint64 length, - int64 discard_padding, - uint64 track_number, - int64 timecode, +uint64 WriteBlockWithDiscardPadding(IMkvWriter* writer, const uint8* data, + uint64 length, int64 discard_padding, + uint64 track_number, int64 timecode, uint64 is_key); // Output a void element. |size| must be the entire size in bytes that will be @@ -148,6 +132,6 @@ void GetVersion(int32* major, int32* minor, int32* build, int32* revision); // the random-number generator (see POSIX rand_r() for semantics). uint64 MakeUID(unsigned int* seed); -} //end namespace mkvmuxer +} // end namespace mkvmuxer -#endif // MKVMUXERUTIL_HPP +#endif // MKVMUXERUTIL_HPP