Added patch to implement support for converting 16 bit depth to 24 bit in msvidc32.

This commit is contained in:
Sebastian Lackner 2016-04-02 22:34:58 +02:00
parent bc7dbd89e0
commit a3ecf01ce2
3 changed files with 210 additions and 0 deletions

View File

@ -0,0 +1,190 @@
From ef25f64580a12fba30413f34c1a9c72e31089e29 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 2 Apr 2016 22:15:37 +0200
Subject: msvidc32: Add support for converting 16 bit depth to 24 bit.
---
dlls/msvfw32/tests/msvfw.c | 5 +++
dlls/msvidc32/msvideo1.c | 91 ++++++++++++++++++++++++++++++++++++++++------
2 files changed, 84 insertions(+), 12 deletions(-)
diff --git a/dlls/msvfw32/tests/msvfw.c b/dlls/msvfw32/tests/msvfw.c
index 125cac5..66956aa 100644
--- a/dlls/msvfw32/tests/msvfw.c
+++ b/dlls/msvfw32/tests/msvfw.c
@@ -202,6 +202,11 @@ static void test_Locate(void)
todo_wine ok(err == ICERR_OK, "Query MSVC->RGB16 height<0: %d\n", err);
bo.biHeight = -bo.biHeight;
+ bo.biBitCount = 24;
+ err = ICDecompressQuery(h, &bi, &bo);
+ ok(err == ICERR_OK, "Query MSVC 16->24: %d\n", err);
+ bo.biBitCount = 16;
+
bi.biCompression = mmioFOURCC('m','s','v','c');
err = ICDecompressQuery(h, &bi, &bo);
ok(err == ICERR_BADFORMAT, "Query msvc->RGB16: %d\n", err);
diff --git a/dlls/msvidc32/msvideo1.c b/dlls/msvidc32/msvideo1.c
index b3faaf6..ab7cc3e 100644
--- a/dlls/msvidc32/msvideo1.c
+++ b/dlls/msvidc32/msvideo1.c
@@ -67,7 +67,7 @@ typedef BYTE uint8_t;
typedef struct Msvideo1Context {
DWORD dwMagic;
- BOOL mode_8bit; /* if it's not 8-bit, it's 16-bit */
+ int depth;
} Msvideo1Context;
static void
@@ -327,8 +327,15 @@ CRAM_DecompressQuery( Msvideo1Context *info, LPBITMAPINFO in, LPBITMAPINFO out )
TRACE("out->bpp = %d\n", out->bmiHeader.biBitCount );
TRACE("out->height = %d\n", out->bmiHeader.biHeight );
TRACE("out->width = %d\n", out->bmiHeader.biWidth );
- if(( in->bmiHeader.biBitCount != out->bmiHeader.biBitCount ) ||
- ( in->bmiHeader.biPlanes != out->bmiHeader.biPlanes ) ||
+
+ if ((in->bmiHeader.biBitCount != out->bmiHeader.biBitCount) &&
+ (in->bmiHeader.biBitCount != 16 || out->bmiHeader.biBitCount != 24))
+ {
+ TRACE("incompatible depth requested\n");
+ return ICERR_BADFORMAT;
+ }
+
+ if(( in->bmiHeader.biPlanes != out->bmiHeader.biPlanes ) ||
( in->bmiHeader.biHeight != out->bmiHeader.biHeight ) ||
( in->bmiHeader.biWidth != out->bmiHeader.biWidth ))
{
@@ -376,21 +383,52 @@ static LRESULT CRAM_DecompressBegin( Msvideo1Context *info, LPBITMAPINFO in, LPB
TRACE("bitmap is %d bpp\n", in->bmiHeader.biBitCount);
if( in->bmiHeader.biBitCount == 8 )
- info->mode_8bit = TRUE;
+ info->depth = 8;
else if( in->bmiHeader.biBitCount == 16 )
- info->mode_8bit = FALSE;
+ info->depth = 16;
else
{
- info->mode_8bit = FALSE;
+ info->depth = 0;
FIXME("Unsupported output format %i\n", in->bmiHeader.biBitCount);
}
return ICERR_OK;
}
+static void convert_depth(char *input, int depth_in, char *output, BITMAPINFOHEADER *out_hdr)
+{
+ int x, y;
+
+ if (depth_in == 16 && out_hdr->biBitCount == 24)
+ {
+ static const unsigned char convert_5to8[] =
+ {
+ 0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
+ 0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
+ 0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
+ 0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
+ };
+
+ WORD *src = (WORD *)input;
+ for (y = 0; y < out_hdr->biHeight; y++)
+ {
+ for (x = 0; x < out_hdr->biWidth; x++)
+ {
+ WORD pixel = *src++;
+ *output++ = convert_5to8[(pixel & 0x7c00u) >> 10];
+ *output++ = convert_5to8[(pixel & 0x03e0u) >> 5];
+ *output++ = convert_5to8[(pixel & 0x001fu)];
+ }
+ }
+ }
+ else
+ FIXME("Conversion from %d to %d bit unimplemented\n", depth_in, out_hdr->biBitCount);
+}
+
static LRESULT CRAM_Decompress( Msvideo1Context *info, ICDECOMPRESS *icd, DWORD size )
{
LONG width, height, stride, sz;
+ void *output;
TRACE("ICM_DECOMPRESS %p %p %d\n", info, icd, size);
@@ -404,15 +442,29 @@ static LRESULT CRAM_Decompress( Msvideo1Context *info, ICDECOMPRESS *icd, DWORD
stride = width; /* in bytes or 16bit words */
sz = icd->lpbiInput->biSizeImage;
- if (info->mode_8bit)
+ output = icd->lpOutput;
+
+ if (icd->lpbiOutput->biBitCount != info->depth)
+ {
+ output = HeapAlloc(GetProcessHeap(), 0, icd->lpbiOutput->biWidth * icd->lpbiOutput->biHeight * info->depth / 8);
+ if (!output) return ICERR_MEMORY;
+ }
+
+ if (info->depth == 8)
{
msvideo1_decode_8bit( width, height, icd->lpInput, sz,
- icd->lpOutput, stride);
+ output, stride );
}
else
{
msvideo1_decode_16bit( width, height, icd->lpInput, sz,
- icd->lpOutput, stride);
+ output, stride );
+ }
+
+ if (icd->lpbiOutput->biBitCount != info->depth)
+ {
+ convert_depth(output, info->depth, icd->lpOutput, icd->lpbiOutput);
+ HeapFree(GetProcessHeap(), 0, output);
}
return ICERR_OK;
@@ -421,6 +473,7 @@ static LRESULT CRAM_Decompress( Msvideo1Context *info, ICDECOMPRESS *icd, DWORD
static LRESULT CRAM_DecompressEx( Msvideo1Context *info, ICDECOMPRESSEX *icd, DWORD size )
{
LONG width, height, stride, sz;
+ void *output;
TRACE("ICM_DECOMPRESSEX %p %p %d\n", info, icd, size);
@@ -434,15 +487,29 @@ static LRESULT CRAM_DecompressEx( Msvideo1Context *info, ICDECOMPRESSEX *icd, DW
stride = width;
sz = icd->lpbiSrc->biSizeImage;
- if (info->mode_8bit)
+ output = icd->lpDst;
+
+ if (icd->lpbiDst->biBitCount != info->depth)
+ {
+ output = HeapAlloc(GetProcessHeap(), 0, icd->lpbiDst->biWidth * icd->lpbiDst->biHeight * info->depth / 8);
+ if (!output) return ICERR_MEMORY;
+ }
+
+ if (info->depth == 8)
{
msvideo1_decode_8bit( width, height, icd->lpSrc, sz,
- icd->lpDst, stride);
+ output, stride );
}
else
{
msvideo1_decode_16bit( width, height, icd->lpSrc, sz,
- icd->lpDst, stride);
+ output, stride );
+ }
+
+ if (icd->lpbiDst->biBitCount != info->depth)
+ {
+ convert_depth(output, info->depth, icd->lpDst, icd->lpbiDst);
+ HeapFree(GetProcessHeap(), 0, output);
}
return ICERR_OK;
--
2.7.1

View File

@ -0,0 +1 @@
Fixes: [14695] Implement support for converting 16 bit depth to 24 bit in msvidc32

View File

@ -195,6 +195,7 @@ patch_enable_all ()
enable_msvcr120__SetWinRTOutOfMemoryExceptionCallback="$1"
enable_msvcrt_Math_Precision="$1"
enable_msvfw32_ICGetDisplayFormat="$1"
enable_msvidc32_Convert_Bitness="$1"
enable_ntdll_APC_Performance="$1"
enable_ntdll_APC_Start_Process="$1"
enable_ntdll_Activation_Context="$1"
@ -764,6 +765,9 @@ patch_enable ()
msvfw32-ICGetDisplayFormat)
enable_msvfw32_ICGetDisplayFormat="$2"
;;
msvidc32-Convert_Bitness)
enable_msvidc32_Convert_Bitness="$2"
;;
ntdll-APC_Performance)
enable_ntdll_APC_Performance="$2"
;;
@ -4598,6 +4602,21 @@ if test "$enable_msvfw32_ICGetDisplayFormat" -eq 1; then
) >> "$patchlist"
fi
# Patchset msvidc32-Convert_Bitness
# |
# | This patchset fixes the following Wine bugs:
# | * [#14695] Implement support for converting 16 bit depth to 24 bit in msvidc32
# |
# | Modified files:
# | * dlls/msvfw32/tests/msvfw.c, dlls/msvidc32/msvideo1.c
# |
if test "$enable_msvidc32_Convert_Bitness" -eq 1; then
patch_apply msvidc32-Convert_Bitness/0001-msvidc32-Add-support-for-converting-16-bit-depth-to-.patch
(
echo '+ { "Michael Müller", "msvidc32: Add support for converting 16 bit depth to 24 bit.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-APC_Performance
# |
# | Modified files: