+2014-06-05 Carl Hetherington <cth@carlh.net>
+
+ * Back-port changes from v2 which work out how separate
+ audio files should be resampled by looking at the video
+ files which are present at the same time.
+
2014-06-03 Carl Hetherington <cth@carlh.net>
* Version 1.69.21 released.
/* 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
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;
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 ());
+}
+
#include "util.h"
#include "types.h"
#include "dci_metadata.h"
+#include "frame_rate_change.h"
class DCPContentType;
class Log;
Time length () const;
bool has_subtitles () const;
OutputVideoFrame best_video_frame_rate () const;
+ FrameRateChange active_frame_rate_change (Time) const;
libdcp::KDM
make_kdm (
}
-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)
{
*/
+#ifndef DCPOMATIC_FRAME_RATE_CHANGE_H
+#define DCPOMATIC_FRAME_RATE_CHANGE_H
+
#include <string>
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) */
std::string description;
};
+
+#endif
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);
+}
#include <boost/enable_shared_from_this.hpp>
#include "ffmpeg_content.h"
#include "audio_mapping.h"
+#include "frame_rate_change.h"
class Content;
class FFmpegContent;
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 ();
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)
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()
);
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 ();
-}
class Node;
}
-class SndfileContentProperty
-{
-public:
- static int const VIDEO_FRAME_RATE;
-};
-
class SndfileContent : public AudioContent
{
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);
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
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).
*/
#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"
} 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);
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");
}
}
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);
}
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);
}
}
+++ /dev/null
-/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
-
- 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <boost/test/unit_test.hpp>
-#include "lib/film.h"
-#include "lib/dcp_content_type.h"
-#include "lib/ratio.h"
-#include "lib/sndfile_content.h"
-#include "lib/audio_buffers.h"
-#include "lib/player.h"
-#include "test.h"
-
-using std::cout;
-using boost::shared_ptr;
-
-static
-void
-process_audio (shared_ptr<const AudioBuffers> buffers, int* samples)
-{
- cout << "weeeeeeeeee " << buffers->frames() << "\n";
- *samples += buffers->frames ();
-}
-
-/** Test the situation where a piece of SndfileContent has its video
- * frame rate specified (i.e. the rate that it was prepared for),
- * and hence might need resampling.
- */
-BOOST_AUTO_TEST_CASE (audio_with_specified_video_frame_rate_test)
-{
- /* Make a film using staircase.wav with the DCP at 30fps and the audio specified
- as being prepared for 29.97.
- */
-
- shared_ptr<Film> film = new_test_film ("audio_with_specified_video_frame_rate_test");
- film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR"));
- film->set_container (Ratio::from_id ("185"));
- film->set_name ("audio_with_specified_video_frame_rate_test");
-
- shared_ptr<SndfileContent> content (new SndfileContent (film, "test/data/sine_440.wav"));
- content->set_video_frame_rate (29.97);
- film->examine_and_add_content (content);
-
- wait_for_jobs ();
-
- film->set_video_frame_rate (30);
-
- BOOST_CHECK_EQUAL (content->content_audio_frame_rate(), 48000);
- BOOST_CHECK_EQUAL (content->output_audio_frame_rate(), 47952);
-}
audio_delay_test.cc
audio_mapping_test.cc
audio_merger_test.cc
- audio_with_specified_video_frame_rate_test.cc
black_fill_test.cc
client_server_test.cc
colour_conversion_test.cc