X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fsubtitle_analysis.cc;h=0838816b04a823fcd8e3201da5001c6f9a41f77d;hp=91fec90b06cc70231de683da718bd51a081ad4de;hb=2d4e8c5f69cc694625ad95dcee554499605f823b;hpb=cef7a679a59044a5c807768042deecfd56ec6fc2 diff --git a/src/lib/subtitle_analysis.cc b/src/lib/subtitle_analysis.cc index 91fec90b0..0838816b0 100644 --- a/src/lib/subtitle_analysis.cc +++ b/src/lib/subtitle_analysis.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington + Copyright (C) 2020-2021 Carl Hetherington This file is part of DCP-o-matic. @@ -18,15 +18,22 @@ */ + #include "subtitle_analysis.h" #include "exceptions.h" +#include "warnings.h" #include #include +DCPOMATIC_DISABLE_WARNINGS #include +DCPOMATIC_ENABLE_WARNINGS + +using std::make_shared; +using std::shared_ptr; using std::string; using dcp::raw_convert; -using boost::shared_ptr; + int const SubtitleAnalysis::_current_state_version = 1; @@ -39,7 +46,7 @@ SubtitleAnalysis::SubtitleAnalysis (boost::filesystem::path path) if (f.optional_number_child("Version").get_value_or(1) < _current_state_version) { /* Too old. Throw an exception so that this analysis is re-run. */ - throw OldFormatError ("Audio analysis file is too old"); + throw OldFormatError ("Subtitle analysis file is too old"); } cxml::NodePtr bounding_box = f.optional_node_child("BoundingBox"); @@ -50,26 +57,31 @@ SubtitleAnalysis::SubtitleAnalysis (boost::filesystem::path path) _bounding_box->width = bounding_box->number_child("Width"); _bounding_box->height = bounding_box->number_child("Height"); } + + _analysis_x_offset = f.number_child("AnalysisXOffset"); + _analysis_y_offset = f.number_child("AnalysisYOffset"); } void SubtitleAnalysis::write (boost::filesystem::path path) const { - shared_ptr doc (new xmlpp::Document); + auto doc = make_shared(); xmlpp::Element* root = doc->create_root_node ("SubtitleAnalysis"); root->add_child("Version")->add_child_text (raw_convert(_current_state_version)); if (_bounding_box) { - xmlpp::Element* bounding_box = root->add_child("BoundingBox"); + auto bounding_box = root->add_child("BoundingBox"); bounding_box->add_child("X")->add_child_text(raw_convert(_bounding_box->x)); bounding_box->add_child("Y")->add_child_text(raw_convert(_bounding_box->y)); bounding_box->add_child("Width")->add_child_text(raw_convert(_bounding_box->width)); bounding_box->add_child("Height")->add_child_text(raw_convert(_bounding_box->height)); } + root->add_child("AnalysisXOffset")->add_child_text(raw_convert(_analysis_x_offset)); + root->add_child("AnalysisYOffset")->add_child_text(raw_convert(_analysis_y_offset)); + doc->write_to_file_formatted (path.string()); } -