diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/butler.cc | 4 | ||||
| -rw-r--r-- | src/lib/butler.h | 2 | ||||
| -rw-r--r-- | src/lib/dcp_video.cc | 2 | ||||
| -rw-r--r-- | src/lib/ffmpeg_encoder.cc | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_file_encoder.cc | 2 | ||||
| -rw-r--r-- | src/lib/image.cc | 18 | ||||
| -rw-r--r-- | src/lib/image.h | 10 | ||||
| -rw-r--r-- | src/lib/player_video.cc | 12 | ||||
| -rw-r--r-- | src/lib/player_video.h | 6 |
9 files changed, 43 insertions, 17 deletions
diff --git a/src/lib/butler.cc b/src/lib/butler.cc index 39da0bd5c..d27778b70 100644 --- a/src/lib/butler.cc +++ b/src/lib/butler.cc @@ -62,6 +62,7 @@ Butler::Butler ( AudioMapping audio_mapping, int audio_channels, function<AVPixelFormat (AVPixelFormat)> pixel_format, + VideoRange video_range, bool aligned, bool fast ) @@ -76,6 +77,7 @@ Butler::Butler ( , _audio_channels (audio_channels) , _disable_audio (false) , _pixel_format (pixel_format) + , _video_range (video_range) , _aligned (aligned) , _fast (fast) { @@ -305,7 +307,7 @@ try /* If the weak_ptr cannot be locked the video obviously no longer requires any work */ if (video) { LOG_TIMING("start-prepare in %1", thread_id()); - video->prepare (_pixel_format, _aligned, _fast); + video->prepare (_pixel_format, _video_range, _aligned, _fast); LOG_TIMING("finish-prepare in %1", thread_id()); } } diff --git a/src/lib/butler.h b/src/lib/butler.h index e13843c90..6b933be4b 100644 --- a/src/lib/butler.h +++ b/src/lib/butler.h @@ -41,6 +41,7 @@ public: AudioMapping map, int audio_channels, boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, + VideoRange video_range, bool aligned, bool fast ); @@ -115,6 +116,7 @@ private: bool _disable_audio; boost::function<AVPixelFormat (AVPixelFormat)> _pixel_format; + VideoRange _video_range; bool _aligned; bool _fast; diff --git a/src/lib/dcp_video.cc b/src/lib/dcp_video.cc index b3461e569..ffeb23a46 100644 --- a/src/lib/dcp_video.cc +++ b/src/lib/dcp_video.cc @@ -99,7 +99,7 @@ DCPVideo::convert_to_xyz (shared_ptr<const PlayerVideo> frame, dcp::NoteHandler { shared_ptr<dcp::OpenJPEGImage> xyz; - shared_ptr<Image> image = frame->image (bind (&PlayerVideo::keep_xyz_or_rgb, _1), true, false); + shared_ptr<Image> image = frame->image (bind (&PlayerVideo::keep_xyz_or_rgb, _1), VIDEO_RANGE_FULL, true, false); if (frame->colour_conversion()) { xyz = dcp::rgb_to_xyz ( image->data()[0], diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index 8f9b3defc..2c76a38c3 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -110,7 +110,9 @@ FFmpegEncoder::FFmpegEncoder ( } } - _butler.reset (new Butler(_player, map, _output_audio_channels, bind(&PlayerVideo::force, _1, FFmpegFileEncoder::pixel_format(format)), true, false)); + _butler.reset ( + new Butler(_player, map, _output_audio_channels, bind(&PlayerVideo::force, _1, FFmpegFileEncoder::pixel_format(format)), VIDEO_RANGE_VIDEO, true, false) + ); } diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index 511730185..05b6b7fe5 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -420,8 +420,10 @@ DCPOMATIC_ENABLE_WARNINGS void FFmpegFileEncoder::video (shared_ptr<PlayerVideo> video, DCPTime time) { + /* All our output formats are video range at the moment */ shared_ptr<Image> image = video->image ( bind (&PlayerVideo::force, _1, _pixel_format), + VIDEO_RANGE_VIDEO, true, false ); diff --git a/src/lib/image.cc b/src/lib/image.cc index 57c152f13..9dae94f7c 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -122,14 +122,24 @@ Image::planes () const * @param inter_size Size to scale the cropped image to. * @param out_size Size of output frame; if this is larger than inter_size there will be black padding. * @param yuv_to_rgb YUV to RGB transformation to use, if required. + * @param video_range Video range of the image. * @param out_format Output pixel format. * @param out_aligned true to make the output image aligned. + * @param out_video_range Video range to use for the output image. * @param fast Try to be fast at the possible expense of quality; at present this means using * fast bilinear rather than bicubic scaling. */ shared_ptr<Image> Image::crop_scale_window ( - Crop crop, dcp::Size inter_size, dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, VideoRange video_range, AVPixelFormat out_format, bool out_aligned, bool fast + Crop crop, + dcp::Size inter_size, + dcp::Size out_size, + dcp::YUVToRGB yuv_to_rgb, + VideoRange video_range, + AVPixelFormat out_format, + VideoRange out_video_range, + bool out_aligned, + bool fast ) const { /* Empirical testing suggests that sws_scale() will crash if @@ -171,13 +181,13 @@ Image::crop_scale_window ( 1 -> destination range JPEG (i.e. "full", 0-255) But remember: sws_setColorspaceDetails ignores these - parameters unless the corresponding image isYUV or isGray. - (If it's neither, it uses video range). + parameters unless the both source and destination images + are isYUV or isGray. (If either is not, it uses video range). */ sws_setColorspaceDetails ( scale_context, sws_getCoefficients (lut[yuv_to_rgb]), video_range == VIDEO_RANGE_VIDEO ? 0 : 1, - sws_getCoefficients (lut[yuv_to_rgb]), 1, + sws_getCoefficients (lut[yuv_to_rgb]), out_video_range == VIDEO_RANGE_VIDEO ? 0 : 1, 0, 1 << 16, 1 << 16 ); diff --git a/src/lib/image.h b/src/lib/image.h index c648fda1b..7dd633f61 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -66,7 +66,15 @@ public: boost::shared_ptr<Image> convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, bool aligned, bool fast) const; boost::shared_ptr<Image> scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, bool aligned, bool fast) const; boost::shared_ptr<Image> crop_scale_window ( - Crop crop, dcp::Size inter_size, dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, VideoRange video_range, AVPixelFormat out_format, bool aligned, bool fast + Crop crop, + dcp::Size inter_size, + dcp::Size out_size, + dcp::YUVToRGB yuv_to_rgb, + VideoRange video_range, + AVPixelFormat out_format, + VideoRange out_video_range, + bool aligned, + bool fast ) const; void make_black (); diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index 620245781..8c1b95bba 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -109,13 +109,13 @@ PlayerVideo::set_text (PositionImage image) } shared_ptr<Image> -PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const +PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const { /* 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 || _crop != _image_crop || _inter_size != _image_inter_size || _out_size != _image_out_size || _fade != _image_fade) { - make_image (pixel_format, aligned, fast); + make_image (pixel_format, video_range, aligned, fast); } return _image; } @@ -128,7 +128,7 @@ PlayerVideo::image (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool a * @param fast true to be fast at the expense of quality. */ void -PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const +PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const { _image_crop = _crop; _image_inter_size = _inter_size; @@ -171,7 +171,7 @@ PlayerVideo::make_image (function<AVPixelFormat (AVPixelFormat)> pixel_format, b } _image = prox.image->crop_scale_window ( - total_crop, _inter_size, _out_size, yuv_to_rgb, _video_range, pixel_format (prox.image->pixel_format()), aligned, fast + total_crop, _inter_size, _out_size, yuv_to_rgb, _video_range, pixel_format (prox.image->pixel_format()), video_range, aligned, fast ); if (_text) { @@ -289,12 +289,12 @@ PlayerVideo::keep_xyz_or_rgb (AVPixelFormat p) } void -PlayerVideo::prepare (function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) +PlayerVideo::prepare (function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) { _in->prepare (_inter_size); boost::mutex::scoped_lock lm (_mutex); if (!_image) { - make_image (pixel_format, aligned, fast); + make_image (pixel_format, video_range, aligned, fast); } } diff --git a/src/lib/player_video.h b/src/lib/player_video.h index 6043632c2..0456457db 100644 --- a/src/lib/player_video.h +++ b/src/lib/player_video.h @@ -67,8 +67,8 @@ public: void set_text (PositionImage); - void prepare (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast); - boost::shared_ptr<Image> image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const; + void prepare (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast); + boost::shared_ptr<Image> image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const; static AVPixelFormat force (AVPixelFormat, AVPixelFormat); static AVPixelFormat keep_xyz_or_rgb (AVPixelFormat); @@ -114,7 +114,7 @@ public: } private: - void make_image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const; + void make_image (boost::function<AVPixelFormat (AVPixelFormat)> pixel_format, VideoRange video_range, bool aligned, bool fast) const; boost::shared_ptr<const ImageProxy> _in; Crop _crop; |
