From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/tests/converter.c | 36 ++++++++++------------------ dlls/windowscodecs/tests/pngformat.c | 3 +-- 2 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 6107deb49d0..63ab44fba32 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -1033,42 +1033,30 @@ typedef struct property_opt_test_data BOOL skippable; } property_opt_test_data;
-static const WCHAR wszTiffCompressionMethod[] = {'T','i','f','f','C','o','m','p','r','e','s','s','i','o','n','M','e','t','h','o','d',0}; -static const WCHAR wszCompressionQuality[] = {'C','o','m','p','r','e','s','s','i','o','n','Q','u','a','l','i','t','y',0}; -static const WCHAR wszInterlaceOption[] = {'I','n','t','e','r','l','a','c','e','O','p','t','i','o','n',0}; -static const WCHAR wszFilterOption[] = {'F','i','l','t','e','r','O','p','t','i','o','n',0}; -static const WCHAR wszImageQuality[] = {'I','m','a','g','e','Q','u','a','l','i','t','y',0}; -static const WCHAR wszBitmapTransform[] = {'B','i','t','m','a','p','T','r','a','n','s','f','o','r','m',0}; -static const WCHAR wszLuminance[] = {'L','u','m','i','n','a','n','c','e',0}; -static const WCHAR wszChrominance[] = {'C','h','r','o','m','i','n','a','n','c','e',0}; -static const WCHAR wszJpegYCrCbSubsampling[] = {'J','p','e','g','Y','C','r','C','b','S','u','b','s','a','m','p','l','i','n','g',0}; -static const WCHAR wszSuppressApp0[] = {'S','u','p','p','r','e','s','s','A','p','p','0',0}; -static const WCHAR wszEnableV5Header32bppBGRA[] = {'E','n','a','b','l','e','V','5','H','e','a','d','e','r','3','2','b','p','p','B','G','R','A',0}; - static const struct property_opt_test_data testdata_tiff_props[] = { - { wszTiffCompressionMethod, VT_UI1, VT_UI1, WICTiffCompressionDontCare }, - { wszCompressionQuality, VT_R4, VT_EMPTY }, + { L"TiffCompressionMethod", VT_UI1, VT_UI1, WICTiffCompressionDontCare }, + { L"CompressionQuality", VT_R4, VT_EMPTY }, { NULL } };
static const struct property_opt_test_data testdata_png_props[] = { - { wszInterlaceOption, VT_BOOL, VT_BOOL, 0 }, - { wszFilterOption, VT_UI1, VT_UI1, WICPngFilterUnspecified, 0.0f, TRUE /* not supported on XP/2k3 */}, + { L"InterlaceOption", VT_BOOL, VT_BOOL, 0 }, + { L"FilterOption", VT_UI1, VT_UI1, WICPngFilterUnspecified, 0.0f, TRUE /* not supported on XP/2k3 */}, { NULL } };
static const struct property_opt_test_data testdata_jpeg_props[] = { - { wszImageQuality, VT_R4, VT_EMPTY }, - { wszBitmapTransform, VT_UI1, VT_UI1, WICBitmapTransformRotate0 }, - { wszLuminance, VT_I4|VT_ARRAY, VT_EMPTY }, - { wszChrominance, VT_I4|VT_ARRAY, VT_EMPTY }, - { wszJpegYCrCbSubsampling, VT_UI1, VT_UI1, WICJpegYCrCbSubsamplingDefault, 0.0f, TRUE }, /* not supported on XP/2k3 */ - { wszSuppressApp0, VT_BOOL, VT_BOOL, FALSE }, + { L"ImageQuality", VT_R4, VT_EMPTY }, + { L"BitmapTransform", VT_UI1, VT_UI1, WICBitmapTransformRotate0 }, + { L"Luminance", VT_I4|VT_ARRAY, VT_EMPTY }, + { L"Chrominance", VT_I4|VT_ARRAY, VT_EMPTY }, + { L"JpegYCrCbSubsampling", VT_UI1, VT_UI1, WICJpegYCrCbSubsamplingDefault, 0.0f, TRUE }, /* not supported on XP/2k3 */ + { L"SuppressApp0", VT_BOOL, VT_BOOL, FALSE }, { NULL } };
static const struct property_opt_test_data testdata_bmp_props[] = { - { wszEnableV5Header32bppBGRA, VT_BOOL, VT_BOOL, VARIANT_FALSE, 0.0f, TRUE }, /* Supported since Win7 */ + { L"EnableV5Header32bppBGRA", VT_BOOL, VT_BOOL, VARIANT_FALSE, 0.0f, TRUE }, /* Supported since Win7 */ { NULL } };
@@ -2081,7 +2069,7 @@ static const struct bitmap_data *single_frame[2] = { NULL};
static const struct setting png_interlace_settings[] = { - {wszInterlaceOption, PROPBAG2_TYPE_DATA, VT_BOOL, (void*)VARIANT_TRUE}, + {L"InterlaceOption", PROPBAG2_TYPE_DATA, VT_BOOL, (void*)VARIANT_TRUE}, {NULL} };
diff --git a/dlls/windowscodecs/tests/pngformat.c b/dlls/windowscodecs/tests/pngformat.c index ca5a220d40d..d9b8ff9b0eb 100644 --- a/dlls/windowscodecs/tests/pngformat.c +++ b/dlls/windowscodecs/tests/pngformat.c @@ -314,13 +314,12 @@ static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitma
static WCHAR *save_profile( BYTE *buffer, UINT size ) { - static const WCHAR tstW[] = {'t','s','t',0}; WCHAR path[MAX_PATH], filename[MAX_PATH], *ret; HANDLE handle; DWORD count;
GetTempPathW(MAX_PATH, path); - GetTempFileNameW(path, tstW, 0, filename); + GetTempFileNameW(path, L"tst", 0, filename);
handle = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if (handle == INVALID_HANDLE_VALUE) return NULL;
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 68 ++++++++++++++++++++++++++++ dlls/windowscodecs/regsvr.c | 1 + dlls/windowscodecs/tests/converter.c | 8 ++++ 3 files changed, 77 insertions(+)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 526d5c05aca..04dcb0b9fc5 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -61,6 +61,7 @@ enum pixelformat { format_32bppCMYK, format_8bppAlpha, format_48bppBGR, + format_48bppRGBHalf, format_64bppRGB, format_64bppBGRA, format_64bppPRGBA, @@ -94,6 +95,24 @@ typedef struct FormatConverter { CRITICAL_SECTION lock; /* must be held when initialized */ } FormatConverter;
+static float float_16_to_32(unsigned short in) +{ + const unsigned short s = (in & 0x8000); + const unsigned short e = (in & 0x7C00) >> 10; + const unsigned short m = in & 0x3FF; + const float sgn = (s ? -1.0f : 1.0f); + + if (e == 0) + { + if (m == 0) return sgn * 0.0f; /* +0.0 or -0.0 */ + else return sgn * powf(2, -14.0f) * (m / 1024.0f); + } + else + { + return sgn * powf(2, e - 15.0f) * (1.0f + (m / 1024.0f)); + } +} + /* https://www.w3.org/Graphics/Color/srgb */ static inline float to_sRGB_component(float f) { @@ -975,6 +994,54 @@ static HRESULT copypixels_to_32bppBGRA(struct FormatConverter *This, const WICRe return res; } return S_OK; + case format_48bppRGBHalf: + if (prc) + { + UINT srcstride, srcdatasize; + const USHORT *srcpixel; + const BYTE *srcrow; + DWORD *dstpixel; + BYTE *srcdata; + BYTE *dstrow; + HRESULT res; + INT x, y; + + srcstride = 6 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = malloc(srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + res = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + + if (SUCCEEDED(res)) + { + srcrow = srcdata; + dstrow = pbBuffer; + for (y = 0; y < prc->Height; y++) + { + srcpixel = (const USHORT *)srcrow; + dstpixel = (DWORD *)dstrow; + for (x = 0; x < prc->Width; x++) + { + BYTE red, green, blue; + + red = (BYTE)floorf(to_sRGB_component(float_16_to_32(*srcpixel++)) * 255.0f + 0.51f); + green = (BYTE)floorf(to_sRGB_component(float_16_to_32(*srcpixel++)) * 255.0f + 0.51f); + blue = (BYTE)floorf(to_sRGB_component(float_16_to_32(*srcpixel++)) * 255.0f + 0.51f); + + *dstpixel++ = 0xff000000 | red << 16 | green << 8 | blue; + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + free(srcdata); + + return res; + } + return S_OK; default: FIXME("Unimplemented conversion path!\n"); return WINCODEC_ERR_UNSUPPORTEDOPERATION; @@ -2024,6 +2091,7 @@ static const struct pixelformatinfo supported_formats[] = { {format_128bppPRGBAFloat, &GUID_WICPixelFormat128bppPRGBAFloat, NULL}, {format_128bppRGBFloat, &GUID_WICPixelFormat128bppRGBFloat, copypixels_to_128bppRGBFloat }, {format_32bppR10G10B10A2, &GUID_WICPixelFormat32bppR10G10B10A2, NULL}, + {format_48bppRGBHalf, &GUID_WICPixelFormat48bppRGBHalf}, {0} };
diff --git a/dlls/windowscodecs/regsvr.c b/dlls/windowscodecs/regsvr.c index eddb6e13024..47a2bd76d2a 100644 --- a/dlls/windowscodecs/regsvr.c +++ b/dlls/windowscodecs/regsvr.c @@ -1681,6 +1681,7 @@ static GUID const * const converter_formats[] = { &GUID_WICPixelFormat32bppPRGBA, &GUID_WICPixelFormat32bppGrayFloat, &GUID_WICPixelFormat48bppRGB, + &GUID_WICPixelFormat48bppRGBHalf, &GUID_WICPixelFormat64bppRGBA, &GUID_WICPixelFormat32bppCMYK, &GUID_WICPixelFormat96bppRGBFloat, diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 63ab44fba32..2f66df954a5 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -684,6 +684,12 @@ static const BYTE bits_32bppBGRA_3[] = { static const struct bitmap_data testdata_32bppBGRA_3 = { &GUID_WICPixelFormat32bppBGRA, 32, bits_32bppBGRA_3, 3, 2, 96.0, 96.0};
+static const WORD bits_48bppRGBHalf[] = { + 0,0,0, 0,0x3c00,0, 0x3c00,0,0, + 0,0,0x3c00, 0,0x3290,0, 0x3290,0,0 }; +static const struct bitmap_data testdata_48bppRGBHalf = { + &GUID_WICPixelFormat48bppRGBHalf, 48, (const BYTE *)bits_48bppRGBHalf, 3, 2, 96.0, 96.0}; + static const float bits_128bppRGBFloat[] = { 0.0f,0.0f,0.0f,1.0f, 0.0f,1.0f,0.0f,1.0f, 0.214039f,0.214053f,0.214039f,1.0f, 1.0f,1.0f,1.0f,1.0f, 0.000012f,0.000012f,0.000012f,1.0f, 0.0f,0.0f,0.000012f,1.0f,}; @@ -2343,6 +2349,8 @@ START_TEST(converter) test_conversion(&testdata_96bppRGBFloat_2, &testdata_32bppBGRA_3, "96bppRGBFloat -> 32bppBGRA", FALSE); test_conversion(&testdata_128bppRGBAFloat_2, &testdata_32bppBGRA_2, "128bppRGBAFloat -> 32bppBGRA", FALSE);
+ test_conversion(&testdata_48bppRGBHalf, &testdata_32bppBGRA_3, "48bppRGBHalf -> 32bppBGRA", FALSE); + test_invalid_conversion(); test_default_converter(); test_can_convert();
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/converter.c | 44 ++++++++++++++++++++++++++++ dlls/windowscodecs/tests/converter.c | 7 +++++ 2 files changed, 51 insertions(+)
diff --git a/dlls/windowscodecs/converter.c b/dlls/windowscodecs/converter.c index 04dcb0b9fc5..3607ac25819 100644 --- a/dlls/windowscodecs/converter.c +++ b/dlls/windowscodecs/converter.c @@ -2048,6 +2048,50 @@ static HRESULT copypixels_to_128bppRGBFloat(struct FormatConverter *This, const free(srcdata); return S_OK; } + case format_48bppRGBHalf: + { + UINT srcstride, srcdatasize; + const USHORT *srcpixel; + const BYTE *srcrow; + float *dstpixel; + BYTE *srcdata; + BYTE *dstrow; + INT x, y; + + if (!prc) + return S_OK; + + srcstride = 6 * prc->Width; + srcdatasize = srcstride * prc->Height; + + srcdata = malloc(srcdatasize); + if (!srcdata) return E_OUTOFMEMORY; + + hr = IWICBitmapSource_CopyPixels(This->source, prc, srcstride, srcdatasize, srcdata); + if (SUCCEEDED(hr)) + { + srcrow = srcdata; + dstrow = pbBuffer; + for (y = 0; y < prc->Height; y++) + { + srcpixel = (USHORT *)srcrow; + dstpixel= (float *)dstrow; + for (x = 0; x < prc->Width; x++) + { + *dstpixel++ = float_16_to_32(*srcpixel++); + *dstpixel++ = float_16_to_32(*srcpixel++); + *dstpixel++ = float_16_to_32(*srcpixel++); + *dstpixel++ = 1.0f; + } + srcrow += srcstride; + dstrow += cbStride; + } + } + + free(srcdata); + return S_OK; + } + default: FIXME("Unimplemented conversion path %d.\n", source_format); return WINCODEC_ERR_UNSUPPORTEDOPERATION; diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 2f66df954a5..a94ab9c0324 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -696,6 +696,12 @@ static const float bits_128bppRGBFloat[] = { static const struct bitmap_data testdata_128bppRGBFloat = { &GUID_WICPixelFormat128bppRGBFloat, 128, (const BYTE *)bits_128bppRGBFloat, 3, 2, 96.0, 96.0};
+static const float bits_128bppRGBFloat_2[] = { + 0.0f,0.0f,0.0f,1.0f, 0.0f,1.0f,0.0f,1.0f, 1.0f,0.0f,0.0f,1.0f, + 0.0f,0.0f,1.0f,1.0f, 0.0f,0.205079f,0.0f,1.0f, 0.205079f,0.0f,0.0f,1.0f}; +static const struct bitmap_data testdata_128bppRGBFloat_2 = { + &GUID_WICPixelFormat128bppRGBFloat, 128, (const BYTE *)bits_128bppRGBFloat_2, 3, 2, 96.0, 96.0}; + static const BYTE bits_24bppBGR_2[] = { 0,0,0, 0,255,0, 0,0,255, 255,0,0, 0,125,0, 0,0,125}; @@ -2350,6 +2356,7 @@ START_TEST(converter) test_conversion(&testdata_128bppRGBAFloat_2, &testdata_32bppBGRA_2, "128bppRGBAFloat -> 32bppBGRA", FALSE);
test_conversion(&testdata_48bppRGBHalf, &testdata_32bppBGRA_3, "48bppRGBHalf -> 32bppBGRA", FALSE); + test_conversion(&testdata_48bppRGBHalf, &testdata_128bppRGBFloat_2, "48bppRGBHalf -> 128bppRGBFloat", FALSE);
test_invalid_conversion(); test_default_converter();
This merge request was approved by Esme Povirk.