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