summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-05-14 10:05:56 +0100
committerCarl Hetherington <cth@carlh.net>2014-05-14 10:05:56 +0100
commit8f7d0cf115980cb357bc3da410842503930e66b8 (patch)
treec555292c0d7b2096f80c89c586137dd57f923e57 /src/lib
parentefc8654faceec410649901ee534861904d11e432 (diff)
Rename PlayerImage to PlayerVideoFrame and give it its own file.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/encoder.cc5
-rw-r--r--src/lib/encoder.h6
-rw-r--r--src/lib/player.cc44
-rw-r--r--src/lib/player.h27
-rw-r--r--src/lib/player_video_frame.cc60
-rw-r--r--src/lib/player_video_frame.h48
-rw-r--r--src/lib/transcoder.cc4
-rw-r--r--src/lib/wscript1
8 files changed, 124 insertions, 71 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 8e8da6229..bb2fe6822 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 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
@@ -35,6 +35,7 @@
#include "writer.h"
#include "server_finder.h"
#include "player.h"
+#include "player_video_frame.h"
#include "i18n.h"
@@ -179,7 +180,7 @@ Encoder::frame_done ()
}
void
-Encoder::process_video (shared_ptr<PlayerImage> image, Eyes eyes, ColourConversion conversion, bool same)
+Encoder::process_video (shared_ptr<PlayerVideoFrame> image, Eyes eyes, ColourConversion conversion, bool same)
{
_waker.nudge ();
diff --git a/src/lib/encoder.h b/src/lib/encoder.h
index e0ee2d414..5cdda459d 100644
--- a/src/lib/encoder.h
+++ b/src/lib/encoder.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 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
@@ -48,7 +48,7 @@ class EncodedData;
class Writer;
class Job;
class ServerFinder;
-class PlayerImage;
+class PlayerVideoFrame;
/** @class Encoder
* @brief Encoder to J2K and WAV for DCP.
@@ -70,7 +70,7 @@ public:
* @param i Video frame image.
* @param same true if i is the same as the last time we were called.
*/
- void process_video (boost::shared_ptr<PlayerImage> i, Eyes eyes, ColourConversion, bool same);
+ void process_video (boost::shared_ptr<PlayerVideoFrame> i, Eyes eyes, ColourConversion, bool same);
/** Call with some audio data */
void process_audio (boost::shared_ptr<const AudioBuffers>);
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 1bb2e7cf4..eb4a3d3a5 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -34,6 +34,7 @@
#include "resampler.h"
#include "log.h"
#include "scaler.h"
+#include "player_video_frame.h"
using std::list;
using std::cout;
@@ -209,8 +210,8 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image
Time const time = content->position() + relative_time + extra - content->trim_start ();
libdcp::Size const image_size = content->scale().size (content, _video_container_size, _film->frame_size ());
- shared_ptr<PlayerImage> pi (
- new PlayerImage (
+ shared_ptr<PlayerVideoFrame> pi (
+ new PlayerVideoFrame (
image,
content->crop(),
image_size,
@@ -519,7 +520,7 @@ Player::set_video_container_size (libdcp::Size s)
im->make_black ();
_black_frame.reset (
- new PlayerImage (
+ new PlayerVideoFrame (
im,
Crop(),
_video_container_size,
@@ -625,40 +626,3 @@ Player::repeat_last_video ()
return true;
}
-
-PlayerImage::PlayerImage (
- shared_ptr<const Image> in,
- Crop crop,
- libdcp::Size inter_size,
- libdcp::Size out_size,
- Scaler const * scaler
- )
- : _in (in)
- , _crop (crop)
- , _inter_size (inter_size)
- , _out_size (out_size)
- , _scaler (scaler)
-{
-
-}
-
-void
-PlayerImage::set_subtitle (shared_ptr<const Image> image, Position<int> pos)
-{
- _subtitle_image = image;
- _subtitle_position = pos;
-}
-
-shared_ptr<Image>
-PlayerImage::image ()
-{
- shared_ptr<Image> out = _in->crop_scale_window (_crop, _inter_size, _out_size, _scaler, PIX_FMT_RGB24, false);
-
- Position<int> const container_offset ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.width) / 2);
-
- if (_subtitle_image) {
- out->alpha_blend (_subtitle_image, _subtitle_position);
- }
-
- return out;
-}
diff --git a/src/lib/player.h b/src/lib/player.h
index 4d911a83b..8f7d9a218 100644
--- a/src/lib/player.h
+++ b/src/lib/player.h
@@ -39,28 +39,7 @@ class AudioContent;
class Piece;
class Image;
class Resampler;
-
-/** A wrapper for an Image which contains some pending operations; these may
- * not be necessary if the receiver of the PlayerImage throws it away.
- */
-class PlayerImage
-{
-public:
- PlayerImage (boost::shared_ptr<const Image>, Crop, libdcp::Size, libdcp::Size, Scaler const *);
-
- void set_subtitle (boost::shared_ptr<const Image>, Position<int>);
-
- boost::shared_ptr<Image> image ();
-
-private:
- boost::shared_ptr<const Image> _in;
- Crop _crop;
- libdcp::Size _inter_size;
- libdcp::Size _out_size;
- Scaler const * _scaler;
- boost::shared_ptr<const Image> _subtitle_image;
- Position<int> _subtitle_position;
-};
+class PlayerVideoFrame;
/** @class Player
* @brief A class which can `play' a Playlist; emitting its audio and video.
@@ -91,7 +70,7 @@ public:
* Fourth parameter is true if the image is the same as the last one that was emitted.
* Fifth parameter is the time.
*/
- boost::signals2::signal<void (boost::shared_ptr<PlayerImage>, Eyes, ColourConversion, bool, Time)> Video;
+ boost::signals2::signal<void (boost::shared_ptr<PlayerVideoFrame>, Eyes, ColourConversion, bool, Time)> Video;
/** Emitted when some audio data is ready */
boost::signals2::signal<void (boost::shared_ptr<const AudioBuffers>, Time)> Audio;
@@ -140,7 +119,7 @@ private:
AudioMerger<Time, AudioContent::Frame> _audio_merger;
libdcp::Size _video_container_size;
- boost::shared_ptr<PlayerImage> _black_frame;
+ boost::shared_ptr<PlayerVideoFrame> _black_frame;
std::map<boost::shared_ptr<AudioContent>, boost::shared_ptr<Resampler> > _resamplers;
std::list<Subtitle> _subtitles;
diff --git a/src/lib/player_video_frame.cc b/src/lib/player_video_frame.cc
new file mode 100644
index 000000000..1c456a253
--- /dev/null
+++ b/src/lib/player_video_frame.cc
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2013-2014 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 "player_video_frame.h"
+#include "image.h"
+
+using boost::shared_ptr;
+
+PlayerVideoFrame::PlayerVideoFrame (
+ shared_ptr<const Image> in,
+ Crop crop,
+ libdcp::Size inter_size,
+ libdcp::Size out_size,
+ Scaler const * scaler
+ )
+ : _in (in)
+ , _crop (crop)
+ , _inter_size (inter_size)
+ , _out_size (out_size)
+ , _scaler (scaler)
+{
+
+}
+
+void
+PlayerVideoFrame::set_subtitle (shared_ptr<const Image> image, Position<int> pos)
+{
+ _subtitle_image = image;
+ _subtitle_position = pos;
+}
+
+shared_ptr<Image>
+PlayerVideoFrame::image ()
+{
+ shared_ptr<Image> out = _in->crop_scale_window (_crop, _inter_size, _out_size, _scaler, PIX_FMT_RGB24, false);
+
+ Position<int> const container_offset ((_out_size.width - _inter_size.width) / 2, (_out_size.height - _inter_size.width) / 2);
+
+ if (_subtitle_image) {
+ out->alpha_blend (_subtitle_image, _subtitle_position);
+ }
+
+ return out;
+}
diff --git a/src/lib/player_video_frame.h b/src/lib/player_video_frame.h
new file mode 100644
index 000000000..51ec7664f
--- /dev/null
+++ b/src/lib/player_video_frame.h
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) 2013-2014 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 <boost/shared_ptr.hpp>
+#include "types.h"
+#include "position.h"
+
+class Image;
+class Scaler;
+
+/** Everything needed to describe a video frame coming out of the player, but with the
+ * bits still their raw form. We may want to combine the bits on a remote machine,
+ * or maybe not even bother to combine them at all.
+ */
+class PlayerVideoFrame
+{
+public:
+ PlayerVideoFrame (boost::shared_ptr<const Image>, Crop, libdcp::Size, libdcp::Size, Scaler const *);
+
+ void set_subtitle (boost::shared_ptr<const Image>, Position<int>);
+
+ boost::shared_ptr<Image> image ();
+
+private:
+ boost::shared_ptr<const Image> _in;
+ Crop _crop;
+ libdcp::Size _inter_size;
+ libdcp::Size _out_size;
+ Scaler const * _scaler;
+ boost::shared_ptr<const Image> _subtitle_image;
+ Position<int> _subtitle_position;
+};
diff --git a/src/lib/transcoder.cc b/src/lib/transcoder.cc
index 1c8f7e3eb..cd729fc22 100644
--- a/src/lib/transcoder.cc
+++ b/src/lib/transcoder.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2014 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
@@ -40,7 +40,7 @@ using boost::weak_ptr;
using boost::dynamic_pointer_cast;
static void
-video_proxy (weak_ptr<Encoder> encoder, shared_ptr<PlayerImage> image, Eyes eyes, ColourConversion conversion, bool same)
+video_proxy (weak_ptr<Encoder> encoder, shared_ptr<PlayerVideoFrame> image, Eyes eyes, ColourConversion conversion, bool same)
{
shared_ptr<Encoder> e = encoder.lock ();
if (e) {
diff --git a/src/lib/wscript b/src/lib/wscript
index d4231fd30..7e2e10e1f 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -42,6 +42,7 @@ sources = """
log.cc
piece.cc
player.cc
+ player_video_frame.cc
playlist.cc
ratio.cc
resampler.cc