Ignore audio streams with no codec, instead of crashing.
[dcpomatic.git] / src / lib / player_video.cc
index 94432d66e046c289eb4f60f31923f8ac62623abe..e36eb1984438add8e0ca4ac98f4d4daf7276b1dd 100644 (file)
@@ -105,10 +105,10 @@ PlayerVideo::set_text (PositionImage image)
 shared_ptr<Image>
 PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const
 {
-       /* XXX: this assumes that image() and prepare() are only ever called with the same parameters */
+       /* XXX: this assumes that image() and prepare() are only ever called with the same parameters (except crop, inter size, out size, fade) */
 
        boost::mutex::scoped_lock lm (_mutex);
-       if (!_image) {
+       if (!_image || _crop != _image_crop || _inter_size != _image_inter_size || _out_size != _image_out_size || _fade != _image_fade) {
                make_image (pixel_format, aligned, fast);
        }
        return _image;
@@ -124,6 +124,11 @@ PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool a
 void
 PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const
 {
+       _image_crop = _crop;
+       _image_inter_size = _inter_size;
+       _image_out_size = _out_size;
+       _image_fade = _fade;
+
        pair<shared_ptr<Image>, int> prox = _in->image (_inter_size);
        shared_ptr<Image> im = prox.first;
        int const reduce = prox.second;
@@ -239,7 +244,7 @@ bool
 PlayerVideo::same (shared_ptr<const PlayerVideo> other) const
 {
        if (_crop != other->_crop ||
-           _fade.get_value_or(0) != other->_fade.get_value_or(0) ||
+           _fade != other->_fade ||
            _inter_size != other->_inter_size ||
            _out_size != other->_out_size ||
            _eyes != other->_eyes ||
@@ -315,7 +320,7 @@ PlayerVideo::shallow_copy () const
  *  @return true if this was possible, false if not.
  */
 bool
-PlayerVideo::reset_metadata (dcp::Size video_container_size, dcp::Size film_frame_size)
+PlayerVideo::reset_metadata (shared_ptr<const Film> film, dcp::Size video_container_size, dcp::Size film_frame_size)
 {
        shared_ptr<Content> content = _content.lock();
        if (!content || !_video_frame) {
@@ -323,7 +328,7 @@ PlayerVideo::reset_metadata (dcp::Size video_container_size, dcp::Size film_fram
        }
 
        _crop = content->video->crop();
-       _fade = content->video->fade(_video_frame.get());
+       _fade = content->video->fade(film, _video_frame.get());
        _inter_size = content->video->scale().size(content->video, video_container_size, film_frame_size);
        _out_size = video_container_size;
        _colour_conversion = content->video->colour_conversion();