Attempt to tidy up internal APIs slightly.
[dcpomatic.git] / src / lib / player_video.cc
index 62dee823ff468c2121cdf05321b6cbd4e592d6ec..b7fb52e3aa8d8b2c27645a5688b5c96aae62bf06 100644 (file)
@@ -23,7 +23,7 @@
 #include "image_proxy.h"
 #include "j2k_image_proxy.h"
 #include "film.h"
-#include "raw_convert.h"
+#include <dcp/raw_convert.h>
 extern "C" {
 #include <libavutil/pixfmt.h>
 }
@@ -37,10 +37,10 @@ using boost::dynamic_pointer_cast;
 using boost::optional;
 using boost::function;
 using dcp::Data;
+using dcp::raw_convert;
 
 PlayerVideo::PlayerVideo (
        shared_ptr<const ImageProxy> in,
-       DCPTime time,
        Crop crop,
        boost::optional<double> fade,
        dcp::Size inter_size,
@@ -50,7 +50,6 @@ PlayerVideo::PlayerVideo (
        optional<ColourConversion> colour_conversion
        )
        : _in (in)
-       , _time (time)
        , _crop (crop)
        , _fade (fade)
        , _inter_size (inter_size)
@@ -64,7 +63,6 @@ PlayerVideo::PlayerVideo (
 
 PlayerVideo::PlayerVideo (shared_ptr<cxml::Node> node, shared_ptr<Socket> socket)
 {
-       _time = DCPTime (node->number_child<DCPTime::Type> ("Time"));
        _crop = Crop (node);
        _fade = node->optional_number_child<double> ("Fade");
 
@@ -105,7 +103,7 @@ PlayerVideo::set_subtitle (PositionImage image)
 shared_ptr<Image>
 PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const
 {
-       shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note));
+       shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note), _inter_size);
 
        Crop total_crop = _crop;
        switch (_part) {
@@ -148,7 +146,6 @@ PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat
 void
 PlayerVideo::add_metadata (xmlpp::Node* node) const
 {
-       node->add_child("Time")->add_child_text (raw_convert<string> (_time.get ()));
        _crop.as_xml (node);
        if (_fade) {
                node->add_child("Fade")->add_child_text (raw_convert<string> (_fade.get ()));
@@ -158,8 +155,8 @@ PlayerVideo::add_metadata (xmlpp::Node* node) const
        node->add_child("InterHeight")->add_child_text (raw_convert<string> (_inter_size.height));
        node->add_child("OutWidth")->add_child_text (raw_convert<string> (_out_size.width));
        node->add_child("OutHeight")->add_child_text (raw_convert<string> (_out_size.height));
-       node->add_child("Eyes")->add_child_text (raw_convert<string> (_eyes));
-       node->add_child("Part")->add_child_text (raw_convert<string> (_part));
+       node->add_child("Eyes")->add_child_text (raw_convert<string> (static_cast<int> (_eyes)));
+       node->add_child("Part")->add_child_text (raw_convert<string> (static_cast<int> (_part)));
        if (_colour_conversion) {
                _colour_conversion.get().as_xml (node);
        }
@@ -190,7 +187,7 @@ PlayerVideo::has_j2k () const
                return false;
        }
 
-       return _crop == Crop () && _inter_size == j2k->size() && !_subtitle && !_fade && !_colour_conversion;
+       return _crop == Crop () && _out_size == j2k->size() && !_subtitle && !_fade && !_colour_conversion;
 }
 
 Data
@@ -207,9 +204,7 @@ PlayerVideo::inter_position () const
        return Position<int> ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.height) / 2);
 }
 
-/** @return true if this PlayerVideo is definitely the same as another
- * (apart from _time), false if it is probably not
- */
+/** @return true if this PlayerVideo is definitely the same as another, false if it is probably not */
 bool
 PlayerVideo::same (shared_ptr<const PlayerVideo> other) const
 {