Tidying.
authorCarl Hetherington <cth@carlh.net>
Sun, 24 Jan 2021 21:56:33 +0000 (22:56 +0100)
committerCarl Hetherington <cth@carlh.net>
Sun, 24 Jan 2021 21:56:33 +0000 (22:56 +0100)
30 files changed:
src/asset.cc
src/asset_factory.cc
src/asset_factory.h
src/combine.h
src/data.h
src/fsk.h
src/key.cc
src/language_tag.h
src/locale_convert.h
src/mono_picture_asset.h
src/openjpeg_image.cc
src/reel_asset.h
src/reel_markers_asset.cc
src/reel_markers_asset.h
src/rgb_xyz.cc
src/rgb_xyz.h
src/smpte_load_font_node.h
src/stereo_picture_frame.cc
src/subtitle.h
src/subtitle_image.cc
src/subtitle_image.h
src/subtitle_string.cc
src/subtitle_string.h
src/transfer_function.cc
src/transfer_function.h
src/types.cc
src/types.h
src/util.h
src/verify.cc
src/verify.h

index 6364d83d8b57ec21624346bf8a83b3c120d18c1c..b911c70b958435c754d2e153c58edc811789e18e 100644 (file)
@@ -33,7 +33,7 @@
 
 
 /** @file  src/asset.cc
- *  @brief Asset class.
+ *  @brief Asset class
  */
 
 
index ecda1701476d2aeb81ec2838116ddbe78ac79407..e02281d2f980c9b4ab9bf705ec008e084d60cd8f 100644 (file)
     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"
 #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)
 {
index 4f7688ebae97356f5b6fcbdef3db9ee4275fc7a1..4bab9beecc80764020612ea53eb1ccae428e3a36 100644 (file)
     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);
 
+
 }
index dd992f1ba0874f6421cfac12d436802bcbdc8e0c..b23b21beaf61f8aa8250efe071c02475c32b7e10 100644 (file)
@@ -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.
 
index 96ed4bb5580e5056ae8e80c8500c2b5e7f055576..063187a6b2e577803f430780854437fb6464b0b1 100644 (file)
@@ -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.
 
index 0f18141d712495a56e942cdd09f30955f73fd67f..49892d004a01c2630b8c1ad0164d36c3f8ca4dd1 100644 (file)
--- a/src/fsk.h
+++ b/src/fsk.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.
 
index 9a7550459b0e18669bec41e4d3d8b2d59254a5ec..a5e92aac67d75474d454b8976db5085233281b02 100644 (file)
@@ -33,7 +33,7 @@
 
 
 /** @file  src/key.cc
- *  @brief Key class.
+ *  @brief Key class
  */
 
 
index 3b0b6ac9f19dd2601c66cc171b96e08bd9b782a6..0f05ac12371ba3d7cdc2ffed4a88695807bdf4a7 100644 (file)
@@ -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
index 9b1b432cd044b4d33b88d2bb2ac65c8f3cc7b5d5..37510a96d32ca08e046335af1991b98e6147b3ed 100644 (file)
@@ -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
  */
 
 
index 8c1521469538c54efe7b237bf42b82bf63f5871e..f6f8877c5e8e9c53484636b8a4b55fe7db47d51f 100644 (file)
@@ -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
index 3594b2bde540e1579510cae18717e20ec21a4043..d17943affe93e010f07f14bfc65d0e557563bea4 100644 (file)
@@ -33,7 +33,7 @@
 
 
 /** @file  src/openjpeg_image.cc
- *  @brief OpenJPEGImage class.
+ *  @brief OpenJPEGImage class
  */
 
 
index 344e41c30a6f7b9eb647af942456c38f82e861fd..ba08c267f36585c0ed3623c5db28a25e3d0af665 100644 (file)
@@ -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 &lt;EntryPoint&gt; from the reel's entry for this asset
 };
 
+
 }
 
+
 #endif
index 52151868e33d31cf49df67c1ef762ffcaad57e3e..360a855aac331a11020777dd59aaa7a84e30a068 100644 (file)
 */
 
 
+/** @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;
 }
index 5b33bbf23dd3fdc7a912e1ecddf68f37eb1836ba..1eae47ef37023b0e8878a3f94850558db5a8f873 100644 (file)
 */
 
 
