Merge branch '1.0' of /home/carl/git/dvdomatic into 1.0
[dcpomatic.git] / src / lib / film.cc
1 /*
2     Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <stdexcept>
21 #include <iostream>
22 #include <algorithm>
23 #include <fstream>
24 #include <cstdlib>
25 #include <sstream>
26 #include <iomanip>
27 #include <unistd.h>
28 #include <boost/filesystem.hpp>
29 #include <boost/algorithm/string.hpp>
30 #include <boost/lexical_cast.hpp>
31 #include <boost/date_time.hpp>
32 #include <libxml++/libxml++.h>
33 #include <libcxml/cxml.h>
34 #include "film.h"
35 #include "job.h"
36 #include "util.h"
37 #include "job_manager.h"
38 #include "transcode_job.h"
39 #include "scp_dcp_job.h"
40 #include "log.h"
41 #include "exceptions.h"
42 #include "examine_content_job.h"
43 #include "scaler.h"
44 #include "config.h"
45 #include "version.h"
46 #include "ui_signaller.h"
47 #include "playlist.h"
48 #include "player.h"
49 #include "dcp_content_type.h"
50 #include "ratio.h"
51 #include "cross.h"
52
53 #include "i18n.h"
54
55 using std::string;
56 using std::stringstream;
57 using std::multimap;
58 using std::pair;
59 using std::map;
60 using std::vector;
61 using std::ifstream;
62 using std::ofstream;
63 using std::setfill;
64 using std::min;
65 using std::make_pair;
66 using std::endl;
67 using std::cout;
68 using std::list;
69 using boost::shared_ptr;
70 using boost::weak_ptr;
71 using boost::lexical_cast;
72 using boost::dynamic_pointer_cast;
73 using boost::to_upper_copy;
74 using boost::ends_with;
75 using boost::starts_with;
76 using boost::optional;
77 using libdcp::Size;
78
79 int const Film::state_version = 4;
80
81 /** Construct a Film object in a given directory.
82  *
83  *  @param dir Film directory.
84  */
85
86 Film::Film (boost::filesystem::path dir)
87         : _playlist (new Playlist)
88         , _use_dci_name (true)
89         , _dcp_content_type (Config::instance()->default_dcp_content_type ())
90         , _container (Config::instance()->default_container ())
91         , _resolution (RESOLUTION_2K)
92         , _scaler (Scaler::from_id ("bicubic"))
93         , _with_subtitles (false)
94         , _j2k_bandwidth (Config::instance()->default_j2k_bandwidth ())
95         , _dci_metadata (Config::instance()->default_dci_metadata ())
96         , _video_frame_rate (24)
97         , _audio_channels (MAX_AUDIO_CHANNELS)
98         , _three_d (false)
99         , _sequence_video (true)
100         , _interop (false)
101         , _dirty (false)
102 {
103         set_dci_date_today ();
104
105         _playlist->Changed.connect (bind (&Film::playlist_changed, this));
106         _playlist->ContentChanged.connect (bind (&Film::playlist_content_changed, this, _1, _2));
107         
108         /* Make state.directory a complete path without ..s (where possible)
109            (Code swiped from Adam Bowen on stackoverflow)
110         */
111         
112         boost::filesystem::path p (boost::filesystem::system_complete (dir));
113         boost::filesystem::path result;
114         for (boost::filesystem::path::iterator i = p.begin(); i != p.end(); ++i) {
115                 if (*i == "..") {
116                         if (boost::filesystem::is_symlink (result) || result.filename() == "..") {
117                                 result /= *i;
118                         } else {
119                                 result = result.parent_path ();
120                         }
121                 } else if (*i != ".") {
122                         result /= *i;
123                 }
124         }
125
126         set_directory (result.string ());
127         _log.reset (new FileLog (file ("log")));
128
129         _playlist->set_sequence_video (_sequence_video);
130 }
131
132 string
133 Film::video_identifier () const
134 {
135         assert (container ());
136         LocaleGuard lg;
137
138         stringstream s;
139         s << container()->id()
140           << "_" << resolution_to_string (_resolution)
141           << "_" << _playlist->video_identifier()
142           << "_" << _video_frame_rate
143           << "_" << scaler()->id()
144           << "_" << j2k_bandwidth();
145
146         if (_interop) {
147                 s << "_I";
148         } else {
149                 s << "_S";
150         }
151
152         if (_three_d) {
153                 s << "_3D";
154         }
155
156         return s.str ();
157 }
158           
159 /** @return The path to the directory to write video frame info files to */
160 string
161 Film::info_dir () const
162 {
163         boost::filesystem::path p;
164         p /= "info";
165         p /= video_identifier ();
166         return dir (p.string());
167 }
168
169 string
170 Film::internal_video_mxf_dir () const
171 {
172         return dir ("video");
173 }
174
175 string
176 Film::internal_video_mxf_filename () const
177 {
178         return video_identifier() + ".mxf";
179 }
180
181 string
182 Film::video_mxf_filename () const
183 {
184         return filename_safe_name() + "_video.mxf";
185 }
186
187 string
188 Film::audio_mxf_filename () const
189 {
190         return filename_safe_name() + "_audio.mxf";
191 }
192
193 string
194 Film::filename_safe_name () const
195 {
196         string const n = name ();
197         string o;
198         for (size_t i = 0; i < n.length(); ++i) {
199                 if (isalnum (n[i])) {
200                         o += n[i];
201                 } else {
202                         o += "_";
203                 }
204         }
205
206         return o;
207 }
208
209 boost::filesystem::path
210 Film::audio_analysis_path (shared_ptr<const AudioContent> c) const
211 {
212         boost::filesystem::path p = dir ("analysis");
213         p /= c->digest();
214         return p;
215 }
216
217 /** Add suitable Jobs to the JobManager to create a DCP for this Film */
218 void
219 Film::make_dcp ()
220 {
221         set_dci_date_today ();
222         
223         if (dcp_name().find ("/") != string::npos) {
224                 throw BadSettingError (_("name"), _("cannot contain slashes"));
225         }
226         
227         log()->log (String::compose ("DCP-o-matic %1 git %2 using %3", dcpomatic_version, dcpomatic_git_commit, dependency_version_summary()));
228
229         {
230                 char buffer[128];
231                 gethostname (buffer, sizeof (buffer));
232                 log()->log (String::compose ("Starting to make DCP on %1", buffer));
233         }
234
235         ContentList cl = content ();
236         for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) {
237                 log()->log (String::compose ("Content: %1", (*i)->technical_summary()));
238         }
239         log()->log (String::compose ("DCP video rate %1 fps", video_frame_rate()));
240         log()->log (String::compose ("%1 threads", Config::instance()->num_local_encoding_threads()));
241         log()->log (String::compose ("J2K bandwidth %1", j2k_bandwidth()));
242 #ifdef DCPOMATIC_DEBUG
243         log()->log ("DCP-o-matic built in debug mode.");
244 #else
245         log()->log ("DCP-o-matic built in optimised mode.");
246 #endif
247 #ifdef LIBDCP_DEBUG
248         log()->log ("libdcp built in debug mode.");
249 #else
250         log()->log ("libdcp built in optimised mode.");
251 #endif
252         log()->log (String::compose ("CPU: %1, %2 processors", cpu_info(), boost::thread::hardware_concurrency ()));
253         list<pair<string, string> > const m = mount_info ();
254         for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) {
255                 log()->log (String::compose ("Mount: %1 %2", i->first, i->second));
256         }
257         
258         if (container() == 0) {
259                 throw MissingSettingError (_("container"));
260         }
261
262         if (content().empty()) {
263                 throw StringError (_("You must add some content to the DCP before creating it"));
264         }
265
266         if (dcp_content_type() == 0) {
267                 throw MissingSettingError (_("content type"));
268         }
269
270         if (name().empty()) {
271                 throw MissingSettingError (_("name"));
272         }
273
274         JobManager::instance()->add (shared_ptr<Job> (new TranscodeJob (shared_from_this())));
275 }
276
277 /** Start a job to send our DCP to the configured TMS */
278 void
279 Film::send_dcp_to_tms ()
280 {
281         shared_ptr<Job> j (new SCPDCPJob (shared_from_this()));
282         JobManager::instance()->add (j);
283 }
284
285 /** Count the number of frames that have been encoded for this film.
286  *  @return frame count.
287  */
288 int
289 Film::encoded_frames () const
290 {
291         if (container() == 0) {
292                 return 0;
293         }
294
295         int N = 0;
296         for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (info_dir ()); i != boost::filesystem::directory_iterator(); ++i) {
297                 ++N;
298                 boost::this_thread::interruption_point ();
299         }
300
301         return N;
302 }
303
304 /** Write state to our `metadata' file */
305 void
306 Film::write_metadata () const
307 {
308         if (!boost::filesystem::exists (directory())) {
309                 boost::filesystem::create_directory (directory());
310         }
311         
312         LocaleGuard lg;
313
314         boost::filesystem::create_directories (directory());
315
316         xmlpp::Document doc;
317         xmlpp::Element* root = doc.create_root_node ("Metadata");
318
319         root->add_child("Version")->add_child_text (lexical_cast<string> (state_version));
320         root->add_child("Name")->add_child_text (_name);
321         root->add_child("UseDCIName")->add_child_text (_use_dci_name ? "1" : "0");
322
323         if (_dcp_content_type) {
324                 root->add_child("DCPContentType")->add_child_text (_dcp_content_type->dci_name ());
325         }
326
327         if (_container) {
328                 root->add_child("Container")->add_child_text (_container->id ());
329         }
330
331         root->add_child("Resolution")->add_child_text (resolution_to_string (_resolution));
332         root->add_child("Scaler")->add_child_text (_scaler->id ());
333         root->add_child("WithSubtitles")->add_child_text (_with_subtitles ? "1" : "0");
334         root->add_child("J2KBandwidth")->add_child_text (lexical_cast<string> (_j2k_bandwidth));
335         _dci_metadata.as_xml (root->add_child ("DCIMetadata"));
336         root->add_child("VideoFrameRate")->add_child_text (lexical_cast<string> (_video_frame_rate));
337         root->add_child("DCIDate")->add_child_text (boost::gregorian::to_iso_string (_dci_date));
338         root->add_child("AudioChannels")->add_child_text (lexical_cast<string> (_audio_channels));
339         root->add_child("ThreeD")->add_child_text (_three_d ? "1" : "0");
340         root->add_child("SequenceVideo")->add_child_text (_sequence_video ? "1" : "0");
341         root->add_child("Interop")->add_child_text (_interop ? "1" : "0");
342         _playlist->as_xml (root->add_child ("Playlist"));
343
344         doc.write_to_file_formatted (file ("metadata.xml"));
345         
346         _dirty = false;
347 }
348
349 /** Read state from our metadata file */
350 void
351 Film::read_metadata ()
352 {
353         LocaleGuard lg;
354
355         if (boost::filesystem::exists (file ("metadata")) && !boost::filesystem::exists (file ("metadata.xml"))) {
356                 throw StringError (_("This film was created with an older version of DCP-o-matic, and unfortunately it cannot be loaded into this version.  You will need to create a new Film, re-add your content and set it up again.  Sorry!"));
357         }
358
359         cxml::File f (file ("metadata.xml"), "Metadata");
360         
361         _name = f.string_child ("Name");
362         _use_dci_name = f.bool_child ("UseDCIName");
363
364         {
365                 optional<string> c = f.optional_string_child ("DCPContentType");
366                 if (c) {
367                         _dcp_content_type = DCPContentType::from_dci_name (c.get ());
368                 }
369         }
370
371         {
372                 optional<string> c = f.optional_string_child ("Container");
373                 if (c) {
374                         _container = Ratio::from_id (c.get ());
375                 }
376         }
377
378         _resolution = string_to_resolution (f.string_child ("Resolution"));
379         _scaler = Scaler::from_id (f.string_child ("Scaler"));
380         _with_subtitles = f.bool_child ("WithSubtitles");
381         _j2k_bandwidth = f.number_child<int> ("J2KBandwidth");
382         _dci_metadata = DCIMetadata (f.node_child ("DCIMetadata"));
383         _video_frame_rate = f.number_child<int> ("VideoFrameRate");
384         _dci_date = boost::gregorian::from_undelimited_string (f.string_child ("DCIDate"));
385         _audio_channels = f.number_child<int> ("AudioChannels");
386         _sequence_video = f.bool_child ("SequenceVideo");
387         _three_d = f.bool_child ("ThreeD");
388         _interop = f.bool_child ("Interop");
389
390         _playlist->set_from_xml (shared_from_this(), f.node_child ("Playlist"));
391
392         _dirty = false;
393 }
394
395 /** Given a directory name, return its full path within the Film's directory.
396  *  The directory (and its parents) will be created if they do not exist.
397  */
398 string
399 Film::dir (string d) const
400 {
401         boost::filesystem::path p;
402         p /= _directory;
403         p /= d;
404         
405         boost::filesystem::create_directories (p);
406         
407         return p.string ();
408 }
409
410 /** Given a file or directory name, return its full path within the Film's directory.
411  *  Any required parent directories will be created.
412  */
413 string
414 Film::file (string f) const
415 {
416         boost::filesystem::path p;
417         p /= _directory;
418         p /= f;
419
420         boost::filesystem::create_directories (p.parent_path ());
421         
422         return p.string ();
423 }
424
425 /** @return a DCI-compliant name for a DCP of this film */
426 string
427 Film::dci_name (bool if_created_now) const
428 {
429         stringstream d;
430
431         string fixed_name = to_upper_copy (name());
432         for (size_t i = 0; i < fixed_name.length(); ++i) {
433                 if (fixed_name[i] == ' ') {
434                         fixed_name[i] = '-';
435                 }
436         }
437
438         /* Spec is that the name part should be maximum 14 characters, as I understand it */
439         if (fixed_name.length() > 14) {
440                 fixed_name = fixed_name.substr (0, 14);
441         }
442
443         d << fixed_name;
444
445         if (dcp_content_type()) {
446                 d << "_" << dcp_content_type()->dci_name();
447                 d << "-" << dci_metadata().content_version;
448         }
449
450         if (three_d ()) {
451                 d << "-3D";
452         }
453
454         if (video_frame_rate() != 24) {
455                 d << "-" << video_frame_rate();
456         }
457
458         if (container()) {
459                 d << "_" << container()->dci_name();
460         }
461
462         DCIMetadata const dm = dci_metadata ();
463
464         if (!dm.audio_language.empty ()) {
465                 d << "_" << dm.audio_language;
466                 if (!dm.subtitle_language.empty() && with_subtitles()) {
467                         d << "-" << dm.subtitle_language;
468                 } else {
469                         d << "-XX";
470                 }
471         }
472
473         if (!dm.territory.empty ()) {
474                 d << "_" << dm.territory;
475                 if (!dm.rating.empty ()) {
476                         d << "-" << dm.rating;
477                 }
478         }
479
480         switch (audio_channels ()) {
481         case 1:
482                 d << "_10";
483                 break;
484         case 2:
485                 d << "_20";
486                 break;
487         case 3:
488                 d << "_30";
489                 break;
490         case 4:
491                 d << "_40";
492                 break;
493         case 5:
494                 d << "_50";
495                 break;
496         case 6:
497                 d << "_51";
498                 break;
499         }
500
501         d << "_" << resolution_to_string (_resolution);
502
503         if (!dm.studio.empty ()) {
504                 d << "_" << dm.studio;
505         }
506
507         if (if_created_now) {
508                 d << "_" << boost::gregorian::to_iso_string (boost::gregorian::day_clock::local_day ());
509         } else {
510                 d << "_" << boost::gregorian::to_iso_string (_dci_date);
511         }
512
513         if (!dm.facility.empty ()) {
514                 d << "_" << dm.facility;
515         }
516
517         if (!dm.package_type.empty ()) {
518                 d << "_" << dm.package_type;
519         }
520
521         return d.str ();
522 }
523
524 /** @return name to give the DCP */
525 string
526 Film::dcp_name (bool if_created_now) const
527 {
528         if (use_dci_name()) {
529                 return dci_name (if_created_now);
530         }
531
532         return name();
533 }
534
535
536 void
537 Film::set_directory (string d)
538 {
539         _directory = d;
540         _dirty = true;
541 }
542
543 void
544 Film::set_name (string n)
545 {
546         _name = n;
547         signal_changed (NAME);
548 }
549
550 void
551 Film::set_use_dci_name (bool u)
552 {
553         _use_dci_name = u;
554         signal_changed (USE_DCI_NAME);
555 }
556
557 void
558 Film::set_dcp_content_type (DCPContentType const * t)
559 {
560         _dcp_content_type = t;
561         signal_changed (DCP_CONTENT_TYPE);
562 }
563
564 void
565 Film::set_container (Ratio const * c)
566 {
567         _container = c;
568         signal_changed (CONTAINER);
569 }
570
571 void
572 Film::set_resolution (Resolution r)
573 {
574         _resolution = r;
575         signal_changed (RESOLUTION);
576 }
577
578 void
579 Film::set_scaler (Scaler const * s)
580 {
581         _scaler = s;
582         signal_changed (SCALER);
583 }
584
585 void
586 Film::set_with_subtitles (bool w)
587 {
588         _with_subtitles = w;
589         signal_changed (WITH_SUBTITLES);
590 }
591
592 void
593 Film::set_j2k_bandwidth (int b)
594 {
595         _j2k_bandwidth = b;
596         signal_changed (J2K_BANDWIDTH);
597 }
598
599 void
600 Film::set_dci_metadata (DCIMetadata m)
601 {
602         _dci_metadata = m;
603         signal_changed (DCI_METADATA);
604 }
605
606 void
607 Film::set_video_frame_rate (int f)
608 {
609         _video_frame_rate = f;
610         signal_changed (VIDEO_FRAME_RATE);
611 }
612
613 void
614 Film::set_audio_channels (int c)
615 {
616         _audio_channels = c;
617         signal_changed (AUDIO_CHANNELS);
618 }
619
620 void
621 Film::set_three_d (bool t)
622 {
623         _three_d = t;
624         signal_changed (THREE_D);
625 }
626
627 void
628 Film::set_interop (bool i)
629 {
630         _interop = i;
631         signal_changed (INTEROP);
632 }
633
634 void
635 Film::signal_changed (Property p)
636 {
637         _dirty = true;
638
639         switch (p) {
640         case Film::CONTENT:
641                 set_video_frame_rate (_playlist->best_dcp_frame_rate ());
642                 break;
643         case Film::VIDEO_FRAME_RATE:
644         case Film::SEQUENCE_VIDEO:
645                 _playlist->maybe_sequence_video ();
646                 break;
647         default:
648                 break;
649         }
650
651         if (ui_signaller) {
652                 ui_signaller->emit (boost::bind (boost::ref (Changed), p));
653         }
654 }
655
656 void
657 Film::set_dci_date_today ()
658 {
659         _dci_date = boost::gregorian::day_clock::local_day ();
660 }
661
662 string
663 Film::info_path (int f, Eyes e) const
664 {
665         boost::filesystem::path p;
666         p /= info_dir ();
667
668         stringstream s;
669         s.width (8);
670         s << setfill('0') << f;
671
672         if (e == EYES_LEFT) {
673                 s << ".L";
674         } else if (e == EYES_RIGHT) {
675                 s << ".R";
676         }
677
678         s << ".md5";
679         
680         p /= s.str();
681
682         /* info_dir() will already have added any initial bit of the path,
683            so don't call file() on this.
684         */
685         return p.string ();
686 }
687
688 string
689 Film::j2c_path (int f, Eyes e, bool t) const
690 {
691         boost::filesystem::path p;
692         p /= "j2c";
693         p /= video_identifier ();
694
695         stringstream s;
696         s.width (8);
697         s << setfill('0') << f;
698
699         if (e == EYES_LEFT) {
700                 s << ".L";
701         } else if (e == EYES_RIGHT) {
702                 s << ".R";
703         }
704         
705         s << ".j2c";
706
707         if (t) {
708                 s << ".tmp";
709         }
710
711         p /= s.str();
712         return file (p.string ());
713 }
714
715 /** Make an educated guess as to whether we have a complete DCP
716  *  or not.
717  *  @return true if we do.
718  */
719
720 bool
721 Film::have_dcp () const
722 {
723         try {
724                 libdcp::DCP dcp (dir (dcp_name()));
725                 dcp.read ();
726         } catch (...) {
727                 return false;
728         }
729
730         return true;
731 }
732
733 shared_ptr<Player>
734 Film::make_player () const
735 {
736         return shared_ptr<Player> (new Player (shared_from_this (), _playlist));
737 }
738
739 shared_ptr<Playlist>
740 Film::playlist () const
741 {
742         return _playlist;
743 }
744
745 ContentList
746 Film::content () const
747 {
748         return _playlist->content ();
749 }
750
751 void
752 Film::examine_and_add_content (shared_ptr<Content> c)
753 {
754         shared_ptr<Job> j (new ExamineContentJob (shared_from_this(), c));
755         j->Finished.connect (bind (&Film::maybe_add_content, this, boost::weak_ptr<Job> (j), boost::weak_ptr<Content> (c)));
756         JobManager::instance()->add (j);
757 }
758
759 void
760 Film::maybe_add_content (weak_ptr<Job> j, weak_ptr<Content> c)
761 {
762         shared_ptr<Job> job = j.lock ();
763         if (!job || !job->finished_ok ()) {
764                 return;
765         }
766         
767         shared_ptr<Content> content = c.lock ();
768         if (content) {
769                 add_content (content);
770         }
771 }
772
773 void
774 Film::add_content (shared_ptr<Content> c)
775 {
776         /* Add video content after any existing content */
777         if (dynamic_pointer_cast<VideoContent> (c)) {
778                 c->set_position (_playlist->video_end ());
779         }
780
781         _playlist->add (c);
782 }
783
784 void
785 Film::remove_content (shared_ptr<Content> c)
786 {
787         _playlist->remove (c);
788 }
789
790 Time
791 Film::length () const
792 {
793         return _playlist->length ();
794 }
795
796 bool
797 Film::has_subtitles () const
798 {
799         return _playlist->has_subtitles ();
800 }
801
802 OutputVideoFrame
803 Film::best_video_frame_rate () const
804 {
805         return _playlist->best_dcp_frame_rate ();
806 }
807
808 void
809 Film::playlist_content_changed (boost::weak_ptr<Content> c, int p)
810 {
811         if (p == VideoContentProperty::VIDEO_FRAME_RATE) {
812                 set_video_frame_rate (_playlist->best_dcp_frame_rate ());
813         } 
814
815         if (ui_signaller) {
816                 ui_signaller->emit (boost::bind (boost::ref (ContentChanged), c, p));
817         }
818 }
819
820 void
821 Film::playlist_changed ()
822 {
823         signal_changed (CONTENT);
824 }       
825
826 OutputAudioFrame
827 Film::time_to_audio_frames (Time t) const
828 {
829         return t * audio_frame_rate () / TIME_HZ;
830 }
831
832 OutputVideoFrame
833 Film::time_to_video_frames (Time t) const
834 {
835         return t * video_frame_rate () / TIME_HZ;
836 }
837
838 Time
839 Film::audio_frames_to_time (OutputAudioFrame f) const
840 {
841         return f * TIME_HZ / audio_frame_rate ();
842 }
843
844 Time
845 Film::video_frames_to_time (OutputVideoFrame f) const
846 {
847         return f * TIME_HZ / video_frame_rate ();
848 }
849
850 OutputAudioFrame
851 Film::audio_frame_rate () const
852 {
853         /* XXX */
854         return 48000;
855 }
856
857 void
858 Film::set_sequence_video (bool s)
859 {
860         _sequence_video = s;
861         _playlist->set_sequence_video (s);
862         signal_changed (SEQUENCE_VIDEO);
863 }
864
865 libdcp::Size
866 Film::full_frame () const
867 {
868         switch (_resolution) {
869         case RESOLUTION_2K:
870                 return libdcp::Size (2048, 1080);
871         case RESOLUTION_4K:
872                 return libdcp::Size (4096, 2160);
873         }
874
875         assert (false);
876         return libdcp::Size ();
877 }