Helper function for writing an EBML element's head (ID + size fields)

This commit is contained in:
Moritz Bunkus 2013-04-15 22:06:31 +02:00
parent 6a187a8702
commit 52710b5bea
2 changed files with 16 additions and 0 deletions

View File

@ -515,3 +515,17 @@ remove_voids_from_master(EbmlElement *element) {
if (master)
DeleteChildren<EbmlVoid>(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);
}

View File

@ -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