int const ContentProperty::TRIM_START = 403;
int const ContentProperty::TRIM_END = 404;
+Content::Content (shared_ptr<const Film> f)
+ : _film (f)
+ , _position (0)
+ , _trim_start (0)
+ , _trim_end (0)
+ , _change_signals_frequent (false)
+{
+
+}
+
Content::Content (shared_ptr<const Film> f, Time p)
: _film (f)
, _position (p)
class Content : public boost::enable_shared_from_this<Content>, public boost::noncopyable
{
public:
+ Content (boost::shared_ptr<const Film>);
Content (boost::shared_ptr<const Film>, Time);
Content (boost::shared_ptr<const Film>, boost::filesystem::path);
Content (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);
return _paths.front ();
}
+ size_t number_of_paths () const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _paths.size ();
+ }
+
+ boost::filesystem::path path (size_t i) const {
+ boost::mutex::scoped_lock lm (_mutex);
+ return _paths[i];
+ }
+
bool path_valid () const;
/** @return MD5 digest of the content's file(s) */
*/
mutable boost::mutex _mutex;
-private:
/** Paths of our data files */
std::vector<boost::filesystem::path> _paths;
+
+private:
std::string _digest;
Time _position;
Time _trim_start;
using boost::shared_ptr;
MovingImageContent::MovingImageContent (shared_ptr<const Film> f, boost::filesystem::path p)
- : Content (f, p)
- , VideoContent (f, p)
+ : Content (f)
+ , VideoContent (f)
{
+ for (boost::filesystem::directory_iterator i(p); i != boost::filesystem::directory_iterator(); ++i) {
+ if (boost::filesystem::is_regular_file (i->path()) && valid_image_file (i->path())) {
+ _paths.push_back (i->path ());
+ }
+ }
+ sort (_paths.begin(), _paths.end());
}
MovingImageContent::MovingImageContent (shared_ptr<const Film> f, shared_ptr<const cxml::Node> node)
: Content (f, node)
, VideoContent (f, node)
{
- list<cxml::NodePtr> c = node->node_children ("File");
- for (list<cxml::NodePtr>::const_iterator i = c.begin(); i != c.end(); ++i) {
- _files.push_back ((*i)->content ());
- }
+
}
string
node->add_child("Type")->add_child_text ("MovingImage");
Content::as_xml (node);
VideoContent::as_xml (node);
-
- for (vector<boost::filesystem::path>::const_iterator i = _files.begin(); i != _files.end(); ++i) {
- node->add_child("File")->add_child_text (i->filename().string());
- }
}
void
take_from_video_examiner (examiner);
- _video_length = examiner->files().size ();
- _files = examiner->files ();
+ _video_length = number_of_paths ();
}
Time
Time full_length () const;
std::string identifier () const;
-
- std::vector<boost::filesystem::path> const & files () const {
- return _files;
- }
-
-private:
- std::vector<boost::filesystem::path> _files;
};
#endif
return;
}
- boost::filesystem::path path = _moving_image_content->path ();
- path /= _moving_image_content->files()[_video_position];
-
- Magick::Image* magick_image = new Magick::Image (path.string());
+ Magick::Image* magick_image = new Magick::Image (_moving_image_content->path(_video_position).string ());
libdcp::Size size (magick_image->columns(), magick_image->rows());
- shared_ptr<Image> image (new Image (PIX_FMT_RGB24, size, false));
+ shared_ptr<Image> image (new Image (PIX_FMT_RGB24, size, true));
using namespace MagickCore;
uint8_t* p = image->data()[0];
for (int y = 0; y < size.height; ++y) {
+ uint8_t* q = p;
for (int x = 0; x < size.width; ++x) {
Magick::Color c = magick_image->pixelColor (x, y);
- *p++ = c.redQuantum() * 255 / QuantumRange;
- *p++ = c.greenQuantum() * 255 / QuantumRange;
- *p++ = c.blueQuantum() * 255 / QuantumRange;
+ *q++ = c.redQuantum() * 255 / QuantumRange;
+ *q++ = c.greenQuantum() * 255 / QuantumRange;
+ *q++ = c.blueQuantum() * 255 / QuantumRange;
}
+ p += image->stride()[0];
}
delete magick_image;
, _video_length (0)
{
list<unsigned int> frames;
- unsigned int files = 0;
-
- for (boost::filesystem::directory_iterator i(content->path()); i != boost::filesystem::directory_iterator(); ++i) {
- if (boost::filesystem::is_regular_file (i->path ())) {
- ++files;
- }
- }
+ size_t const N = content->number_of_paths ();
int j = 0;
- for (boost::filesystem::directory_iterator i(content->path()); i != boost::filesystem::directory_iterator(); ++i) {
- if (!boost::filesystem::is_regular_file (i->path ())) {
- continue;
+ for (size_t i = 0; i < N; ++i) {
+ boost::filesystem::path const p = content->path (i);
+ frames.push_back (lexical_cast<int> (p.stem().string()));
+
+ if (!_video_size) {
+ using namespace MagickCore;
+ Magick::Image* image = new Magick::Image (p.string());
+ _video_size = libdcp::Size (image->columns(), image->rows());
+ delete image;
}
-
- if (valid_image_file (i->path ())) {
- int n = lexical_cast<int> (i->path().stem().string());
- frames.push_back (n);
- _files.push_back (i->path().filename ());
-
- if (!_video_size) {
- using namespace MagickCore;
- Magick::Image* image = new Magick::Image (i->path().string());
- _video_size = libdcp::Size (image->columns(), image->rows());
- delete image;
- }
- }
-
- job->set_progress (float (j) / files);
- ++j;
+
+ job->set_progress (float (i) / N);
}
frames.sort ();
- sort (_files.begin(), _files.end ());
if (frames.size() < 2) {
throw StringError (String::compose (_("only %1 file(s) found in moving image directory"), frames.size ()));
libdcp::Size video_size () const;
VideoContent::Frame video_length () const;
- std::vector<boost::filesystem::path> const & files () const {
- return _files;
- }
-
private:
boost::weak_ptr<const Film> _film;
boost::optional<libdcp::Size> _video_size;
VideoContent::Frame _video_length;
- std::vector<boost::filesystem::path> _files;
};
using boost::lexical_cast;
using boost::optional;
+VideoContent::VideoContent (shared_ptr<const Film> f)
+ : Content (f)
+ , _video_length (0)
+ , _video_frame_rate (0)
+ , _video_frame_type (VIDEO_FRAME_TYPE_2D)
+ , _ratio (Ratio::from_id ("185"))
+{
+ setup_default_colour_conversion ();
+}
+
VideoContent::VideoContent (shared_ptr<const Film> f, Time s, VideoContent::Frame len)
: Content (f, s)
, _video_length (len)
public:
typedef int Frame;
+ VideoContent (boost::shared_ptr<const Film>);
VideoContent (boost::shared_ptr<const Film>, Time, VideoContent::Frame);
VideoContent (boost::shared_ptr<const Film>, boost::filesystem::path);
VideoContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>);