diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-24 22:56:33 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-24 22:56:33 +0100 |
| commit | e1e7de8d73bedd0c741e7df0390068c67867e09f (patch) | |
| tree | 02f007aad80f4d99707f2507a81b0685865026d0 /src | |
| parent | ceaf7bc52712cb60708ed5eb5c62c5e463dd8e89 (diff) | |
Tidying.
Diffstat (limited to 'src')
| -rw-r--r-- | src/asset.cc | 2 | ||||
| -rw-r--r-- | src/asset_factory.cc | 8 | ||||
| -rw-r--r-- | src/asset_factory.h | 8 | ||||
| -rw-r--r-- | src/combine.h | 2 | ||||
| -rw-r--r-- | src/data.h | 2 | ||||
| -rw-r--r-- | src/fsk.h | 2 | ||||
| -rw-r--r-- | src/key.cc | 2 | ||||
| -rw-r--r-- | src/language_tag.h | 3 | ||||
| -rw-r--r-- | src/locale_convert.h | 2 | ||||
| -rw-r--r-- | src/mono_picture_asset.h | 4 | ||||
| -rw-r--r-- | src/openjpeg_image.cc | 2 | ||||
| -rw-r--r-- | src/reel_asset.h | 4 | ||||
| -rw-r--r-- | src/reel_markers_asset.cc | 9 | ||||
| -rw-r--r-- | src/reel_markers_asset.h | 5 | ||||
| -rw-r--r-- | src/rgb_xyz.cc | 13 | ||||
| -rw-r--r-- | src/rgb_xyz.h | 5 | ||||
| -rw-r--r-- | src/smpte_load_font_node.h | 2 | ||||
| -rw-r--r-- | src/stereo_picture_frame.cc | 5 | ||||
| -rw-r--r-- | src/subtitle.h | 8 | ||||
| -rw-r--r-- | src/subtitle_image.cc | 17 | ||||
| -rw-r--r-- | src/subtitle_image.h | 13 | ||||
| -rw-r--r-- | src/subtitle_string.cc | 21 | ||||
| -rw-r--r-- | src/subtitle_string.h | 31 | ||||
| -rw-r--r-- | src/transfer_function.cc | 17 | ||||
| -rw-r--r-- | src/transfer_function.h | 2 | ||||
| -rw-r--r-- | src/types.cc | 109 | ||||
| -rw-r--r-- | src/types.h | 106 | ||||
| -rw-r--r-- | src/util.h | 3 | ||||
| -rw-r--r-- | src/verify.cc | 14 | ||||
| -rw-r--r-- | src/verify.h | 13 |
30 files changed, 312 insertions, 122 deletions
diff --git a/src/asset.cc b/src/asset.cc index 6364d83d..b911c70b 100644 --- a/src/asset.cc +++ b/src/asset.cc @@ -33,7 +33,7 @@ /** @file src/asset.cc - * @brief Asset class. + * @brief Asset class */ diff --git a/src/asset_factory.cc b/src/asset_factory.cc index ecda1701..e02281d2 100644 --- a/src/asset_factory.cc +++ b/src/asset_factory.cc @@ -31,6 +31,12 @@ files in the program, then also delete it here. */ + +/** @file src/asset_factory.cc + * @brief asset_factory() method + */ + + #include "mono_picture_asset.h" #include "stereo_picture_asset.h" #include "sound_asset.h" @@ -41,10 +47,12 @@ #include "asset_factory.h" #include <memory> + using std::shared_ptr; using std::make_shared; using namespace dcp; + shared_ptr<Asset> dcp::asset_factory (boost::filesystem::path path, bool ignore_incorrect_picture_mxf_type) { diff --git a/src/asset_factory.h b/src/asset_factory.h index 4f7688eb..4bab9bee 100644 --- a/src/asset_factory.h +++ b/src/asset_factory.h @@ -31,8 +31,16 @@ files in the program, then also delete it here. */ + +/** @file src/asset_factory.h + * @brief asset_factory() method + */ + + namespace dcp { + std::shared_ptr<Asset> asset_factory (boost::filesystem::path path, bool ignore_incorrect_picture_mxf_type); + } diff --git a/src/combine.h b/src/combine.h index dd992f1b..b23b21be 100644 --- a/src/combine.h +++ b/src/combine.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -1,5 +1,5 @@ /* - Copyright (C) 2015-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -33,7 +33,7 @@ /** @file src/key.cc - * @brief Key class. + * @brief Key class */ diff --git a/src/language_tag.h b/src/language_tag.h index 3b0b6ac9..0f05ac12 100644 --- a/src/language_tag.h +++ b/src/language_tag.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -248,4 +248,5 @@ extern void load_language_tag_lists (boost::filesystem::path tags_directory); } + #endif diff --git a/src/locale_convert.h b/src/locale_convert.h index 9b1b432c..37510a96 100644 --- a/src/locale_convert.h +++ b/src/locale_convert.h @@ -33,7 +33,7 @@ /** @file src/locale_convert.cc - * @brief Methods to convert to/from string using the current locale. + * @brief Methods to convert to/from string using the current locale */ diff --git a/src/mono_picture_asset.h b/src/mono_picture_asset.h index 8c152146..f6f8877c 100644 --- a/src/mono_picture_asset.h +++ b/src/mono_picture_asset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -82,6 +82,8 @@ private: std::string cpl_node_name () const; }; + } + #endif diff --git a/src/openjpeg_image.cc b/src/openjpeg_image.cc index 3594b2bd..d17943af 100644 --- a/src/openjpeg_image.cc +++ b/src/openjpeg_image.cc @@ -33,7 +33,7 @@ /** @file src/openjpeg_image.cc - * @brief OpenJPEGImage class. + * @brief OpenJPEGImage class */ diff --git a/src/reel_asset.h b/src/reel_asset.h index 344e41c3..ba08c267 100644 --- a/src/reel_asset.h +++ b/src/reel_asset.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net> + Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -150,6 +150,8 @@ private: boost::optional<int64_t> _entry_point; ///< The <EntryPoint> from the reel's entry for this asset }; + } + #endif diff --git a/src/reel_markers_asset.cc b/src/reel_markers_asset.cc index 52151868..360a855a 100644 --- a/src/reel_markers_asset.cc +++ b/src/reel_markers_asset.cc @@ -32,6 +32,11 @@ */ +/** @file src/reel_markers_asset.cc + * @brief ReelMarkersAsset class + */ + + #include "reel_markers_asset.h" #include "raw_convert.h" #include "dcp_assert.h" @@ -88,9 +93,9 @@ ReelMarkersAsset::unset (Marker m) optional<Time> ReelMarkersAsset::get (Marker m) const { - map<Marker, Time>::const_iterator i = _markers.find (m); + auto i = _markers.find (m); if (i == _markers.end ()) { - return optional<Time>(); + return {}; } return i->second; } diff --git a/src/reel_markers_asset.h b/src/reel_markers_asset.h index 5b33bbf2..1eae47ef 100644 --- a/src/reel_markers_asset.h +++ b/src/reel_markers_asset.h @@ -32,6 +32,11 @@ */ +/** @file src/reel_markers_asset.cc + * @brief ReelMarkersAsset class + */ + + #include "reel_asset.h" #include "dcp_time.h" #include <map> diff --git a/src/rgb_xyz.cc b/src/rgb_xyz.cc index a5fd2a24..a8766b8e 100644 --- a/src/rgb_xyz.cc +++ b/src/rgb_xyz.cc @@ -32,6 +32,11 @@ */ +/** @file rgb_xyz.cc + * @brief Conversion between RGB and XYZ + */ + + #include "colour_conversion.h" #include "compose.hpp" #include "dcp_assert.h" @@ -154,7 +159,7 @@ dcp::xyz_to_rgb ( double const * lut_in = conversion.out()->lut (12, false); double const * lut_out = conversion.in()->lut (16, true); - boost::numeric::ublas::matrix<double> const matrix = conversion.xyz_to_rgb (); + auto const matrix = conversion.xyz_to_rgb (); double fast_matrix[9] = { matrix (0, 0), matrix (0, 1), matrix (0, 2), @@ -166,7 +171,7 @@ dcp::xyz_to_rgb ( int const width = xyz_image->size().width; for (int y = 0; y < height; ++y) { - uint16_t* rgb_line = reinterpret_cast<uint16_t*> (rgb + y * stride); + auto rgb_line = reinterpret_cast<uint16_t*> (rgb + y * stride); for (int x = 0; x < width; ++x) { int cx = *xyz_x++; @@ -228,8 +233,8 @@ dcp::xyz_to_rgb ( void dcp::combined_rgb_to_xyz (ColourConversion const & conversion, double* matrix) { - boost::numeric::ublas::matrix<double> const rgb_to_xyz = conversion.rgb_to_xyz (); - boost::numeric::ublas::matrix<double> const bradford = conversion.bradford (); + auto const rgb_to_xyz = conversion.rgb_to_xyz (); + auto const bradford = conversion.bradford (); matrix[0] = (bradford (0, 0) * rgb_to_xyz (0, 0) + bradford (0, 1) * rgb_to_xyz (1, 0) + bradford (0, 2) * rgb_to_xyz (2, 0)) * DCI_COEFFICIENT * 65535; diff --git a/src/rgb_xyz.h b/src/rgb_xyz.h index eb1b5ac8..4a920efb 100644 --- a/src/rgb_xyz.h +++ b/src/rgb_xyz.h @@ -32,6 +32,11 @@ */ +/** @file rgb_xyz.h + * @brief Conversion between RGB and XYZ + */ + + #include "types.h" #include <memory> #include <boost/optional.hpp> diff --git a/src/smpte_load_font_node.h b/src/smpte_load_font_node.h index 7109e98b..81abfe0b 100644 --- a/src/smpte_load_font_node.h +++ b/src/smpte_load_font_node.h @@ -33,7 +33,7 @@ /** @file src/smpte_load_font_node.h - * @brief SMPTELoadFontNode class. + * @brief SMPTELoadFontNode class */ diff --git a/src/stereo_picture_frame.cc b/src/stereo_picture_frame.cc index 8df4fcc2..ac9cb6d9 100644 --- a/src/stereo_picture_frame.cc +++ b/src/stereo_picture_frame.cc @@ -32,6 +32,11 @@ */ +/** @file src/stereo_picture_frame.cc + * @brief StereoPictureFrame class + */ + + #include "stereo_picture_frame.h" #include "exceptions.h" #include "util.h" diff --git a/src/subtitle.h b/src/subtitle.h index 8beca192..e0132dbe 100644 --- a/src/subtitle.h +++ b/src/subtitle.h @@ -32,15 +32,15 @@ */ -#ifndef LIBDCP_SUBTITLE_H -#define LIBDCP_SUBTITLE_H - - /** @file src/subtitle.h * @brief Subtitle class */ +#ifndef LIBDCP_SUBTITLE_H +#define LIBDCP_SUBTITLE_H + + #include "dcp_time.h" diff --git a/src/subtitle_image.cc b/src/subtitle_image.cc index 7bfc4b86..b281d754 100644 --- a/src/subtitle_image.cc +++ b/src/subtitle_image.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2018-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,14 +31,22 @@ files in the program, then also delete it here. */ + +/** @file src/subtitle_image.cc + * @brief SubtitleImage class + */ + + #include "subtitle_image.h" #include "util.h" + using std::ostream; using std::string; using std::shared_ptr; using namespace dcp; + SubtitleImage::SubtitleImage ( ArrayData png_image, Time in, @@ -57,6 +65,7 @@ SubtitleImage::SubtitleImage ( } + SubtitleImage::SubtitleImage ( ArrayData png_image, string id, @@ -76,6 +85,7 @@ SubtitleImage::SubtitleImage ( } + void SubtitleImage::read_png_file (boost::filesystem::path file) { @@ -83,6 +93,7 @@ SubtitleImage::read_png_file (boost::filesystem::path file) _png_image = ArrayData (file); } + void SubtitleImage::write_png_file (boost::filesystem::path file) const { @@ -90,6 +101,7 @@ SubtitleImage::write_png_file (boost::filesystem::path file) const png_image().write (file); } + bool dcp::operator== (SubtitleImage const & a, SubtitleImage const & b) { @@ -107,12 +119,14 @@ dcp::operator== (SubtitleImage const & a, SubtitleImage const & b) ); } + bool dcp::operator!= (SubtitleImage const & a, SubtitleImage const & b) { return !(a == b); } + bool SubtitleImage::equals (shared_ptr<SubtitleImage> other, EqualityOptions options, NoteHandler note) { @@ -178,6 +192,7 @@ SubtitleImage::equals (shared_ptr<SubtitleImage> other, EqualityOptions options, return true; } + ostream& dcp::operator<< (ostream& s, SubtitleImage const & sub) { diff --git a/src/subtitle_image.h b/src/subtitle_image.h index 2cdfea25..595320f7 100644 --- a/src/subtitle_image.h +++ b/src/subtitle_image.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington <cth@carlh.net> + Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,10 +31,12 @@ files in the program, then also delete it here. */ + /** @file src/subtitle_image.h - * @brief SubtitleImage class. + * @brief SubtitleImage class */ + #ifndef LIBDCP_SUBTITLE_IMAGE_H #define LIBDCP_SUBTITLE_IMAGE_H @@ -46,10 +48,12 @@ #include <boost/optional.hpp> #include <string> + namespace dcp { + /** @class SubtitleImage - * @brief A bitmap subtitle with all the associated attributes. + * @brief A bitmap subtitle with all the associated attributes */ class SubtitleImage : public Subtitle { @@ -107,10 +111,13 @@ private: mutable boost::optional<boost::filesystem::path> _file; }; + bool operator== (SubtitleImage const & a, SubtitleImage const & b); bool operator!= (SubtitleImage const & a, SubtitleImage const & b); std::ostream& operator<< (std::ostream& s, SubtitleImage const & sub); + } + #endif diff --git a/src/subtitle_string.cc b/src/subtitle_string.cc index 0f89291e..28c02114 100644 --- a/src/subtitle_string.cc +++ b/src/subtitle_string.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,16 +31,25 @@ files in the program, then also delete it here. */ + +/** @file src/subtitle_string.cc + * @brief SubtitleString class + */ + + #include "subtitle_string.h" #include "xml.h" #include <cmath> -using std::string; + +using std::max; +using std::min; using std::ostream; +using std::string; using boost::optional; using namespace dcp; -/** @param v_position Vertical position as a fraction of the screen height (between 0 and 1) from v_align */ + SubtitleString::SubtitleString ( optional<string> font, bool italic, @@ -75,9 +84,10 @@ SubtitleString::SubtitleString ( , _effect (effect) , _effect_colour (effect_colour) { - + _aspect_adjust = max(min(_aspect_adjust, 4.0), 0.25); } + int SubtitleString::size_in_pixels (int screen_height) const { @@ -89,6 +99,7 @@ SubtitleString::size_in_pixels (int screen_height) const return _size * screen_height / (11 * 72); } + bool dcp::operator== (SubtitleString const & a, SubtitleString const & b) { @@ -115,12 +126,14 @@ dcp::operator== (SubtitleString const & a, SubtitleString const & b) ); } + bool dcp::operator!= (SubtitleString const & a, SubtitleString const & b) { return !(a == b); } + ostream& dcp::operator<< (ostream& s, SubtitleString const & sub) { diff --git a/src/subtitle_string.h b/src/subtitle_string.h index 8e798d8e..bf9c87d9 100644 --- a/src/subtitle_string.h +++ b/src/subtitle_string.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,27 +31,52 @@ files in the program, then also delete it here. */ + /** @file src/subtitle_string.h - * @brief SubtitleString class. + * @brief SubtitleString class */ + #ifndef LIBDCP_SUBTITLE_STRING_H #define LIBDCP_SUBTITLE_STRING_H + #include "types.h" #include "subtitle.h" #include "dcp_time.h" #include <boost/optional.hpp> #include <string> + namespace dcp { + /** @class SubtitleString * @brief A single line of subtitle text with all the associated attributes. */ class SubtitleString : public Subtitle { public: + /** @param font Font ID, or empty to use the default + * @param italic true for italic text + * @param bold true for bold text + * @param underline true for underlined text + * @param colour Colour of the text + * @param size Size in points as if the screen height is 11 inches, so a 72pt font would be 1/11th of the screen height + * @param aspect_adjust greater than 1 to stretch text to be wider, less than 1 to shrink text to be narrower (must be between 0.25 and 4) + * @param in start time + * @param out finish time + * @param h_position Horizontal position as a fraction of the screen width (between 0 and 1) from h_align + * @param h_align Horizontal alignment point + * @param v_position Vertical position as a fraction of the screen height (between 0 and 1) from v_align + * @param v_align Vertical alignment point + * @param direction Direction of text + * @param text The text to display + * @param effect Effect to use + * @param effect_colour Colour of the effect + * @param fade_up_time Time to fade the text in + * @param fade_down_time Time to fade the text out + */ SubtitleString ( boost::optional<std::string> font, bool italic, @@ -183,6 +208,8 @@ bool operator== (SubtitleString const & a, SubtitleString const & b); bool operator!= (SubtitleString const & a, SubtitleString const & b); std::ostream& operator<< (std::ostream& s, SubtitleString const & sub); + } + #endif diff --git a/src/transfer_function.cc b/src/transfer_function.cc index 8746c828..00968e2f 100644 --- a/src/transfer_function.cc +++ b/src/transfer_function.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,9 +31,16 @@ files in the program, then also delete it here. */ + +/* @file src/transfer_function.cc + * @brief TransferFunction + */ + + #include "transfer_function.h" #include <cmath> + using std::pow; using std::map; using std::pair; @@ -41,23 +48,25 @@ using std::make_pair; using std::shared_ptr; using namespace dcp; + TransferFunction::~TransferFunction () { boost::mutex::scoped_lock lm (_mutex); - for (map<pair<int, bool>, double*>::const_iterator i = _luts.begin(); i != _luts.end(); ++i) { - delete[] i->second; + for (auto const& i: _luts) { + delete[] i.second; } _luts.clear (); } + double const * TransferFunction::lut (int bit_depth, bool inverse) const { boost::mutex::scoped_lock lm (_mutex); - map<pair<int, bool>, double*>::const_iterator i = _luts.find (make_pair (bit_depth, inverse)); + auto i = _luts.find (make_pair (bit_depth, inverse)); if (i != _luts.end ()) { return i->second; } diff --git a/src/transfer_function.h b/src/transfer_function.h index 508ff934..a52011ec 100644 --- a/src/transfer_function.h +++ b/src/transfer_function.h @@ -33,7 +33,7 @@ /** @file src/transfer_function.h - * @brief TransferFunction class. + * @brief TransferFunction class */ diff --git a/src/types.cc b/src/types.cc index 099512c6..f22bfa91 100644 --- a/src/types.cc +++ b/src/types.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,6 +31,12 @@ files in the program, then also delete it here. */ + +/** @file src/types.cc + * @brief Miscellaneous types + */ + + #include "raw_convert.h" #include "types.h" #include "exceptions.h" @@ -44,17 +50,20 @@ #include <cstdio> #include <iomanip> + using std::string; using std::ostream; using std::vector; using namespace dcp; using namespace boost; + bool dcp::operator== (dcp::Size const & a, dcp::Size const & b) { return (a.width == b.width && a.height == b.height); } + bool dcp::operator!= (dcp::Size const & a, dcp::Size const & b) { return !(a == b); @@ -69,24 +78,27 @@ Fraction::Fraction (string s) vector<string> b; split (b, s, is_any_of (" ")); if (b.size() != 2) { - boost::throw_exception (XMLError ("malformed fraction " + s + " in XML node")); + boost::throw_exception (XMLError("malformed fraction " + s + " in XML node")); } numerator = raw_convert<int> (b[0]); denominator = raw_convert<int> (b[1]); } + string Fraction::as_string () const { return String::compose ("%1 %2", numerator, denominator); } + bool dcp::operator== (Fraction const & a, Fraction const & b) { return (a.numerator == b.numerator && a.denominator == b.denominator); } + bool dcp::operator!= (Fraction const & a, Fraction const & b) { @@ -94,18 +106,12 @@ dcp::operator!= (Fraction const & a, Fraction const & b) } -/** Construct a Colour, initialising it to black. */ Colour::Colour () - : r (0) - , g (0) - , b (0) { } -/** Construct a Colour from R, G and B. The values run between - * 0 and 255. - */ + Colour::Colour (int r_, int g_, int b_) : r (r_) , g (g_) @@ -114,10 +120,7 @@ Colour::Colour (int r_, int g_, int b_) } -/** Construct a Colour from an ARGB hex string; the alpha value is ignored. - * @param argb_hex A string of the form AARRGGBB, where e.g. RR is a two-character - * hex value. - */ + Colour::Colour (string argb_hex) { int alpha; @@ -126,9 +129,7 @@ Colour::Colour (string argb_hex) } } -/** @return An ARGB string of the form AARRGGBB, where e.g. RR is a two-character - * hex value. The alpha value will always be FF (ie 255; maximum alpha). - */ + string Colour::to_argb_string () const { @@ -137,9 +138,7 @@ Colour::to_argb_string () const return buffer; } -/** @return An RGB string of the form RRGGBB, where e.g. RR is a two-character - * hex value. - */ + string Colour::to_rgb_string () const { @@ -148,20 +147,14 @@ Colour::to_rgb_string () const return buffer; } -/** operator== for Colours. - * @param a First colour to compare. - * @param b Second colour to compare. - */ + bool dcp::operator== (Colour const & a, Colour const & b) { return (a.r == b.r && a.g == b.g && a.b == b.b); } -/** operator!= for Colours. - * @param a First colour to compare. - * @param b Second colour to compare. - */ + bool dcp::operator!= (Colour const & a, Colour const & b) { @@ -181,9 +174,10 @@ dcp::effect_to_string (Effect e) return "shadow"; } - boost::throw_exception (MiscError ("unknown effect type")); + boost::throw_exception (MiscError("unknown effect type")); } + Effect dcp::string_to_effect (string s) { @@ -195,7 +189,7 @@ dcp::string_to_effect (string s) return Effect::SHADOW; } - boost::throw_exception (ReadError ("unknown subtitle effect type")); + boost::throw_exception (ReadError("unknown subtitle effect type")); } @@ -211,9 +205,10 @@ dcp::halign_to_string (HAlign h) return "right"; } - boost::throw_exception (MiscError ("unknown subtitle halign type")); + boost::throw_exception (MiscError("unknown subtitle halign type")); } + HAlign dcp::string_to_halign (string s) { @@ -225,9 +220,10 @@ dcp::string_to_halign (string s) return HAlign::RIGHT; } - boost::throw_exception (ReadError ("unknown subtitle halign type")); + boost::throw_exception (ReadError("unknown subtitle halign type")); } + string dcp::valign_to_string (VAlign v) { @@ -240,9 +236,10 @@ dcp::valign_to_string (VAlign v) return "bottom"; } - boost::throw_exception (MiscError ("unknown subtitle valign type")); + boost::throw_exception (MiscError("unknown subtitle valign type")); } + VAlign dcp::string_to_valign (string s) { @@ -254,9 +251,10 @@ dcp::string_to_valign (string s) return VAlign::BOTTOM; } - boost::throw_exception (ReadError ("unknown subtitle valign type")); + boost::throw_exception (ReadError("unknown subtitle valign type")); } + string dcp::direction_to_string (Direction v) { @@ -271,9 +269,10 @@ dcp::direction_to_string (Direction v) return "btt"; } - boost::throw_exception (MiscError ("unknown subtitle direction type")); + boost::throw_exception (MiscError("unknown subtitle direction type")); } + Direction dcp::string_to_direction (string s) { @@ -287,13 +286,14 @@ dcp::string_to_direction (string s) return Direction::BTT; } - boost::throw_exception (ReadError ("unknown subtitle direction type")); + boost::throw_exception (ReadError("unknown subtitle direction type")); } + /** Convert a content kind to a string which can be used in a - * <ContentKind> node. - * @param kind ContentKind. - * @return string. + * <ContentKind> node + * @param kind ContentKind + * @return string */ string dcp::content_kind_to_string (ContentKind kind) @@ -328,10 +328,11 @@ dcp::content_kind_to_string (ContentKind kind) DCP_ASSERT (false); } + /** Convert a string from a <ContentKind> node to a libdcp ContentKind. - * Reasonably tolerant about varying case. - * @param kind Content kind string. - * @return libdcp ContentKind. + * Reasonably tolerant about varying case + * @param kind Content kind string + * @return libdcp ContentKind */ dcp::ContentKind dcp::content_kind_from_string (string kind) @@ -397,6 +398,7 @@ dcp::marker_to_string (dcp::Marker m) DCP_ASSERT (false); } + dcp::Marker dcp::marker_from_string (string s) { @@ -425,13 +427,15 @@ dcp::marker_from_string (string s) DCP_ASSERT (false); } + Rating::Rating (cxml::ConstNodePtr node) + : agency(node->string_child("Agency")) + , label(node->string_child("Label")) { - agency = node->string_child("Agency"); - label = node->string_child("Label"); node->done (); } + void Rating::as_xml (xmlpp::Element* parent) const { @@ -439,12 +443,14 @@ Rating::as_xml (xmlpp::Element* parent) const parent->add_child("Label")->add_child_text(label); } + bool dcp::operator== (Rating const & a, Rating const & b) { return a.agency == b.agency && a.label == b.label; } + ContentVersion::ContentVersion () : id ("urn:uuid:" + make_uuid()) { @@ -453,9 +459,10 @@ ContentVersion::ContentVersion () ContentVersion::ContentVersion (cxml::ConstNodePtr node) + : id(node->string_child("Id")) + , label_text(node->string_child("LabelText")) { - id = node->string_child("Id"); - label_text = node->string_child("LabelText"); + } @@ -470,16 +477,17 @@ ContentVersion::ContentVersion (string label_text_) void ContentVersion::as_xml (xmlpp::Element* parent) const { - xmlpp::Node* cv = parent->add_child("ContentVersion"); + auto cv = parent->add_child("ContentVersion"); cv->add_child("Id")->add_child_text(id); cv->add_child("LabelText")->add_child_text(label_text); } Luminance::Luminance (cxml::ConstNodePtr node) + : _unit(string_to_unit(node->string_attribute("units"))) + , _value(raw_convert<float>(node->content())) { - _unit = string_to_unit (node->string_attribute("units")); - _value = raw_convert<float> (node->content()); + } @@ -504,7 +512,7 @@ Luminance::set_value (float v) void Luminance::as_xml (xmlpp::Element* parent, string ns) const { - xmlpp::Element* lum = parent->add_child("Luminance", ns); + auto lum = parent->add_child("Luminance", ns); lum->set_attribute("units", unit_to_string(_unit)); lum->add_child_text(raw_convert<string>(_value, 3)); } @@ -522,7 +530,7 @@ Luminance::unit_to_string (Unit u) DCP_ASSERT (false); } - return ""; + return {}; } @@ -641,7 +649,6 @@ dcp::status_to_string (Status s) default: DCP_ASSERT (false); } - } diff --git a/src/types.h b/src/types.h index 4f2048b4..374dd8b8 100644 --- a/src/types.h +++ b/src/types.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -31,13 +31,16 @@ files in the program, then also delete it here. */ + /** @file src/types.h - * @brief Miscellaneous types. + * @brief Miscellaneous types */ + #ifndef LIBDCP_TYPES_H #define LIBDCP_TYPES_H + #include <libcxml/cxml.h> #include <asdcp/KLV.h> #include <memory> @@ -53,9 +56,11 @@ namespace xmlpp { class Element; } + namespace dcp { + /** @struct Size * @brief The integer, two-dimensional size of something. */ @@ -79,9 +84,11 @@ struct Size int height; }; + extern bool operator== (Size const & a, Size const & b); extern bool operator!= (Size const & a, Size const & b); + /** Identifier for a sound channel */ enum class Channel { LEFT = 0, ///< left @@ -102,6 +109,7 @@ enum class Channel { CHANNEL_COUNT = 16 }; + std::vector<dcp::Channel> used_audio_channels (); @@ -134,9 +142,11 @@ enum class ContentKind PROMO }; + extern std::string content_kind_to_string (ContentKind kind); extern ContentKind content_kind_from_string (std::string kind); + enum class Effect { NONE, @@ -144,9 +154,11 @@ enum class Effect SHADOW }; + extern std::string effect_to_string (Effect e); extern Effect string_to_effect (std::string s); + enum class HAlign { LEFT, ///< horizontal position is distance from left of screen to left of subtitle @@ -154,9 +166,11 @@ enum class HAlign RIGHT, ///< horizontal position is distance from right of screen to right of subtitle }; + extern std::string halign_to_string (HAlign a); extern HAlign string_to_halign (std::string s); + enum class VAlign { TOP, ///< vertical position is distance from top of screen to top of subtitle @@ -164,9 +178,11 @@ enum class VAlign BOTTOM ///< vertical position is distance from bottom of screen to bottom of subtitle }; + extern std::string valign_to_string (VAlign a); extern VAlign string_to_valign (std::string s); + /** Direction for subtitle test */ enum class Direction { @@ -176,15 +192,18 @@ enum class Direction BTT ///< bottom-to-top }; + extern std::string direction_to_string (Direction a); extern Direction string_to_direction (std::string s); + enum class Eye { LEFT, RIGHT }; + /** @class Fraction * @brief A fraction (i.e. a thing with an integer numerator and an integer denominator). */ @@ -192,7 +211,7 @@ class Fraction { public: /** Construct a fraction of 0/0 */ - Fraction () : numerator (0), denominator (0) {} + Fraction () {} explicit Fraction (std::string s); /** Construct a fraction with a specified numerator and denominator. * @param n Numerator. @@ -206,13 +225,15 @@ public: std::string as_string () const; - int numerator; - int denominator; + int numerator = 0; + int denominator = 0; }; + extern bool operator== (Fraction const & a, Fraction const & b); extern bool operator!= (Fraction const & a, Fraction const & b); + /** @struct EqualityOptions * @brief A class to describe what "equality" means for a particular test. * @@ -224,37 +245,26 @@ extern bool operator!= (Fraction const & a, Fraction const & b); struct EqualityOptions { /** Construct an EqualityOptions where nothing at all can differ */ - EqualityOptions () - : max_mean_pixel_error (0) - , max_std_dev_pixel_error (0) - , max_audio_sample_error (0) - , cpl_annotation_texts_can_differ (false) - , reel_annotation_texts_can_differ (false) - , reel_hashes_can_differ (false) - , issue_dates_can_differ (false) - , load_font_nodes_can_differ (false) - , keep_going (false) - , export_differing_subtitles (false) - {} + EqualityOptions () {} /** The maximum allowable mean difference in pixel value between two images */ - double max_mean_pixel_error; + double max_mean_pixel_error = 0; /** The maximum standard deviation of the differences in pixel value between two images */ - double max_std_dev_pixel_error; + double max_std_dev_pixel_error = 0; /** The maximum difference in audio sample value between two soundtracks */ - int max_audio_sample_error; + int max_audio_sample_error = 0; /** true if the <AnnotationText> nodes of CPLs are allowed to differ */ - bool cpl_annotation_texts_can_differ; + bool cpl_annotation_texts_can_differ = false; /** true if the <AnnotationText> nodes of Reels are allowed to differ */ - bool reel_annotation_texts_can_differ; + bool reel_annotation_texts_can_differ = false; /** true if <Hash>es in Reels can differ */ - bool reel_hashes_can_differ; + bool reel_hashes_can_differ = false; /** true if IssueDate nodes can differ */ - bool issue_dates_can_differ; - bool load_font_nodes_can_differ; - bool keep_going; + bool issue_dates_can_differ = false; + bool load_font_nodes_can_differ = false; + bool keep_going = false; /** true to save the first pair of differeng image subtitles to the current working directory */ - bool export_differing_subtitles; + bool export_differing_subtitles = false; }; @@ -280,38 +290,61 @@ enum class Formulation { MODIFIED_TRANSITIONAL_TEST }; + /** @class Colour - * @brief An RGB colour. + * @brief An RGB colour */ class Colour { public: + /** Construct a Colour, initialising it to black */ Colour (); + + /** Construct a Colour from R, G and B. The values run between + * 0 and 255. + */ Colour (int r_, int g_, int b_); + + /** Construct a Colour from an ARGB hex string; the alpha value is ignored. + * @param argb_hex A string of the form AARRGGBB, where e.g. RR is a two-character + * hex value. + */ explicit Colour (std::string argb_hex); - int r; ///< red component, from 0 to 255 - int g; ///< green component, from 0 to 255 - int b; ///< blue component, from 0 to 255 + int r = 0; ///< red component, from 0 to 255 + int g = 0; ///< green component, from 0 to 255 + int b = 0; ///< blue component, from 0 to 255 + /** @return An RGB string of the form RRGGBB, where e.g. RR is a two-character + * hex value. + */ std::string to_rgb_string () const; + + /** @return An ARGB string of the form AARRGGBB, where e.g. RR is a two-character + * hex value. The alpha value will always be FF (ie 255; maximum alpha). + */ std::string to_argb_string () const; }; + extern bool operator== (Colour const & a, Colour const & b); extern bool operator!= (Colour const & a, Colour const & b); + typedef boost::function<void (NoteType, std::string)> NoteHandler; + /** Maximum absolute difference between dcp::SubtitleString::aspect_adjust values that - * are considered equal. + * are considered equal */ -const float ASPECT_ADJUST_EPSILON = 1e-3; +constexpr float ASPECT_ADJUST_EPSILON = 1e-3; + /** Maximum absolute difference between dcp::SubtitleString alignment values that * are considered equal. */ -const float ALIGN_EPSILON = 1e-3; +constexpr float ALIGN_EPSILON = 1e-3; + enum class Marker { FFOC, ///< first frame of composition @@ -326,9 +359,11 @@ enum class Marker { LFMC ///< last frame of moving credits }; + std::string marker_to_string (Marker); Marker marker_from_string (std::string); + class Rating { public: @@ -347,6 +382,7 @@ public: std::string label; }; + extern bool operator== (Rating const & a, Rating const & b); @@ -418,6 +454,7 @@ private: Unit _unit; }; + bool operator== (Luminance const& a, Luminance const& b); @@ -448,4 +485,5 @@ private: } + #endif @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net> This file is part of libdcp. @@ -166,4 +166,5 @@ private: } + #endif diff --git a/src/verify.cc b/src/verify.cc index 6f6a48f1..3cb61bad 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -31,6 +31,12 @@ files in the program, then also delete it here. */ + +/** @file src/verify.cc + * @brief dcp::verify() method and associated code + */ + + #include "verify.h" #include "dcp.h" #include "cpl.h" @@ -72,6 +78,7 @@ #include <vector> #include <iostream> + using std::list; using std::vector; using std::string; @@ -85,9 +92,11 @@ using boost::optional; using boost::function; using std::dynamic_pointer_cast; + using namespace dcp; using namespace xercesc; + static string xml_ch_to_string (XMLCh const * a) @@ -98,6 +107,7 @@ xml_ch_to_string (XMLCh const * a) return o; } + class XMLValidationError { public: @@ -183,6 +193,7 @@ private: list<XMLValidationError> _errors; }; + class StringToXMLCh { public: @@ -207,6 +218,7 @@ private: XMLCh* _buffer; }; + class LocalFileResolver : public EntityResolver { public: @@ -1341,6 +1353,7 @@ dcp::verify ( return notes; } + string dcp::note_to_string (VerificationNote note) { @@ -1493,6 +1506,7 @@ dcp::operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b) return a.type() == b.type() && a.code() == b.code() && a.note() == b.note() && a.file() == b.file() && a.line() == b.line(); } + std::ostream& dcp::operator<< (std::ostream& s, dcp::VerificationNote const& note) { diff --git a/src/verify.h b/src/verify.h index ee90b226..0a8b39ca 100644 --- a/src/verify.h +++ b/src/verify.h @@ -31,20 +31,30 @@ files in the program, then also delete it here. */ + +/** @file src/verify.h + * @brief dcp::verify() method and associated code + */ + + #ifndef LIBDCP_VERIFY_H #define LIBDCP_VERIFY_H + #include <boost/filesystem.hpp> #include <boost/function.hpp> #include <boost/optional.hpp> #include <string> #include <vector> + /* Something in windows.h defines this */ #undef ERROR + namespace dcp { + class VerificationNote { public: @@ -373,6 +383,7 @@ private: boost::optional<uint64_t> _line; }; + std::vector<VerificationNote> verify ( std::vector<boost::filesystem::path> directories, boost::function<void (std::string, boost::optional<boost::filesystem::path>)> stage, @@ -386,6 +397,8 @@ bool operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b) std::ostream& operator<<(std::ostream& s, dcp::VerificationNote const& note); + } + #endif |
