msvidc32: Add support for converting 16 bit depth to 24 bit.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=14695 Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bc389cff39
commit
e287917a3a
|
@ -247,6 +247,11 @@ static void test_Locate(void)
|
||||||
todo_wine ok(err == ICERR_OK, "Query MSVC->RGB16 height<0: %d\n", err);
|
todo_wine ok(err == ICERR_OK, "Query MSVC->RGB16 height<0: %d\n", err);
|
||||||
bo.biHeight = -bo.biHeight;
|
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');
|
bi.biCompression = mmioFOURCC('m','s','v','c');
|
||||||
err = ICDecompressQuery(h, &bi, &bo);
|
err = ICDecompressQuery(h, &bi, &bo);
|
||||||
ok(err == ICERR_BADFORMAT, "Query msvc->RGB16: %d\n", err);
|
ok(err == ICERR_BADFORMAT, "Query msvc->RGB16: %d\n", err);
|
||||||
|
|
|
@ -67,7 +67,7 @@ typedef BYTE uint8_t;
|
||||||
|
|
||||||
typedef struct Msvideo1Context {
|
typedef struct Msvideo1Context {
|
||||||
DWORD dwMagic;
|
DWORD dwMagic;
|
||||||
BOOL mode_8bit; /* if it's not 8-bit, it's 16-bit */
|
int depth;
|
||||||
} Msvideo1Context;
|
} Msvideo1Context;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -327,8 +327,15 @@ CRAM_DecompressQuery( Msvideo1Context *info, LPBITMAPINFO in, LPBITMAPINFO out )
|
||||||
TRACE("out->bpp = %d\n", out->bmiHeader.biBitCount );
|
TRACE("out->bpp = %d\n", out->bmiHeader.biBitCount );
|
||||||
TRACE("out->height = %d\n", out->bmiHeader.biHeight );
|
TRACE("out->height = %d\n", out->bmiHeader.biHeight );
|
||||||
TRACE("out->width = %d\n", out->bmiHeader.biWidth );
|
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.biHeight != out->bmiHeader.biHeight ) ||
|
||||||
( in->bmiHeader.biWidth != out->bmiHeader.biWidth ))
|
( 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);
|
TRACE("bitmap is %d bpp\n", in->bmiHeader.biBitCount);
|
||||||
if( in->bmiHeader.biBitCount == 8 )
|
if( in->bmiHeader.biBitCount == 8 )
|
||||||
info->mode_8bit = TRUE;
|
info->depth = 8;
|
||||||
else if( in->bmiHeader.biBitCount == 16 )
|
else if( in->bmiHeader.biBitCount == 16 )
|
||||||
info->mode_8bit = FALSE;
|
info->depth = 16;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
info->mode_8bit = FALSE;
|
info->depth = 0;
|
||||||
FIXME("Unsupported output format %i\n", in->bmiHeader.biBitCount);
|
FIXME("Unsupported output format %i\n", in->bmiHeader.biBitCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ICERR_OK;
|
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 )
|
static LRESULT CRAM_Decompress( Msvideo1Context *info, ICDECOMPRESS *icd, DWORD size )
|
||||||
{
|
{
|
||||||
LONG width, height, stride, sz;
|
LONG width, height, stride, sz;
|
||||||
|
void *output;
|
||||||
|
|
||||||
TRACE("ICM_DECOMPRESS %p %p %d\n", info, icd, size);
|
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 */
|
stride = width; /* in bytes or 16bit words */
|
||||||
sz = icd->lpbiInput->biSizeImage;
|
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,
|
msvideo1_decode_8bit( width, height, icd->lpInput, sz,
|
||||||
icd->lpOutput, stride);
|
output, stride );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msvideo1_decode_16bit( width, height, icd->lpInput, sz,
|
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;
|
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 )
|
static LRESULT CRAM_DecompressEx( Msvideo1Context *info, ICDECOMPRESSEX *icd, DWORD size )
|
||||||
{
|
{
|
||||||
LONG width, height, stride, sz;
|
LONG width, height, stride, sz;
|
||||||
|
void *output;
|
||||||
|
|
||||||
TRACE("ICM_DECOMPRESSEX %p %p %d\n", info, icd, size);
|
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;
|
stride = width;
|
||||||
sz = icd->lpbiSrc->biSizeImage;
|
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,
|
msvideo1_decode_8bit( width, height, icd->lpSrc, sz,
|
||||||
icd->lpDst, stride);
|
output, stride );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msvideo1_decode_16bit( width, height, icd->lpSrc, sz,
|
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;
|
return ICERR_OK;
|
||||||
|
|
Loading…
Reference in New Issue