PlayerVideo::PlayerVideo (
shared_ptr<const ImageProxy> in,
- DCPTime time,
Crop crop,
boost::optional<double> fade,
dcp::Size inter_size,
optional<ColourConversion> colour_conversion
)
: _in (in)
- , _time (time)
, _crop (crop)
, _fade (fade)
, _inter_size (inter_size)
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");
if (node->optional_number_child<int> ("SubtitleX")) {
shared_ptr<Image> image (
- new Image (AV_PIX_FMT_RGBA, dcp::Size (node->number_child<int> ("SubtitleWidth"), node->number_child<int> ("SubtitleHeight")), true)
+ new Image (AV_PIX_FMT_BGRA, dcp::Size (node->number_child<int> ("SubtitleWidth"), node->number_child<int> ("SubtitleHeight")), true)
);
image->read_from_socket (socket);
* @param pixel_format Function which is called to decide what pixel format the output image should be;
* it is passed the pixel format of the input image from the ImageProxy, and should return the desired
* output pixel format. Two functions always_rgb and keep_xyz_or_rgb are provided for use here.
+ * @param aligned true if the output image should be aligned to 32-byte boundaries.
+ * @param fast true to be fast at the expense of quality.
*/
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) {
);
if (_subtitle) {
- out->alpha_blend (_subtitle->image, _subtitle->position);
+ out->alpha_blend (Image::ensure_aligned (_subtitle->image), _subtitle->position);
}
if (_fade) {
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 ()));
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
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
{
{
return p == AV_PIX_FMT_XYZ12LE ? AV_PIX_FMT_XYZ12LE : AV_PIX_FMT_RGB48LE;
}
+
+void
+PlayerVideo::prepare ()
+{
+ _in->prepare (_inter_size);
+}
+
+size_t
+PlayerVideo::memory_used () const
+{
+ return _in->memory_used();
+}
+
+/** @return Shallow copy of this; _in and _subtitle are shared between the original and the copy */
+shared_ptr<PlayerVideo>
+PlayerVideo::shallow_copy () const
+{
+ return shared_ptr<PlayerVideo>(
+ new PlayerVideo(
+ _in,
+ _crop,
+ _fade,
+ _inter_size,
+ _out_size,
+ _eyes,
+ _part,
+ _colour_conversion
+ )
+ );
+}