Rename PlayerImage to PlayerVideoFrame and give it its own file.
authorCarl Hetherington <cth@carlh.net>
Wed, 14 May 2014 09:05:56 +0000 (10:05 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 14 May 2014 09:05:56 +0000 (10:05 +0100)
12 files changed:
src/lib/encoder.cc
src/lib/encoder.h
src/lib/player.cc
src/lib/player.h
src/lib/player_video_frame.cc [new file with mode: 0644]
src/lib/player_video_frame.h [new file with mode: 0644]
src/lib/transcoder.cc
src/lib/wscript
src/tools/server_test.cc
src/wx/film_viewer.cc
src/wx/film_viewer.h
test/play_test.cc

index 8e8da6229099002dc1cb6cfb61d5914532c46b58..bb2fe682287b630baed38d0d4dbf02a0b9b324ec 100644 (file)
@@ -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 ();
        
index e0ee2d41480f3fbf7b413cf0e974a96a4967c735..5cdda459df6efbbfb9d8069100e411753bb1c155 100644 (file)
@@ -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>);
index 1bb2e7cf4329a3fbd303b5b0338d487d9e9c4614..eb4a3d3a56711a7567e774894aae4b1c9fc47033 100644 (file)
@@ -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;
-}
index 4d911a83be3f4ecd9daa715a2aef3848bba025a8..8f7d9a218f4167a808db592b683b8b8577c917d2 100644 (file)
@@ -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 (file)
index 0000000..1c456a2
--- /dev/null
@@ -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 (file)
index 0000000..51ec766
--- /dev/null
@@ -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;
+};
index 1c8f7e3eb0b021d03f6c62a0076ce4cd41f56188..cd729fc228c23e9fc9f0b8c4746ac85831e1f453 100644 (file)
@@ -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) {
index d4231fd30d042518dae6dfd69d3439da5b4f17e6..7e2e10e1f3dc4fff2efef8cac150410ca09fc2b0 100644 (file)
@@ -42,6 +42,7 @@ sources = """
           log.cc
           piece.cc
           player.cc
+          player_video_frame.cc
           playlist.cc
           ratio.cc
           resampler.cc
index 039088862ef8bf7801af1d76da482ff85c425373..48d817cfe981eeb44c9e998ab5ed4a7747a68d6e 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/log.h"
 #include "lib/video_decoder.h"
 #include "lib/player.h"
+#include "lib/player_video_frame.h"
 
 using std::cout;
 using std::cerr;
@@ -47,7 +48,7 @@ static shared_ptr<FileLog> log_ (new FileLog ("servomatictest.log"));
 static int frame = 0;
 
 void
-process_video (shared_ptr<PlayerImage> image, Eyes eyes, ColourConversion conversion, Time)
+process_video (shared_ptr<PlayerVideoFrame> image, Eyes eyes, ColourConversion conversion, Time)
 {
        shared_ptr<DCPVideoFrame> local  (new DCPVideoFrame (image->image(), frame, eyes, conversion, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_));
        shared_ptr<DCPVideoFrame> remote (new DCPVideoFrame (image->image(), frame, eyes, conversion, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_));
index ce5eab00e1db8e8f0bd4bb7e707fe470e59bc7cb..79f46238c7e594761dac6492ebb5d877d0264612 100644 (file)
@@ -34,6 +34,7 @@
 #include "lib/examine_content_job.h"
 #include "lib/filter.h"
 #include "lib/player.h"
+#include "lib/player_video_frame.h"
 #include "lib/video_content.h"
 #include "lib/video_decoder.h"
 #include "film_viewer.h"
@@ -288,7 +289,7 @@ FilmViewer::check_play_state ()
 }
 
 void
-FilmViewer::process_video (shared_ptr<PlayerImage> image, Eyes eyes, Time t)
+FilmViewer::process_video (shared_ptr<PlayerVideoFrame> image, Eyes eyes, Time t)
 {
        if (eyes == EYES_RIGHT) {
                return;
index c99c7344047448b088115a9e085bb5eb389937fa..be8fd9f4e114b16130d25b81f2cf128230120af2 100644 (file)
@@ -28,7 +28,7 @@ class wxToggleButton;
 class FFmpegPlayer;
 class Image;
 class RGBPlusAlphaImage;
-class PlayerImage;
+class PlayerVideoFrame;
 
 /** @class FilmViewer
  *  @brief A wx widget to view a preview of a Film.
@@ -59,7 +59,7 @@ private:
        void slider_moved ();
        void play_clicked ();
        void timer ();
-       void process_video (boost::shared_ptr<PlayerImage>, Eyes, Time);
+       void process_video (boost::shared_ptr<PlayerVideoFrame>, Eyes, Time);
        void calculate_sizes ();
        void check_play_state ();
        void fetch_current_frame_again ();
index 51e2272568acbf26a1bc321d0ad1bdf63af3bc36..a0ad494d1bcf25cd26179cb806b1e255517a59eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    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
@@ -21,6 +21,7 @@
 #include "lib/player.h"
 #include "lib/ratio.h"
 #include "lib/dcp_content_type.h"
+#include "lib/player_video_frame.h"
 #include "test.h"
 
 /* This test needs stuff in Player that is only included in debug mode */
@@ -46,7 +47,7 @@ public:
                _player->Video.connect (bind (&PlayerWrapper::process_video, this, _1, _2, _5));
        }
 
-       void process_video (shared_ptr<PlayerImage> i, bool, Time t)
+       void process_video (shared_ptr<PlayerVideoFrame> i, bool, Time t)
        {
                Video v;
                v.content = _player->_last_video;