X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fplayer.cc;h=1d3e22e2094435f0488237ebb179357a40533076;hb=5a5324ed3a381a86dfe0a6e3932c1d58fdcd596f;hp=6d155836fbd47f4055cdbf4832883c1392ec7f2a;hpb=48e51965d74cf2a2f2f6f4c5e9c349f1b1103e66;p=dcpomatic.git diff --git a/src/lib/player.cc b/src/lib/player.cc index 6d155836f..1d3e22e20 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -1,38 +1,27 @@ /* Copyright (C) 2013-2016 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic 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, + DCP-o-matic 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. + along with DCP-o-matic. If not, see . */ #include "player.h" #include "film.h" -#include "ffmpeg_decoder.h" -#include "video_decoder.h" -#include "audio_decoder.h" #include "audio_buffers.h" -#include "audio_content.h" -#include "ffmpeg_content.h" -#include "image_decoder.h" #include "content_audio.h" -#include "image_content.h" -#include "subtitle_content.h" -#include "text_subtitle_decoder.h" -#include "text_subtitle_content.h" -#include "video_mxf_decoder.h" -#include "video_mxf_content.h" #include "dcp_content.h" #include "job.h" #include "image.h" @@ -44,18 +33,26 @@ #include "content_video.h" #include "player_video.h" #include "frame_rate_change.h" -#include "dcp_content.h" -#include "dcp_decoder.h" -#include "dcp_subtitle_content.h" -#include "dcp_subtitle_decoder.h" #include "audio_processor.h" #include "playlist.h" #include "referenced_reel_asset.h" +#include "decoder_factory.h" +#include "decoder.h" +#include "video_decoder.h" +#include "audio_decoder.h" +#include "subtitle_content.h" +#include "subtitle_decoder.h" +#include "ffmpeg_content.h" +#include "audio_content.h" +#include "content_subtitle.h" +#include "dcp_decoder.h" +#include "image_decoder.h" #include #include #include #include #include +#include #include #include #include @@ -75,6 +72,7 @@ using std::map; using std::make_pair; using std::copy; using boost::shared_ptr; +using boost::make_shared; using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::optional; @@ -119,7 +117,6 @@ Player::Player (shared_ptr film, shared_ptr playlist void Player::setup_pieces () { - list > old_pieces = _pieces; _pieces.clear (); BOOST_FOREACH (shared_ptr i, _playlist->content ()) { @@ -128,65 +125,8 @@ Player::setup_pieces () continue; } - shared_ptr decoder; - optional frc; - - /* FFmpeg */ - shared_ptr fc = dynamic_pointer_cast (i); - if (fc) { - decoder.reset (new FFmpegDecoder (fc, _film->log(), _fast)); - frc = FrameRateChange (fc->active_video_frame_rate(), _film->video_frame_rate()); - } - - shared_ptr dc = dynamic_pointer_cast (i); - if (dc) { - decoder.reset (new DCPDecoder (dc, _film->log(), _fast)); - frc = FrameRateChange (dc->active_video_frame_rate(), _film->video_frame_rate()); - } - - /* ImageContent */ - shared_ptr ic = dynamic_pointer_cast (i); - if (ic) { - /* See if we can re-use an old ImageDecoder */ - for (list >::const_iterator j = old_pieces.begin(); j != old_pieces.end(); ++j) { - shared_ptr imd = dynamic_pointer_cast ((*j)->decoder); - if (imd && imd->content() == ic) { - decoder = imd; - } - } - - if (!decoder) { - decoder.reset (new ImageDecoder (ic, _film->log())); - } - - frc = FrameRateChange (ic->active_video_frame_rate(), _film->video_frame_rate()); - } - - /* It's questionable whether subtitle content should have a video frame rate; perhaps - it should be assumed that any subtitle content has been prepared at the same rate - as simultaneous video content (like we do with audio). - */ - - /* TextSubtitleContent */ - shared_ptr rc = dynamic_pointer_cast (i); - if (rc) { - decoder.reset (new TextSubtitleDecoder (rc)); - frc = FrameRateChange (rc->active_video_frame_rate(), _film->video_frame_rate()); - } - - /* DCPSubtitleContent */ - shared_ptr dsc = dynamic_pointer_cast (i); - if (dsc) { - decoder.reset (new DCPSubtitleDecoder (dsc)); - frc = FrameRateChange (dsc->active_video_frame_rate(), _film->video_frame_rate()); - } - - /* VideoMXFContent */ - shared_ptr vmc = dynamic_pointer_cast (i); - if (vmc) { - decoder.reset (new VideoMXFDecoder (vmc, _film->log())); - frc = FrameRateChange (vmc->active_video_frame_rate(), _film->video_frame_rate()); - } + shared_ptr decoder = decoder_factory (i, _film->log(), _fast); + FrameRateChange frc (i->active_video_frame_rate(), _film->video_frame_rate()); if (!decoder) { /* Not something that we can decode; e.g. Atmos content */ @@ -201,7 +141,7 @@ Player::setup_pieces () decoder->audio->set_ignore (); } - _pieces.push_back (shared_ptr (new Piece (i, decoder, frc.get ()))); + _pieces.push_back (make_shared (i, decoder, frc)); } _have_valid_pieces = true; @@ -340,7 +280,7 @@ Player::black_player_video_frame (DCPTime time) const { return shared_ptr ( new PlayerVideo ( - shared_ptr (new RawImageProxy (_black_image)), + make_shared (_black_image), time, Crop (), optional (), @@ -436,12 +376,12 @@ Player::get_video (DCPTime time, bool accurate) shared_ptr ( new PlayerVideo ( i->image, - content_video_to_dcp (piece, i->frame), + time, piece->content->video->crop (), - piece->content->video->fade (i->frame), + piece->content->video->fade (i->frame.index()), image_size, _video_container_size, - i->eyes, + i->frame.eyes(), i->part, piece->content->video->colour_conversion () ) @@ -475,7 +415,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) Frame const length_frames = length.frames_round (_film->audio_frame_rate ()); - shared_ptr audio (new AudioBuffers (_film->audio_channels(), length_frames)); + shared_ptr audio = make_shared (_film->audio_channels(), length_frames); audio->make_silent (); list > ov = overlaps (time, time + length, has_audio); @@ -532,13 +472,13 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) /* Gain */ if (i->content->audio->gain() != 0) { - shared_ptr gain (new AudioBuffers (all.audio)); + shared_ptr gain = make_shared (all.audio); gain->apply_gain (i->content->audio->gain ()); all.audio = gain; } /* Remap channels */ - shared_ptr dcp_mapped (new AudioBuffers (_film->audio_channels(), all.audio->frames())); + shared_ptr dcp_mapped = make_shared (_film->audio_channels(), all.audio->frames()); dcp_mapped->make_silent (); AudioMapping map = j->mapping (); for (int i = 0; i < map.input_channels(); ++i) {