From 23b3d6d7a6551e436cc44c44e78547cb34558d73 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sat, 22 Jul 2017 12:38:05 +0200 Subject: [PATCH] kax_analyzer_c: allow caller to take care of mandatory elements Chapters and tags in WebM only allow a subset of elements, among them certain elements that are mandatory in Matroska. So if the caller is already aware of that, it can take care of them properly so that the analyzer doesn't have to anymore. --- src/common/kax_analyzer.cpp | 11 +++++++---- src/common/kax_analyzer.h | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/common/kax_analyzer.cpp b/src/common/kax_analyzer.cpp index cc8fc396d..129355f91 100644 --- a/src/common/kax_analyzer.cpp +++ b/src/common/kax_analyzer.cpp @@ -412,17 +412,20 @@ kax_analyzer_c::read_element(kax_analyzer_data_c const &element_data) { kax_analyzer_c::update_element_result_e kax_analyzer_c::update_element(ebml_element_cptr const &e, - bool write_defaults) { - return update_element(e.get(), write_defaults); + bool write_defaults, + bool add_mandatory_elements_if_missing) { + return update_element(e.get(), write_defaults, add_mandatory_elements_if_missing); } kax_analyzer_c::update_element_result_e kax_analyzer_c::update_element(EbmlElement *e, - bool write_defaults) { + bool write_defaults, + bool add_mandatory_elements_if_missing) { try { reopen_file_for_writing(); - fix_mandatory_elements(e); + if (add_mandatory_elements_if_missing) + fix_mandatory_elements(e); remove_voids_from_master(e); placement_strategy_e strategy = get_placement_strategy_for(e); diff --git a/src/common/kax_analyzer.h b/src/common/kax_analyzer.h index 66e9b9bd0..e2b4a7c68 100644 --- a/src/common/kax_analyzer.h +++ b/src/common/kax_analyzer.h @@ -120,8 +120,8 @@ public: kax_analyzer_c(mm_io_c *file); virtual ~kax_analyzer_c(); - virtual update_element_result_e update_element(EbmlElement *e, bool write_defaults = false); - virtual update_element_result_e update_element(ebml_element_cptr const &e, bool write_defaults = false); + virtual update_element_result_e update_element(EbmlElement *e, bool write_defaults = false, bool add_mandatory_elements_if_missing = true); + virtual update_element_result_e update_element(ebml_element_cptr const &e, bool write_defaults = false, bool add_mandatory_elements_if_missing = true); virtual update_element_result_e remove_elements(EbmlId const &id);