#include "job.h"
#include "image.h"
#include "ratio.h"
-#include "resampler.h"
#include "log.h"
#include "scaler.h"
, _have_valid_pieces (false)
, _video_position (0)
, _audio_position (0)
- , _audio_buffers (f->dcp_audio_channels(), 0)
+ , _audio_buffers (f->audio_channels(), 0)
{
_playlist->Changed.connect (bind (&Player::playlist_changed, this));
_playlist->ContentChanged.connect (bind (&Player::content_changed, this, _1, _2, _3));
shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
assert (content);
- FrameRateConversion frc (content->video_frame_rate(), _film->dcp_video_frame_rate());
+ FrameRateConversion frc (content->video_frame_rate(), _film->video_frame_rate());
if (frc.skip && (frame % 2) == 1) {
return;
}
work_image = work_image->scale_and_convert_to_rgb (image_size, _film->scaler(), true);
- Time time = content->start() + (frame * frc.factor() * TIME_HZ / _film->dcp_video_frame_rate());
+ Time time = content->start() + (frame * frc.factor() * TIME_HZ / _film->video_frame_rate());
if (_film->with_subtitles () && _out_subtitle.image && time >= _out_subtitle.from && time <= _out_subtitle.to) {
work_image->alpha_blend (_out_subtitle.image, _out_subtitle.position);
#endif
Video (work_image, eyes, same, time);
- time += TIME_HZ / _film->dcp_video_frame_rate();
+ time += TIME_HZ / _film->video_frame_rate();
if (frc.repeat) {
Video (work_image, eyes, true, time);
- time += TIME_HZ / _film->dcp_video_frame_rate();
+ time += TIME_HZ / _film->video_frame_rate();
}
_video_position = piece->video_position = time;
shared_ptr<AudioContent> content = dynamic_pointer_cast<AudioContent> (piece->content);
assert (content);
- /* Resample */
- if (content->content_audio_frame_rate() != content->output_audio_frame_rate()) {
- shared_ptr<Resampler> r = resampler (content);
- audio = r->run (audio);
- }
-
/* Remap channels */
- shared_ptr<AudioBuffers> dcp_mapped (new AudioBuffers (_film->dcp_audio_channels(), audio->frames()));
+ shared_ptr<AudioBuffers> dcp_mapped (new AudioBuffers (_film->audio_channels(), audio->frames()));
dcp_mapped->make_silent ();
list<pair<int, libdcp::Channel> > map = content->audio_mapping().content_to_dcp ();
for (list<pair<int, libdcp::Channel> >::iterator i = map.begin(); i != map.end(); ++i) {
audio = dcp_mapped;
- Time time = content->start() + (frame * TIME_HZ / _film->dcp_audio_frame_rate()) + (content->audio_delay() * TIME_HZ / 1000);
+ Time time = content->start()
+ + _film->audio_frames_to_time (frame)
+ + (content->audio_delay() * TIME_HZ / 1000);
/* We must cut off anything that comes before the start of all time */
if (time < 0) {
- int const frames = - time * _film->dcp_audio_frame_rate() / TIME_HZ;
+ int const frames = - time * _film->audio_frame_rate() / TIME_HZ;
if (frames >= audio->frames ()) {
return;
}
*/
if (time > _audio_position) {
- /* We can emit some audio from our buffers */
+ /* We can emit some audio from our buffers; this is how many frames */
OutputAudioFrame const N = _film->time_to_audio_frames (time - _audio_position);
if (N > _audio_buffers.frames()) {
/* We need some extra silence before whatever is in the buffers */
_audio_buffers.set_frames (N);
}
assert (N <= _audio_buffers.frames());
+
+ /* XXX: not convinced that a copy is necessary here */
shared_ptr<AudioBuffers> emit (new AudioBuffers (_audio_buffers.channels(), N));
emit->copy_from (&_audio_buffers, N, 0, 0);
Audio (emit, _audio_position);
- _audio_position = piece->audio_position = time + _film->audio_frames_to_time (N);
+ _audio_position = piece->audio_position = _audio_position + _film->audio_frames_to_time (N);
/* And remove it from our buffers */
if (_audio_buffers.frames() > N) {
(*i)->video_position = (*i)->audio_position = vc->start() + s;
- FrameRateConversion frc (vc->video_frame_rate(), _film->dcp_video_frame_rate());
+ FrameRateConversion frc (vc->video_frame_rate(), _film->video_frame_rate());
/* Here we are converting from time (in the DCP) to a frame number in the content.
Hence we need to use the DCP's frame rate and the double/skip correction, not
the source's rate.
*/
- VideoContent::Frame f = s * _film->dcp_video_frame_rate() / (frc.factor() * TIME_HZ);
+ VideoContent::Frame f = s * _film->video_frame_rate() / (frc.factor() * TIME_HZ);
dynamic_pointer_cast<VideoDecoder>((*i)->decoder)->seek (f, accurate);
}
update_subtitle ();
Changed (frequent);
} else if (property == VideoContentProperty::VIDEO_FRAME_TYPE) {
- cout << "vft change.\n";
Changed (frequent);
}
}
_black_frame->make_black ();
}
-shared_ptr<Resampler>
-Player::resampler (shared_ptr<AudioContent> c)
-{
- map<shared_ptr<AudioContent>, shared_ptr<Resampler> >::iterator i = _resamplers.find (c);
- if (i != _resamplers.end ()) {
- return i->second;
- }
-
- shared_ptr<Resampler> r (new Resampler (c->content_audio_frame_rate(), c->output_audio_frame_rate(), c->audio_channels()));
- _resamplers[c] = r;
- return r;
-}
-
void
Player::emit_black ()
{
void
Player::emit_silence (OutputAudioFrame most)
{
- OutputAudioFrame N = min (most, _film->dcp_audio_frame_rate() / 2);
- shared_ptr<AudioBuffers> silence (new AudioBuffers (_film->dcp_audio_channels(), N));
+ OutputAudioFrame N = min (most, _film->audio_frame_rate() / 2);
+ shared_ptr<AudioBuffers> silence (new AudioBuffers (_film->audio_channels(), N));
silence->make_silent ();
Audio (silence, _audio_position);
_audio_position += _film->audio_frames_to_time (N);