Tiny optimisation; Object default constructor calls make_uuid.
[libdcp.git] / src / util.cc
index 1334b21db6c298e5c5c03cf0d2bd756104ff62e4..86d1bc87d2810e0bfe7f3632e4509b586015447e 100644 (file)
 #include "util.h"
 #include "exceptions.h"
 #include "types.h"
-#include "argb_frame.h"
 #include "certificates.h"
-#include "gamma_lut.h"
-#include "xyz_frame.h"
+#include "xyz_image.h"
+#include "dcp_assert.h"
 #include "compose.hpp"
 #include "KM_util.h"
 #include "KM_fileio.h"
@@ -155,7 +154,7 @@ dcp::content_kind_to_string (ContentKind kind)
                return "advertisement";
        }
 
-       assert (false);
+       DCP_ASSERT (false);
 }
 
 /** Convert a string from a <ContentKind> node to a libdcp ContentKind.
@@ -190,7 +189,7 @@ dcp::content_kind_from_string (string kind)
                return ADVERTISEMENT;
        }
 
-       assert (false);
+       DCP_ASSERT (false);
 }
 
 /** Decompress a JPEG2000 image to a bitmap.
@@ -202,7 +201,7 @@ dcp::content_kind_from_string (string kind)
  *  This is useful for scaling 4K DCP images down to 2K.
  *  @return XYZ image.
  */
-shared_ptr<dcp::XYZFrame>
+shared_ptr<dcp::XYZImage>
 dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
 {
        opj_dinfo_t* decoder = opj_create_decompress (CODEC_J2K);
@@ -223,7 +222,7 @@ dcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
 
        image->x1 = rint (float(image->x1) / pow (2, reduce));
        image->y1 = rint (float(image->y1) / pow (2, reduce));
-       return shared_ptr<XYZFrame> (new XYZFrame (image));
+       return shared_ptr<XYZImage> (new XYZImage (image));
 }
 
 /** @param s A string.
@@ -415,3 +414,16 @@ dcp::private_key_fingerprint (string key)
        char digest_base64[64];
        return Kumu::base64encode (digest, 20, digest_base64, 64);
 }
+
+xmlpp::Node *
+dcp::find_child (xmlpp::Node const * node, string name)
+{
+       xmlpp::Node::NodeList c = node->get_children ();
+       xmlpp::Node::NodeList::iterator i = c.begin();
+       while (i != c.end() && (*i)->get_name() != name) {
+               ++i;
+       }
+
+       DCP_ASSERT (i != c.end ());
+       return *i;
+}