Remove unused progress parameter to make_digest; some comment tweaks.
authorCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 13:04:43 +0000 (13:04 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 13 Jan 2013 13:04:43 +0000 (13:04 +0000)
src/asset.cc
src/dcp.cc
src/util.cc
src/util.h

index 5ecc2e9f72c5b4f6072c3b8a9991baae9671ddb8..3d2a0e03e21054b02805279ea6fd9ff4d303050a 100644 (file)
@@ -85,7 +85,7 @@ string
 Asset::digest () const
 {
        if (_digest.empty ()) {
-               _digest = make_digest (path().string(), 0);
+               _digest = make_digest (path().string());
        }
 
        return _digest;
index 03c1cdc2782c0329114b85708e32175aa98ac7d3..edb247a51970abf9977d2e77ddbf701d558de8be 100644 (file)
@@ -462,7 +462,7 @@ CPL::write_xml () const
 
        os.close ();
 
-       _digest = make_digest (p.string (), 0);
+       _digest = make_digest (p.string ());
        _length = boost::filesystem::file_size (p.string ());
 }
 
index 78ef7676979c6e227ac01fdc5835f94fc8d47390..ca621a445cdafc25fc8f5e38e8d958bb289a030d 100644 (file)
@@ -59,15 +59,11 @@ libdcp::make_uuid ()
 
 /** Create a digest for a file.
  *  @param filename File name.
- *  @param progress If non-0, a signal which will be emitted periodically to update
- *  progress; the parameter will start at 0.5 and proceed to 1.
  *  @return Digest.
  */
 string
-libdcp::make_digest (string filename, boost::signals2::signal<void (float)>* progress)
+libdcp::make_digest (string filename)
 {
-       int const file_size = boost::filesystem::file_size (filename);
-       
        Kumu::FileReader reader;
        if (ASDCP_FAILURE (reader.OpenRead (filename.c_str ()))) {
                throw FileError ("could not open file to compute digest", filename);
@@ -90,10 +86,6 @@ libdcp::make_digest (string filename, boost::signals2::signal<void (float)>* pro
                
                SHA1_Update (&sha, read_buffer.Data(), read);
                done += read;
-
-               if (progress) {
-                       (*progress) (0.5 + (0.5 * done / file_size));
-               }
        }
 
        byte_t byte_buffer[20];
@@ -104,8 +96,8 @@ libdcp::make_digest (string filename, boost::signals2::signal<void (float)>* pro
        return Kumu::base64encode (byte_buffer, 20, digest, 64);
 }
 
-/** Convert a content kind to a string which is representative,
- *  but not necessarily human-readable.
+/** Convert a content kind to a string which can be used in a
+ *  <ContentKind> node.
  *  @param kind ContentKind.
  *  @return string.
  */
@@ -138,9 +130,16 @@ libdcp::content_kind_to_string (ContentKind kind)
        assert (false);
 }
 
+/** Convert a string from a <ContentKind> node to a libdcp ContentKind.
+ *  Reasonably tolerant about varying case.
+ *  @param type Content kind string.
+ *  @return libdcp ContentKind.
+ */
 libdcp::ContentKind
 libdcp::content_kind_from_string (string type)
 {
+       /* XXX: should probably just convert type to lower-case and have done with it */
+       
        if (type == "feature") {
                return FEATURE;
        } else if (type == "short") {
@@ -165,7 +164,11 @@ libdcp::content_kind_from_string (string type)
 
        assert (false);
 }
-               
+
+/** @param big A string.
+ *  @param little A string which is the same length as, or shorter than, big.
+ *  @return true if `big' starts with `little'.
+ */
 bool
 libdcp::starts_with (string big, string little)
 {
@@ -176,6 +179,10 @@ libdcp::starts_with (string big, string little)
        return big.substr (0, little.length()) == little;
 }
 
+/** @param big A string.
+ *  @param little A string which is the same length as, or shorter than, big.
+ *  @return true if `big' ends with `little'.
+ */
 bool
 libdcp::ends_with (string big, string little)
 {
@@ -186,6 +193,15 @@ libdcp::ends_with (string big, string little)
        return big.compare (big.length() - little.length(), little.length(), little) == 0;
 }
 
+/** Decompress a JPEG2000 image to a bitmap.
+ *  @param data JPEG2000 data.
+ *  @param size Size of data in bytes.
+ *  @param reduce A power of 2 by which to reduce the size of the decoded image;
+ *  e.g. 0 reduces by (2^0 == 1), ie keeping the same size.
+ *       1 reduces by (2^1 == 2), ie halving the size of the image.
+ *  This is useful for scaling 4K DCP images down to 2K.
+ *  @return openjpeg image, which the caller must call opj_image_destroy() on.
+ */
 opj_image_t *
 libdcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
 {
@@ -209,6 +225,10 @@ libdcp::decompress_j2k (uint8_t* data, int64_t size, int reduce)
        return image;
 }
 
+/** Convert an openjpeg XYZ image to RGB.
+ *  @param xyz_frame Frame in XYZ.
+ *  @return RGB image.
+ */
 shared_ptr<ARGBFrame>
 libdcp::xyz_to_rgb (opj_image_t* xyz_frame)
 {
@@ -271,6 +291,9 @@ libdcp::xyz_to_rgb (opj_image_t* xyz_frame)
        return argb_frame;
 }
 
+/** @param s A string.
+ *  @return true if the string contains only space, newline or tab characters, or is empty.
+ */
 bool
 libdcp::empty_or_white_space (string s)
 {
index 619c15c5d4b1a627c6e4db866bb4c96f35e3aad5..14893065c8d4606444eb5da5b5fda280207355dc 100644 (file)
@@ -23,7 +23,6 @@
 
 #include <string>
 #include <stdint.h>
-#include <boost/signals2.hpp>
 #include <openjpeg.h>
 #include "types.h"
 
@@ -32,7 +31,7 @@ namespace libdcp {
 class ARGBFrame;       
        
 extern std::string make_uuid ();
-extern std::string make_digest (std::string filename, boost::signals2::signal<void (float)>* progress);
+extern std::string make_digest (std::string filename);
 extern std::string content_kind_to_string (ContentKind kind);
 extern ContentKind content_kind_from_string (std::string kind);
 extern bool starts_with (std::string big, std::string little);