+/** @file  src/reel_markers_asset.cc
+ *  @brief ReelMarkersAsset class
+ */
+
+
 #include "reel_asset.h"
 #include "dcp_time.h"
 #include <map>
index a5fd2a24b5057aaac23f42852dc1059afad7b825..a8766b8e4000a565db972964ef1dda0263f91ab8 100644 (file)
 */
 
 
+/** @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;
index eb1b5ac8a8a7f9fdbcbdce273d5d563af19d2d8e..4a920efb3db9908a4e498c74f678e8ed166ad464 100644 (file)
 */
 
 
+/** @file  rgb_xyz.h
+ *  @brief Conversion between RGB and XYZ
+ */
+
+
 #include "types.h"
 #include <memory>
 #include <boost/optional.hpp>
index 7109e98bb3f670b45f122b636394d5dab47184be..81abfe0bf841f0a3af1a876b7f3cf21d9abe6ac6 100644 (file)
@@ -33,7 +33,7 @@
 
 
 /** @file  src/smpte_load_font_node.h
- *  @brief SMPTELoadFontNode class.
+ *  @brief SMPTELoadFontNode class
  */
 
 
index 8df4fcc261271034f4f08947c76f7c57d1be73fa..ac9cb6d9890396b12ec3424c32c81fa601357231 100644 (file)
 */
 
 
+/** @file  src/stereo_picture_frame.cc
+ *  @brief StereoPictureFrame class
+ */
+
+
 #include "stereo_picture_frame.h"
 #include "exceptions.h"
 #include "util.h"
index 8beca192ce77c0946617f291d2729965de409bd1..e0132dbe8a99152792a4d5fd739b14cd6dc45559 100644 (file)
 */
 
 
-#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"
 
 
index 7bfc4b865263c171d9f9b06639968cb6bb811899..b281d7541a2cea3dbbe61387ac3230d0a814e42e 100644 (file)
@@ -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.
 
     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)
 {
index 2cdfea25ea5715cb971190d26ecd7578da491e73..595320f79303b092ade88ba2d16b54c9f7b7e009 100644 (file)
@@ -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.
 
     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
 
 #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
index 0f89291e893b6175a55c10c2f9400d1f89723f18..28c02114ceb749fbdc9dbc4a2579bdb6f3093e91 100644 (file)
@@ -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.
 
     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)
 {
index 8e798d8ec6fdcb19ebe638efcf7dbba41d2e2ea8..bf9c87d9036cf32f1919872d773c2dc22afc07a8 100644 (file)
@@ -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.
 
     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
index 8746c8284e428180ec09cbd745162cd4942557c4..00968e2f633a1651a43f4e1d50147349f183a7a2 100644 (file)
@@ -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.
 
     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;
        }
index 508ff93428ba2aedcd3f34af4a20b8693485aa64..a52011ec003c844db49d1f74b466d3f2a417cdb5 100644 (file)
@@ -33,7 +33,7 @@
 
 
 /** @file  src/transfer_function.h
- *  @brief TransferFunction class.
+ *  @brief TransferFunction class
  */
 
 
index 099512c62e3635261a0cb5663bc5c46c04a7fc1b..f22bfa911a1a9786e6ac260180c7722690f8f024 100644 (file)
@@ -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.
 
     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"
 #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
- *  &lt;ContentKind&gt; node.
- *  @param kind ContentKind.
- *  @return string.
+ *  &lt;ContentKind&gt; 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 &lt;ContentKind&gt; 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);
        }
-
 }
 
 
index 4f2048b43c04876f32ff1b4dd45d793fe8d5d931..374dd8b8c1d22741deeafbd252ddae3ffe3340c2 100644 (file)
@@ -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.
 
     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 &lt;AnnotationText&gt; nodes of CPLs are allowed to differ */
-       bool cpl_annotation_texts_can_differ;
+       bool cpl_annotation_texts_can_differ = false;
        /** true if the &lt;AnnotationText&gt; 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
index cc272b643522247ff6213a1fb417d7825b184921..d6803cdf32772c9df8c62388a2092458913f58bd 100644 (file)
@@ -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
index 6f6a48f1b8a418fc4a1f0e6703b028438275b8d5..3cb61bad286629c863c8ff14af8d132ec7845696 100644 (file)
     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)
 {
index ee90b2262d1da61d0f7412e673c2db6e313df2b8..0a8b39ca03e6cbad3d97bccdf1c73b2630f196e0 100644 (file)
     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