summaryrefslogtreecommitdiff
path: root/src/lib/player_video.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-04-13 23:23:00 +0100
committerCarl Hetherington <cth@carlh.net>2018-04-13 23:23:00 +0100
commit0ff4fa6058b305476e7bc60c590acb6135c49b1c (patch)
tree1ea7e181846964bd1bab52bbfafc118f49b584f8 /src/lib/player_video.cc
parent9106e6ed551b13e1b7c7ee2088d54ce0ae430bcf (diff)
Account for J2K decoding at lower-than-maximum resolution when croppingv2.13.14
the resulting images; fixes #1274.
Diffstat (limited to 'src/lib/player_video.cc')
-rw-r--r--src/lib/player_video.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc
index 8eb39efed..a50b196a2 100644
--- a/src/lib/player_video.cc
+++ b/src/lib/player_video.cc
@@ -34,6 +34,7 @@ extern "C" {
using std::string;
using std::cout;
+using std::pair;
using boost::shared_ptr;
using boost::weak_ptr;
using boost::dynamic_pointer_cast;
@@ -112,7 +113,9 @@ PlayerVideo::set_subtitle (PositionImage image)
shared_ptr<Image>
PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat)> pixel_format, bool aligned, bool fast) const
{
- shared_ptr<Image> im = _in->image (optional<dcp::NoteHandler> (note), _inter_size);
+ pair<shared_ptr<Image>, int> prox = _in->image (optional<dcp::NoteHandler> (note), _inter_size);
+ shared_ptr<Image> im = prox.first;
+ int const reduce = prox.second;
Crop total_crop = _crop;
switch (_part) {
@@ -132,6 +135,15 @@ PlayerVideo::image (dcp::NoteHandler note, function<AVPixelFormat (AVPixelFormat
break;
}
+ if (reduce > 0) {
+ /* Scale the crop down to account for the scaling that has already happened in ImageProxy::image */
+ int const r = pow(2, reduce);
+ total_crop.left /= r;
+ total_crop.right /= r;
+ total_crop.top /= r;
+ total_crop.bottom /= r;
+ }
+
dcp::YUVToRGB yuv_to_rgb = dcp::YUV_TO_RGB_REC601;
if (_colour_conversion) {
yuv_to_rgb = _colour_conversion.get().yuv_to_rgb();