From 57f112a2bd073123a686141be6c16ba997349056 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 25 Jul 2019 11:37:52 +0100 Subject: Optimise decoder_factory for DCPDecoder by offering the old decoder (if available) to recover the list of reels from, rather than having to scan the filesystem again. --- src/lib/decoder_factory.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/lib/decoder_factory.cc') diff --git a/src/lib/decoder_factory.cc b/src/lib/decoder_factory.cc index 4b2a594e1..5d758956d 100644 --- a/src/lib/decoder_factory.cc +++ b/src/lib/decoder_factory.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2016 Carl Hetherington + Copyright (C) 2016-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -30,14 +30,26 @@ #include "dcp_subtitle_decoder.h" #include "video_mxf_content.h" #include "video_mxf_decoder.h" +#include "timer.h" #include using std::list; using boost::shared_ptr; using boost::dynamic_pointer_cast; +template +shared_ptr +maybe_cast (shared_ptr d) +{ + if (!d) { + return shared_ptr (); + } + return dynamic_pointer_cast (d); +} + +/** @param old_decoder A `used' decoder that has been previously made for this piece of content, or 0 */ shared_ptr -decoder_factory (shared_ptr film, shared_ptr content, bool fast) +decoder_factory (shared_ptr film, shared_ptr content, bool fast, shared_ptr old_decoder) { shared_ptr fc = dynamic_pointer_cast (content); if (fc) { @@ -47,7 +59,7 @@ decoder_factory (shared_ptr film, shared_ptr content, shared_ptr dc = dynamic_pointer_cast (content); if (dc) { try { - return shared_ptr (new DCPDecoder(film, dc, fast)); + return shared_ptr (new DCPDecoder(film, dc, fast, maybe_cast(old_decoder))); } catch (KDMError& e) { /* This will be found and reported to the user when the content is examined */ return shared_ptr(); -- cgit v1.2.3