From: Carl Hetherington Date: Wed, 27 May 2015 01:09:22 +0000 (+0100) Subject: Untested use of Frame for video/audio content lengths. X-Git-Tag: v2.0.48~36 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=387304bc9147933b68eda2b38ba8cac0d250e87e Untested use of Frame for video/audio content lengths. --- diff --git a/doc/design/resampling.tex b/doc/design/resampling.tex index cf9cfb1ed..cb7388eb8 100644 --- a/doc/design/resampling.tex +++ b/doc/design/resampling.tex @@ -53,4 +53,11 @@ and $C_A$, resample the audio to $R_A$ where R_A &= \frac{C_V F_A}{F_V} \end{align*} +Once this is done, consider 1 second's worth of content samples ($C_A$ +samples). We have turned them into $R_A$ samples which should still +last 1 second. These samples are then played back at $F_A$ samples +per second, so they last $R_A / F_A$ seconds. Hence there is a +scaling between some content time and some DCP time of $R_A / F_A$ +i.e. $C_V / F_V$. + \end{document} diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index 53160fdb0..def123fb1 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -188,9 +188,9 @@ string AudioContent::technical_summary () const { return String::compose ( - "audio: channels %1, length %2, content rate %3, resampled rate %4", + "audio: channels %1, length %2 frames, content rate %3, resampled rate %4", audio_channels(), - audio_length().seconds(), + audio_length(), audio_frame_rate(), resampled_audio_frame_rate() ); diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index f4a537b30..cb14c70cb 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -68,7 +68,7 @@ public: /** @return number of audio channels in the content */ virtual int audio_channels () const = 0; /** @return the length of the audio in the content */ - virtual ContentTime audio_length () const = 0; + virtual Frame audio_length () const = 0; /** @return the frame rate of the content */ virtual int audio_frame_rate () const = 0; virtual AudioMapping audio_mapping () const = 0; diff --git a/src/lib/audio_examiner.h b/src/lib/audio_examiner.h index d6d4dbe97..a5f055984 100644 --- a/src/lib/audio_examiner.h +++ b/src/lib/audio_examiner.h @@ -30,6 +30,6 @@ public: virtual ~AudioExaminer () {} virtual int audio_channels () const = 0; - virtual ContentTime audio_length () const = 0; + virtual Frame audio_length () const = 0; virtual int audio_frame_rate () const = 0; }; diff --git a/src/lib/config.h b/src/lib/config.h index b39e7af3a..20529911b 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -449,6 +449,7 @@ private: /** Default ISDCF metadata for newly-created Films */ ISDCFMetadata _default_isdcf_metadata; boost::optional _language; + /** Default length of still image content (seconds) */ int _default_still_length; Ratio const * _default_container; DCPContentType const * _default_dcp_content_type; diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 51c7f8549..0c8968531 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -141,7 +141,8 @@ DCPContent::full_length () const { shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - return DCPTime (video_length (), FrameRateChange (video_frame_rate (), film->video_frame_rate ())); + FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ()); + return DCPTime::from_frames (rint (video_length () * frc.factor ()), film->video_frame_rate ()); } string diff --git a/src/lib/dcp_examiner.cc b/src/lib/dcp_examiner.cc index 9dbac14d0..a0d13a722 100644 --- a/src/lib/dcp_examiner.cc +++ b/src/lib/dcp_examiner.cc @@ -81,7 +81,7 @@ DCPExaminer::DCPExaminer (shared_ptr content) throw DCPError (_("Mismatched video sizes in DCP")); } - _video_length += ContentTime::from_frames ((*i)->main_picture()->duration(), _video_frame_rate.get ()); + _video_length += (*i)->main_picture()->duration(); } if ((*i)->main_sound ()) { @@ -99,7 +99,7 @@ DCPExaminer::DCPExaminer (shared_ptr content) throw DCPError (_("Mismatched audio frame rates in DCP")); } - _audio_length += ContentTime::from_frames ((*i)->main_sound()->duration(), _video_frame_rate.get ()); + _audio_length += (*i)->main_sound()->duration(); } if ((*i)->main_subtitle ()) { diff --git a/src/lib/dcp_examiner.h b/src/lib/dcp_examiner.h index 26957b3e4..bf083e8ec 100644 --- a/src/lib/dcp_examiner.h +++ b/src/lib/dcp_examiner.h @@ -39,7 +39,7 @@ public: return _video_size.get_value_or (dcp::Size (1998, 1080)); } - ContentTime video_length () const { + Frame video_length () const { return _video_length; } @@ -59,7 +59,7 @@ public: return _audio_channels.get_value_or (0); } - ContentTime audio_length () const { + Frame audio_length () const { return _audio_length; } @@ -74,10 +74,10 @@ public: private: boost::optional _video_frame_rate; boost::optional _video_size; - ContentTime _video_length; + Frame _video_length; boost::optional _audio_channels; boost::optional _audio_frame_rate; - ContentTime _audio_length; + Frame _audio_length; std::string _name; bool _has_subtitles; bool _encrypted; diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index 187d61953..9acc883fd 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -249,14 +249,18 @@ FFmpegContent::set_audio_stream (shared_ptr s) signal_changed (FFmpegContentProperty::AUDIO_STREAM); } -ContentTime +Frame FFmpegContent::audio_length () const { if (!audio_stream ()) { - return ContentTime (); + return 0; } - return video_length (); + /* We're talking about the content's audio length here, at the content's frame + rate. We assume it's the same as the video's length, and we can just convert + using the content's rates. + */ + return (video_length () / video_frame_rate ()) * audio_frame_rate (); } int @@ -300,7 +304,8 @@ FFmpegContent::full_length () const { shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - return DCPTime (video_length_after_3d_combine(), FrameRateChange (video_frame_rate (), film->video_frame_rate ())); + FrameRateChange const frc (video_frame_rate (), film->video_frame_rate ()); + return DCPTime::from_frames (rint (video_length_after_3d_combine() * frc.factor()), film->video_frame_rate()); } AudioMapping diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index bc1872ac1..cff5eaed8 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -69,7 +69,7 @@ public: /* AudioContent */ int audio_channels () const; - ContentTime audio_length () const; + Frame audio_length () const; int audio_frame_rate () const; AudioMapping audio_mapping () const; void set_audio_mapping (AudioMapping); diff --git a/src/lib/ffmpeg_examiner.cc b/src/lib/ffmpeg_examiner.cc index 8afd4c164..eea99e1e8 100644 --- a/src/lib/ffmpeg_examiner.cc +++ b/src/lib/ffmpeg_examiner.cc @@ -70,7 +70,7 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr c, shared_ptrduration == AV_NOPTS_VALUE; if (!_need_video_length) { - _video_length = ContentTime::from_seconds (double (_format_context->duration) / AV_TIME_BASE); + _video_length = (double (_format_context->duration) / AV_TIME_BASE) * video_frame_rate().get (); } else if (job) { job->sub (_("Finding length")); job->set_progress_unknown (); @@ -126,7 +126,9 @@ FFmpegExaminer::video_packet (AVCodecContext* context) _first_video = frame_time (_format_context->streams[_video_stream]); } if (_need_video_length) { - _video_length = frame_time (_format_context->streams[_video_stream]).get_value_or (ContentTime ()); + _video_length = frame_time ( + _format_context->streams[_video_stream] + ).get_value_or (ContentTime ()).frames (video_frame_rate().get ()); } } } @@ -195,11 +197,10 @@ FFmpegExaminer::video_size () const } /** @return Length according to our content's header */ -ContentTime +Frame FFmpegExaminer::video_length () const { - ContentTime const length = ContentTime::from_seconds (double (_format_context->duration) / AV_TIME_BASE); - return ContentTime (max (ContentTime (1), _video_length)); + return max (Frame (1), _video_length); } optional diff --git a/src/lib/ffmpeg_examiner.h b/src/lib/ffmpeg_examiner.h index 34d4b1e0d..d6149446a 100644 --- a/src/lib/ffmpeg_examiner.h +++ b/src/lib/ffmpeg_examiner.h @@ -31,7 +31,7 @@ public: boost::optional video_frame_rate () const; dcp::Size video_size () const; - ContentTime video_length () const; + Frame video_length () const; boost::optional sample_aspect_ratio () const; std::vector > subtitle_streams () const { @@ -62,7 +62,7 @@ private: /** Video length, either obtained from the header or derived by running * through the whole file. */ - ContentTime _video_length; + Frame _video_length; bool _need_video_length; boost::optional _last_subtitle_start; diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 54ac56eae..c0004e59c 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 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 @@ -126,7 +126,7 @@ ImageContent::examine (shared_ptr job) } void -ImageContent::set_video_length (ContentTime len) +ImageContent::set_video_length (Frame len) { { boost::mutex::scoped_lock lm (_mutex); @@ -141,7 +141,8 @@ ImageContent::full_length () const { shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - return DCPTime (video_length_after_3d_combine(), FrameRateChange (video_frame_rate(), film->video_frame_rate())); + FrameRateChange const frc (video_frame_rate(), film->video_frame_rate()); + return DCPTime::from_frames (rint (video_length_after_3d_combine() * frc.factor ()), film->video_frame_rate ()); } string @@ -149,7 +150,7 @@ ImageContent::identifier () const { SafeStringStream s; s << VideoContent::identifier (); - s << "_" << video_length().get(); + s << "_" << video_length(); return s.str (); } diff --git a/src/lib/image_content.h b/src/lib/image_content.h index 83a02a166..11c932153 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 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 @@ -48,7 +48,7 @@ public: /* VideoContent */ void set_default_colour_conversion (); - void set_video_length (ContentTime); + void set_video_length (Frame); bool still () const; void set_video_frame_rate (float); }; diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 250c8f845..10eee2f6d 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -45,7 +45,7 @@ ImageDecoder::ImageDecoder (shared_ptr c) bool ImageDecoder::pass (PassReason) { - if (_video_position >= _image_content->video_length().frames (_image_content->video_frame_rate ())) { + if (_video_position >= _image_content->video_length()) { return true; } diff --git a/src/lib/image_examiner.cc b/src/lib/image_examiner.cc index 1fd9cd554..502e8adbe 100644 --- a/src/lib/image_examiner.cc +++ b/src/lib/image_examiner.cc @@ -68,11 +68,9 @@ ImageExaminer::ImageExaminer (shared_ptr film, shared_ptrstill ()) { - _video_length = ContentTime::from_seconds (Config::instance()->default_still_length()); + _video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (24); } else { - _video_length = ContentTime::from_frames ( - _image_content->number_of_paths (), video_frame_rate().get_value_or (24) - ); + _video_length = _image_content->number_of_paths (); } } diff --git a/src/lib/image_examiner.h b/src/lib/image_examiner.h index 1917a23f3..937a565f3 100644 --- a/src/lib/image_examiner.h +++ b/src/lib/image_examiner.h @@ -32,7 +32,7 @@ public: boost::optional video_frame_rate () const; dcp::Size video_size () const; - ContentTime video_length () const { + Frame video_length () const { return _video_length; } @@ -40,5 +40,5 @@ private: boost::weak_ptr _film; boost::shared_ptr _image_content; boost::optional _video_size; - ContentTime _video_length; + Frame _video_length; }; diff --git a/src/lib/single_stream_audio_content.cc b/src/lib/single_stream_audio_content.cc index 4547ae600..b470d1a99 100644 --- a/src/lib/single_stream_audio_content.cc +++ b/src/lib/single_stream_audio_content.cc @@ -52,7 +52,7 @@ SingleStreamAudioContent::SingleStreamAudioContent (shared_ptr f, cx , _audio_mapping (node->node_child ("AudioMapping"), version) { _audio_channels = node->number_child ("AudioChannels"); - _audio_length = ContentTime (node->number_child ("AudioLength")); + _audio_length = node->number_child ("AudioLength"); _audio_frame_rate = node->number_child ("AudioFrameRate"); } @@ -73,7 +73,7 @@ SingleStreamAudioContent::as_xml (xmlpp::Node* node) const { AudioContent::as_xml (node); node->add_child("AudioChannels")->add_child_text (raw_convert (audio_channels ())); - node->add_child("AudioLength")->add_child_text (raw_convert (audio_length().get ())); + node->add_child("AudioLength")->add_child_text (raw_convert (audio_length ())); node->add_child("AudioFrameRate")->add_child_text (raw_convert (audio_frame_rate ())); _audio_mapping.as_xml (node->add_child("AudioMapping")); } diff --git a/src/lib/single_stream_audio_content.h b/src/lib/single_stream_audio_content.h index fcfaf14ca..d1d512d67 100644 --- a/src/lib/single_stream_audio_content.h +++ b/src/lib/single_stream_audio_content.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 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 @@ -45,7 +45,7 @@ public: return _audio_channels; } - ContentTime audio_length () const { + Frame audio_length () const { boost::mutex::scoped_lock lm (_mutex); return _audio_length; } @@ -66,7 +66,7 @@ public: protected: int _audio_channels; - ContentTime _audio_length; + Frame _audio_length; int _audio_frame_rate; AudioMapping _audio_mapping; }; diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 9f9ea351e..363c11b09 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -93,6 +93,7 @@ SndfileContent::full_length () const { shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - return DCPTime (audio_length(), film->active_frame_rate_change (position ())); + FrameRateChange const frc = film->active_frame_rate_change (position ()); + return DCPTime::from_frames (audio_length() / frc.speed_up, film->audio_frame_rate ()); } diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 09059a8b0..ecd1a7e16 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2015 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 @@ -116,10 +116,10 @@ SndfileDecoder::audio_channels () const return _info.channels; } -ContentTime +Frame SndfileDecoder::audio_length () const { - return ContentTime::from_frames (_info.frames, audio_frame_rate ()); + return _info.frames; } int diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index 68c8633a0..932394626 100644 --- a/src/lib/sndfile_decoder.h +++ b/src/lib/sndfile_decoder.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2013 Carl Hetherington + Copyright (C) 2012-2015 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,7 +31,7 @@ public: ~SndfileDecoder (); int audio_channels () const; - ContentTime audio_length () const; + Frame audio_length () const; int audio_frame_rate () const; private: diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index db9a2a5e8..0397647ef 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -70,7 +70,7 @@ VideoContent::VideoContent (shared_ptr f) set_default_colour_conversion (); } -VideoContent::VideoContent (shared_ptr f, DCPTime s, ContentTime len) +VideoContent::VideoContent (shared_ptr f, DCPTime s, Frame len) : Content (f, s) , _video_length (len) , _video_frame_rate (0) @@ -96,14 +96,7 @@ VideoContent::VideoContent (shared_ptr f, cxml::ConstNodePtr node, i _video_size.width = node->number_child ("VideoWidth"); _video_size.height = node->number_child ("VideoHeight"); _video_frame_rate = node->number_child ("VideoFrameRate"); - - if (version < 32) { - /* DCP-o-matic 1.0 branch */ - _video_length = ContentTime::from_frames (node->number_child ("VideoLength"), _video_frame_rate); - } else { - _video_length = ContentTime (node->number_child ("VideoLength")); - } - + _video_length = node->number_child ("VideoLength"); _video_frame_type = static_cast (node->number_child ("VideoFrameType")); _sample_aspect_ratio = node->optional_number_child ("SampleAspectRatio"); _crop.left = node->number_child ("LeftCrop"); @@ -125,8 +118,8 @@ VideoContent::VideoContent (shared_ptr f, cxml::ConstNodePtr node, i _colour_conversion = ColourConversion (node->node_child ("ColourConversion"), version); } if (version >= 32) { - _fade_in = ContentTime (node->number_child ("FadeIn")); - _fade_out = ContentTime (node->number_child ("FadeOut")); + _fade_in = node->number_child ("FadeIn"); + _fade_out = node->number_child ("FadeOut"); } } @@ -185,7 +178,7 @@ void VideoContent::as_xml (xmlpp::Node* node) const { boost::mutex::scoped_lock lm (_mutex); - node->add_child("VideoLength")->add_child_text (raw_convert (_video_length.get ())); + node->add_child("VideoLength")->add_child_text (raw_convert (_video_length)); node->add_child("VideoWidth")->add_child_text (raw_convert (_video_size.width)); node->add_child("VideoHeight")->add_child_text (raw_convert (_video_size.height)); node->add_child("VideoFrameRate")->add_child_text (raw_convert (_video_frame_rate)); @@ -198,8 +191,8 @@ VideoContent::as_xml (xmlpp::Node* node) const if (_colour_conversion) { _colour_conversion.get().as_xml (node->add_child("ColourConversion")); } - node->add_child("FadeIn")->add_child_text (raw_convert (_fade_in.get ())); - node->add_child("FadeOut")->add_child_text (raw_convert (_fade_out.get ())); + node->add_child("FadeIn")->add_child_text (raw_convert (_fade_in)); + node->add_child("FadeOut")->add_child_text (raw_convert (_fade_out)); } void @@ -216,7 +209,7 @@ VideoContent::take_from_video_examiner (shared_ptr d) /* These examiner calls could call other content methods which take a lock on the mutex */ dcp::Size const vs = d->video_size (); optional const vfr = d->video_frame_rate (); - ContentTime vl = d->video_length (); + Frame vl = d->video_length (); optional const ar = d->sample_aspect_ratio (); { @@ -235,7 +228,7 @@ VideoContent::take_from_video_examiner (shared_ptr d) shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length.frames (_video_frame_rate)); + LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length); set_default_colour_conversion (); @@ -355,8 +348,8 @@ string VideoContent::technical_summary () const { string s = String::compose ( - N_("video: length %1, size %2x%3, rate %4"), - video_length_after_3d_combine().seconds(), + N_("video: length %1 frames, size %2x%3, rate %4"), + video_length_after_3d_combine(), video_size().width, video_size().height, video_frame_rate() @@ -413,7 +406,7 @@ VideoContent::set_colour_conversion (ColourConversion c) } void -VideoContent::set_fade_in (ContentTime t) +VideoContent::set_fade_in (Frame t) { { boost::mutex::scoped_lock lm (_mutex); @@ -424,7 +417,7 @@ VideoContent::set_fade_in (ContentTime t) } void -VideoContent::set_fade_out (ContentTime t) +VideoContent::set_fade_out (Frame t) { { boost::mutex::scoped_lock lm (_mutex); @@ -487,13 +480,13 @@ VideoContent::fade (Frame f) const { DCPOMATIC_ASSERT (f >= 0); - if (f < fade_in().frames (video_frame_rate ())) { - return float (f) / _fade_in.frames (video_frame_rate ()); + if (f < fade_in()) { + return float (f) / fade_in(); } - Frame fade_out_start = ContentTime (video_length() - fade_out()).frames (video_frame_rate ()); + Frame fade_out_start = video_length() - fade_out(); if (f >= fade_out_start) { - return 1 - float (f - fade_out_start) / fade_out().frames (video_frame_rate ()); + return 1 - float (f - fade_out_start) / fade_out(); } return optional (); diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 72bad21f8..abc9c5fa3 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -44,7 +44,7 @@ class VideoContent : public virtual Content { public: VideoContent (boost::shared_ptr); - VideoContent (boost::shared_ptr, DCPTime, ContentTime); + VideoContent (boost::shared_ptr, DCPTime, Frame); VideoContent (boost::shared_ptr, boost::filesystem::path); VideoContent (boost::shared_ptr, cxml::ConstNodePtr, int); VideoContent (boost::shared_ptr, std::vector >); @@ -55,15 +55,15 @@ public: virtual void set_default_colour_conversion (); - ContentTime video_length () const { + Frame video_length () const { boost::mutex::scoped_lock lm (_mutex); return _video_length; } - ContentTime video_length_after_3d_combine () const { + Frame video_length_after_3d_combine () const { boost::mutex::scoped_lock lm (_mutex); if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) { - return ContentTime (_video_length.get() / 2); + return _video_length / 2; } return _video_length; @@ -91,8 +91,8 @@ public: void unset_colour_conversion (bool signal = true); void set_colour_conversion (ColourConversion); - void set_fade_in (ContentTime); - void set_fade_out (ContentTime); + void set_fade_in (Frame); + void set_fade_out (Frame); VideoFrameType video_frame_type () const { boost::mutex::scoped_lock lm (_mutex); @@ -140,12 +140,12 @@ public: return _sample_aspect_ratio; } - ContentTime fade_in () const { + Frame fade_in () const { boost::mutex::scoped_lock lm (_mutex); return _fade_in; } - ContentTime fade_out () const { + Frame fade_out () const { boost::mutex::scoped_lock lm (_mutex); return _fade_out; } @@ -165,7 +165,7 @@ public: protected: void take_from_video_examiner (boost::shared_ptr); - ContentTime _video_length; + Frame _video_length; float _video_frame_rate; boost::optional _colour_conversion; @@ -185,8 +185,8 @@ private: if there is one. */ boost::optional _sample_aspect_ratio; - ContentTime _fade_in; - ContentTime _fade_out; + Frame _fade_in; + Frame _fade_out; }; #endif diff --git a/src/lib/video_examiner.h b/src/lib/video_examiner.h index 2dcacfc34..f8d247d15 100644 --- a/src/lib/video_examiner.h +++ b/src/lib/video_examiner.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2014 Carl Hetherington + Copyright (C) 2013-2015 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 @@ -34,7 +34,7 @@ public: virtual ~VideoExaminer () {} virtual boost::optional video_frame_rate () const = 0; virtual dcp::Size video_size () const = 0; - virtual ContentTime video_length () const = 0; + virtual Frame video_length () const = 0; virtual boost::optional sample_aspect_ratio () const { return boost::optional (); } diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc index d121eb0cc..a826a1071 100644 --- a/src/tools/dcpomatic_create.cc +++ b/src/tools/dcpomatic_create.cc @@ -190,7 +190,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 (ContentTime::from_seconds (still_length)); + ic->set_video_length (still_length * 24); } } diff --git a/src/wx/content_properties_dialog.cc b/src/wx/content_properties_dialog.cc index 76de75ea6..45593fd5b 100644 --- a/src/wx/content_properties_dialog.cc +++ b/src/wx/content_properties_dialog.cc @@ -40,7 +40,7 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr (video->video_length ().frames (video->video_frame_rate ()))) + " " + _("video frames") + std_to_wx (raw_convert (video->video_length ())) + " " + _("video frames") ); add_property ( _("Video size"), @@ -60,7 +60,7 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr (audio->audio_length().frames (audio->audio_frame_rate ()))) + " " + _("audio frames") + std_to_wx (raw_convert (audio->audio_length())) + " " + _("audio frames") ); } diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index cafb06dfc..74c1756a5 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -284,8 +284,8 @@ TimingPanel::full_length_changed () for (ContentList::iterator i = c.begin(); i != c.end(); ++i) { shared_ptr ic = dynamic_pointer_cast (*i); if (ic && ic->still ()) { - /* XXX: No effective FRC here... is this right? */ - ic->set_video_length (ContentTime (_full_length->get (_parent->film()->video_frame_rate()), FrameRateChange (1, 1))); + int const vfr = _parent->film()->video_frame_rate (); + ic->set_video_length (_full_length->get (vfr).frames (vfr)); } } } diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 0f241506e..9ddfd6714 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -277,24 +277,24 @@ VideoPanel::film_content_changed (int property) } } } else if (property == VideoContentProperty::VIDEO_FADE_IN) { - set check; + set check; for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) { check.insert ((*i)->fade_in ()); } if (check.size() == 1) { - _fade_in->set (vc.front()->fade_in (), vc.front()->video_frame_rate ()); + _fade_in->set (ContentTime::from_frames (vc.front()->fade_in (), vc.front()->video_frame_rate ()), vc.front()->video_frame_rate ()); } else { _fade_in->clear (); } } else if (property == VideoContentProperty::VIDEO_FADE_OUT) { - set check; + set check; for (VideoContentList::const_iterator i = vc.begin (); i != vc.end(); ++i) { check.insert ((*i)->fade_out ()); } if (check.size() == 1) { - _fade_out->set (vc.front()->fade_out (), vc.front()->video_frame_rate ()); + _fade_out->set (ContentTime::from_frames (vc.front()->fade_out (), vc.front()->video_frame_rate ()), vc.front()->video_frame_rate ()); } else { _fade_out->clear (); } @@ -394,7 +394,8 @@ VideoPanel::fade_in_changed () { VideoContentList vc = _parent->selected_video (); for (VideoContentList::const_iterator i = vc.begin(); i != vc.end(); ++i) { - (*i)->set_fade_in (_fade_in->get (_parent->film()->video_frame_rate ())); + int const vfr = _parent->film()->video_frame_rate (); + (*i)->set_fade_in (_fade_in->get (vfr).frames (vfr)); } } @@ -403,7 +404,8 @@ VideoPanel::fade_out_changed () { VideoContentList vc = _parent->selected_video (); for (VideoContentList::const_iterator i = vc.begin(); i != vc.end(); ++i) { - (*i)->set_fade_out (_fade_out->get (_parent->film()->video_frame_rate ())); + int const vfr = _parent->film()->video_frame_rate (); + (*i)->set_fade_out (_fade_out->get (vfr).frames (vfr)); } } diff --git a/src/wx/video_panel.h b/src/wx/video_panel.h index 28d6aa4bb..9c496c4ee 100644 --- a/src/wx/video_panel.h +++ b/src/wx/video_panel.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012-2014 Carl Hetherington + Copyright (C) 2012-2015 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 diff --git a/test/audio_decoder_test.cc b/test/audio_decoder_test.cc index e31689d3f..7b7fa637b 100644 --- a/test/audio_decoder_test.cc +++ b/test/audio_decoder_test.cc @@ -44,7 +44,7 @@ public: { Frame const N = min ( Frame (2000), - _audio_content->audio_length().frames (_audio_content->resampled_audio_frame_rate ()) - _position + _audio_content->audio_length() - _position ); shared_ptr buffers (new AudioBuffers (_audio_content->audio_channels(), N)); @@ -87,15 +87,15 @@ public: } DCPTime full_length () const { - return DCPTime (audio_length().get ()); + return DCPTime::from_seconds (float (audio_length()) / audio_frame_rate ()); } int audio_channels () const { return 2; } - ContentTime audio_length () const { - return ContentTime::from_seconds (61.2942); + Frame audio_length () const { + return rint (61.2942 * audio_frame_rate ()); } int audio_frame_rate () const { diff --git a/test/black_fill_test.cc b/test/black_fill_test.cc index 5981552d1..e6f4b69ee 100644 --- a/test/black_fill_test.cc +++ b/test/black_fill_test.cc @@ -45,10 +45,10 @@ BOOST_AUTO_TEST_CASE (black_fill_test) wait_for_jobs (); contentA->set_scale (VideoContentScale (Ratio::from_id ("185"))); - contentA->set_video_length (ContentTime::from_frames (3, 24)); + contentA->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 (ContentTime::from_frames (1, 24)); + contentB->set_video_length (1); contentB->set_position (DCPTime::from_frames (7, film->video_frame_rate ())); film->make_dcp (); diff --git a/test/ffmpeg_decoder_sequential_test.cc b/test/ffmpeg_decoder_sequential_test.cc index 551157652..6b02efcb5 100644 --- a/test/ffmpeg_decoder_sequential_test.cc +++ b/test/ffmpeg_decoder_sequential_test.cc @@ -54,7 +54,7 @@ test (boost::filesystem::path file, float fps, int gaps) BOOST_CHECK_CLOSE (decoder.video_content()->video_frame_rate(), fps, 0.01); - Frame const N = decoder.video_content()->video_length().frames (decoder.video_content()->video_frame_rate ()); + Frame const N = decoder.video_content()->video_length(); #ifdef DCPOMATIC_DEBUG decoder.test_gaps = 0; #endif diff --git a/test/scaling_test.cc b/test/scaling_test.cc index 441af6bf3..105683ad1 100644 --- a/test/scaling_test.cc +++ b/test/scaling_test.cc @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE (scaling_test) wait_for_jobs (); - imc->set_video_length (ContentTime::from_frames (1, 24)); + imc->set_video_length (1); scaling_test_for (film, imc, "133", "185"); scaling_test_for (film, imc, "185", "185"); diff --git a/test/wscript b/test/wscript index d28b96f41..055dc9def 100644 --- a/test/wscript +++ b/test/wscript @@ -77,6 +77,7 @@ def build(bld): stream_test.cc test.cc threed_test.cc + time_calculation_test.cc update_checker_test.cc upmixer_a_test.cc util_test.cc