From 0758d834992f0adb8aa8d4d9908a64ce8708f05c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 10 May 2016 14:37:57 +0100 Subject: [PATCH] Rename some methods. --- src/lib/audio_decoder.cc | 17 ++-- src/lib/audio_decoder.h | 9 +- src/lib/dcp_decoder.cc | 10 +-- src/lib/dcp_subtitle_decoder.cc | 2 +- src/lib/ffmpeg_decoder.cc | 10 +-- src/lib/image_decoder.cc | 2 +- src/lib/player.cc | 14 +-- src/lib/sndfile_decoder.cc | 2 +- src/lib/subtitle_decoder.cc | 36 ++++---- src/lib/subtitle_decoder.h | 24 +++--- src/lib/text_subtitle_decoder.cc | 2 +- src/lib/video_decoder.cc | 115 +++++++++++++------------ src/lib/video_decoder.h | 18 ++-- src/wx/subtitle_view.cc | 2 +- test/audio_decoder_test.cc | 4 +- test/dcp_subtitle_test.cc | 2 +- test/ffmpeg_decoder_seek_test.cc | 2 +- test/ffmpeg_decoder_sequential_test.cc | 6 +- test/seek_zero_test.cc | 2 +- test/video_decoder_fill_test.cc | 18 ++-- 20 files changed, 148 insertions(+), 149 deletions(-) diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 7ceb9680b..404c85466 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -31,25 +31,24 @@ using std::map; using boost::shared_ptr; AudioDecoder::AudioDecoder (Decoder* parent, shared_ptr content, bool fast, shared_ptr log) - : _audio_content (content) - , _ignore_audio (false) + : _ignore (false) , _fast (fast) { BOOST_FOREACH (AudioStreamPtr i, content->streams ()) { - _streams[i] = shared_ptr (new AudioDecoderStream (_audio_content, i, parent, log)); + _streams[i] = shared_ptr (new AudioDecoderStream (content, i, parent, log)); } } ContentAudio -AudioDecoder::get_audio (AudioStreamPtr stream, Frame frame, Frame length, bool accurate) +AudioDecoder::get (AudioStreamPtr stream, Frame frame, Frame length, bool accurate) { return _streams[stream]->get (frame, length, accurate); } void -AudioDecoder::audio (AudioStreamPtr stream, shared_ptr data, ContentTime time) +AudioDecoder::give (AudioStreamPtr stream, shared_ptr data, ContentTime time) { - if (_ignore_audio) { + if (_ignore) { return; } @@ -95,9 +94,9 @@ AudioDecoder::seek (ContentTime t, bool accurate) } } -/** Set this player never to produce any audio data */ +/** Set this decoder never to produce any data */ void -AudioDecoder::set_ignore_audio () +AudioDecoder::set_ignore () { - _ignore_audio = true; + _ignore = true; } diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index a56847daf..1a52b8591 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -48,23 +48,22 @@ public: * @param accurate true to try hard to return frames from exactly `frame', false if we don't mind nearby frames. * @return Time-stamped audio data which may or may not be from the location (and of the length) requested. */ - ContentAudio get_audio (AudioStreamPtr stream, Frame time, Frame length, bool accurate); + ContentAudio get (AudioStreamPtr stream, Frame time, Frame length, bool accurate); - void set_ignore_audio (); + void set_ignore (); bool fast () const { return _fast; } - void audio (AudioStreamPtr stream, boost::shared_ptr, ContentTime); + void give (AudioStreamPtr stream, boost::shared_ptr, ContentTime); void flush (); void seek (ContentTime t, bool accurate); private: - boost::shared_ptr _audio_content; /** An AudioDecoderStream object to manage each stream in _audio_content */ std::map > _streams; - bool _ignore_audio; + bool _ignore; bool _fast; }; diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 2a7691666..1b47cc0d3 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -97,14 +97,14 @@ DCPDecoder::pass (PassReason reason, bool) shared_ptr stereo = dynamic_pointer_cast (asset); int64_t const entry_point = (*_reel)->main_picture()->entry_point (); if (mono) { - video->video (shared_ptr (new J2KImageProxy (mono->get_frame (entry_point + frame), asset->size())), offset + frame); + video->give (shared_ptr (new J2KImageProxy (mono->get_frame (entry_point + frame), asset->size())), offset + frame); } else { - video->video ( + video->give ( shared_ptr (new J2KImageProxy (stereo->get_frame (entry_point + frame), asset->size(), dcp::EYE_LEFT)), offset + frame ); - video->video ( + video->give ( shared_ptr (new J2KImageProxy (stereo->get_frame (entry_point + frame), asset->size(), dcp::EYE_RIGHT)), offset + frame ); @@ -126,7 +126,7 @@ DCPDecoder::pass (PassReason reason, bool) } } - audio->audio (_dcp_content->audio->stream(), data, ContentTime::from_frames (offset, vfr) + _next); + audio->give (_dcp_content->audio->stream(), data, ContentTime::from_frames (offset, vfr) + _next); } if ((*_reel)->main_subtitle ()) { @@ -139,7 +139,7 @@ DCPDecoder::pass (PassReason reason, bool) if (!subs.empty ()) { /* XXX: assuming that all `subs' are at the same time; maybe this is ok */ - subtitle->text_subtitle ( + subtitle->give_text ( ContentTimePeriod ( ContentTime::from_frames (offset - entry_point, vfr) + ContentTime::from_seconds (subs.front().in().as_seconds ()), ContentTime::from_frames (offset - entry_point, vfr) + ContentTime::from_seconds (subs.front().out().as_seconds ()) diff --git a/src/lib/dcp_subtitle_decoder.cc b/src/lib/dcp_subtitle_decoder.cc index 23f5dd529..7ad9c458c 100644 --- a/src/lib/dcp_subtitle_decoder.cc +++ b/src/lib/dcp_subtitle_decoder.cc @@ -77,7 +77,7 @@ DCPSubtitleDecoder::pass (PassReason, bool) ++_next; } - subtitle->text_subtitle (p, s); + subtitle->give_text (p, s); return false; } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 2f123e484..14c2e63e2 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -141,7 +141,7 @@ FFmpegDecoder::pass (PassReason reason, bool accurate) int const si = _packet.stream_index; shared_ptr fc = _ffmpeg_content; - if (_video_stream && si == _video_stream.get() && !video->ignore_video() && (accurate || reason != PASS_REASON_SUBTITLE)) { + if (_video_stream && si == _video_stream.get() && !video->ignore() && (accurate || reason != PASS_REASON_SUBTITLE)) { decode_video_packet (); } else if (fc->subtitle_stream() && fc->subtitle_stream()->uses_index (_format_context, si)) { decode_subtitle_packet (); @@ -395,7 +395,7 @@ FFmpegDecoder::decode_audio_packet () } if (data->frames() > 0) { - audio->audio (*stream, data, ct); + audio->give (*stream, data, ct); } } @@ -440,7 +440,7 @@ FFmpegDecoder::decode_video_packet () if (i->second != AV_NOPTS_VALUE) { double const pts = i->second * av_q2d (_format_context->streams[_video_stream.get()]->time_base) + _pts_offset.seconds (); - video->video ( + video->give ( shared_ptr (new RawImageProxy (image)), llrint (pts * _ffmpeg_content->active_video_frame_rate ()) ); @@ -584,7 +584,7 @@ FFmpegDecoder::decode_bitmap_subtitle (AVSubtitleRect const * rect, ContentTimeP static_cast (rect->h) / vs.height ); - subtitle->image_subtitle (period, image, scaled_rect); + subtitle->give_image (period, image, scaled_rect); } void @@ -651,5 +651,5 @@ FFmpegDecoder::decode_ass_subtitle (string ass, ContentTimePeriod period) } } - subtitle->text_subtitle (period, ss); + subtitle->give_text (period, ss); } diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index 71157dd5d..588d89246 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -63,7 +63,7 @@ ImageDecoder::pass (PassReason, bool) } } - video->video (_image, _video_position); + video->give (_image, _video_position); ++_video_position; return false; } diff --git a/src/lib/player.cc b/src/lib/player.cc index ba386e39a..53df8a372 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -208,11 +208,11 @@ Player::setup_pieces () } if (decoder->video && _ignore_video) { - decoder->video->set_ignore_video (); + decoder->video->set_ignore (); } if (decoder->audio && _ignore_audio) { - decoder->audio->set_ignore_audio (); + decoder->audio->set_ignore (); } _pieces.push_back (shared_ptr (new Piece (i, decoder, frc.get ()))); @@ -437,7 +437,7 @@ Player::get_video (DCPTime time, bool accurate) if (use) { /* We want to use this piece */ - list content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate); + list content_video = decoder->get (dcp_to_content_video (piece, time), accurate); if (content_video.empty ()) { pvf.push_back (black_player_video_frame (time)); } else { @@ -465,7 +465,7 @@ Player::get_video (DCPTime time, bool accurate) } } else { /* Discard unused video */ - decoder->get_video (dcp_to_content_video (piece, time), accurate); + decoder->get (dcp_to_content_video (piece, time), accurate); } } } @@ -542,7 +542,7 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) } /* Audio from this piece's decoder stream (which might be more or less than what we asked for) */ - ContentAudio all = decoder->get_audio (j, content_frame, request_frames, accurate); + ContentAudio all = decoder->get (j, content_frame, request_frames, accurate); /* Gain */ if (i->content->audio->gain() != 0) { @@ -660,7 +660,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt, /* XXX: this video_frame_rate() should be the rate that the subtitle content has been prepared for */ ContentTime const to = from + ContentTime::from_frames (1, _film->video_frame_rate ()); - list image = subtitle_decoder->get_image_subtitles (ContentTimePeriod (from, to), starting, accurate); + list image = subtitle_decoder->get_image (ContentTimePeriod (from, to), starting, accurate); for (list::iterator i = image.begin(); i != image.end(); ++i) { /* Apply content's subtitle offsets */ @@ -678,7 +678,7 @@ Player::get_subtitles (DCPTime time, DCPTime length, bool starting, bool burnt, ps.image.push_back (i->sub); } - list text = subtitle_decoder->get_text_subtitles (ContentTimePeriod (from, to), starting, accurate); + list text = subtitle_decoder->get_text (ContentTimePeriod (from, to), starting, accurate); BOOST_FOREACH (ContentTextSubtitle& ts, text) { BOOST_FOREACH (dcp::SubtitleString s, ts.subs) { s.set_h_position (s.h_position() + (*j)->content->subtitle->x_offset ()); diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 7762ab1e4..2a2b3fe4a 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -86,7 +86,7 @@ SndfileDecoder::pass (PassReason, bool) } data->set_frames (this_time); - audio->audio (_sndfile_content->audio->stream (), data, ContentTime::from_frames (_done, _info.samplerate)); + audio->give (_sndfile_content->audio->stream (), data, ContentTime::from_frames (_done, _info.samplerate)); _done += this_time; _remaining -= this_time; diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index e9692b99f..f182c53e5 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -32,13 +32,13 @@ using boost::function; SubtitleDecoder::SubtitleDecoder ( Decoder* parent, shared_ptr c, - function (ContentTimePeriod, bool)> image_subtitles_during, - function (ContentTimePeriod, bool)> text_subtitles_during + function (ContentTimePeriod, bool)> image_during, + function (ContentTimePeriod, bool)> text_during ) : _parent (parent) - , _subtitle_content (c) - , _image_subtitles_during (image_subtitles_during) - , _text_subtitles_during (text_subtitles_during) + , _content (c) + , _image_during (image_during) + , _text_during (text_during) { } @@ -51,15 +51,15 @@ SubtitleDecoder::SubtitleDecoder ( * of the video frame) */ void -SubtitleDecoder::image_subtitle (ContentTimePeriod period, shared_ptr image, dcpomatic::Rect rect) +SubtitleDecoder::give_image (ContentTimePeriod period, shared_ptr image, dcpomatic::Rect rect) { - _decoded_image_subtitles.push_back (ContentImageSubtitle (period, image, rect)); + _decoded_image.push_back (ContentImageSubtitle (period, image, rect)); } void -SubtitleDecoder::text_subtitle (ContentTimePeriod period, list s) +SubtitleDecoder::give_text (ContentTimePeriod period, list s) { - _decoded_text_subtitles.push_back (ContentTextSubtitle (period, s)); + _decoded_text.push_back (ContentTextSubtitle (period, s)); } /** @param sp Full periods of subtitles that are showing or starting during the specified period */ @@ -95,8 +95,8 @@ SubtitleDecoder::get (list const & subs, list const & sp, /* Discard anything in _decoded_image_subtitles that is outside 5 seconds either side of period */ - list::iterator i = _decoded_image_subtitles.begin(); - while (i != _decoded_image_subtitles.end()) { + list::iterator i = _decoded_image.begin(); + while (i != _decoded_image.end()) { list::iterator tmp = i; ++tmp; @@ -104,7 +104,7 @@ SubtitleDecoder::get (list const & subs, list const & sp, i->period().to < (period.from - ContentTime::from_seconds (5)) || i->period().from > (period.to + ContentTime::from_seconds (5)) ) { - _decoded_image_subtitles.erase (i); + _decoded_image.erase (i); } i = tmp; @@ -114,20 +114,20 @@ SubtitleDecoder::get (list const & subs, list const & sp, } list -SubtitleDecoder::get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate) +SubtitleDecoder::get_text (ContentTimePeriod period, bool starting, bool accurate) { - return get (_decoded_text_subtitles, _text_subtitles_during (period, starting), period, starting, accurate); + return get (_decoded_text, _text_during (period, starting), period, starting, accurate); } list -SubtitleDecoder::get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate) +SubtitleDecoder::get_image (ContentTimePeriod period, bool starting, bool accurate) { - return get (_decoded_image_subtitles, _image_subtitles_during (period, starting), period, starting, accurate); + return get (_decoded_image, _image_during (period, starting), period, starting, accurate); } void SubtitleDecoder::seek (ContentTime, bool) { - _decoded_text_subtitles.clear (); - _decoded_image_subtitles.clear (); + _decoded_text.clear (); + _decoded_image.clear (); } diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index 317755107..3b101526a 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -38,33 +38,33 @@ public: SubtitleDecoder ( Decoder* parent, boost::shared_ptr, - boost::function (ContentTimePeriod, bool)> image_subtitles_during, - boost::function (ContentTimePeriod, bool)> text_subtitles_during + boost::function (ContentTimePeriod, bool)> image_during, + boost::function (ContentTimePeriod, bool)> text_during ); - std::list get_image_subtitles (ContentTimePeriod period, bool starting, bool accurate); - std::list get_text_subtitles (ContentTimePeriod period, bool starting, bool accurate); + std::list get_image (ContentTimePeriod period, bool starting, bool accurate); + std::list get_text (ContentTimePeriod period, bool starting, bool accurate); void seek (ContentTime, bool); - void image_subtitle (ContentTimePeriod period, boost::shared_ptr, dcpomatic::Rect); - void text_subtitle (ContentTimePeriod period, std::list); + void give_image (ContentTimePeriod period, boost::shared_ptr, dcpomatic::Rect); + void give_text (ContentTimePeriod period, std::list); boost::shared_ptr content () const { - return _subtitle_content; + return _content; } private: Decoder* _parent; - std::list _decoded_image_subtitles; - std::list _decoded_text_subtitles; - boost::shared_ptr _subtitle_content; + std::list _decoded_image; + std::list _decoded_text; + boost::shared_ptr _content; template std::list get (std::list const & subs, std::list const & sp, ContentTimePeriod period, bool starting, bool accurate); - boost::function (ContentTimePeriod, bool)> _image_subtitles_during; - boost::function (ContentTimePeriod, bool)> _text_subtitles_during; + boost::function (ContentTimePeriod, bool)> _image_during; + boost::function (ContentTimePeriod, bool)> _text_during; }; #endif diff --git a/src/lib/text_subtitle_decoder.cc b/src/lib/text_subtitle_decoder.cc index f76bb7f75..23ec518b3 100644 --- a/src/lib/text_subtitle_decoder.cc +++ b/src/lib/text_subtitle_decoder.cc @@ -108,7 +108,7 @@ TextSubtitleDecoder::pass (PassReason, bool) } } - subtitle->text_subtitle (content_time_period (_subtitles[_next]), out); + subtitle->give_text (content_time_period (_subtitles[_next]), out); ++_next; return false; diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index fce5b367a..a734f9b2a 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -23,6 +23,7 @@ #include "film.h" #include "log.h" #include "compose.hpp" +#include #include #include "i18n.h" @@ -38,27 +39,27 @@ VideoDecoder::VideoDecoder (Decoder* parent, shared_ptr c, shared #ifdef DCPOMATIC_DEBUG : test_gaps (0) , _parent (parent), - _video_content (c) + _content (c) #else : _parent (parent) - , _video_content (c) + , _content (c) #endif , _log (log) , _last_seek_accurate (true) - , _ignore_video (false) + , _ignore (false) { - _black_image.reset (new Image (AV_PIX_FMT_RGB24, _video_content->video->size(), true)); + _black_image.reset (new Image (AV_PIX_FMT_RGB24, _content->video->size(), true)); _black_image->make_black (); } list -VideoDecoder::decoded_video (Frame frame) +VideoDecoder::decoded (Frame frame) { list output; - for (list::const_iterator i = _decoded_video.begin(); i != _decoded_video.end(); ++i) { - if (i->frame == frame) { - output.push_back (*i); + BOOST_FOREACH (ContentVideo const & i, _decoded) { + if (i.frame == frame) { + output.push_back (i); } } @@ -71,21 +72,21 @@ VideoDecoder::decoded_video (Frame frame) * @return Frames; there may be none (if there is no video there), 1 for 2D or 2 for 3D. */ list -VideoDecoder::get_video (Frame frame, bool accurate) +VideoDecoder::get (Frame frame, bool accurate) { if (_no_data_frame && frame >= _no_data_frame.get()) { return list (); } - /* At this stage, if we have get_video()ed before, _decoded_video will contain the last frame that this - method returned (and possibly a few more). If the requested frame is not in _decoded_video and it is not the next - one after the end of _decoded_video we need to seek. + /* At this stage, if we have get_video()ed before, _decoded will contain the last frame that this + method returned (and possibly a few more). If the requested frame is not in _decoded and it is not the next + one after the end of _decoded we need to seek. */ _log->log (String::compose ("VD has request for %1", frame), LogEntry::TYPE_DEBUG_DECODE); - if (_decoded_video.empty() || frame < _decoded_video.front().frame || frame > (_decoded_video.back().frame + 1)) { - seek (ContentTime::from_frames (frame, _video_content->active_video_frame_rate()), accurate); + if (_decoded.empty() || frame < _decoded.front().frame || frame > (_decoded.back().frame + 1)) { + seek (ContentTime::from_frames (frame, _content->active_video_frame_rate()), accurate); } list dec; @@ -102,7 +103,7 @@ VideoDecoder::get_video (Frame frame, bool accurate) bool no_data = false; while (true) { - if (!decoded_video(frame).empty ()) { + if (!decoded(frame).empty ()) { /* We got what we want */ break; } @@ -113,7 +114,7 @@ VideoDecoder::get_video (Frame frame, bool accurate) break; } - if (!_decoded_video.empty() && _decoded_video.front().frame > frame) { + if (!_decoded.empty() && _decoded.front().frame > frame) { /* We're never going to get the frame we want. Perhaps the caller is asking * for a video frame before the content's video starts (if its audio * begins before its video, for example). @@ -122,7 +123,7 @@ VideoDecoder::get_video (Frame frame, bool accurate) } } - dec = decoded_video (frame); + dec = decoded (frame); if (no_data && dec.empty()) { _no_data_frame = frame; @@ -130,22 +131,22 @@ VideoDecoder::get_video (Frame frame, bool accurate) } else { /* Any frame will do: use the first one that comes out of pass() */ - while (_decoded_video.empty() && !_parent->pass (Decoder::PASS_REASON_VIDEO, accurate)) {} - if (!_decoded_video.empty ()) { - dec.push_back (_decoded_video.front ()); + while (_decoded.empty() && !_parent->pass (Decoder::PASS_REASON_VIDEO, accurate)) {} + if (!_decoded.empty ()) { + dec.push_back (_decoded.front ()); } } - /* Clean up _decoded_video; keep the frame we are returning, if any (which may have two images + /* Clean up _decoded; keep the frame we are returning, if any (which may have two images for 3D), but nothing before that */ - while (!_decoded_video.empty() && !dec.empty() && _decoded_video.front().frame < dec.front().frame) { - _decoded_video.pop_front (); + while (!_decoded.empty() && !dec.empty() && _decoded.front().frame < dec.front().frame) { + _decoded.pop_front (); } return dec; } -/** Fill _decoded_video from `from' up to, but not including, `to' with +/** Fill _decoded from `from' up to, but not including, `to' with * a frame for one particular Eyes value (which could be EYES_BOTH, * EYES_LEFT or EYES_RIGHT) */ @@ -162,22 +163,22 @@ VideoDecoder::fill_one_eye (Frame from, Frame to, Eyes eye) Part filler_part = PART_WHOLE; /* ...unless there's some video we can fill with */ - if (!_decoded_video.empty ()) { - filler_image = _decoded_video.back().image; - filler_part = _decoded_video.back().part; + if (!_decoded.empty ()) { + filler_image = _decoded.back().image; + filler_part = _decoded.back().part; } for (Frame i = from; i < to; ++i) { #ifdef DCPOMATIC_DEBUG test_gaps++; #endif - _decoded_video.push_back ( + _decoded.push_back ( ContentVideo (filler_image, eye, filler_part, i) ); } } -/** Fill _decoded_video from `from' up to, but not including, `to' +/** Fill _decoded from `from' up to, but not including, `to' * adding both left and right eye frames. */ void @@ -195,7 +196,7 @@ VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye) Part filler_right_part = PART_WHOLE; /* ...unless there's some video we can fill with */ - for (list::const_reverse_iterator i = _decoded_video.rbegin(); i != _decoded_video.rend(); ++i) { + for (list::const_reverse_iterator i = _decoded.rbegin(); i != _decoded.rend(); ++i) { if (i->eyes == EYES_LEFT && !filler_left_image) { filler_left_image = i->image; filler_left_part = i->part; @@ -210,16 +211,16 @@ VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye) } Frame filler_frame = from; - Eyes filler_eye = _decoded_video.empty() ? EYES_LEFT : _decoded_video.back().eyes; + Eyes filler_eye = _decoded.empty() ? EYES_LEFT : _decoded.back().eyes; - if (_decoded_video.empty ()) { + if (_decoded.empty ()) { filler_frame = 0; filler_eye = EYES_LEFT; - } else if (_decoded_video.back().eyes == EYES_LEFT) { - filler_frame = _decoded_video.back().frame; + } else if (_decoded.back().eyes == EYES_LEFT) { + filler_frame = _decoded.back().frame; filler_eye = EYES_RIGHT; - } else if (_decoded_video.back().eyes == EYES_RIGHT) { - filler_frame = _decoded_video.back().frame + 1; + } else if (_decoded.back().eyes == EYES_RIGHT) { + filler_frame = _decoded.back().frame + 1; filler_eye = EYES_LEFT; } @@ -229,7 +230,7 @@ VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye) test_gaps++; #endif - _decoded_video.push_back ( + _decoded.push_back ( ContentVideo ( filler_eye == EYES_LEFT ? filler_left_image : filler_right_image, filler_eye, @@ -247,19 +248,19 @@ VideoDecoder::fill_both_eyes (Frame from, Frame to, Eyes eye) } } -/** Called by subclasses when they have a video frame ready */ +/** Called by decoder classes when they have a video frame ready */ void -VideoDecoder::video (shared_ptr image, Frame frame) +VideoDecoder::give (shared_ptr image, Frame frame) { - if (_ignore_video) { + if (_ignore) { return; } _log->log (String::compose ("VD receives %1", frame), LogEntry::TYPE_DEBUG_DECODE); - /* Work out what we are going to push into _decoded_video next */ + /* Work out what we are going to push into _decoded next */ list to_push; - switch (_video_content->video->frame_type ()) { + switch (_content->video->frame_type ()) { case VIDEO_FRAME_TYPE_2D: to_push.push_back (ContentVideo (image, EYES_BOTH, PART_WHOLE, frame)); break; @@ -268,7 +269,7 @@ VideoDecoder::video (shared_ptr image, Frame frame) /* We receive the same frame index twice for 3D-alternate; hence we know which frame this one is. */ - bool const same = (!_decoded_video.empty() && frame == _decoded_video.back().frame); + bool const same = (!_decoded.empty() && frame == _decoded.back().frame); to_push.push_back (ContentVideo (image, same ? EYES_RIGHT : EYES_LEFT, PART_WHOLE, frame)); break; } @@ -291,18 +292,18 @@ VideoDecoder::video (shared_ptr image, Frame frame) } /* Now VideoDecoder is required never to have gaps in the frames that it presents - via get_video(). Hence we need to fill in any gap between the last thing in _decoded_video + via get_video(). Hence we need to fill in any gap between the last thing in _decoded and the things we are about to push. */ optional from; optional to; - if (_decoded_video.empty() && _last_seek_time && _last_seek_accurate) { - from = _last_seek_time->frames_round (_video_content->active_video_frame_rate ()); + if (_decoded.empty() && _last_seek_time && _last_seek_accurate) { + from = _last_seek_time->frames_round (_content->active_video_frame_rate ()); to = to_push.front().frame; - } else if (!_decoded_video.empty ()) { - from = _decoded_video.back().frame + 1; + } else if (!_decoded.empty ()) { + from = _decoded.back().frame + 1; to = to_push.front().frame; } @@ -315,7 +316,7 @@ VideoDecoder::video (shared_ptr image, Frame frame) } if (from) { - switch (_video_content->video->frame_type ()) { + switch (_content->video->frame_type ()) { case VIDEO_FRAME_TYPE_2D: fill_one_eye (from.get(), to.get (), EYES_BOTH); break; @@ -333,29 +334,29 @@ VideoDecoder::video (shared_ptr image, Frame frame) } } - copy (to_push.begin(), to_push.end(), back_inserter (_decoded_video)); + copy (to_push.begin(), to_push.end(), back_inserter (_decoded)); /* We can't let this build up too much or we will run out of memory. There is a - `best' value for the allowed size of _decoded_video which balances memory use + `best' value for the allowed size of _decoded which balances memory use with decoding efficiency (lack of seeks). Throwing away video frames here is not a problem for correctness, so do it. */ - while (_decoded_video.size() > 96) { - _decoded_video.pop_back (); + while (_decoded.size() > 96) { + _decoded.pop_back (); } } void VideoDecoder::seek (ContentTime s, bool accurate) { - _decoded_video.clear (); + _decoded.clear (); _last_seek_time = s; _last_seek_accurate = accurate; } -/** Set this player never to produce any video data */ +/** Set this decoder never to produce any data */ void -VideoDecoder::set_ignore_video () +VideoDecoder::set_ignore () { - _ignore_video = true; + _ignore = true; } diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index c14a877f2..712ea5060 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -44,11 +44,11 @@ class VideoDecoder public: VideoDecoder (Decoder* parent, boost::shared_ptr c, boost::shared_ptr log); - std::list get_video (Frame frame, bool accurate); + std::list get (Frame frame, bool accurate); - void set_ignore_video (); - bool ignore_video () const { - return _ignore_video; + void set_ignore (); + bool ignore () const { + return _ignore; } #ifdef DCPOMATIC_DEBUG @@ -61,23 +61,23 @@ public: friend void ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int gaps, int video_length); void seek (ContentTime time, bool accurate); - void video (boost::shared_ptr, Frame frame); + void give (boost::shared_ptr, Frame frame); private: - std::list decoded_video (Frame frame); + std::list decoded (Frame frame); void fill_one_eye (Frame from, Frame to, Eyes); void fill_both_eyes (Frame from, Frame to, Eyes); Decoder* _parent; - boost::shared_ptr _video_content; + boost::shared_ptr _content; boost::shared_ptr _log; - std::list _decoded_video; + std::list _decoded; boost::shared_ptr _black_image; boost::optional _last_seek_time; bool _last_seek_accurate; /** true if this decoder should ignore all video; i.e. never produce any */ - bool _ignore_video; + bool _ignore; /** if set, this is a frame for which we got no data because the Decoder said * it has no more to give. */ diff --git a/src/wx/subtitle_view.cc b/src/wx/subtitle_view.cc index a33a401df..0852fabea 100644 --- a/src/wx/subtitle_view.cc +++ b/src/wx/subtitle_view.cc @@ -65,7 +65,7 @@ SubtitleView::SubtitleView (wxWindow* parent, shared_ptr film, shared_ptr< sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - list subs = decoder->subtitle->get_text_subtitles (ContentTimePeriod (ContentTime(), ContentTime::max ()), true, true); + list subs = decoder->subtitle->get_text (ContentTimePeriod (ContentTime(), ContentTime::max ()), true, true); FrameRateChange const frc = film->active_frame_rate_change (position); int n = 0; for (list::const_iterator i = subs.begin(); i != subs.end(); ++i) { diff --git a/test/audio_decoder_test.cc b/test/audio_decoder_test.cc index 5eabc4074..73d515492 100644 --- a/test/audio_decoder_test.cc +++ b/test/audio_decoder_test.cc @@ -82,7 +82,7 @@ public: } } - audio->audio (_test_audio_content->audio->stream(), buffers, ContentTime::from_frames (_position, 48000)); + audio->give (_test_audio_content->audio->stream(), buffers, ContentTime::from_frames (_position, 48000)); _position += N; return N < 2000; @@ -106,7 +106,7 @@ static ContentAudio get (Frame from, Frame length) { decoder->seek (ContentTime::from_frames (from, content->audio->resampled_frame_rate ()), true); - ContentAudio ca = decoder->audio->get_audio (content->audio->stream(), from, length, true); + ContentAudio ca = decoder->audio->get (content->audio->stream(), from, length, true); BOOST_CHECK_EQUAL (ca.frame, from); return ca; } diff --git a/test/dcp_subtitle_test.cc b/test/dcp_subtitle_test.cc index 80e0a3dd1..5d77681e9 100644 --- a/test/dcp_subtitle_test.cc +++ b/test/dcp_subtitle_test.cc @@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE (dcp_subtitle_within_dcp_test) BOOST_CHECK_EQUAL (ctp.back().from, ContentTime::from_seconds (25 + 12 * 0.04)); BOOST_CHECK_EQUAL (ctp.back().to, ContentTime::from_seconds (26 + 4 * 0.04)); - list subs = decoder->subtitle->get_text_subtitles ( + list subs = decoder->subtitle->get_text ( ContentTimePeriod ( ContentTime::from_seconds (25), ContentTime::from_seconds (26) diff --git a/test/ffmpeg_decoder_seek_test.cc b/test/ffmpeg_decoder_seek_test.cc index 83efc4201..d70471bbd 100644 --- a/test/ffmpeg_decoder_seek_test.cc +++ b/test/ffmpeg_decoder_seek_test.cc @@ -46,7 +46,7 @@ static void check (shared_ptr decoder, int frame) { list v; - v = decoder->video->get_video (frame, true); + v = decoder->video->get (frame, true); BOOST_CHECK (v.size() == 1); BOOST_CHECK_EQUAL (v.front().frame, frame); } diff --git a/test/ffmpeg_decoder_sequential_test.cc b/test/ffmpeg_decoder_sequential_test.cc index e1e29ab17..3548d15f2 100644 --- a/test/ffmpeg_decoder_sequential_test.cc +++ b/test/ffmpeg_decoder_sequential_test.cc @@ -55,15 +55,15 @@ ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int shared_ptr log (new NullLog); shared_ptr decoder (new FFmpegDecoder (content, log, false)); - BOOST_REQUIRE (decoder->video->_video_content->video_frame_rate()); - BOOST_CHECK_CLOSE (decoder->video->_video_content->video_frame_rate().get(), fps, 0.01); + BOOST_REQUIRE (decoder->video->_content->video_frame_rate()); + BOOST_CHECK_CLOSE (decoder->video->_content->video_frame_rate().get(), fps, 0.01); #ifdef DCPOMATIC_DEBUG decoder->video->test_gaps = 0; #endif for (Frame i = 0; i < video_length; ++i) { list v; - v = decoder->video->get_video (i, true); + v = decoder->video->get (i, true); BOOST_REQUIRE_EQUAL (v.size(), 1U); BOOST_CHECK_EQUAL (v.front().frame, i); } diff --git a/test/seek_zero_test.cc b/test/seek_zero_test.cc index 0c65fa3b8..33561206c 100644 --- a/test/seek_zero_test.cc +++ b/test/seek_zero_test.cc @@ -64,7 +64,7 @@ BOOST_AUTO_TEST_CASE (seek_zero_test) Frame const first_frame = video_delay.round_up (content->active_video_frame_rate ()).frames_round (content->active_video_frame_rate ()); FFmpegDecoder decoder (content, film->log(), false); - list a = decoder.video->get_video (first_frame, true); + list a = decoder.video->get (first_frame, true); BOOST_CHECK (a.size() == 1); BOOST_CHECK_EQUAL (a.front().frame, first_frame); } diff --git a/test/video_decoder_fill_test.cc b/test/video_decoder_fill_test.cc index 539392718..974c50280 100644 --- a/test/video_decoder_fill_test.cc +++ b/test/video_decoder_fill_test.cc @@ -37,18 +37,18 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test1) ImageDecoder decoder (c, film->log()); decoder.video->fill_one_eye (0, 4, EYES_BOTH); - BOOST_CHECK_EQUAL (decoder.video->_decoded_video.size(), 4U); - list::iterator i = decoder.video->_decoded_video.begin(); + BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 4U); + list::iterator i = decoder.video->_decoded.begin(); for (int j = 0; j < 4; ++j) { BOOST_CHECK_EQUAL (i->frame, j); ++i; } - decoder.video->_decoded_video.clear (); + decoder.video->_decoded.clear (); decoder.video->fill_one_eye (0, 7, EYES_BOTH); - BOOST_CHECK_EQUAL (decoder.video->_decoded_video.size(), 7); - i = decoder.video->_decoded_video.begin(); + BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 7); + i = decoder.video->_decoded.begin(); for (int j = 0; j < 7; ++j) { BOOST_CHECK_EQUAL (i->frame, j); ++i; @@ -62,8 +62,8 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test2) ImageDecoder decoder (c, film->log()); decoder.video->fill_both_eyes (0, 4, EYES_LEFT); - BOOST_CHECK_EQUAL (decoder.video->_decoded_video.size(), 8); - list::iterator i = decoder.video->_decoded_video.begin(); + BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 8); + list::iterator i = decoder.video->_decoded.begin(); for (int j = 0; j < 8; ++j) { BOOST_CHECK_EQUAL (i->frame, j / 2); BOOST_CHECK_EQUAL (i->eyes, (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT); @@ -71,8 +71,8 @@ BOOST_AUTO_TEST_CASE (video_decoder_fill_test2) } decoder.video->fill_both_eyes (0, 7, EYES_RIGHT); - BOOST_CHECK_EQUAL (decoder.video->_decoded_video.size(), 15); - i = decoder.video->_decoded_video.begin(); + BOOST_CHECK_EQUAL (decoder.video->_decoded.size(), 15); + i = decoder.video->_decoded.begin(); for (int j = 0; j < 15; ++j) { BOOST_CHECK_EQUAL (i->frame, j / 2); BOOST_CHECK_EQUAL (i->eyes, (j % 2) == 0 ? EYES_LEFT : EYES_RIGHT); -- 2.30.2