diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-23 15:32:01 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-23 17:34:47 +0100 |
| commit | 77f52850eb56fa72bca3c072e9445649dc85493c (patch) | |
| tree | 19c0059c2a30b71028dfaa64f073ec8893546e66 /src | |
| parent | a66f89834d66c089d3328f36d319821d110b7ea1 (diff) | |
Use fmt for conversions from number to string (instead of raw_convert).
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset_map.cc | 5 | ||||
| -rw-r--r-- | src/combine.cc | 4 | ||||
| -rw-r--r-- | src/cpl.cc | 17 | ||||
| -rw-r--r-- | src/interop_text_asset.cc | 4 | ||||
| -rw-r--r-- | src/pkl.cc | 4 | ||||
| -rw-r--r-- | src/reel_asset.cc | 10 | ||||
| -rw-r--r-- | src/reel_markers_asset.cc | 4 | ||||
| -rw-r--r-- | src/reel_picture_asset.cc | 4 | ||||
| -rw-r--r-- | src/smpte_text_asset.cc | 5 | ||||
| -rw-r--r-- | src/text_asset_internal.cc | 31 | ||||
| -rw-r--r-- | src/types.cc | 3 | ||||
| -rw-r--r-- | src/verify.cc | 16 | ||||
| -rw-r--r-- | src/verify_j2k.cc | 21 |
13 files changed, 66 insertions, 62 deletions
diff --git a/src/asset_map.cc b/src/asset_map.cc index 0ee4b486..b8d455fe 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -36,11 +36,12 @@ #include "dcp_assert.h" #include "exceptions.h" #include "filesystem.h" -#include "raw_convert.h" +#include "util.h" #include "warnings.h" LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> #include <boost/algorithm/string.hpp> @@ -214,6 +215,6 @@ AssetMap::Asset::write_xml(xmlpp::Element* asset_list, boost::filesystem::path d cxml::add_text_child(chunk, "Path", relative_path->generic_string()); cxml::add_text_child(chunk, "VolumeIndex", "1"); cxml::add_text_child(chunk, "Offset", "0"); - cxml::add_text_child(chunk, "Length", raw_convert<string>(filesystem::file_size(_path))); + cxml::add_text_child(chunk, "Length", fmt::to_string(filesystem::file_size(_path))); } diff --git a/src/combine.cc b/src/combine.cc index 74456bfb..3320aab2 100644 --- a/src/combine.cc +++ b/src/combine.cc @@ -46,7 +46,7 @@ #include "filesystem.h" #include "font_asset.h" #include "interop_text_asset.h" -#include "raw_convert.h" +#include <fmt/core.h> #include <boost/filesystem.hpp> #include <set> #include <string> @@ -70,7 +70,7 @@ make_unique (boost::filesystem::path path) } for (int i = 0; i < 10000; ++i) { - boost::filesystem::path p = path.parent_path() / (path.stem().string() + dcp::raw_convert<string>(i) + path.extension().string()); + boost::filesystem::path p = path.parent_path() / (path.stem().string() + fmt::to_string(i) + path.extension().string()); if (!dcp::filesystem::exists(p)) { return p; } @@ -62,6 +62,7 @@ LIBDCP_ENABLE_WARNINGS LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> #include <boost/algorithm/string.hpp> @@ -448,7 +449,7 @@ CPL::write_mca_subdescriptors(xmlpp::Element* parent, shared_ptr<const SoundAsse cxml::add_child(ch, "MCATagName", string("r1"))->add_child_text(buffer); } if (!channel->MCAChannelID.empty()) { - cxml::add_child(ch, "MCAChannelID", string("r1"))->add_child_text(raw_convert<string>(channel->MCAChannelID.get())); + cxml::add_child(ch, "MCAChannelID", string("r1"))->add_child_text(fmt::to_string(channel->MCAChannelID.get())); } if (!channel->RFC5646SpokenLanguage.empty()) { channel->RFC5646SpokenLanguage.get().EncodeString(buffer, sizeof(buffer)); @@ -487,7 +488,7 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m auto mp = _reels.front()->main_picture(); cxml::add_text_child(meta, "EditRate", mp->edit_rate().as_string()); - cxml::add_text_child(meta, "IntrinsicDuration", raw_convert<string>(mp->intrinsic_duration())); + cxml::add_text_child(meta, "IntrinsicDuration", fmt::to_string(mp->intrinsic_duration())); auto fctt = cxml::add_child(meta, "FullContentTitleText", string("meta")); if (_full_content_title_text && !_full_content_title_text->empty()) { @@ -503,7 +504,7 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m if (_version_number) { auto vn = cxml::add_child(meta, "VersionNumber", string("meta")); - vn->add_child_text(raw_convert<string>(*_version_number)); + vn->add_child_text(fmt::to_string(*_version_number)); if (_status) { vn->set_attribute("status", status_to_string(*_status)); } @@ -535,15 +536,15 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m if (_main_sound_configuration) { cxml::add_child(meta, "MainSoundConfiguration", string("meta"))->add_child_text(_main_sound_configuration->to_string()); } - cxml::add_child(meta, "MainSoundSampleRate", string("meta"))->add_child_text(raw_convert<string>(*_main_sound_sample_rate) + " 1"); + cxml::add_child(meta, "MainSoundSampleRate", string("meta"))->add_child_text(fmt::to_string(*_main_sound_sample_rate) + " 1"); auto stored = cxml::add_child(meta, "MainPictureStoredArea", string("meta")); - cxml::add_child(stored, "Width", string("meta"))->add_child_text(raw_convert<string>(_main_picture_stored_area->width)); - cxml::add_child(stored, "Height", string("meta"))->add_child_text(raw_convert<string>(_main_picture_stored_area->height)); + cxml::add_child(stored, "Width", string("meta"))->add_child_text(fmt::to_string(_main_picture_stored_area->width)); + cxml::add_child(stored, "Height", string("meta"))->add_child_text(fmt::to_string(_main_picture_stored_area->height)); auto active = cxml::add_child(meta, "MainPictureActiveArea", string("meta")); - cxml::add_child(active, "Width", string("meta"))->add_child_text(raw_convert<string>(_main_picture_active_area->width)); - cxml::add_child(active, "Height", string("meta"))->add_child_text(raw_convert<string>(_main_picture_active_area->height)); + cxml::add_child(active, "Width", string("meta"))->add_child_text(fmt::to_string(_main_picture_active_area->width)); + cxml::add_child(active, "Height", string("meta"))->add_child_text(fmt::to_string(_main_picture_active_area->height)); optional<string> first_subtitle_language; for (auto i: _reels) { diff --git a/src/interop_text_asset.cc b/src/interop_text_asset.cc index 01e0f89a..4650904f 100644 --- a/src/interop_text_asset.cc +++ b/src/interop_text_asset.cc @@ -45,7 +45,6 @@ #include "file.h" #include "interop_load_font_node.h" #include "interop_text_asset.h" -#include "raw_convert.h" #include "text_asset_internal.h" #include "text_image.h" #include "util.h" @@ -54,6 +53,7 @@ LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> #include <boost/weak_ptr.hpp> #include <cmath> #include <cstdio> @@ -117,7 +117,7 @@ InteropTextAsset::xml_as_string() const cxml::add_text_child(root, "SubtitleID", _id); cxml::add_text_child(root, "MovieTitle", _movie_title); - cxml::add_text_child(root, "ReelNumber", raw_convert<string> (_reel_number)); + cxml::add_text_child(root, "ReelNumber", fmt::to_string(_reel_number)); cxml::add_text_child(root, "Language", _language); for (auto i: _load_font_nodes) { @@ -41,13 +41,13 @@ #include "exceptions.h" #include "filesystem.h" #include "pkl.h" -#include "raw_convert.h" #include "util.h" #include "warnings.h" #include "verify.h" LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> #include <iostream> @@ -137,7 +137,7 @@ PKL::write_xml (boost::filesystem::path file, shared_ptr<const CertificateChain> cxml::add_text_child(asset, "AnnotationText", *i->annotation_text()); } cxml::add_text_child(asset, "Hash", i->hash()); - cxml::add_text_child(asset, "Size", raw_convert<string>(i->size())); + cxml::add_text_child(asset, "Size", fmt::to_string(i->size())); cxml::add_text_child(asset, "Type", i->type()); if (auto filename = i->original_filename()) { cxml::add_text_child(asset, "OriginalFileName", *filename); diff --git a/src/reel_asset.cc b/src/reel_asset.cc index 1d3d1d1f..46812e49 100644 --- a/src/reel_asset.cc +++ b/src/reel_asset.cc @@ -41,13 +41,13 @@ #include "compose.hpp" #include "dcp_assert.h" #include "equality_options.h" -#include "raw_convert.h" #include "reel_asset.h" #include "warnings.h" #include <libcxml/cxml.h> LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> using std::make_pair; @@ -102,12 +102,12 @@ ReelAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const cxml::add_text_child(a, "AnnotationText", *_annotation_text); } cxml::add_text_child(a, "EditRate", _edit_rate.as_string()); - cxml::add_text_child(a, "IntrinsicDuration", raw_convert<string>(_intrinsic_duration)); + cxml::add_text_child(a, "IntrinsicDuration", fmt::to_string(_intrinsic_duration)); if (_entry_point) { - cxml::add_text_child(a, "EntryPoint", raw_convert<string>(*_entry_point)); + cxml::add_text_child(a, "EntryPoint", fmt::to_string(*_entry_point)); } if (_duration) { - cxml::add_text_child(a, "Duration", raw_convert<string>(*_duration)); + cxml::add_text_child(a, "Duration", fmt::to_string(*_duration)); } return a; } @@ -131,7 +131,7 @@ template <class T> string optional_to_string (optional<T> o) { - return o ? raw_convert<string>(*o) : "[none]"; + return o ? fmt::to_string(*o) : "[none]"; } diff --git a/src/reel_markers_asset.cc b/src/reel_markers_asset.cc index ce3891f4..91d8948d 100644 --- a/src/reel_markers_asset.cc +++ b/src/reel_markers_asset.cc @@ -38,12 +38,12 @@ #include "dcp_assert.h" -#include "raw_convert.h" #include "reel_markers_asset.h" #include "warnings.h" LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> using std::string; @@ -113,7 +113,7 @@ ReelMarkersAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const for (auto const& i: _markers) { auto m = cxml::add_child(ml, "Marker"); cxml::add_text_child(m, "Label", marker_to_string(i.first)); - cxml::add_text_child(m, "Offset", raw_convert<string>(i.second.as_editable_units_ceil(tcr))); + cxml::add_text_child(m, "Offset", fmt::to_string(i.second.as_editable_units_ceil(tcr))); } return asset; diff --git a/src/reel_picture_asset.cc b/src/reel_picture_asset.cc index 37a6bfcc..cd6fef44 100644 --- a/src/reel_picture_asset.cc +++ b/src/reel_picture_asset.cc @@ -40,13 +40,13 @@ #include "compose.hpp" #include "dcp_assert.h" #include "j2k_picture_asset.h" -#include "raw_convert.h" #include "reel_picture_asset.h" #include "warnings.h" #include <libcxml/cxml.h> LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> #include <iomanip> #include <cmath> @@ -113,7 +113,7 @@ ReelPictureAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const } } - cxml::add_text_child(asset, "ScreenAspectRatio", raw_convert<string>(closest.get(), 2, true)); + cxml::add_text_child(asset, "ScreenAspectRatio", fmt::format("{:.2f}", closest.get())); } else { cxml::add_text_child( asset, diff --git a/src/smpte_text_asset.cc b/src/smpte_text_asset.cc index f92a091a..18ea27d9 100644 --- a/src/smpte_text_asset.cc +++ b/src/smpte_text_asset.cc @@ -56,6 +56,7 @@ LIBDCP_DISABLE_WARNINGS #include <asdcp/KM_log.h> #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS +#include <fmt/core.h> #include <boost/algorithm/string.hpp> @@ -379,13 +380,13 @@ SMPTETextAsset::xml_as_string() const } cxml::add_text_child(root, "IssueDate", _issue_date.as_string(false, false)); if (_reel_number) { - cxml::add_text_child(root, "ReelNumber", raw_convert<string>(_reel_number.get())); + cxml::add_text_child(root, "ReelNumber", fmt::to_string(_reel_number.get())); } if (_language) { cxml::add_text_child(root, "Language", _language.get()); } cxml::add_text_child(root, "EditRate", _edit_rate.as_string()); - cxml::add_text_child(root, "TimeCodeRate", raw_convert<string>(_time_code_rate)); + cxml::add_text_child(root, "TimeCodeRate", fmt::to_string(_time_code_rate)); if (_start_time) { cxml::add_text_child(root, "StartTime", _start_time.get().as_string(Standard::SMPTE)); } diff --git a/src/text_asset_internal.cc b/src/text_asset_internal.cc index aba26edd..bd4355e5 100644 --- a/src/text_asset_internal.cc +++ b/src/text_asset_internal.cc @@ -40,6 +40,7 @@ #include "text_asset_internal.h" #include "text_string.h" #include "compose.hpp" +#include <fmt/core.h> #include <cmath> @@ -60,8 +61,8 @@ order::Font::Font(shared_ptr<TextString> s, Standard standard) } _values["Italic"] = s->italic() ? "yes" : "no"; _values["Color"] = s->colour().to_argb_string(); - _values["Size"] = raw_convert<string> (s->size()); - _values["AspectAdjust"] = raw_convert<string>(s->aspect_adjust(), 1, true); + _values["Size"] = fmt::to_string(s->size()); + _values["AspectAdjust"] = fmt::format("{:.1f}", s->aspect_adjust()); _values["Effect"] = effect_to_string (s->effect()); _values["EffectColor"] = s->effect_colour().to_argb_string(); _values["Script"] = "normal"; @@ -138,7 +139,7 @@ order::String::as_xml (xmlpp::Element* parent, Context& context) const { if (fabs(_space_before) > SPACE_BEFORE_EPSILON) { auto space = cxml::add_child(parent, "Space"); - auto size = raw_convert<string>(_space_before, 2); + auto size = fmt::format("{:.2f}", _space_before); if (context.standard == Standard::INTEROP) { size += "em"; } @@ -177,9 +178,9 @@ position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, floa if (fabs(h_position) > ALIGN_EPSILON) { if (context.standard == Standard::SMPTE) { - e->set_attribute ("Hposition", raw_convert<string> (h_position * 100, 6)); + e->set_attribute("Hposition", fmt::format("{:.6f}", h_position * 100)); } else { - e->set_attribute ("HPosition", raw_convert<string> (h_position * 100, 6)); + e->set_attribute("HPosition", fmt::format("{:.6f}", h_position * 100)); } } @@ -191,9 +192,9 @@ position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, floa if (fabs(v_position) > ALIGN_EPSILON) { if (context.standard == Standard::SMPTE) { - e->set_attribute ("Vposition", raw_convert<string> (v_position * 100, 6)); + e->set_attribute("Vposition", fmt::format("{:.6f}", v_position * 100)); } else { - e->set_attribute ("VPosition", raw_convert<string> (v_position * 100, 6)); + e->set_attribute("VPosition", fmt::format("{:.6f}", v_position * 100, 6)); } } else { if (context.standard == Standard::SMPTE) { @@ -204,7 +205,7 @@ position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, floa } if (fabs(z_position) > ALIGN_EPSILON && context.standard == Standard::SMPTE) { - e->set_attribute("Zposition", raw_convert<string>(z_position * 100, 6)); + e->set_attribute("Zposition", fmt::format("{:.6f}", z_position * 100)); } } @@ -228,11 +229,11 @@ order::Text::as_xml (xmlpp::Element* parent, Context& context) const cxml::add_child(xml, "Rb")->add_child_text(ruby.base); auto rt = cxml::add_child(xml, "Rt"); rt->add_child_text(ruby.annotation); - rt->set_attribute("Size", dcp::raw_convert<string>(ruby.size, 6)); + rt->set_attribute("Size", fmt::format("{:.6f}", ruby.size)); rt->set_attribute("Position", ruby.position == RubyPosition::BEFORE ? "before" : "after"); - rt->set_attribute("Offset", dcp::raw_convert<string>(ruby.offset, 6)); - rt->set_attribute("Spacing", dcp::raw_convert<string>(ruby.spacing, 6)); - rt->set_attribute("AspectAdjust", dcp::raw_convert<string>(ruby.aspect_adjust, 6)); + rt->set_attribute("Offset", fmt::format("{:.6f}", ruby.offset)); + rt->set_attribute("Spacing", fmt::format("{:.6f}", ruby.spacing)); + rt->set_attribute("AspectAdjust", fmt::format("{:.6f}", ruby.aspect_adjust)); } return e; @@ -243,15 +244,15 @@ xmlpp::Element* order::Subtitle::as_xml (xmlpp::Element* parent, Context& context) const { auto e = cxml::add_child(parent, "Subtitle"); - e->set_attribute ("SpotNumber", raw_convert<string> (context.spot_number++)); + e->set_attribute("SpotNumber", fmt::to_string (context.spot_number++)); e->set_attribute ("TimeIn", _in.rebase(context.time_code_rate).as_string(context.standard)); e->set_attribute ("TimeOut", _out.rebase(context.time_code_rate).as_string(context.standard)); if (context.standard == Standard::SMPTE) { e->set_attribute ("FadeUpTime", _fade_up.rebase(context.time_code_rate).as_string(context.standard)); e->set_attribute ("FadeDownTime", _fade_down.rebase(context.time_code_rate).as_string(context.standard)); } else { - e->set_attribute ("FadeUpTime", raw_convert<string> (_fade_up.as_editable_units_ceil(context.time_code_rate))); - e->set_attribute ("FadeDownTime", raw_convert<string> (_fade_down.as_editable_units_ceil(context.time_code_rate))); + e->set_attribute("FadeUpTime", fmt::to_string(_fade_up.as_editable_units_ceil(context.time_code_rate))); + e->set_attribute("FadeDownTime", fmt::to_string(_fade_down.as_editable_units_ceil(context.time_code_rate))); } return e; } diff --git a/src/types.cc b/src/types.cc index 99b2f6c8..58c2dee0 100644 --- a/src/types.cc +++ b/src/types.cc @@ -47,6 +47,7 @@ LIBDCP_DISABLE_WARNINGS #include <libxml++/libxml++.h> LIBDCP_ENABLE_WARNINGS #include <boost/algorithm/string.hpp> +#include <fmt/core.h> #include <string> #include <vector> #include <cmath> @@ -355,7 +356,7 @@ Luminance::as_xml (xmlpp::Element* parent, string ns) const { auto lum = cxml::add_child(parent, "Luminance", ns); lum->set_attribute("units", unit_to_string(_unit)); - lum->add_child_text(raw_convert<string>(_value, 3)); + lum->add_child_text(fmt::format("{:.3f}", _value)); } diff --git a/src/verify.cc b/src/verify.cc index 68f838cf..15fb0608 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -45,7 +45,6 @@ #include "interop_text_asset.h" #include "mono_j2k_picture_asset.h" #include "mono_j2k_picture_frame.h" -#include "raw_convert.h" #include "reel.h" #include "reel_interop_text_asset.h" #include "reel_markers_asset.h" @@ -78,6 +77,7 @@ #include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/sax/HandlerBase.hpp> #include <xercesc/util/PlatformUtils.hpp> +#include <fmt/core.h> #include <boost/algorithm/string.hpp> #include <iostream> #include <map> @@ -639,10 +639,10 @@ verify_main_sound_asset(Context& context, shared_ptr<const ReelSoundAsset> reel_ verify_language_tag(context, *lang); } if (asset->sampling_rate() != 48000) { - context.bv21_error(VerificationNote::Code::INVALID_SOUND_FRAME_RATE, raw_convert<string>(asset->sampling_rate()), file); + context.bv21_error(VerificationNote::Code::INVALID_SOUND_FRAME_RATE, fmt::to_string(asset->sampling_rate()), file); } if (asset->bit_depth() != 24) { - context.error(VerificationNote::Code::INVALID_SOUND_BIT_DEPTH, raw_convert<string>(asset->bit_depth()), file); + context.error(VerificationNote::Code::INVALID_SOUND_BIT_DEPTH, fmt::to_string(asset->bit_depth()), file); } } @@ -695,7 +695,7 @@ verify_smpte_timed_text_asset ( auto const size = filesystem::file_size(asset->file().get()); if (size > 115 * 1024 * 1024) { - context.bv21_error(VerificationNote::Code::INVALID_TIMED_TEXT_SIZE_IN_BYTES, raw_convert<string>(size), *asset->file()); + context.bv21_error(VerificationNote::Code::INVALID_TIMED_TEXT_SIZE_IN_BYTES, fmt::to_string(size), *asset->file()); } /* XXX: I'm not sure what Bv2.1_7.2.1 means when it says "the font resource shall not be larger than 10MB" @@ -707,7 +707,7 @@ verify_smpte_timed_text_asset ( total_size += i.second.size(); } if (total_size > 10 * 1024 * 1024) { - context.bv21_error(VerificationNote::Code::INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES, raw_convert<string>(total_size), asset->file().get()); + context.bv21_error(VerificationNote::Code::INVALID_TIMED_TEXT_FONT_SIZE_IN_BYTES, fmt::to_string(total_size), asset->file().get()); } if (!asset->start_time()) { @@ -840,7 +840,7 @@ verify_closed_caption_asset ( if (raw_xml) { validate_xml(context, *raw_xml); if (raw_xml->size() > 256 * 1024) { - context.bv21_error(VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES, raw_convert<string>(raw_xml->size()), *asset->file()); + context.bv21_error(VerificationNote::Code::INVALID_CLOSED_CAPTION_XML_SIZE_IN_BYTES, fmt::to_string(raw_xml->size()), *asset->file()); } } else { context.warning(VerificationNote::Code::MISSED_CHECK_OF_ENCRYPTED); @@ -1666,7 +1666,7 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl) if (ffoc == markers_seen.end()) { context.warning(VerificationNote::Code::MISSING_FFOC); } else if (ffoc->second.e != 1) { - context.warning(VerificationNote::Code::INCORRECT_FFOC, raw_convert<string>(ffoc->second.e)); + context.warning(VerificationNote::Code::INCORRECT_FFOC, fmt::to_string(ffoc->second.e)); } auto lfoc = markers_seen.find(Marker::LFOC); @@ -1675,7 +1675,7 @@ verify_cpl(Context& context, shared_ptr<const CPL> cpl) } else { auto lfoc_time = lfoc->second.as_editable_units_ceil(lfoc->second.tcr); if (lfoc_time != (cpl->reels().back()->duration() - 1)) { - context.warning(VerificationNote::Code::INCORRECT_LFOC, raw_convert<string>(lfoc_time)); + context.warning(VerificationNote::Code::INCORRECT_LFOC, fmt::to_string(lfoc_time)); } } diff --git a/src/verify_j2k.cc b/src/verify_j2k.cc index f89ff840..12ea90e6 100644 --- a/src/verify_j2k.cc +++ b/src/verify_j2k.cc @@ -39,9 +39,9 @@ #include "compose.hpp" #include "data.h" -#include "raw_convert.h" #include "verify.h" #include "verify_j2k.h" +#include <fmt/core.h> #include <memory> #include <vector> @@ -52,7 +52,6 @@ using std::runtime_error; using std::string; using std::vector; using boost::optional; -using dcp::raw_convert; class InvalidCodestream : public runtime_error @@ -161,7 +160,7 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in require_marker ("SIZ"); auto L_siz = get_16(); if (L_siz != 47) { - throw InvalidCodestream("unexpected SIZ size " + raw_convert<string>(L_siz)); + throw InvalidCodestream("unexpected SIZ size " + fmt::to_string(L_siz)); } get_16(); // CA: codestream capabilities @@ -209,10 +208,10 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in auto const tile_part_index = get_8(); auto tile_parts = get_8(); if (!fourk && tile_parts != 3) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_2K, raw_convert<string>(tile_parts) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_2K, fmt::to_string(tile_parts) }); } if (fourk && tile_parts != 6) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_4K, raw_convert<string>(tile_parts) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_TILE_PARTS_FOR_4K, fmt::to_string(tile_parts) }); } if (tile_part_length > max_tile_part_size) { VerificationNote note{VerificationNote::Type::ERROR, VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE}; @@ -239,11 +238,11 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in require_8(fourk ? 6 : 5, "invalid number of transform levels %1"); auto log_code_block_width = get_8(); if (log_code_block_width != 3) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_WIDTH, raw_convert<string>(4 * (2 << log_code_block_width)) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_WIDTH, fmt::to_string(4 * (2 << log_code_block_width)) }); } auto log_code_block_height = get_8(); if (log_code_block_height != 3) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_HEIGHT, raw_convert<string>(4 * (2 << log_code_block_height)) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_CODE_BLOCK_HEIGHT, fmt::to_string(4 * (2 << log_code_block_height)) }); } require_8(0, "invalid mode variations"); require_8(0, "invalid wavelet transform type %1"); // 9/7 irreversible @@ -262,10 +261,10 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in auto quantization_style = get_8(); int guard_bits = (quantization_style >> 5) & 7; if (fourk && guard_bits != 2) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_4K, raw_convert<string>(guard_bits) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_4K, fmt::to_string(guard_bits) }); } if (!fourk && guard_bits != 1) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_2K, raw_convert<string>(guard_bits) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_GUARD_BITS_FOR_2K, fmt::to_string(guard_bits) }); } ptr += L_qcd - 3; } else if (*marker_name == "COC") { @@ -344,10 +343,10 @@ dcp::verify_j2k(shared_ptr<const Data> j2k, int start_index, int frame_index, in throw InvalidCodestream("more than one QCD marker found"); } if (num_POC_in_main != 0 && !fourk) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_2K, raw_convert<string>(num_POC_in_main) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_2K, fmt::to_string(num_POC_in_main) }); } if (num_POC_in_main != 1 && fourk) { - notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_4K, raw_convert<string>(num_POC_in_main) }); + notes.push_back({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INCORRECT_JPEG2000_POC_MARKER_COUNT_FOR_4K, fmt::to_string(num_POC_in_main) }); } if (num_POC_after_main != 0) { notes.push_back ({ VerificationNote::Type::BV21_ERROR, VerificationNote::Code::INVALID_JPEG2000_POC_MARKER_LOCATION }); |
