From 6f344b876689a1234a5eb75041882f06f5d9fe5c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Apr 2016 22:10:54 +0100 Subject: [PATCH] Reasonably straightforward stuff; main things are adding a _parent to VideoContent (mainly, but not only, for signalling) and moving the video shared_ptr into Content, which makes much more sense to replace dynamic_cast tests for whether something has video or whatever. Nearly builds. --- src/lib/content.h | 5 ++- src/lib/dcp_content.cc | 17 +++++---- src/lib/dcp_content.h | 2 -- src/lib/dcp_decoder.cc | 4 +-- src/lib/dcp_decoder.h | 4 +-- src/lib/ffmpeg_content.cc | 21 +++++++----- src/lib/ffmpeg_content.h | 2 -- src/lib/ffmpeg_decoder.cc | 8 ++--- src/lib/ffmpeg_examiner.h | 1 + src/lib/film.cc | 20 +++++------ src/lib/image_content.cc | 31 ++++++----------- src/lib/image_content.h | 3 -- src/lib/image_decoder.cc | 10 +++--- src/lib/image_decoder.h | 4 +-- src/lib/image_examiner.cc | 4 +-- src/lib/player.cc | 43 ++++++++++++----------- src/lib/playlist.cc | 33 ++++++++---------- src/lib/types.h | 1 - src/lib/video_content.cc | 63 +++++++++++++++++++++------------- src/lib/video_content.h | 17 ++++++--- src/lib/video_decoder.cc | 7 ++-- src/lib/video_decoder.h | 4 ++- src/tools/dcpomatic.cc | 13 +++---- src/tools/dcpomatic_create.cc | 10 +++--- src/wx/content_panel.cc | 13 ++++--- src/wx/content_panel.h | 2 +- src/wx/dcp_panel.cc | 3 +- src/wx/timeline.cc | 2 +- src/wx/timing_panel.cc | 18 +++++----- src/wx/video_panel.cc | 55 ++++++++++++++++------------- test/4k_test.cc | 3 +- test/black_fill_test.cc | 11 +++--- test/dcp_subtitle_test.cc | 2 +- test/ffmpeg_audio_test.cc | 3 +- test/ffmpeg_dcp_test.cc | 3 +- test/ffmpeg_pts_offset_test.cc | 2 +- test/frame_rate_test.cc | 55 ++++++++++++++--------------- test/isdcf_name_test.cc | 5 +-- 38 files changed, 264 insertions(+), 240 deletions(-) diff --git a/src/lib/content.h b/src/lib/content.h index d08540a9a..0ce9d39c1 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -166,9 +166,12 @@ public: boost::signals2::signal, int, bool)> Changed; -protected: + boost::shared_ptr video; + void signal_changed (int); +protected: + virtual void add_properties (std::list &) const {} boost::weak_ptr _film; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 3bc28598d..5a9a47fb1 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -55,7 +55,6 @@ DCPContent::DCPContent (shared_ptr film, boost::filesystem::path p) : Content (film) , SingleStreamAudioContent (film) , SubtitleContent (film) - , video (new VideoContent (film)) , _has_subtitles (false) , _encrypted (false) , _kdm_valid (false) @@ -63,6 +62,8 @@ DCPContent::DCPContent (shared_ptr film, boost::filesystem::path p) , _reference_audio (false) , _reference_subtitle (false) { + video.reset (new VideoContent (this, film)); + read_directory (p); set_default_colour_conversion (); } @@ -71,8 +72,9 @@ DCPContent::DCPContent (shared_ptr film, cxml::ConstNodePtr node, in : Content (film, node) , SingleStreamAudioContent (film, node, version) , SubtitleContent (film, node, version) - , video (new VideoContent (film, node, version)) { + video.reset (new VideoContent (this, film, node, version)); + _name = node->string_child ("Name"); _has_subtitles = node->bool_child ("HasSubtitles"); _encrypted = node->bool_child ("Encrypted"); @@ -165,7 +167,7 @@ DCPTime DCPContent::full_length () const { FrameRateChange const frc (video->video_frame_rate (), film()->video_frame_rate ()); - return DCPTime::from_frames (llrint (video_length () * frc.factor ()), film()->video_frame_rate ()); + return DCPTime::from_frames (llrint (video->video_length () * frc.factor ()), film()->video_frame_rate ()); } string @@ -259,7 +261,7 @@ DCPContent::reels () const list p; scoped_ptr decoder; try { - decoder.reset (new DCPDecoder (shared_from_this(), false)); + decoder.reset (new DCPDecoder (shared_from_this(), film()->log(), false)); } catch (...) { /* Could not load the DCP; guess reels */ list p; @@ -314,13 +316,14 @@ DCPContent::can_reference (string overlapping, list& why_not) const bool DCPContent::can_reference_video (list& why_not) const { - return can_reference (_("There is other video content overlapping this DCP; remove it."), why_not); + /* XXX: this needs to be fixed */ + return true; } bool DCPContent::can_reference_audio (list& why_not) const { - DCPDecoder decoder (shared_from_this(), false); + DCPDecoder decoder (shared_from_this(), film()->log(), false); BOOST_FOREACH (shared_ptr i, decoder.reels()) { if (!i->main_sound()) { why_not.push_back (_("The DCP does not have sound in all reels.")); @@ -334,7 +337,7 @@ DCPContent::can_reference_audio (list& why_not) const bool DCPContent::can_reference_subtitle (list& why_not) const { - DCPDecoder decoder (shared_from_this(), false); + DCPDecoder decoder (shared_from_this(), film()->log(), false); BOOST_FOREACH (shared_ptr i, decoder.reels()) { if (!i->main_subtitle()) { why_not.push_back (_("The DCP does not have subtitles in all reels.")); diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index 04352b269..1edc3a3aa 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -121,8 +121,6 @@ public: bool can_reference_subtitle (std::list &) const; - boost::shared_ptr video; - protected: void add_properties (std::list& p) const; diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 873b3634f..e8c64a086 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -42,8 +42,8 @@ using std::cout; using boost::shared_ptr; using boost::dynamic_pointer_cast; -DCPDecoder::DCPDecoder (shared_ptr c, bool fast) - : VideoDecoder (c->video) +DCPDecoder::DCPDecoder (shared_ptr c, shared_ptr log, bool fast) + : VideoDecoder (c->video, log) , AudioDecoder (c, fast) , SubtitleDecoder (c) , _dcp_content (c) diff --git a/src/lib/dcp_decoder.h b/src/lib/dcp_decoder.h index 32d334ec1..ce9a3ef9a 100644 --- a/src/lib/dcp_decoder.h +++ b/src/lib/dcp_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ struct dcp_subtitle_within_dcp_test; class DCPDecoder : public VideoDecoder, public AudioDecoder, public SubtitleDecoder { public: - DCPDecoder (boost::shared_ptr, bool fast); + DCPDecoder (boost::shared_ptr, boost::shared_ptr log, bool fast); std::list > reels () const { return _reels; diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 54e0b470a..a8b7fb716 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -63,8 +63,9 @@ FFmpegContent::FFmpegContent (shared_ptr film, boost::filesystem::pa : Content (film, p) , AudioContent (film, p) , SubtitleContent (film, p) - , video (new VideoContent (film)) { + video.reset (new VideoContent (this, film)); + set_default_colour_conversion (); } @@ -72,8 +73,9 @@ FFmpegContent::FFmpegContent (shared_ptr film, cxml::ConstNodePtr no : Content (film, node) , AudioContent (film, node) , SubtitleContent (film, node, version) - , video (new VideoContent (film, node, version)) { + video.reset (new VideoContent (this, film, node, version)); + list c = node->node_children ("SubtitleStream"); for (list::const_iterator i = c.begin(); i != c.end(); ++i) { _subtitle_streams.push_back (shared_ptr (new FFmpegSubtitleStream (*i, version))); @@ -120,8 +122,9 @@ FFmpegContent::FFmpegContent (shared_ptr film, vector ref = dynamic_pointer_cast (c[0]); DCPOMATIC_ASSERT (ref); @@ -194,7 +197,7 @@ FFmpegContent::examine (shared_ptr job) Content::examine (job); shared_ptr examiner (new FFmpegExaminer (shared_from_this (), job)); - take_from_video_examiner (examiner); + video->take_from_video_examiner (examiner); set_default_colour_conversion (); { @@ -287,8 +290,8 @@ operator!= (FFmpegStream const & a, FFmpegStream const & b) DCPTime FFmpegContent::full_length () const { - FrameRateChange const frc (video_frame_rate (), film()->video_frame_rate ()); - return DCPTime::from_frames (llrint (video_length_after_3d_combine() * frc.factor()), film()->video_frame_rate()); + FrameRateChange const frc (video->video_frame_rate (), film()->video_frame_rate ()); + return DCPTime::from_frames (llrint (video->video_length_after_3d_combine() * frc.factor()), film()->video_frame_rate()); } void @@ -373,14 +376,14 @@ FFmpegContent::has_text_subtitles () const void FFmpegContent::set_default_colour_conversion () { - dcp::Size const s = video_size (); + dcp::Size const s = video->video_size (); boost::mutex::scoped_lock lm (_mutex); if (s.width < 1080) { - _colour_conversion = PresetColourConversion::from_id ("rec601").conversion; + video->set_colour_conversion (PresetColourConversion::from_id ("rec601").conversion); } else { - _colour_conversion = PresetColourConversion::from_id ("rec709").conversion; + video->set_colour_conversion (PresetColourConversion::from_id ("rec709").conversion); } } diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index f5bbbd31e..d210d63a8 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -106,8 +106,6 @@ public: void signal_subtitle_stream_changed (); - boost::shared_ptr video; - protected: void add_properties (std::list &) const; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 698078b5b..5240decb2 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -72,12 +72,12 @@ using boost::split; using dcp::Size; FFmpegDecoder::FFmpegDecoder (shared_ptr c, shared_ptr log, bool fast) - : VideoDecoder (c) + : VideoDecoder (c->video, log) , AudioDecoder (c, fast) , SubtitleDecoder (c) , FFmpeg (c) , _log (log) - , _pts_offset (pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->video_frame_rate())) + , _pts_offset (pts_offset (c->ffmpeg_audio_streams(), c->first_video(), c->video->video_frame_rate())) { } @@ -414,7 +414,7 @@ FFmpegDecoder::decode_video_packet () double const pts = i->second * av_q2d (_format_context->streams[_video_stream]->time_base) + _pts_offset.seconds (); video ( shared_ptr (new RawImageProxy (image)), - llrint (pts * _ffmpeg_content->video_frame_rate ()) + llrint (pts * _ffmpeg_content->video->video_frame_rate ()) ); } else { LOG_WARNING_NC ("Dropping frame without PTS"); @@ -548,7 +548,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP out_p += image->stride()[0] / sizeof (uint32_t); } - dcp::Size const vs = _ffmpeg_content->video_size (); + dcp::Size const vs = _ffmpeg_content->video->video_size (); dcpomatic::Rect const scaled_rect ( static_cast (rect->x) / vs.width, static_cast (rect->y) / vs.height, diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index f64ea8d79..b9ca04e4c 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -25,6 +25,7 @@ struct AVStream; class FFmpegAudioStream; class FFmpegSubtitleStream; +class Job; class FFmpegExaminer : public FFmpeg, public VideoExaminer { diff --git a/src/lib/film.cc b/src/lib/film.cc index dbcb9f31a..7d319fc1e 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -617,13 +617,12 @@ Film::isdcf_name (bool if_created_now) const if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) { Ratio const * content_ratio = 0; BOOST_FOREACH (shared_ptr i, content ()) { - shared_ptr vc = dynamic_pointer_cast (i); - if (vc) { + if (i->video) { /* Here's the first piece of video content */ - if (vc->scale().ratio ()) { - content_ratio = vc->scale().ratio (); + if (i->video->scale().ratio ()) { + content_ratio = i->video->scale().ratio (); } else { - content_ratio = Ratio::from_ratio (vc->video_size().ratio ()); + content_ratio = Ratio::from_ratio (i->video->video_size().ratio ()); } break; } @@ -1049,7 +1048,7 @@ void Film::add_content (shared_ptr c) { /* Add {video,subtitle} content after any existing {video,subtitle} content */ - if (dynamic_pointer_cast (c)) { + if (c->video) { c->set_position (_playlist->video_end ()); } else if (dynamic_pointer_cast (c)) { c->set_position (_playlist->subtitle_end ()); @@ -1377,18 +1376,17 @@ Film::reels () const case REELTYPE_BY_VIDEO_CONTENT: { optional last_split; - shared_ptr last_video; + shared_ptr last_video; ContentList cl = content (); BOOST_FOREACH (shared_ptr c, content ()) { - shared_ptr v = dynamic_pointer_cast (c); - if (v) { - BOOST_FOREACH (DCPTime t, v->reel_split_points()) { + if (c->video) { + BOOST_FOREACH (DCPTime t, c->reel_split_points()) { if (last_split) { p.push_back (DCPTimePeriod (last_split.get(), t)); } last_split = t; } - last_video = v; + last_video = c; } } diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index ed290dd6c..231eb9f8c 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -40,8 +40,9 @@ using boost::shared_ptr; ImageContent::ImageContent (shared_ptr film, boost::filesystem::path p) : Content (film) - , video (new VideoContent (film)) { + video.reset (new VideoContent (this, film)); + if (boost::filesystem::is_regular_file (p) && valid_image_file (p)) { _paths.push_back (p); } else { @@ -64,9 +65,8 @@ ImageContent::ImageContent (shared_ptr film, boost::filesystem::path ImageContent::ImageContent (shared_ptr film, cxml::ConstNodePtr node, int version) : Content (film, node) - , video (new VideoContent (film, node, version)) { - + video.reset (new VideoContent (this, film, node, version)); } string @@ -115,28 +115,17 @@ ImageContent::examine (shared_ptr job) DCPOMATIC_ASSERT (film); shared_ptr examiner (new ImageExaminer (film, shared_from_this(), job)); - take_from_video_examiner (examiner); + video->take_from_video_examiner (examiner); set_default_colour_conversion (); } -void -ImageContent::set_video_length (Frame len) -{ - { - boost::mutex::scoped_lock lm (_mutex); - _video_length = len; - } - - signal_changed (ContentProperty::LENGTH); -} - DCPTime ImageContent::full_length () const { shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - FrameRateChange const frc (video_frame_rate(), film->video_frame_rate()); - return DCPTime::from_frames (llrint (video_length_after_3d_combine() * frc.factor ()), film->video_frame_rate ()); + FrameRateChange const frc (video->video_frame_rate(), film->video_frame_rate()); + return DCPTime::from_frames (llrint (video->video_length_after_3d_combine() * frc.factor ()), film->video_frame_rate ()); } string @@ -145,7 +134,7 @@ ImageContent::identifier () const SafeStringStream s; s << Content::identifier(); s << "_" << video->identifier (); - s << "_" << video_length(); + s << "_" << video->video_length(); return s.str (); } @@ -161,7 +150,7 @@ ImageContent::set_default_colour_conversion () BOOST_FOREACH (boost::filesystem::path i, _paths) { if (valid_j2k_file (i)) { /* We default to no colour conversion if we have JPEG2000 files */ - unset_colour_conversion (); + video->unset_colour_conversion (); return; } } @@ -171,8 +160,8 @@ ImageContent::set_default_colour_conversion () boost::mutex::scoped_lock lm (_mutex); if (s) { - _colour_conversion = PresetColourConversion::from_id ("srgb").conversion; + video->set_colour_conversion (PresetColourConversion::from_id ("srgb").conversion); } else { - _colour_conversion = PresetColourConversion::from_id ("rec709").conversion; + video->set_colour_conversion (PresetColourConversion::from_id ("rec709").conversion); } } diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 353ce8370..dcdb7b526 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -42,10 +42,7 @@ public: void set_default_colour_conversion (); - void set_video_length (Frame); bool still () const; - - boost::shared_ptr video; }; #endif diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 2291daecd..e26574f61 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -34,8 +34,8 @@ using std::cout; using boost::shared_ptr; using dcp::Size; -ImageDecoder::ImageDecoder (shared_ptr c) - : VideoDecoder (c) +ImageDecoder::ImageDecoder (shared_ptr c, shared_ptr log) + : VideoDecoder (c->video, log) , _image_content (c) , _video_position (0) { @@ -45,7 +45,7 @@ ImageDecoder::ImageDecoder (shared_ptr c) bool ImageDecoder::pass (PassReason, bool) { - if (_video_position >= _image_content->video_length()) { + if (_video_position >= _image_content->video->video_length()) { return true; } @@ -56,7 +56,7 @@ ImageDecoder::pass (PassReason, bool) /* We can't extract image size from a JPEG2000 codestream without decoding it, so pass in the image content's size here. */ - _image.reset (new J2KImageProxy (path, _image_content->video_size ())); + _image.reset (new J2KImageProxy (path, _image_content->video->video_size ())); } else { _image.reset (new MagickImageProxy (path)); } @@ -71,5 +71,5 @@ void ImageDecoder::seek (ContentTime time, bool accurate) { VideoDecoder::seek (time, accurate); - _video_position = time.frames_round (_image_content->video_frame_rate ()); + _video_position = time.frames_round (_image_content->video->video_frame_rate ()); } diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index e2de56acb..9d81cdac1 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2013 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,7 +24,7 @@ class ImageContent; class ImageDecoder : public VideoDecoder { public: - ImageDecoder (boost::shared_ptr c); + ImageDecoder (boost::shared_ptr c, boost::shared_ptr log); boost::shared_ptr content () { return _image_content; diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 7b02de956..010275429 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -85,9 +85,9 @@ ImageExaminer::video_size () const optional ImageExaminer::video_frame_rate () const { - if (_image_content->has_own_video_frame_rate()) { + if (_image_content->video->has_own_video_frame_rate()) { /* The content already knows what frame rate it should be */ - return _image_content->video_frame_rate(); + return _image_content->video->video_frame_rate(); } /* Don't know */ diff --git a/src/lib/player.cc b/src/lib/player.cc index d35c1b76b..2b65fd54e 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -113,13 +113,13 @@ Player::setup_pieces () shared_ptr fc = dynamic_pointer_cast (i); if (fc) { decoder.reset (new FFmpegDecoder (fc, _film->log(), _fast)); - frc = FrameRateChange (fc->video_frame_rate(), _film->video_frame_rate()); + frc = FrameRateChange (fc->video->video_frame_rate(), _film->video_frame_rate()); } shared_ptr dc = dynamic_pointer_cast (i); if (dc) { - decoder.reset (new DCPDecoder (dc, _fast)); - frc = FrameRateChange (dc->video_frame_rate(), _film->video_frame_rate()); + decoder.reset (new DCPDecoder (dc, _film->log(), _fast)); + frc = FrameRateChange (dc->video->video_frame_rate(), _film->video_frame_rate()); } /* ImageContent */ @@ -134,10 +134,10 @@ Player::setup_pieces () } if (!decoder) { - decoder.reset (new ImageDecoder (ic)); + decoder.reset (new ImageDecoder (ic, _film->log())); } - frc = FrameRateChange (ic->video_frame_rate(), _film->video_frame_rate()); + frc = FrameRateChange (ic->video->video_frame_rate(), _film->video_frame_rate()); } /* SndfileContent */ @@ -147,22 +147,21 @@ Player::setup_pieces () /* Work out a FrameRateChange for the best overlap video for this content */ DCPTime best_overlap_t; - shared_ptr best_overlap; + shared_ptr best_overlap; BOOST_FOREACH (shared_ptr j, _playlist->content ()) { - shared_ptr vc = dynamic_pointer_cast (j); - if (!vc) { + if (!j->video) { continue; } - DCPTime const overlap = min (vc->end(), i->end()) - max (vc->position(), i->position()); + DCPTime const overlap = min (j->end(), i->end()) - max (j->position(), i->position()); if (overlap > best_overlap_t) { - best_overlap = vc; + best_overlap = j; best_overlap_t = overlap; } } if (best_overlap) { - frc = FrameRateChange (best_overlap->video_frame_rate(), _film->video_frame_rate ()); + frc = FrameRateChange (best_overlap->video->video_frame_rate(), _film->video_frame_rate ()); } else { /* No video overlap; e.g. if the DCP is just audio */ frc = FrameRateChange (_film->video_frame_rate(), _film->video_frame_rate ()); @@ -397,17 +396,15 @@ Player::get_video (DCPTime time, bool accurate) } else { /* Some video content at this time */ shared_ptr last = *(ov.rbegin ()); - VideoFrameType const last_type = dynamic_pointer_cast (last->content)->video_frame_type (); + VideoFrameType const last_type = last->content->video->video_frame_type (); /* Get video from appropriate piece(s) */ BOOST_FOREACH (shared_ptr piece, ov) { shared_ptr decoder = dynamic_pointer_cast (piece->decoder); DCPOMATIC_ASSERT (decoder); - shared_ptr video_content = dynamic_pointer_cast (piece->content); - DCPOMATIC_ASSERT (video_content); - shared_ptr dcp_content = dynamic_pointer_cast (video_content); + shared_ptr dcp_content = dynamic_pointer_cast (piece->content); if (dcp_content && dcp_content->reference_video () && !_play_referenced) { continue; } @@ -416,8 +413,8 @@ Player::get_video (DCPTime time, bool accurate) /* always use the last video */ piece == last || /* with a corresponding L/R eye if appropriate */ - (last_type == VIDEO_FRAME_TYPE_3D_LEFT && video_content->video_frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) || - (last_type == VIDEO_FRAME_TYPE_3D_RIGHT && video_content->video_frame_type() == VIDEO_FRAME_TYPE_3D_LEFT); + (last_type == VIDEO_FRAME_TYPE_3D_LEFT && piece->content->video->video_frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) || + (last_type == VIDEO_FRAME_TYPE_3D_RIGHT && piece->content->video->video_frame_type() == VIDEO_FRAME_TYPE_3D_LEFT); if (use) { /* We want to use this piece */ @@ -425,7 +422,9 @@ Player::get_video (DCPTime time, bool accurate) if (content_video.empty ()) { pvf.push_back (black_player_video_frame (time)); } else { - dcp::Size image_size = video_content->scale().size (video_content, _video_container_size, _film->frame_size ()); + dcp::Size image_size = piece->content->video->scale().size ( + piece->content->video, _video_container_size, _film->frame_size () + ); for (list::const_iterator i = content_video.begin(); i != content_video.end(); ++i) { pvf.push_back ( @@ -433,13 +432,13 @@ Player::get_video (DCPTime time, bool accurate) new PlayerVideo ( i->image, content_video_to_dcp (piece, i->frame), - video_content->crop (), - video_content->fade (i->frame), + piece->content->video->crop (), + piece->content->video->fade (i->frame), image_size, _video_container_size, i->eyes, i->part, - video_content->colour_conversion () + piece->content->video->colour_conversion () ) ) ); @@ -770,7 +769,7 @@ Player::get_reel_assets () scoped_ptr decoder; try { - decoder.reset (new DCPDecoder (j, false)); + decoder.reset (new DCPDecoder (j, _film->log(), false)); } catch (...) { return a; } diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 82a4666cd..f03f8a9a1 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -110,20 +110,19 @@ Playlist::maybe_sequence () DCPTime next_left; DCPTime next_right; BOOST_FOREACH (shared_ptr i, _content) { - shared_ptr vc = dynamic_pointer_cast (i); - if (!vc) { + if (!i->video) { continue; } - if (vc->video_frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) { - vc->set_position (next_right); - next_right = vc->end(); + if (i->video->video_frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) { + i->set_position (next_right); + next_right = i->end(); } else { - vc->set_position (next_left); - next_left = vc->end(); + i->set_position (next_left); + next_left = i->end(); } - placed.push_back (vc); + placed.push_back (i); } /* Subtitles */ @@ -271,15 +270,14 @@ Playlist::best_dcp_frame_rate () const float this_error = 0; BOOST_FOREACH (shared_ptr j, _content) { - shared_ptr vc = dynamic_pointer_cast (j); - if (!vc || !vc->has_own_video_frame_rate()) { + if (!j->video || !j->video->has_own_video_frame_rate()) { continue; } /* Best error for this content; we could use the content as-is or double its rate */ float best_error = min ( - float (fabs (i->source - vc->video_frame_rate ())), - float (fabs (i->source - vc->video_frame_rate () * 2)) + float (fabs (i->source - j->video->video_frame_rate ())), + float (fabs (i->source - j->video->video_frame_rate () * 2)) ); /* Use the largest difference between DCP and source as the "error" */ @@ -373,16 +371,15 @@ FrameRateChange Playlist::active_frame_rate_change (DCPTime t, int dcp_video_frame_rate) const { for (ContentList::const_reverse_iterator i = _content.rbegin(); i != _content.rend(); ++i) { - shared_ptr vc = dynamic_pointer_cast (*i); - if (!vc) { + if (!(*i)->video) { continue; } - if (vc->position() <= t) { + if ((*i)->position() <= t) { /* This is the first piece of content (going backwards...) that starts before t, so it's the active one. */ - return FrameRateChange (vc->video_frame_rate(), dcp_video_frame_rate); + return FrameRateChange ((*i)->video->video_frame_rate(), dcp_video_frame_rate); } } @@ -403,9 +400,9 @@ ContentSorter::operator() (shared_ptr a, shared_ptr b) } /* Put video before audio if they start at the same time */ - if (dynamic_pointer_cast(a) && !dynamic_pointer_cast(b)) { + if (a->video && !b->video) { return true; - } else if (!dynamic_pointer_cast(a) && dynamic_pointer_cast(b)) { + } else if (!a->video && b->video) { return false; } diff --git a/src/lib/types.h b/src/lib/types.h index 105432f83..33bad1d24 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -48,7 +48,6 @@ namespace xmlpp { #define SERVER_LINK_VERSION (64+0) typedef std::vector > ContentList; -typedef std::vector > VideoContentList; typedef std::vector > AudioContentList; typedef std::vector > SubtitleContentList; typedef std::vector > FFmpegContentList; diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 91701415e..708edee76 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -18,6 +18,7 @@ */ #include "video_content.h" +#include "content.h" #include "video_examiner.h" #include "compose.hpp" #include "ratio.h" @@ -63,8 +64,9 @@ using boost::shared_ptr; using boost::optional; using boost::dynamic_pointer_cast; -VideoContent::VideoContent (shared_ptr film) - : _film (film) +VideoContent::VideoContent (Content* parent, shared_ptr film) + : _parent (parent) + , _film (film) , _video_length (0) , _video_frame_type (VIDEO_FRAME_TYPE_2D) , _scale (VideoContentScale (Ratio::from_id ("178"))) @@ -75,8 +77,9 @@ VideoContent::VideoContent (shared_ptr film) } -VideoContent::VideoContent (shared_ptr film, cxml::ConstNodePtr node, int version) - : _film (film) +VideoContent::VideoContent (Content* parent, shared_ptr film, cxml::ConstNodePtr node, int version) + : _parent (parent) + , _film (film) { _video_size.width = node->number_child ("VideoWidth"); _video_size.height = node->number_child ("VideoHeight"); @@ -113,8 +116,9 @@ VideoContent::VideoContent (shared_ptr film, cxml::ConstNodePtr node } } -VideoContent::VideoContent (shared_ptr film, vector > c) - : _film (film) +VideoContent::VideoContent (Content* parent, shared_ptr film, vector > c) + : _parent (parent) + , _film (film) , _video_length (0) , _yuv (false) { @@ -229,10 +233,10 @@ VideoContent::take_from_video_examiner (shared_ptr d) DCPOMATIC_ASSERT (film); LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length); - signal_changed (VideoContentProperty::VIDEO_SIZE); - signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); - signal_changed (VideoContentProperty::VIDEO_SCALE); - signal_changed (ContentProperty::LENGTH); + _parent->signal_changed (VideoContentProperty::VIDEO_SIZE); + _parent->signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); + _parent->signal_changed (VideoContentProperty::VIDEO_SCALE); + _parent->signal_changed (ContentProperty::LENGTH); } void @@ -248,7 +252,7 @@ VideoContent::set_left_crop (int c) _crop.left = c; } - signal_changed (VideoContentProperty::VIDEO_CROP); + _parent->signal_changed (VideoContentProperty::VIDEO_CROP); } void @@ -263,7 +267,7 @@ VideoContent::set_right_crop (int c) _crop.right = c; } - signal_changed (VideoContentProperty::VIDEO_CROP); + _parent->signal_changed (VideoContentProperty::VIDEO_CROP); } void @@ -278,7 +282,7 @@ VideoContent::set_top_crop (int c) _crop.top = c; } - signal_changed (VideoContentProperty::VIDEO_CROP); + _parent->signal_changed (VideoContentProperty::VIDEO_CROP); } void @@ -293,7 +297,7 @@ VideoContent::set_bottom_crop (int c) _crop.bottom = c; } - signal_changed (VideoContentProperty::VIDEO_CROP); + _parent->signal_changed (VideoContentProperty::VIDEO_CROP); } void @@ -308,7 +312,7 @@ VideoContent::set_scale (VideoContentScale s) _scale = s; } - signal_changed (VideoContentProperty::VIDEO_SCALE); + _parent->signal_changed (VideoContentProperty::VIDEO_SCALE); } /** @return string which includes everything about how this content looks */ @@ -339,7 +343,7 @@ VideoContent::set_video_frame_type (VideoFrameType t) _video_frame_type = t; } - signal_changed (VideoContentProperty::VIDEO_FRAME_TYPE); + _parent->signal_changed (VideoContentProperty::VIDEO_FRAME_TYPE); } string @@ -387,7 +391,7 @@ VideoContent::unset_colour_conversion () _colour_conversion = boost::optional (); } - signal_changed (VideoContentProperty::COLOUR_CONVERSION); + _parent->signal_changed (VideoContentProperty::COLOUR_CONVERSION); } void @@ -398,7 +402,7 @@ VideoContent::set_colour_conversion (ColourConversion c) _colour_conversion = c; } - signal_changed (VideoContentProperty::COLOUR_CONVERSION); + _parent->signal_changed (VideoContentProperty::COLOUR_CONVERSION); } void @@ -409,7 +413,7 @@ VideoContent::set_fade_in (Frame t) _fade_in = t; } - signal_changed (VideoContentProperty::VIDEO_FADE_IN); + _parent->signal_changed (VideoContentProperty::VIDEO_FADE_IN); } void @@ -420,7 +424,7 @@ VideoContent::set_fade_out (Frame t) _fade_out = t; } - signal_changed (VideoContentProperty::VIDEO_FADE_OUT); + _parent->signal_changed (VideoContentProperty::VIDEO_FADE_OUT); } /** @return Video size after 3D split and crop */ @@ -470,7 +474,7 @@ VideoContent::set_video_frame_rate (double r) _video_frame_rate = r; } - signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); + _parent->signal_changed (VideoContentProperty::VIDEO_FRAME_RATE); } /** @param f Frame index within the whole (untrimmed) content */ @@ -479,12 +483,12 @@ VideoContent::fade (Frame f) const { DCPOMATIC_ASSERT (f >= 0); - Frame const ts = trim_start().frames_round(video_frame_rate()); + Frame const ts = _parent->trim_start().frames_round(video_frame_rate()); if ((f - ts) < fade_in()) { return double (f - ts) / fade_in(); } - Frame fade_out_start = video_length() - trim_end().frames_round(video_frame_rate()) - fade_out(); + Frame fade_out_start = video_length() - _parent->trim_end().frames_round(video_frame_rate()) - fade_out(); if (f >= fade_out_start) { return 1 - double (f - fade_out_start) / fade_out(); } @@ -529,7 +533,7 @@ VideoContent::processing_description () const shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); dcp::Size const container_size = film->frame_size (); - dcp::Size const scaled = scale().size (dynamic_pointer_cast (shared_from_this ()), container_size, container_size); + dcp::Size const scaled = scale().size (shared_from_this(), container_size, container_size); if (scaled != video_size_after_crop ()) { d << String::compose ( @@ -575,3 +579,14 @@ VideoContent::video_frame_rate () const DCPOMATIC_ASSERT (film); return _video_frame_rate.get_value_or (film->video_frame_rate ()); } + +void +VideoContent::set_video_length (Frame len) +{ + { + boost::mutex::scoped_lock lm (_mutex); + _video_length = len; + } + + _parent->signal_changed (ContentProperty::LENGTH); +} diff --git a/src/lib/video_content.h b/src/lib/video_content.h index b93744053..768f1897d 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -24,12 +24,15 @@ #include "video_content_scale.h" #include "dcpomatic_time.h" #include "user_property.h" +#include "types.h" #include #include +#include class VideoExaminer; class Ratio; class Film; +class Content; class VideoContentProperty { @@ -44,12 +47,12 @@ public: static int const VIDEO_FADE_OUT; }; -class VideoContent +class VideoContent : public boost::enable_shared_from_this { public: - VideoContent (boost::shared_ptr); - VideoContent (boost::shared_ptr, cxml::ConstNodePtr, int); - VideoContent (boost::shared_ptr, std::vector >); + VideoContent (Content* parent, boost::shared_ptr); + VideoContent (Content* parent, boost::shared_ptr, cxml::ConstNodePtr, int); + VideoContent (Content* parent, boost::shared_ptr, std::vector >); void as_xml (xmlpp::Node *) const; std::string technical_summary () const; @@ -174,10 +177,14 @@ public: std::string processing_description () const; -private: + void set_video_length (Frame); + void take_from_video_examiner (boost::shared_ptr); void add_properties (std::list &) const; +private: + + Content* _parent; boost::weak_ptr _film; mutable boost::mutex _mutex; Frame _video_length; diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index 0936d1bda..f68f0815c 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -34,13 +34,14 @@ using std::back_inserter; using boost::shared_ptr; using boost::optional; -VideoDecoder::VideoDecoder (shared_ptr c) +VideoDecoder::VideoDecoder (shared_ptr c, shared_ptr log) #ifdef DCPOMATIC_DEBUG : test_gaps (0) , _video_content (c) #else : _video_content (c) #endif + , _log (log) , _last_seek_accurate (true) , _ignore_video (false) { @@ -79,7 +80,7 @@ VideoDecoder::get_video (Frame frame, bool accurate) one after the end of _decoded_video we need to seek. */ - _video_content->film()->log()->log (String::compose ("VD has request for %1", frame), LogEntry::TYPE_DEBUG_DECODE); + _log->log (String::compose ("VD has request for %1", frame), LogEntry::TYPE_DEBUG_DECODE); if (_decoded_video.empty() || frame < _decoded_video.front().frame || frame > (_decoded_video.back().frame + 1)) { seek (ContentTime::from_frames (frame, _video_content->video_frame_rate()), accurate); @@ -252,7 +253,7 @@ VideoDecoder::video (shared_ptr image, Frame frame) return; } - _video_content->film()->log()->log (String::compose ("VD receives %1", frame), LogEntry::TYPE_DEBUG_DECODE); + _log->log (String::compose ("VD receives %1", frame), LogEntry::TYPE_DEBUG_DECODE); /* Work out what we are going to push into _decoded_video next */ list to_push; diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index af24b93bc..c787faa04 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -34,6 +34,7 @@ class VideoContent; class ImageProxy; class Image; +class Log; /** @class VideoDecoder * @brief Parent for classes which decode video. @@ -41,7 +42,7 @@ class Image; class VideoDecoder : public virtual Decoder { public: - VideoDecoder (boost::shared_ptr c); + VideoDecoder (boost::shared_ptr c, boost::shared_ptr log); std::list get_video (Frame frame, bool accurate); @@ -66,6 +67,7 @@ protected: void fill_both_eyes (Frame from, Frame to, Eyes); boost::shared_ptr _video_content; + boost::shared_ptr _log; std::list _decoded_video; boost::shared_ptr _black_image; boost::optional _last_seek_time; diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index f336f0a85..edc44ee66 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -41,6 +41,7 @@ #include "lib/config.h" #include "lib/util.h" #include "lib/video_content.h" +#include "lib/content.h" #include "lib/version.h" #include "lib/signal_manager.h" #include "lib/log.h" @@ -585,17 +586,17 @@ private: void content_scale_to_fit_width () { - VideoContentList vc = _film_editor->content_panel()->selected_video (); - for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) { - (*i)->scale_and_crop_to_fit_width (); + ContentList vc = _film_editor->content_panel()->selected_video (); + for (ContentList::iterator i = vc.begin(); i != vc.end(); ++i) { + (*i)->video->scale_and_crop_to_fit_width (); } } void content_scale_to_fit_height () { - VideoContentList vc = _film_editor->content_panel()->selected_video (); - for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) { - (*i)->scale_and_crop_to_fit_height (); + ContentList vc = _film_editor->content_panel()->selected_video (); + for (ContentList::iterator i = vc.begin(); i != vc.end(); ++i) { + (*i)->video->scale_and_crop_to_fit_height (); } } diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index 2911be0a7..0e5bee70a 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2015 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include "lib/dcp_content_type.h" #include "lib/ratio.h" #include "lib/image_content.h" +#include "lib/video_content.h" #include #include #include @@ -215,9 +216,8 @@ main (int argc, char* argv[]) for (int i = optind; i < argc; ++i) { shared_ptr c = content_factory (film, boost::filesystem::canonical (argv[i])); - shared_ptr vc = dynamic_pointer_cast (c); - if (vc) { - vc->set_scale (VideoContentScale (content_ratio)); + if (c->video) { + c->video->set_scale (VideoContentScale (content_ratio)); } film->examine_and_add_content (c); } @@ -231,7 +231,7 @@ main (int argc, char* argv[]) for (ContentList::iterator i = content.begin(); i != content.end(); ++i) { shared_ptr ic = dynamic_pointer_cast (*i); if (ic) { - ic->set_video_length (still_length * 24); + ic->video->set_video_length (still_length * 24); } } diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 654378248..55dd671e9 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -149,15 +149,14 @@ ContentPanel::selected () return sel; } -VideoContentList +ContentList ContentPanel::selected_video () { - VideoContentList vc; + ContentList vc; BOOST_FOREACH (shared_ptr i, selected ()) { - shared_ptr t = dynamic_pointer_cast (i); - if (t) { - vc.push_back (t); + if (i->video) { + vc.push_back (i); } } @@ -337,7 +336,7 @@ ContentPanel::add_folder_clicked () return; } - ic->set_video_frame_rate (frame_rate); + ic->video->set_video_frame_rate (frame_rate); } _film->examine_and_add_content (content); @@ -388,7 +387,7 @@ ContentPanel::setup_sensitivity () _add_folder->Enable (_generally_sensitive); ContentList selection = selected (); - VideoContentList video_selection = selected_video (); + ContentList video_selection = selected_video (); AudioContentList audio_selection = selected_audio (); _remove->Enable (!selection.empty() && _generally_sensitive); diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index 9e6cf9f24..e735213d3 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -59,7 +59,7 @@ public: } ContentList selected (); - VideoContentList selected_video (); + ContentList selected_video (); AudioContentList selected_audio (); SubtitleContentList selected_subtitle (); FFmpegContentList selected_ffmpeg (); diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 7ffc24f7d..42d2f1537 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -29,6 +29,7 @@ #include "lib/film.h" #include "lib/ffmpeg_content.h" #include "lib/audio_processor.h" +#include "lib/video_content.h" #include "lib/dcp_content.h" #include #include diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 786d70721..31981deea 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -145,7 +145,7 @@ Timeline::recreate_views () _views.push_back (_labels_view); BOOST_FOREACH (shared_ptr i, film->content ()) { - if (dynamic_pointer_cast (i)) { + if (i->video) { _views.push_back (shared_ptr (new TimelineVideoContentView (*this, i))); } diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index cad346823..241b0f706 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -29,6 +29,7 @@ #include "lib/dcp_subtitle_content.h" #include "lib/audio_content.h" #include "lib/text_subtitle_content.h" +#include "lib/video_content.h" #include #include #include @@ -259,16 +260,15 @@ TimingPanel::film_content_changed (int property) if (property == VideoContentProperty::VIDEO_FRAME_RATE || property == SubtitleContentProperty::SUBTITLE_VIDEO_FRAME_RATE) { set check_vc; - shared_ptr vc; + shared_ptr vc; int count_ac = 0; - shared_ptr ac; + shared_ptr ac; int count_sc = 0; shared_ptr sc; BOOST_FOREACH (shared_ptr i, _parent->selected ()) { - shared_ptr vt = dynamic_pointer_cast (i); - if (vt) { - check_vc.insert (vt->video_frame_rate ()); - vc = vt; + if (i->video) { + check_vc.insert (i->video->video_frame_rate ()); + vc = i; } shared_ptr at = dynamic_pointer_cast (i); if (at) { @@ -287,9 +287,9 @@ TimingPanel::film_content_changed (int property) if ((check_vc.size() == 1 || count_ac == 1 || count_sc == 1) && !single_frame_image_content) { if (vc) { - checked_set (_video_frame_rate, raw_convert (vc->video_frame_rate (), 5)); + checked_set (_video_frame_rate, raw_convert (vc->video->video_frame_rate (), 5)); } else if (ac) { - checked_set (_video_frame_rate, raw_convert (ac->audio_video_frame_rate (), 5)); + checked_set (_video_frame_rate, raw_convert (ac->audio->audio_video_frame_rate (), 5)); } else if (sc) { checked_set (_video_frame_rate, raw_convert (sc->subtitle_video_frame_rate (), 5)); } @@ -329,7 +329,7 @@ TimingPanel::full_length_changed () shared_ptr ic = dynamic_pointer_cast (i); if (ic && ic->still ()) { int const vfr = _parent->film()->video_frame_rate (); - ic->set_video_length (_full_length->get (vfr).frames_round (vfr)); + ic->video->set_video_length (_full_length->get (vfr).frames_round (vfr)); } } } diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index f2f164ad5..f6f234a0d 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2015 Carl Hetherington + Copyright (C) 2012-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -31,6 +31,7 @@ #include "lib/ratio.h" #include "lib/frame_rate_change.h" #include "lib/dcp_content.h" +#include "lib/video_content.h" #include #include #include @@ -258,8 +259,8 @@ VideoPanel::film_changed (Film::Property property) void VideoPanel::film_content_changed (int property) { - VideoContentList vc = _parent->selected_video (); - shared_ptr vcs; + ContentList vc = _parent->selected_video (); + shared_ptr vcs; shared_ptr fcs; if (!vc.empty ()) { vcs = vc.front (); @@ -275,8 +276,8 @@ VideoPanel::film_content_changed (int property) } else if (property == VideoContentProperty::VIDEO_FRAME_RATE) { setup_description (); } else if (property == VideoContentProperty::COLOUR_CONVERSION) { - if (vcs && vcs->colour_conversion ()) { - optional preset = vcs->colour_conversion().get().preset (); + if (vcs && vcs->video->colour_conversion ()) { + optional preset = vcs->video->colour_conversion().get().preset (); vector cc = PresetColourConversion::all (); if (preset) { checked_set (_colour_conversion, preset.get() + 1); @@ -303,23 +304,29 @@ VideoPanel::film_content_changed (int property) } } else if (property == VideoContentProperty::VIDEO_FADE_IN) { set check; - BOOST_FOREACH (shared_ptr i, vc) { - check.insert (i->fade_in ()); + BOOST_FOREACH (shared_ptr i, vc) { + check.insert (i->video->fade_in ()); } if (check.size() == 1) { - _fade_in->set (ContentTime::from_frames (vc.front()->fade_in (), vc.front()->video_frame_rate ()), vc.front()->video_frame_rate ()); + _fade_in->set ( + ContentTime::from_frames (vc.front()->video->fade_in (), vc.front()->video->video_frame_rate ()), + vc.front()->video->video_frame_rate () + ); } else { _fade_in->clear (); } } else if (property == VideoContentProperty::VIDEO_FADE_OUT) { set check; - BOOST_FOREACH (shared_ptr i, vc) { - check.insert (i->fade_out ()); + BOOST_FOREACH (shared_ptr i, vc) { + check.insert (i->video->fade_out ()); } if (check.size() == 1) { - _fade_out->set (ContentTime::from_frames (vc.front()->fade_out (), vc.front()->video_frame_rate ()), vc.front()->video_frame_rate ()); + _fade_out->set ( + ContentTime::from_frames (vc.front()->video->fade_out (), vc.front()->video->video_frame_rate ()), + vc.front()->video->video_frame_rate () + ); } else { _fade_out->clear (); } @@ -353,7 +360,7 @@ VideoPanel::edit_filters_clicked () void VideoPanel::setup_description () { - VideoContentList vc = _parent->selected_video (); + ContentList vc = _parent->selected_video (); if (vc.empty ()) { checked_set (_description, wxT ("")); return; @@ -362,7 +369,7 @@ VideoPanel::setup_description () return; } - string d = vc.front()->processing_description (); + string d = vc.front()->video->processing_description (); size_t lines = count (d.begin(), d.end(), '\n'); for (int i = lines; i < 6; ++i) { @@ -376,7 +383,7 @@ VideoPanel::setup_description () void VideoPanel::colour_conversion_changed () { - VideoContentList vc = _parent->selected_video (); + ContentList vc = _parent->selected_video (); if (vc.size() != 1) { return; } @@ -385,33 +392,33 @@ VideoPanel::colour_conversion_changed () vector all = PresetColourConversion::all (); if (s == 0) { - vc.front()->unset_colour_conversion (); + vc.front()->video->unset_colour_conversion (); } else if (s == int (all.size() + 1)) { edit_colour_conversion_clicked (); } else { - vc.front()->set_colour_conversion (all[s - 1].conversion); + vc.front()->video->set_colour_conversion (all[s - 1].conversion); } } void VideoPanel::edit_colour_conversion_clicked () { - VideoContentList vc = _parent->selected_video (); + ContentList vc = _parent->selected_video (); if (vc.size() != 1) { return; } ContentColourConversionDialog* d = new ContentColourConversionDialog (this, vc.front()->yuv ()); - d->set (vc.front()->colour_conversion().get_value_or (PresetColourConversion::all().front ().conversion)); + d->set (vc.front()->video->colour_conversion().get_value_or (PresetColourConversion::all().front ().conversion)); d->ShowModal (); - vc.front()->set_colour_conversion (d->get ()); + vc.front()->video->set_colour_conversion (d->get ()); d->Destroy (); } void VideoPanel::content_selection_changed () { - VideoContentList video_sel = _parent->selected_video (); + ContentList video_sel = _parent->selected_video (); _frame_type->set_content (video_sel); _left_crop->set_content (video_sel); @@ -459,7 +466,7 @@ VideoPanel::setup_sensitivity () _filters_button->Enable (false); _colour_conversion->Enable (false); } else { - VideoContentList video_sel = _parent->selected_video (); + ContentList video_sel = _parent->selected_video (); FFmpegContentList ffmpeg_sel = _parent->selected_ffmpeg (); bool const single = video_sel.size() == 1; @@ -477,13 +484,13 @@ VideoPanel::setup_sensitivity () _colour_conversion->Enable (single && !video_sel.empty ()); } - VideoContentList vc = _parent->selected_video (); - shared_ptr vcs; + ContentList vc = _parent->selected_video (); + shared_ptr vcs; if (!vc.empty ()) { vcs = vc.front (); } - if (vcs && vcs->colour_conversion ()) { + if (vcs && vcs->video->colour_conversion ()) { _edit_colour_conversion_button->Enable (!vcs->colour_conversion().get().preset()); } else { _edit_colour_conversion_button->Enable (false); diff --git a/test/4k_test.cc b/test/4k_test.cc index de4e5218b..9ad2dfb58 100644 --- a/test/4k_test.cc +++ b/test/4k_test.cc @@ -27,6 +27,7 @@ #include "lib/film.h" #include "lib/ffmpeg_content.h" #include "lib/dcp_content_type.h" +#include "lib/video_content.h" #include "lib/ratio.h" #include "test.h" @@ -37,7 +38,7 @@ BOOST_AUTO_TEST_CASE (fourk_test) shared_ptr film = new_test_film ("4k_test"); film->set_name ("4k_test"); shared_ptr c (new FFmpegContent (film, "test/data/test.mp4")); - c->set_scale (VideoContentScale (Ratio::from_id ("185"))); + c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); film->set_resolution (RESOLUTION_4K); film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR")); film->set_container (Ratio::from_id ("185")); diff --git a/test/black_fill_test.cc b/test/black_fill_test.cc index 6da0b037a..173c256e2 100644 --- a/test/black_fill_test.cc +++ b/test/black_fill_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -22,6 +22,7 @@ #include "lib/dcp_content_type.h" #include "lib/film.h" #include "lib/ratio.h" +#include "lib/video_content.h" #include "test.h" /** @file test/black_fill_test.cc @@ -44,11 +45,11 @@ BOOST_AUTO_TEST_CASE (black_fill_test) film->examine_and_add_content (contentB); wait_for_jobs (); - contentA->set_scale (VideoContentScale (Ratio::from_id ("185"))); - contentA->set_video_length (3); + contentA->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); + contentA->video->set_video_length (3); contentA->set_position (DCPTime::from_frames (2, film->video_frame_rate ())); - contentB->set_scale (VideoContentScale (Ratio::from_id ("185"))); - contentB->set_video_length (1); + contentB->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); + contentB->video->set_video_length (1); contentB->set_position (DCPTime::from_frames (7, film->video_frame_rate ())); film->make_dcp (); diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc index 0e5f2d6ad..7e13b1c1a 100644 --- a/test/dcp_subtitle_test.cc +++ b/test/dcp_subtitle_test.cc @@ -67,7 +67,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test) film->examine_and_add_content (content); wait_for_jobs (); - shared_ptr decoder (new DCPDecoder (content, false)); + shared_ptr decoder (new DCPDecoder (content, film->log(), false)); list ctp = decoder->text_subtitles_during ( ContentTimePeriod ( diff --git a/test/ffmpeg_audio_test.cc b/test/ffmpeg_audio_test.cc index a93d77fc1..4d6200d78 100644 --- a/test/ffmpeg_audio_test.cc +++ b/test/ffmpeg_audio_test.cc @@ -31,6 +31,7 @@ #include "lib/sndfile_content.h" #include "lib/film.h" #include "lib/dcp_content_type.h" +#include "lib/video_content.h" #include "lib/ratio.h" #include "lib/ffmpeg_content.h" #include "test.h" @@ -47,7 +48,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_audio_test) wait_for_jobs (); - c->set_scale (VideoContentScale (Ratio::from_id ("185"))); + c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); film->set_container (Ratio::from_id ("185")); film->set_audio_channels (6); diff --git a/test/ffmpeg_dcp_test.cc b/test/ffmpeg_dcp_test.cc index ce8ecad6b..c32220f99 100644 --- a/test/ffmpeg_dcp_test.cc +++ b/test/ffmpeg_dcp_test.cc @@ -30,6 +30,7 @@ #include "lib/ffmpeg_content.h" #include "lib/ratio.h" #include "lib/dcp_content_type.h" +#include "lib/video_content.h" #include "test.h" using boost::shared_ptr; @@ -43,7 +44,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_dcp_test) wait_for_jobs (); - c->set_scale (VideoContentScale (Ratio::from_id ("185"))); + c->video->set_scale (VideoContentScale (Ratio::from_id ("185"))); film->set_container (Ratio::from_id ("185")); film->set_dcp_content_type (DCPContentType::from_pretty_name ("Test")); diff --git a/test/ffmpeg_pts_offset_test.cc b/test/ffmpeg_pts_offset_test.cc index 65ed6436d..0148487ed 100644 --- a/test/ffmpeg_pts_offset_test.cc +++ b/test/ffmpeg_pts_offset_test.cc @@ -35,7 +35,7 @@ BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test) shared_ptr film = new_test_film ("ffmpeg_pts_offset_test"); shared_ptr content (new FFmpegContent (film, "test/data/test.mp4")); content->_audio_streams.push_back (shared_ptr (new FFmpegAudioStream)); - content->_video_frame_rate = 24; + content->video->_video_frame_rate = 24; { /* Sound == video so no offset required */ diff --git a/test/frame_rate_test.cc b/test/frame_rate_test.cc index a318ada11..78d092b94 100644 --- a/test/frame_rate_test.cc +++ b/test/frame_rate_test.cc @@ -29,6 +29,7 @@ #include "lib/playlist.h" #include "lib/ffmpeg_audio_stream.h" #include "lib/frame_rate_change.h" +#include "lib/video_content.h" #include "test.h" using boost::shared_ptr; @@ -52,7 +53,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) afr.push_back (30); Config::instance()->set_allowed_dcp_frame_rates (afr); - content->_video_frame_rate = 60; + content->video->_video_frame_rate = 60; int best = film->best_video_frame_rate (); FrameRateChange frc = FrameRateChange (60, best); BOOST_CHECK_EQUAL (best, 30); @@ -61,7 +62,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 50; + content->video->_video_frame_rate = 50; best = film->best_video_frame_rate (); frc = FrameRateChange (50, best); BOOST_CHECK_EQUAL (best, 25); @@ -70,7 +71,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 48; + content->video->_video_frame_rate = 48; best = film->best_video_frame_rate (); frc = FrameRateChange (48, best); BOOST_CHECK_EQUAL (best, 24); @@ -79,7 +80,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 30; + content->video->_video_frame_rate = 30; best = film->best_video_frame_rate (); frc = FrameRateChange (30, best); BOOST_CHECK_EQUAL (best, 30); @@ -88,7 +89,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 29.97; + content->video->_video_frame_rate = 29.97; best = film->best_video_frame_rate (); frc = FrameRateChange (29.97, best); BOOST_CHECK_EQUAL (best, 30); @@ -97,7 +98,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, true); BOOST_CHECK_CLOSE (frc.speed_up, 30 / 29.97, 0.1); - content->_video_frame_rate = 25; + content->video->_video_frame_rate = 25; best = film->best_video_frame_rate (); frc = FrameRateChange (25, best); BOOST_CHECK_EQUAL (best, 25); @@ -106,7 +107,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 24; + content->video->_video_frame_rate = 24; best = film->best_video_frame_rate (); frc = FrameRateChange (24, best); BOOST_CHECK_EQUAL (best, 24); @@ -115,7 +116,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 14.5; + content->video->_video_frame_rate = 14.5; best = film->best_video_frame_rate (); frc = FrameRateChange (14.5, best); BOOST_CHECK_EQUAL (best, 30); @@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, true); BOOST_CHECK_CLOSE (frc.speed_up, 15 / 14.5, 0.1); - content->_video_frame_rate = 12.6; + content->video->_video_frame_rate = 12.6; best = film->best_video_frame_rate (); frc = FrameRateChange (12.6, best); BOOST_CHECK_EQUAL (best, 25); @@ -133,7 +134,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, true); BOOST_CHECK_CLOSE (frc.speed_up, 25 / 25.2, 0.1); - content->_video_frame_rate = 12.4; + content->video->_video_frame_rate = 12.4; best = film->best_video_frame_rate (); frc = FrameRateChange (12.4, best); BOOST_CHECK_EQUAL (best, 25); @@ -142,7 +143,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, true); BOOST_CHECK_CLOSE (frc.speed_up, 25 / 24.8, 0.1); - content->_video_frame_rate = 12; + content->video->_video_frame_rate = 12; best = film->best_video_frame_rate (); frc = FrameRateChange (12, best); BOOST_CHECK_EQUAL (best, 24); @@ -160,7 +161,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) afr.push_back (60); Config::instance()->set_allowed_dcp_frame_rates (afr); - content->_video_frame_rate = 60; + content->video->_video_frame_rate = 60; best = film->best_video_frame_rate (); frc = FrameRateChange (60, best); BOOST_CHECK_EQUAL (best, 60); @@ -169,7 +170,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 50; + content->video->_video_frame_rate = 50; best = film->best_video_frame_rate (); frc = FrameRateChange (50, best); BOOST_CHECK_EQUAL (best, 50); @@ -178,7 +179,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) BOOST_CHECK_EQUAL (frc.change_speed, false); BOOST_CHECK_CLOSE (frc.speed_up, 1, 0.1); - content->_video_frame_rate = 48; + content->video->_video_frame_rate = 48; best = film->best_video_frame_rate (); frc = FrameRateChange (48, best); BOOST_CHECK_EQUAL (best, 48); @@ -201,7 +202,7 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_single) afr.push_back (24); Config::instance()->set_allowed_dcp_frame_rates (afr); - content->_video_frame_rate = 25; + content->video->_video_frame_rate = 25; best = film->best_video_frame_rate (); frc = FrameRateChange (25, best); BOOST_CHECK_EQUAL (best, 24); @@ -232,16 +233,16 @@ BOOST_AUTO_TEST_CASE (best_dcp_frame_rate_test_double) afr.push_back (30); Config::instance()->set_allowed_dcp_frame_rates (afr); - A->_video_frame_rate = 30; - B->_video_frame_rate = 24; + A->video->_video_frame_rate = 30; + B->video->_video_frame_rate = 24; BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 25); - A->_video_frame_rate = 24; - B->_video_frame_rate = 24; + A->video->_video_frame_rate = 24; + B->video->_video_frame_rate = 24; BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 24); - A->_video_frame_rate = 24; - B->_video_frame_rate = 48; + A->video->_video_frame_rate = 24; + B->video->_video_frame_rate = 48; BOOST_CHECK_EQUAL (film->best_video_frame_rate(), 24); } @@ -261,7 +262,7 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) shared_ptr stream (new FFmpegAudioStream ("foo", 0, 0, 0)); content->_audio_streams.push_back (stream); - content->_video_frame_rate = 24; + content->video->_video_frame_rate = 24; film->set_video_frame_rate (24); stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 48000); @@ -272,30 +273,30 @@ BOOST_AUTO_TEST_CASE (audio_sampling_rate_test) stream->_frame_rate = 80000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 96000); - content->_video_frame_rate = 23.976; + content->video->_video_frame_rate = 23.976; film->set_video_frame_rate (24); stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 47952); - content->_video_frame_rate = 29.97; + content->video->_video_frame_rate = 29.97; film->set_video_frame_rate (30); BOOST_CHECK_EQUAL (film->video_frame_rate (), 30); stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 47952); - content->_video_frame_rate = 25; + content->video->_video_frame_rate = 25; film->set_video_frame_rate (24); stream->_frame_rate = 48000; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 50000); - content->_video_frame_rate = 25; + content->video->_video_frame_rate = 25; film->set_video_frame_rate (24); stream->_frame_rate = 44100; BOOST_CHECK_EQUAL (content->resampled_audio_frame_rate(), 50000); /* Check some out-there conversions (not the best) */ - content->_video_frame_rate = 14.99; + content->video->_video_frame_rate = 14.99; film->set_video_frame_rate (25); stream->_frame_rate = 16000; /* The FrameRateChange within resampled_audio_frame_rate should choose to double-up diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc index a7c077643..fb5e26a2d 100644 --- a/test/isdcf_name_test.cc +++ b/test/isdcf_name_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2016 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -23,6 +23,7 @@ #include "lib/dcp_content_type.h" #include "lib/image_content.h" #include "lib/sndfile_content.h" +#include "lib/video_content.h" #include "test.h" #include @@ -75,7 +76,7 @@ BOOST_AUTO_TEST_CASE (isdcf_name_test) shared_ptr content (new ImageContent (film, "test/data/simple_testcard_640x480.png")); film->examine_and_add_content (content); wait_for_jobs (); - content->set_scale (VideoContentScale (Ratio::from_id ("133"))); + content->video->set_scale (VideoContentScale (Ratio::from_id ("133"))); film->set_container (Ratio::from_id ("185")); BOOST_CHECK_EQUAL (film->isdcf_name(false), "MyNiceFilmWith_TLR-2_F_DE-fr_US-R_4K_DI_20140704_PP_SMPTE_OV"); -- 2.30.2