Add SWS_ACCURATE_RND to sws flags. Without this, conversions to RGB in
authorCarl Hetherington <cth@carlh.net>
Mon, 12 Feb 2018 23:47:02 +0000 (23:47 +0000)
committerCarl Hetherington <cth@carlh.net>
Mon, 12 Feb 2018 23:47:02 +0000 (23:47 +0000)
crop_scale_window_test leave the 6 pixels at the right side of the image
uninitialised (sws_scale doesn't fill them in with anything) so you get
garbage in the output.  SWS_ACCURATE_RND fixes it.  There are whisperings
that this is slow, so the impact of this patch may need to be measured
in some "real" situations.

src/lib/image.cc

index c3795dfa2a1adc8f7107d1ddafc6851fb4d2b90a..158bce1d901aab1b7ff3de884ce8b090bb035805 100644 (file)
@@ -246,7 +246,7 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo
        struct SwsContext* scale_context = sws_getContext (
                size().width, size().height, pixel_format(),
                out_size.width, out_size.height, out_format,
-               fast ? SWS_FAST_BILINEAR : SWS_BICUBIC, 0, 0, 0
+               (fast ? SWS_FAST_BILINEAR : SWS_BICUBIC) | SWS_ACCURATE_RND, 0, 0, 0
                );
 
        DCPOMATIC_ASSERT (yuv_to_rgb < dcp::YUV_TO_RGB_COUNT);