#include <libcxml/cxml.h>
#include "audio_content.h"
+#include "film.h"
using std::string;
using boost::shared_ptr;
signal_changed (AudioContentProperty::AUDIO_DELAY);
}
-
using std::stringstream;
using std::list;
using std::pair;
+using std::cout;
using boost::optional;
using boost::shared_ptr;
}
Audio (dcp_mapped, time);
+ cout << "bumping n.a. by " << data->frames() << " ie " << film->audio_frames_to_time(data->frames()) << "\n";
_next_audio = time + film->audio_frames_to_time (data->frames());
}
-
+bool
+AudioDecoder::audio_done () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ return (_audio_content->length() - _next_audio) < film->audio_frames_to_time (1);
+}
+
protected:
void audio (boost::shared_ptr<const AudioBuffers>, Time);
+ bool audio_done () const;
Time _next_audio;
boost::shared_ptr<const AudioContent> _audio_content;
_next_video += f->video_frames_to_time (1);
}
+
+bool
+BlackDecoder::done () const
+{
+ return video_done ();
+}
+
+
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
/* VideoDecoder */
*/
virtual Time next () const = 0;
+ virtual bool done () const = 0;
+
protected:
/** The Film that we are decoding in */
return _next_video;
}
+
+bool
+FFmpegDecoder::done () const
+{
+ return (!_decode_audio || !_audio_codec_context || audio_done()) && (!_decode_video || video_done());
+}
+
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
/* VideoDecoder */
FrameRateConversion frc (24, film->dcp_video_frame_rate ());
return video_length() * frc.factor() * TIME_HZ / film->dcp_video_frame_rate ();
}
+
*/
+#ifndef DVDOMATIC_IMAGEMAGICK_CONTENT_H
+#define DVDOMATIC_IMAGEMAGICK_CONTENT_H
+
#include <boost/enable_shared_from_this.hpp>
#include "video_content.h"
static bool valid_file (boost::filesystem::path);
};
+
+#endif
{
return _next_video;
}
+
+
+bool
+ImageMagickDecoder::done () const
+{
+ return video_done ();
+}
+
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
/* VideoDecoder */
shared_ptr<Piece> earliest;
for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
-// cout << "check " << (*i)->content->file() << " start=" << (*i)->content->start() << ", next=" << (*i)->decoder->next() << ", end=" << (*i)->content->end() << "\n";
- if (((*i)->decoder->next() + (*i)->content->start()) >= (*i)->content->end()) {
+ cout << "check " << (*i)->content->file()
+ << " start=" << (*i)->content->start()
+ << ", next=" << (*i)->decoder->next()
+ << ", end=" << (*i)->content->end() << "\n";
+
+ if ((*i)->decoder->done ()) {
continue;
}
Time const t = (*i)->content->start() + (*i)->decoder->next();
if (t < earliest_t) {
-// cout << "\t candidate; " << t << " " << (t / TIME_HZ) << ".\n";
+ cout << "\t candidate; " << t << " " << (t / TIME_HZ) << ".\n";
earliest_t = t;
earliest = *i;
}
Player::add_black_piece (Time s, Time len)
{
shared_ptr<NullContent> nc (new NullContent (_film, s, len));
+ nc->set_ratio (_film->container ());
shared_ptr<BlackDecoder> bd (new BlackDecoder (_film, nc));
bd->Video.connect (bind (&Player::process_video, this, nc, _1, _2, _3));
_pieces.push_back (shared_ptr<Piece> (new Piece (nc, bd)));
#include "audio_buffers.h"
using std::min;
+using std::cout;
using boost::shared_ptr;
SilenceDecoder::SilenceDecoder (shared_ptr<const Film> f, shared_ptr<NullContent> c)
{
shared_ptr<const Film> film = _film.lock ();
assert (film);
-
+
Time const this_time = min (_audio_content->length() - _next_audio, TIME_HZ / 2);
+ cout << "silence emit " << this_time << " from " << _audio_content->length() << "\n";
shared_ptr<AudioBuffers> data (new AudioBuffers (film->dcp_audio_channels(), film->time_to_audio_frames (this_time)));
data->make_silent ();
audio (data, _next_audio);
{
return _next_audio;
}
+
+bool
+SilenceDecoder::done () const
+{
+ return audio_done ();
+}
+
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
};
{
return _next_audio;
}
+
+bool
+SndfileDecoder::done () const
+{
+ return audio_done ();
+}
void seek_back () {}
void seek_forward () {}
Time next () const;
+ bool done () const;
int audio_channels () const;
ContentAudioFrame audio_length () const;
_timed_subtitle->subtitle()->set_position (Position (p.x - _video_content->crop().left, p.y - _video_content->crop().top));
}
}
+
+bool
+VideoDecoder::video_done () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ return (_video_content->length() - _next_video) < film->video_frames_to_time (1);
+}
void video (boost::shared_ptr<Image>, bool, Time);
void subtitle (boost::shared_ptr<TimedSubtitle>);
+ bool video_done () const;
Time _next_video;
boost::shared_ptr<const VideoContent> _video_content;
--- /dev/null
+/*
+ Copyright (C) 2013 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 "imagemagick_content.h"
+
+/** @file test/black_fill_test.cc
+ * @brief Test insertion of black frames between video content.
+ */
+
+using boost::shared_ptr;
+
+BOOST_AUTO_TEST_CASE (black_fill_test)
+{
+ shared_ptr<Film> film = new_test_film ("black_fill_test");
+ film->set_dcp_content_type (DCPContentType::from_dci_name ("FTR"));
+ film->set_name ("black_fill_test");
+ film->set_container (Ratio::from_id ("185"));
+ film->set_sequence_video (false);
+ shared_ptr<ImageMagickContent> contentA (new ImageMagickContent (film, "test/data/simple_testcard_640x480.png"));
+ contentA->set_ratio (Ratio::from_id ("185"));
+ shared_ptr<ImageMagickContent> contentB (new ImageMagickContent (film, "test/data/simple_testcard_640x480.png"));
+ contentB->set_ratio (Ratio::from_id ("185"));
+
+ film->examine_and_add_content (contentA);
+ film->examine_and_add_content (contentB);
+ while (JobManager::instance()->work_to_do ());
+
+ contentA->set_video_length (3);
+ contentA->set_start (film->video_frames_to_time (2));
+ contentB->set_video_length (1);
+ contentB->set_start (film->video_frames_to_time (7));
+
+ film->make_dcp ();
+
+ while (JobManager::instance()->work_to_do ());
+
+ BOOST_CHECK (!JobManager::instance()->errors());
+
+ boost::filesystem::path ref;
+ ref = "test";
+ ref /= "data";
+ ref /= "black_fill_test";
+
+ boost::filesystem::path check;
+ check = "build";
+ check /= "test";
+ check /= "black_fill_test";
+ check /= film->dcp_name();
+
+ check_dcp (ref.string(), check.string());
+}
+
BOOST_CHECK (ref_dcp.equals (check_dcp, options, boost::bind (note, _1, _2)));
}
-
+#include "black_fill_test.cc"
#include "scaling_test.cc"
#include "ratio_test.cc"
#include "pixel_formats_test.cc"