diff --git a/src/common/ebml.cpp b/src/common/ebml.cpp index a3068e4b7..2cb291d9c 100644 --- a/src/common/ebml.cpp +++ b/src/common/ebml.cpp @@ -515,3 +515,17 @@ remove_voids_from_master(EbmlElement *element) { if (master) DeleteChildren(master); } + +int +write_ebml_element_head(mm_io_c &out, + EbmlId const &id, + int64_t content_size) { + int id_size = EBML_ID_LENGTH(id); + int coded_size = CodedSizeLength(content_size, 0); + uint8_t buffer[4 + 8]; + + id.Fill(buffer); + CodedValueLength(content_size, coded_size, &buffer[id_size]); + + return out.write(buffer, id_size + coded_size); +} diff --git a/src/common/ebml.h b/src/common/ebml.h index af5ec16ad..4ac0d08b0 100644 --- a/src/common/ebml.h +++ b/src/common/ebml.h @@ -45,6 +45,8 @@ int kt_get_a_bps(KaxTrackEntry &track); int kt_get_v_pixel_width(KaxTrackEntry &track); int kt_get_v_pixel_height(KaxTrackEntry &track); +int write_ebml_element_head(mm_io_c &out, EbmlId const &id, int64_t content_size); + #define is_id(e, ref) (EbmlId(*e) == EBML_ID(ref)) #if !defined(EBML_INFO) #define EBML_INFO(ref) ref::ClassInfos