From d80e5a10e99b81bb4c19a8c776769b99fa927b4e Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 2 Jan 2018 23:35:43 +0000 Subject: Add convert_pixel_format convenience function. --- src/lib/image.cc | 6 ++++++ src/lib/image.h | 1 + test/image_test.cc | 4 ++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib/image.cc b/src/lib/image.cc index a6354f2d1..4371c5997 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -220,6 +220,12 @@ Image::crop_scale_window ( return out; } +shared_ptr +Image::convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, bool out_aligned, bool fast) const +{ + return scale(size(), yuv_to_rgb, out_format, out_aligned, fast); +} + /** @param out_size Size to scale to. * @param yuv_to_rgb YUVToRGB transform transform to use, if required. * @param out_format Output pixel format. diff --git a/src/lib/image.h b/src/lib/image.h index ce57c5317..8de0a2c69 100644 --- a/src/lib/image.h +++ b/src/lib/image.h @@ -59,6 +59,7 @@ public: dcp::Size sample_size (int) const; float bytes_per_pixel (int) const; + boost::shared_ptr convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, bool aligned, bool fast) const; boost::shared_ptr scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, bool aligned, bool fast) const; boost::shared_ptr crop_scale_window ( Crop crop, dcp::Size inter_size, dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, bool aligned, bool fast diff --git a/test/image_test.cc b/test/image_test.cc index 7428d5183..67daaa509 100644 --- a/test/image_test.cc +++ b/test/image_test.cc @@ -140,7 +140,7 @@ alpha_blend_test_one (AVPixelFormat format, string suffix) { shared_ptr proxy (new MagickImageProxy (private_data / "prophet_frame.tiff")); shared_ptr raw = proxy->image(); - shared_ptr background = raw->scale (raw->size(), dcp::YUV_TO_RGB_REC709, format, true, false); + shared_ptr background = raw->convert_pixel_format (dcp::YUV_TO_RGB_REC709, format, true, false); shared_ptr overlay (new Image (AV_PIX_FMT_RGBA, raw->size(), true)); overlay->make_transparent (); @@ -171,7 +171,7 @@ alpha_blend_test_one (AVPixelFormat format, string suffix) background->alpha_blend (overlay, Position (0, 0)); - shared_ptr save = background->scale (background->size(), dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, false, false); + shared_ptr save = background->convert_pixel_format (dcp::YUV_TO_RGB_REC709, AV_PIX_FMT_RGB24, false, false); write_image (save, "build/test/image_test_" + suffix + ".png", "RGB"); check_image ("build/test/image_test_" + suffix + ".png", private_data / ("image_test_" + suffix + ".png")); -- cgit v1.2.3