summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-06-05 11:48:54 +0100
committerCarl Hetherington <cth@carlh.net>2014-06-05 11:48:54 +0100
commitb60186064405914b41780021f74dd7830f2ffecb (patch)
treee5a1f1522dc8c96c981e8c91f3338d60ec198f7a /src
parent3f9891137747cd7434ce20f69b8d88b967dbdfaf (diff)
Back port active_frame_rate_change stuff from v2, removing specification of video frame rate for sndfile sources.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_content.cc2
-rw-r--r--src/lib/content.h2
-rw-r--r--src/lib/film.cc7
-rw-r--r--src/lib/film.h2
-rw-r--r--src/lib/frame_rate_change.cc6
-rw-r--r--src/lib/frame_rate_change.h8
-rw-r--r--src/lib/playlist.cc17
-rw-r--r--src/lib/playlist.h2
-rw-r--r--src/lib/sndfile_content.cc22
-rw-r--r--src/lib/sndfile_content.h21
-rw-r--r--src/lib/util.cc27
-rw-r--r--src/wx/timing_panel.cc14
12 files changed, 46 insertions, 84 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index 7d77154e1..bf00b672a 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -160,7 +160,7 @@ AudioContent::output_audio_frame_rate () const
/* Resample to a DCI-approved sample rate */
double t = dcp_audio_frame_rate (content_audio_frame_rate ());
- FrameRateChange frc (video_frame_rate(), film->video_frame_rate());
+ FrameRateChange frc = film->active_frame_rate_change (position ());
/* Compensate if the DCP is being run at a different frame rate
to the source; that is, if the video is run such that it will
diff --git a/src/lib/content.h b/src/lib/content.h
index 3cea93cfc..596a0a905 100644
--- a/src/lib/content.h
+++ b/src/lib/content.h
@@ -65,8 +65,6 @@ public:
virtual void as_xml (xmlpp::Node *) const;
virtual Time full_length () const = 0;
virtual std::string identifier () const;
- /** @return the video frame rate that this content has or was prepared to be used with */
- virtual float video_frame_rate () const = 0;
boost::shared_ptr<Content> clone () const;
diff --git a/src/lib/film.cc b/src/lib/film.cc
index 1b5b2b366..9dce80071 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -1041,3 +1041,10 @@ Film::should_be_enough_disk_space (double& required, double& available) const
available = double (s.available) / 1073741824.0f;
return (available - required) > 1;
}
+
+FrameRateChange
+Film::active_frame_rate_change (Time t) const
+{
+ return _playlist->active_frame_rate_change (t, video_frame_rate ());
+}
+
diff --git a/src/lib/film.h b/src/lib/film.h
index 06c770efa..909bc0beb 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -36,6 +36,7 @@
#include "util.h"
#include "types.h"
#include "dci_metadata.h"
+#include "frame_rate_change.h"
class DCPContentType;
class Log;
@@ -119,6 +120,7 @@ public:
Time length () const;
bool has_subtitles () const;
OutputVideoFrame best_video_frame_rate () const;
+ FrameRateChange active_frame_rate_change (Time) const;
libdcp::KDM
make_kdm (
diff --git a/src/lib/frame_rate_change.cc b/src/lib/frame_rate_change.cc
index 3e9c4b505..454938ada 100644
--- a/src/lib/frame_rate_change.cc
+++ b/src/lib/frame_rate_change.cc
@@ -51,8 +51,10 @@ about_equal (float a, float b)
}
-FrameRateChange::FrameRateChange (float source, int dcp)
- : skip (false)
+FrameRateChange::FrameRateChange (float source_, int dcp_)
+ : source (source_)
+ , dcp (dcp_)
+ , skip (false)
, repeat (1)
, change_speed (false)
{
diff --git a/src/lib/frame_rate_change.h b/src/lib/frame_rate_change.h
index 6165f6840..f53adc059 100644
--- a/src/lib/frame_rate_change.h
+++ b/src/lib/frame_rate_change.h
@@ -17,6 +17,9 @@
*/
+#ifndef DCPOMATIC_FRAME_RATE_CHANGE_H
+#define DCPOMATIC_FRAME_RATE_CHANGE_H
+
#include <string>
struct FrameRateChange
@@ -34,6 +37,9 @@ struct FrameRateChange
return repeat;
}
+ float source;
+ int dcp;
+
/** true to skip every other frame */
bool skip;
/** number of times to use each frame (e.g. 1 is normal, 2 means repeat each frame once, and so on) */
@@ -56,3 +62,5 @@ struct FrameRateChange
std::string description;
};
+
+#endif
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 1f00d4d67..247c4837b 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -397,3 +397,20 @@ Playlist::move_later (shared_ptr<Content> c)
Changed ();
}
+
+FrameRateChange
+Playlist::active_frame_rate_change (Time t, int dcp_video_frame_rate) const
+{
+ for (ContentList::const_iterator i = _content.begin(); i != _content.end(); ++i) {
+ shared_ptr<const VideoContent> vc = dynamic_pointer_cast<const VideoContent> (*i);
+ if (!vc) {
+ break;
+ }
+
+ if (vc->position() >= t && t < vc->end()) {
+ return FrameRateChange (vc->video_frame_rate(), dcp_video_frame_rate);
+ }
+ }
+
+ return FrameRateChange (dcp_video_frame_rate, dcp_video_frame_rate);
+}
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 394023f5c..effc52101 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -25,6 +25,7 @@
#include <boost/enable_shared_from_this.hpp>
#include "ffmpeg_content.h"
#include "audio_mapping.h"
+#include "frame_rate_change.h"
class Content;
class FFmpegContent;
@@ -74,6 +75,7 @@ public:
int best_dcp_frame_rate () const;
Time video_end () const;
+ FrameRateChange active_frame_rate_change (Time, int dcp_frame_rate) const;
void set_sequence_video (bool);
void maybe_sequence_video ();
diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc
index 6f18ebbb4..3efba6fd5 100644
--- a/src/lib/sndfile_content.cc
+++ b/src/lib/sndfile_content.cc
@@ -34,8 +34,6 @@ using std::cout;
using boost::shared_ptr;
using libdcp::raw_convert;
-int const SndfileContentProperty::VIDEO_FRAME_RATE = 600;
-
SndfileContent::SndfileContent (shared_ptr<const Film> f, boost::filesystem::path p)
: Content (f, p)
, AudioContent (f, p)
@@ -150,9 +148,10 @@ SndfileContent::full_length () const
shared_ptr<const Film> film = _film.lock ();
assert (film);
- float const rate = _video_frame_rate.get_value_or (film->video_frame_rate ());
+ FrameRateChange frc = film->active_frame_rate_change (position ());
+
OutputAudioFrame const len = divide_with_round (
- audio_length() * output_audio_frame_rate() * rate,
+ audio_length() * output_audio_frame_rate() * frc.source,
content_audio_frame_rate() * film->video_frame_rate()
);
@@ -169,18 +168,3 @@ SndfileContent::set_audio_mapping (AudioMapping m)
signal_changed (AudioContentProperty::AUDIO_MAPPING);
}
-
-float
-SndfileContent::video_frame_rate () const
-{
- {
- boost::mutex::scoped_lock lm (_mutex);
- if (_video_frame_rate) {
- return _video_frame_rate.get ();
- }
- }
-
- shared_ptr<const Film> film = _film.lock ();
- assert (film);
- return film->video_frame_rate ();
-}
diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h
index dcfdfd8d7..a32043c5c 100644
--- a/src/lib/sndfile_content.h
+++ b/src/lib/sndfile_content.h
@@ -29,12 +29,6 @@ namespace cxml {
class Node;
}
-class SndfileContentProperty
-{
-public:
- static int const VIDEO_FRAME_RATE;
-};
-
class SndfileContent : public AudioContent
{
public:
@@ -73,17 +67,6 @@ public:
return _audio_mapping;
}
- void set_video_frame_rate (float r) {
- {
- boost::mutex::scoped_lock lm (_mutex);
- _video_frame_rate = r;
- }
-
- signal_changed (SndfileContentProperty::VIDEO_FRAME_RATE);
- }
-
- float video_frame_rate () const;
-
void set_audio_mapping (AudioMapping);
static bool valid_file (boost::filesystem::path);
@@ -93,10 +76,6 @@ private:
AudioContent::Frame _audio_length;
int _audio_frame_rate;
AudioMapping _audio_mapping;
- /** Video frame rate that this audio has been prepared for,
- if specified.
- */
- boost::optional<float> _video_frame_rate;
};
#endif
diff --git a/src/lib/util.cc b/src/lib/util.cc
index fa7be179a..200d311dc 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -465,33 +465,6 @@ md5_digest (vector<boost::filesystem::path> files, shared_ptr<Job> job)
return digester.get ();
}
-static bool
-about_equal (float a, float b)
-{
- /* A film of F seconds at f FPS will be Ff frames;
- Consider some delta FPS d, so if we run the same
- film at (f + d) FPS it will last F(f + d) seconds.
-
- Hence the difference in length over the length of the film will
- be F(f + d) - Ff frames
- = Ff + Fd - Ff frames
- = Fd frames
- = Fd/f seconds
-
- So if we accept a difference of 1 frame, ie 1/f seconds, we can
- say that
-
- 1/f = Fd/f
- ie 1 = Fd
- ie d = 1/F
-
- So for a 3hr film, ie F = 3 * 60 * 60 = 10800, the acceptable
- FPS error is 1/F ~= 0.0001 ~= 10-e4
- */
-
- return (fabs (a - b) < 1e-4);
-}
-
/** @param An arbitrary audio frame rate.
* @return The appropriate DCP-approved frame rate (48kHz or 96kHz).
*/
diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc
index 5cefe318a..6d9bf4539 100644
--- a/src/wx/timing_panel.cc
+++ b/src/wx/timing_panel.cc
@@ -19,7 +19,6 @@
#include "lib/content.h"
#include "lib/image_content.h"
-#include "lib/sndfile_content.h"
#include "timing_panel.h"
#include "wx_util.h"
#include "timecode.h"
@@ -93,8 +92,7 @@ TimingPanel::film_content_changed (int property)
} else if (
property == ContentProperty::LENGTH ||
property == VideoContentProperty::VIDEO_FRAME_RATE ||
- property == VideoContentProperty::VIDEO_FRAME_TYPE ||
- property == SndfileContentProperty::VIDEO_FRAME_RATE
+ property == VideoContentProperty::VIDEO_FRAME_TYPE
) {
if (content) {
_full_length->set (content->full_length (), film_video_frame_rate);
@@ -124,11 +122,8 @@ TimingPanel::film_content_changed (int property)
if (property == VideoContentProperty::VIDEO_FRAME_RATE) {
if (content) {
shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (content);
- shared_ptr<SndfileContent> sc = dynamic_pointer_cast<SndfileContent> (content);
if (vc) {
_video_frame_rate->SetValue (std_to_wx (lexical_cast<string> (vc->video_frame_rate ())));
- } else if (sc) {
- _video_frame_rate->SetValue (std_to_wx (lexical_cast<string> (sc->video_frame_rate ())));
} else {
_video_frame_rate->SetValue ("24");
}
@@ -138,10 +133,9 @@ TimingPanel::film_content_changed (int property)
}
shared_ptr<ImageContent> ic = dynamic_pointer_cast<ImageContent> (content);
- shared_ptr<SndfileContent> sc = dynamic_pointer_cast<SndfileContent> (content);
_full_length->set_editable (ic && ic->still ());
_play_length->set_editable (!ic || !ic->still ());
- _video_frame_rate->Enable ((ic && !ic->still ()) || sc);
+ _video_frame_rate->Enable (ic && !ic->still ());
_set_video_frame_rate->Enable (false);
}
@@ -209,10 +203,6 @@ TimingPanel::set_video_frame_rate ()
if (ic) {
ic->set_video_frame_rate (lexical_cast<float> (wx_to_std (_video_frame_rate->GetValue ())));
}
- shared_ptr<SndfileContent> sc = dynamic_pointer_cast<SndfileContent> (c.front ());
- if (sc) {
- sc->set_video_frame_rate (lexical_cast<float> (wx_to_std (_video_frame_rate->GetValue ())));
- }
_set_video_frame_rate->Enable (false);
}
}