Speed up referencing of existing DCPs.
authorCarl Hetherington <cth@carlh.net>
Thu, 2 Jun 2016 09:59:16 +0000 (10:59 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 2 Jun 2016 09:59:16 +0000 (10:59 +0100)
When referring to an existing DCP, assume that the hash in the CPL
is correct rather than recalculating it.  This can be a big benefit
when, for example, referring to an existing picture MXF.

src/lib/reel_writer.cc

index d707550bbf3599e1270d44c5dd55852b1d902760..bc0013ff130ec7230f324f80563114f7f131f8f5 100644 (file)
@@ -329,6 +329,10 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
        }
 
        reel->add (reel_picture_asset);
+       /* If we have a hash for this asset in the CPL, assume that it is correct */
+       if (reel_picture_asset->hash()) {
+               reel_picture_asset->asset_ref()->set_hash (reel_picture_asset->hash().get());
+       }
 
        if (_sound_asset) {
                /* We have made a sound asset of our own.  Put it into the reel */
@@ -339,6 +343,10 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
                        shared_ptr<dcp::ReelSoundAsset> k = dynamic_pointer_cast<dcp::ReelSoundAsset> (j.asset);
                        if (k && j.period == _period) {
                                reel->add (k);
+                               /* If we have a hash for this asset in the CPL, assume that it is correct */
+                               if (k->hash()) {
+                                       k->asset_ref()->set_hash (k->hash().get());
+                               }
                        }
                }
        }
@@ -397,6 +405,10 @@ ReelWriter::create_reel (list<ReferencedReelAsset> const & refs, list<shared_ptr
                        shared_ptr<dcp::ReelSubtitleAsset> k = dynamic_pointer_cast<dcp::ReelSubtitleAsset> (j.asset);
                        if (k && j.period == _period) {
                                reel->add (k);
+                               /* If we have a hash for this asset in the CPL, assume that it is correct */
+                               if (k->hash()) {
+                                       k->asset_ref()->set_hash (k->hash().get());
+                               }
                        }
                }
        }