X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Fimage.cc;h=3aba3ebd535715a820d437cf0859f4b67a162cb9;hp=5866ee5b418a82b01eec841e832a9fd0bb8db86c;hb=87c1ac59d40f611fed94fa4120f9c21ef2baa2d2;hpb=f2b10879dcafccdb28f88d53dc1fc22094b96c1d diff --git a/src/lib/image.cc b/src/lib/image.cc index 5866ee5b4..3aba3ebd5 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -27,6 +27,7 @@ #include "compose.hpp" #include "dcpomatic_assert.h" #include "dcpomatic_socket.h" +#include "enum_indexed_vector.h" #include "exceptions.h" #include "image.h" #include "maths_util.h" @@ -236,10 +237,10 @@ Image::crop_scale_window ( } DCPOMATIC_ASSERT (yuv_to_rgb < dcp::YUVToRGB::COUNT); - int const lut[static_cast(dcp::YUVToRGB::COUNT)] = { - SWS_CS_ITU601, - SWS_CS_ITU709 - }; + EnumIndexedVector lut; + lut[dcp::YUVToRGB::REC601] = SWS_CS_ITU601; + lut[dcp::YUVToRGB::REC709] = SWS_CS_ITU709; + lut[dcp::YUVToRGB::REC2020] = SWS_CS_BT2020; /* The 3rd parameter here is: 0 -> source range MPEG (i.e. "video", 16-235) @@ -254,8 +255,8 @@ Image::crop_scale_window ( */ sws_setColorspaceDetails ( scale_context, - sws_getCoefficients (lut[static_cast(yuv_to_rgb)]), video_range == VideoRange::VIDEO ? 0 : 1, - sws_getCoefficients (lut[static_cast(yuv_to_rgb)]), out_video_range == VideoRange::VIDEO ? 0 : 1, + sws_getCoefficients(lut[yuv_to_rgb]), video_range == VideoRange::VIDEO ? 0 : 1, + sws_getCoefficients(lut[yuv_to_rgb]), out_video_range == VideoRange::VIDEO ? 0 : 1, 0, 1 << 16, 1 << 16 ); @@ -327,7 +328,7 @@ Image::convert_pixel_format (dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_format, /** @param out_size Size to scale to. * @param yuv_to_rgb YUVToRGB transform transform to use, if required. * @param out_format Output pixel format. - * @param out_aligment Output alignment. + * @param out_alignment Output alignment. * @param fast Try to be fast at the possible expense of quality; at present this means using * fast bilinear rather than bicubic scaling. */ @@ -347,10 +348,10 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo ); DCPOMATIC_ASSERT (yuv_to_rgb < dcp::YUVToRGB::COUNT); - int const lut[static_cast(dcp::YUVToRGB::COUNT)] = { - SWS_CS_ITU601, - SWS_CS_ITU709 - }; + EnumIndexedVector lut; + lut[dcp::YUVToRGB::REC601] = SWS_CS_ITU601; + lut[dcp::YUVToRGB::REC709] = SWS_CS_ITU709; + lut[dcp::YUVToRGB::REC2020] = SWS_CS_BT2020; /* The 3rd parameter here is: 0 -> source range MPEG (i.e. "video", 16-235) @@ -365,8 +366,8 @@ Image::scale (dcp::Size out_size, dcp::YUVToRGB yuv_to_rgb, AVPixelFormat out_fo */ sws_setColorspaceDetails ( scale_context, - sws_getCoefficients (lut[static_cast(yuv_to_rgb)]), 0, - sws_getCoefficients (lut[static_cast(yuv_to_rgb)]), 0, + sws_getCoefficients(lut[yuv_to_rgb]), 0, + sws_getCoefficients(lut[yuv_to_rgb]), 0, 0, 1 << 16, 1 << 16 ); @@ -478,6 +479,21 @@ Image::make_part_black (int const start, int const width) } break; } + case AV_PIX_FMT_YUV444P10LE: + { + y_part(); + for (int i = 1; i < 3; ++i) { + auto p = reinterpret_cast(data()[i]); + int const h = sample_size(i).height; + for (int y = 0; y < h; ++y) { + for (int x = start; x < (start + width); ++x) { + p[x] = ten_bit_uv; + } + p += stride()[i] / 2; + } + } + break; + } default: throw PixelFormatError ("make_part_black()", _pixel_format); }