diff --git a/src/common/ebml.cpp b/src/common/ebml.cpp index 1a867a917..61fe81526 100644 --- a/src/common/ebml.cpp +++ b/src/common/ebml.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -593,3 +594,22 @@ fix_mandatory_elements(EbmlElement *master) { else if (NULL != dynamic_cast(master)) fix_mandatory_chapter_elements(master); } + +void +remove_voids_from_master(EbmlElement *element) { + EbmlMaster *master = dynamic_cast(element); + if (NULL == master) + return; + + size_t idx = 0; + while (master->ListSize() > idx) { + element = (*master)[idx]; + if (NULL != dynamic_cast(element)) + master->Remove(idx); + + else { + remove_voids_from_master(element); + ++idx; + } + } +} diff --git a/src/common/ebml.h b/src/common/ebml.h index d0bf25496..623513b4a 100644 --- a/src/common/ebml.h +++ b/src/common/ebml.h @@ -183,6 +183,7 @@ GetFirstOrNextChild(EbmlMaster *master, EbmlElement *MTX_DLL_API empty_ebml_master(EbmlElement *e); EbmlElement *MTX_DLL_API create_ebml_element(const EbmlCallbacks &callbacks, const EbmlId &id); EbmlMaster *MTX_DLL_API sort_ebml_master(EbmlMaster *e); +void MTX_DLL_API remove_voids_from_master(EbmlElement *element); const EbmlCallbacks *MTX_DLL_API find_ebml_callbacks(const EbmlCallbacks &base, const EbmlId &id); const EbmlCallbacks *MTX_DLL_API find_ebml_callbacks(const EbmlCallbacks &base, const char *debug_name); diff --git a/src/common/kax_analyzer.cpp b/src/common/kax_analyzer.cpp index ba7a0124c..c5f6a3a8c 100644 --- a/src/common/kax_analyzer.cpp +++ b/src/common/kax_analyzer.cpp @@ -326,6 +326,7 @@ kax_analyzer_c::update_element(EbmlElement *e, reopen_file(); fix_mandatory_elements(e); + remove_voids_from_master(e); placement_strategy_e strategy = get_placement_strategy_for(e);