summaryrefslogtreecommitdiff
path: root/src/lib/audio_content.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-06-03 22:58:46 +0100
committerCarl Hetherington <cth@carlh.net>2014-06-03 22:58:46 +0100
commit82926443230084739cb673a83b2ab1f9d733a07b (patch)
tree72ff6a2564bc5950f52730b9d00151a5ebbbe00f /src/lib/audio_content.cc
parent5ff10668facca32723efae3f08dfaab8a3d8bd44 (diff)
All audio content should resample if the output frame rate and content
frame rates differ; make Sndfile sources use the video-frame-rate-based calculation for output frame rate (like FFmpeg sources do). Also, fix small problems when flushing Resamplers used to get fed back to Resamplers again.
Diffstat (limited to 'src/lib/audio_content.cc')
-rw-r--r--src/lib/audio_content.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index dbca6652c..79912f1ae 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -29,6 +29,7 @@
#include "i18n.h"
using std::string;
+using std::cout;
using std::vector;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
@@ -148,3 +149,28 @@ AudioContent::technical_summary () const
{
return String::compose ("audio: channels %1, length %2, raw rate %3, out rate %4", audio_channels(), audio_length(), content_audio_frame_rate(), output_audio_frame_rate());
}
+
+int
+AudioContent::output_audio_frame_rate () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ /* Resample to a DCI-approved sample rate */
+ double t = dcp_audio_frame_rate (content_audio_frame_rate ());
+
+ FrameRateConversion frc (video_frame_rate(), film->video_frame_rate());
+
+ /* 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
+ look different in the DCP compared to the source (slower or faster).
+ skip/repeat doesn't come into effect here.
+ */
+
+ if (frc.change_speed) {
+ t *= video_frame_rate() * frc.factor() / film->video_frame_rate();
+ }
+
+ return rint (t);
+}
+