}
list<PositionImage>
-Player::process_content_image_subtitles (shared_ptr<SubtitleContent> content, list<shared_ptr<ContentImageSubtitle> > subs)
+Player::process_content_image_subtitles (shared_ptr<SubtitleContent> content, list<shared_ptr<ContentImageSubtitle> > subs) const
{
list<PositionImage> all;
}
list<PositionImage>
-Player::process_content_text_subtitles (list<shared_ptr<ContentTextSubtitle> > sub)
+Player::process_content_text_subtitles (list<shared_ptr<ContentTextSubtitle> > sub) const
{
list<PositionImage> all;
for (list<shared_ptr<ContentTextSubtitle> >::const_iterator i = sub.begin(); i != sub.end(); ++i) {
}
shared_ptr<DCPVideo>
-Player::get_video (DCPTime time, bool accurate)
+Player::content_to_dcp (
+ shared_ptr<VideoContent> content,
+ ContentVideo content_video,
+ list<shared_ptr<Piece> > subs,
+ DCPTime time,
+ dcp::Size image_size) const
{
- if (!_have_valid_pieces) {
- setup_pieces ();
- }
-
- list<shared_ptr<Piece> > ov = overlaps<VideoContent> (
- time,
- time + DCPTime::from_frames (1, _film->video_frame_rate ())
- );
-
- if (ov.empty ()) {
- /* No video content at this time */
- return black_dcp_video (time);
- }
-
- /* Create a DCPVideo from the content's video at this time */
-
- shared_ptr<Piece> piece = ov.back ();
- shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
- assert (decoder);
- shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
- assert (content);
-
- optional<ContentVideo> dec = decoder->get_video (dcp_to_content_video (piece, time), accurate);
- if (!dec) {
- return black_dcp_video (time);
- }
-
- dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ());
- if (_approximate_size) {
- image_size.width &= ~3;
- image_size.height &= ~3;
- }
-
shared_ptr<DCPVideo> dcp_video (
new DCPVideo (
- dec->image,
- dec->eyes,
+ content_video.image,
+ content_video.eyes,
content->crop (),
image_size,
_video_container_size,
time
)
);
-
+
+
/* Add subtitles */
-
- ov = overlaps<SubtitleContent> (
- time,
- time + DCPTime::from_frames (1, _film->video_frame_rate ())
- );
list<PositionImage> sub_images;
- for (list<shared_ptr<Piece> >::const_iterator i = ov.begin(); i != ov.end(); ++i) {
+ for (list<shared_ptr<Piece> >::const_iterator i = subs.begin(); i != subs.end(); ++i) {
shared_ptr<SubtitleDecoder> subtitle_decoder = dynamic_pointer_cast<SubtitleDecoder> ((*i)->decoder);
shared_ptr<SubtitleContent> subtitle_content = dynamic_pointer_cast<SubtitleContent> ((*i)->content);
ContentTime const from = dcp_to_content_subtitle (*i, time);
subtitle_content,
image_subtitles
);
-
+
copy (im.begin(), im.end(), back_inserter (sub_images));
}
-
+
if (_burn_subtitles) {
list<shared_ptr<ContentTextSubtitle> > text_subtitles = subtitle_decoder->get_text_subtitles (from, to);
if (!text_subtitles.empty ()) {
}
}
}
-
+
if (!sub_images.empty ()) {
dcp_video->set_subtitle (merge (sub_images));
}
return dcp_video;
}
+/** @return All DCPVideo at the given time (there may be two frames for 3D) */
+list<shared_ptr<DCPVideo> >
+Player::get_video (DCPTime time, bool accurate)
+{
+ if (!_have_valid_pieces) {
+ setup_pieces ();
+ }
+
+ list<shared_ptr<Piece> > ov = overlaps<VideoContent> (
+ time,
+ time + DCPTime::from_frames (1, _film->video_frame_rate ())
+ );
+
+ list<shared_ptr<DCPVideo> > dcp_video;
+
+ if (ov.empty ()) {
+ /* No video content at this time */
+ dcp_video.push_back (black_dcp_video (time));
+ return dcp_video;
+ }
+
+ /* Create a DCPVideo from the content's video at this time */
+
+ shared_ptr<Piece> piece = ov.back ();
+ shared_ptr<VideoDecoder> decoder = dynamic_pointer_cast<VideoDecoder> (piece->decoder);
+ assert (decoder);
+ shared_ptr<VideoContent> content = dynamic_pointer_cast<VideoContent> (piece->content);
+ assert (content);
+
+ list<ContentVideo> content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate);
+ if (content_video.empty ()) {
+ dcp_video.push_back (black_dcp_video (time));
+ return dcp_video;
+ }
+
+ dcp::Size image_size = content->scale().size (content, _video_container_size, _film->frame_size ());
+ if (_approximate_size) {
+ image_size.width &= ~3;
+ image_size.height &= ~3;
+ }
+
+ for (list<ContentVideo>::const_iterator i = content_video.begin(); i != content_video.end(); ++i) {
+ list<shared_ptr<Piece> > subs = overlaps<SubtitleContent> (
+ time,
+ time + DCPTime::from_frames (1, _film->video_frame_rate ())
+ );
+
+ dcp_video.push_back (content_to_dcp (content, *i, subs, time, image_size));
+ }
+
+ return dcp_video;
+}
+
shared_ptr<AudioBuffers>
Player::get_audio (DCPTime time, DCPTime length, bool accurate)
{
#include "content_subtitle.h"
#include "position_image.h"
#include "piece.h"
+#include "content_video.h"
class Job;
class Film;
public:
Player (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist>);
- boost::shared_ptr<DCPVideo> get_video (DCPTime time, bool accurate);
+ std::list<boost::shared_ptr<DCPVideo> > get_video (DCPTime time, bool accurate);
boost::shared_ptr<AudioBuffers> get_audio (DCPTime time, DCPTime length, bool accurate);
void set_video_container_size (dcp::Size);
void film_changed (Film::Property);
std::list<PositionImage> process_content_image_subtitles (
boost::shared_ptr<SubtitleContent>, std::list<boost::shared_ptr<ContentImageSubtitle> >
- );
- std::list<PositionImage> process_content_text_subtitles (std::list<boost::shared_ptr<ContentTextSubtitle> >);
+ ) const;
+ std::list<PositionImage> process_content_text_subtitles (std::list<boost::shared_ptr<ContentTextSubtitle> >) const;
void update_subtitle_from_text ();
VideoFrame dcp_to_content_video (boost::shared_ptr<const Piece> piece, DCPTime t) const;
AudioFrame dcp_to_content_audio (boost::shared_ptr<const Piece> piece, DCPTime t) const;
ContentTime dcp_to_content_subtitle (boost::shared_ptr<const Piece> piece, DCPTime t) const;
boost::shared_ptr<DCPVideo> black_dcp_video (DCPTime) const;
+ boost::shared_ptr<DCPVideo> content_to_dcp (
+ boost::shared_ptr<VideoContent> content,
+ ContentVideo content_video,
+ std::list<boost::shared_ptr<Piece> > subs,
+ DCPTime time,
+ dcp::Size image_size
+ ) const;
/** @return Pieces of content type C that overlap a specified time range in the DCP */
template<class C>
using std::string;
using std::cout;
+using std::list;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
DCPTime const frame = DCPTime::from_frames (1, _film->video_frame_rate ());
for (DCPTime t; t < _film->length(); t += frame) {
- _encoder->process_video (_player->get_video (t, true));
+ list<shared_ptr<DCPVideo> > v = _player->get_video (t, true);
+ for (list<shared_ptr<DCPVideo> >::const_iterator i = v.begin(); i != v.end(); ++i) {
+ _encoder->process_video (*i);
+ }
_encoder->process_audio (_player->get_audio (t, frame, true));
}
}
-optional<ContentVideo>
+list<ContentVideo>
VideoDecoder::decoded_video (VideoFrame frame)
{
+ list<ContentVideo> output;
+
for (list<ContentVideo>::const_iterator i = _decoded_video.begin(); i != _decoded_video.end(); ++i) {
if (i->frame == frame) {
- return *i;
+ output.push_back (*i);
}
}
- return optional<ContentVideo> ();
+ return output;
}
-optional<ContentVideo>
+list<ContentVideo>
VideoDecoder::get_video (VideoFrame frame, bool accurate)
{
if (_decoded_video.empty() || (frame < _decoded_video.front().frame || frame > (_decoded_video.back().frame + 1))) {
seek (ContentTime::from_frames (frame, _video_content->video_frame_rate()), accurate);
}
- optional<ContentVideo> dec;
+ list<ContentVideo> dec;
/* Now enough pass() calls should either:
* (a) give us what we want, or
* This could all be one statement but it's split up for clarity.
*/
while (true) {
- if (decoded_video (frame)) {
+ if (!decoded_video(frame).empty ()) {
/* We got what we want */
break;
}
/* Any frame will do: use the first one that comes out of pass() */
while (_decoded_video.empty() && !pass ()) {}
if (!_decoded_video.empty ()) {
- dec = _decoded_video.front ();
+ dec.push_back (_decoded_video.front ());
}
}
public:
VideoDecoder (boost::shared_ptr<const VideoContent> c);
- boost::optional<ContentVideo> get_video (VideoFrame frame, bool accurate);
+ std::list<ContentVideo> get_video (VideoFrame frame, bool accurate);
boost::shared_ptr<const VideoContent> video_content () const {
return _video_content;
void seek (ContentTime time, bool accurate);
void video (boost::shared_ptr<const Image>, VideoFrame frame);
- boost::optional<ContentVideo> decoded_video (VideoFrame frame);
+ std::list<ContentVideo> decoded_video (VideoFrame frame);
boost::shared_ptr<const VideoContent> _video_content;
std::list<ContentVideo> _decoded_video;
DCPTime const frame = DCPTime::from_frames (1, film->video_frame_rate ());
for (DCPTime t; t < film->length(); t += frame) {
- process_video (player->get_video (t, true));
+ process_video (player->get_video(t, true).front ());
}
} catch (std::exception& e) {
cerr << "Error: " << e.what() << "\n";
return;
}
- shared_ptr<DCPVideo> dcp_video = _player->get_video (p, accurate);
- if (dcp_video) {
- _frame = dcp_video->image (PIX_FMT_BGRA, true);
+ list<shared_ptr<DCPVideo> > dcp_video = _player->get_video (p, accurate);
+ if (!dcp_video.empty ()) {
+ _frame = dcp_video.front()->image (PIX_FMT_BGRA, true);
_frame = _frame->scale (_frame->size(), Scaler::from_id ("fastbilinear"), PIX_FMT_RGB24, false);
} else {
_frame.reset ();
using std::cerr;
using std::vector;
+using std::list;
using boost::shared_ptr;
using boost::optional;
static void
check (FFmpegDecoder& decoder, int frame)
{
- optional<ContentVideo> v;
+ list<ContentVideo> v;
v = decoder.get_video (frame, true);
- BOOST_CHECK (v);
- BOOST_CHECK_EQUAL (v->frame, frame);
+ BOOST_CHECK (v.size() == 1);
+ BOOST_CHECK_EQUAL (v.front().frame, frame);
}
static void
using std::cout;
using std::cerr;
+using std::list;
using boost::shared_ptr;
using boost::optional;
VideoFrame const N = decoder.video_content()->video_length().frames (decoder.video_content()->video_frame_rate ());
decoder.test_gaps = 0;
for (VideoFrame i = 0; i < N; ++i) {
- optional<ContentVideo> v;
+ list<ContentVideo> v;
v = decoder.get_video (i, true);
if (i < first) {
- BOOST_CHECK (!v);
+ BOOST_CHECK (v.empty ());
} else {
- BOOST_CHECK (v);
- BOOST_CHECK_EQUAL (v->frame, i);
+ BOOST_CHECK (v.size() == 1);
+ BOOST_CHECK_EQUAL (v.front().frame, i);
}
}
BOOST_CHECK_EQUAL (decoder.test_gaps, 0);
using boost::shared_ptr;
static void
-note (dcp::NoteType, string n)
+note (dcp::NoteType t, string n)
{
- cout << n << "\n";
+ if (t == dcp::ERROR) {
+ cout << n << "\n";
+ }
}
BOOST_AUTO_TEST_CASE (recover_test)
film->make_dcp ();
wait_for_jobs ();
- boost::filesystem::path const video = "build/test/recover_test/video/185_2K_aa7e8a4665281568bbe11645a3d4ba4e_24_bicubic_200000000_P_S_3D.mxf";
+ boost::filesystem::path const video = "build/test/recover_test/video/185_2K_3651eded785682b85f4baca4b1d3b7a9_24_bicubic_200000000_P_S_3D.mxf";
boost::filesystem::copy_file (
video,
#include "test.h"
using std::cout;
+using std::list;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
using boost::optional;
VideoFrame const first_frame = video_delay.round_up (content->video_frame_rate ()).frames (content->video_frame_rate ());
FFmpegDecoder decoder (content, film->log());
- optional<ContentVideo> a = decoder.get_video (first_frame, true);
- BOOST_CHECK (a);
- BOOST_CHECK_EQUAL (a->frame, first_frame);
+ list<ContentVideo> a = decoder.get_video (first_frame, true);
+ BOOST_CHECK (a.size() == 1);
+ BOOST_CHECK_EQUAL (a.front().frame, first_frame);
}