diff options
| author | Carl Hetherington <cth@carlh.net> | 2012-10-09 17:13:28 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2012-10-09 17:13:28 +0100 |
| commit | 64f24832974e5b05dabf7117d5b2d34ea079c033 (patch) | |
| tree | aefe8a3a4fb34ddb67f2d1f947699f038048d732 /src/lib | |
| parent | dc1b54d559dac0b722e8854d1f48c77a07507497 (diff) | |
Simplify and test audio sample rate alteration.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/film_state.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/film_state.cc b/src/lib/film_state.cc index 3cd7091ca..3d58a4fec 100644 --- a/src/lib/film_state.cc +++ b/src/lib/film_state.cc @@ -283,18 +283,14 @@ FilmState::bytes_per_sample () const int FilmState::target_sample_rate () const { + /* Resample to a DCI-approved sample rate */ double t = dcp_audio_sample_rate (audio_sample_rate); + + /* Compensate for the fact that video will be rounded to the + nearest integer number of frames per second. + */ if (rint (frames_per_second) != frames_per_second) { - if (fabs (frames_per_second - 23.976) < 1e-6 || (fabs (frames_per_second - 29.97) < 1e-6)) { - /* 24fps or 30fps drop-frame ie {24,30} * 1000 / 1001 frames per second; - hence we need to resample the audio to dcp_audio_sample_rate * 1000 / 1001 - so that when we play it back at dcp_audio_sample_rate it is sped up - by the same amount that the video is - */ - t *= double(1000) / 1001; - } else { - throw EncodeError ("unknown fractional frame rate"); - } + t *= frames_per_second / rint (frames_per_second); } return rint (t); |
