From: Carl Hetherington Date: Wed, 14 May 2014 09:05:56 +0000 (+0100) Subject: Rename PlayerImage to PlayerVideoFrame and give it its own file. X-Git-Tag: v2.0.48~551^2~190^2~4 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=8f7d0cf115980cb357bc3da410842503930e66b8;hp=efc8654faceec410649901ee534861904d11e432;p=dcpomatic.git Rename PlayerImage to PlayerVideoFrame and give it its own file. --- 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 + Copyright (C) 2012-2014 Carl Hetherington 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 image, Eyes eyes, ColourConversion conversion, bool same) +Encoder::process_video (shared_ptr 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 + Copyright (C) 2012-2014 Carl Hetherington 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 i, Eyes eyes, ColourConversion, bool same); + void process_video (boost::shared_ptr i, Eyes eyes, ColourConversion, bool same); /** Call with some audio data */ void process_audio (boost::shared_ptr); 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 weak_piece, shared_ptr 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 pi ( - new PlayerImage ( + shared_ptr 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 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 image, Position pos) -{ - _subtitle_image = image; - _subtitle_position = pos; -} - -shared_ptr -PlayerImage::image () -{ - shared_ptr out = _in->crop_scale_window (_crop, _inter_size, _out_size, _scaler, PIX_FMT_RGB24, false); - - Position 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, Crop, libdcp::Size, libdcp::Size, Scaler const *); - - void set_subtitle (boost::shared_ptr, Position); - - boost::shared_ptr image (); - -private: - boost::shared_ptr _in; - Crop _crop; - libdcp::Size _inter_size; - libdcp::Size _out_size; - Scaler const * _scaler; - boost::shared_ptr _subtitle_image; - Position _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, Eyes, ColourConversion, bool, Time)> Video; + boost::signals2::signal, Eyes, ColourConversion, bool, Time)> Video; /** Emitted when some audio data is ready */ boost::signals2::signal, Time)> Audio; @@ -140,7 +119,7 @@ private: AudioMerger _audio_merger; libdcp::Size _video_container_size; - boost::shared_ptr _black_frame; + boost::shared_ptr _black_frame; std::map, boost::shared_ptr > _resamplers; std::list _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 + + 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 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 image, Position pos) +{ + _subtitle_image = image; + _subtitle_position = pos; +} + +shared_ptr +PlayerVideoFrame::image () +{ + shared_ptr out = _in->crop_scale_window (_crop, _inter_size, _out_size, _scaler, PIX_FMT_RGB24, false); + + Position 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 + + 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 +#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, Crop, libdcp::Size, libdcp::Size, Scaler const *); + + void set_subtitle (boost::shared_ptr, Position); + + boost::shared_ptr image (); + +private: + boost::shared_ptr _in; + Crop _crop; + libdcp::Size _inter_size; + libdcp::Size _out_size; + Scaler const * _scaler; + boost::shared_ptr _subtitle_image; + Position _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 + Copyright (C) 2012-2014 Carl Hetherington 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, shared_ptr image, Eyes eyes, ColourConversion conversion, bool same) +video_proxy (weak_ptr encoder, shared_ptr image, Eyes eyes, ColourConversion conversion, bool same) { shared_ptr 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 diff --git a/src/tools/server_test.cc b/src/tools/server_test.cc index 039088862..48d817cfe 100644 --- a/src/tools/server_test.cc +++ b/src/tools/server_test.cc @@ -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 log_ (new FileLog ("servomatictest.log")); static int frame = 0; void -process_video (shared_ptr image, Eyes eyes, ColourConversion conversion, Time) +process_video (shared_ptr image, Eyes eyes, ColourConversion conversion, Time) { shared_ptr local (new DCPVideoFrame (image->image(), frame, eyes, conversion, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_)); shared_ptr remote (new DCPVideoFrame (image->image(), frame, eyes, conversion, film->video_frame_rate(), 250000000, RESOLUTION_2K, log_)); diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc index ce5eab00e..79f46238c 100644 --- a/src/wx/film_viewer.cc +++ b/src/wx/film_viewer.cc @@ -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 image, Eyes eyes, Time t) +FilmViewer::process_video (shared_ptr image, Eyes eyes, Time t) { if (eyes == EYES_RIGHT) { return; diff --git a/src/wx/film_viewer.h b/src/wx/film_viewer.h index c99c73440..be8fd9f4e 100644 --- a/src/wx/film_viewer.h +++ b/src/wx/film_viewer.h @@ -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, Eyes, Time); + void process_video (boost::shared_ptr, Eyes, Time); void calculate_sizes (); void check_play_state (); void fetch_current_frame_again (); diff --git a/test/play_test.cc b/test/play_test.cc index 51e227256..a0ad494d1 100644 --- a/test/play_test.cc +++ b/test/play_test.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington 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 i, bool, Time t) + void process_video (shared_ptr i, bool, Time t) { Video v; v.content = _player->_last_video;