[MSVIDC32] Sync with Wine 3.0. CORE-14225

This commit is contained in:
Amine Khaldi 2018-01-20 12:33:41 +01:00
parent 8e65919260
commit d023d396ee
2 changed files with 17 additions and 100 deletions

View File

@ -71,14 +71,9 @@ typedef BYTE uint8_t;
typedef struct Msvideo1Context {
DWORD dwMagic;
int depth;
BOOL mode_8bit; /* if it's not 8-bit, it's 16-bit */
} Msvideo1Context;
static inline int get_stride(int width, int depth)
{
return ((depth * width + 31) >> 3) & ~3;
}
static void
msvideo1_decode_8bit( int width, int height, const unsigned char *buf, int buf_size,
unsigned char *pixels, int stride)
@ -336,15 +331,8 @@ 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.biBitCount != 16 || out->bmiHeader.biBitCount != 24))
{
TRACE("incompatible depth requested\n");
return ICERR_BADFORMAT;
}
if(( in->bmiHeader.biPlanes != out->bmiHeader.biPlanes ) ||
if(( in->bmiHeader.biBitCount != out->bmiHeader.biBitCount ) ||
( in->bmiHeader.biPlanes != out->bmiHeader.biPlanes ) ||
( in->bmiHeader.biHeight != out->bmiHeader.biHeight ) ||
( in->bmiHeader.biWidth != out->bmiHeader.biWidth ))
{
@ -371,17 +359,12 @@ CRAM_DecompressGetFormat( Msvideo1Context *info, LPBITMAPINFO in, LPBITMAPINFO o
if (in->bmiHeader.biBitCount <= 8)
size += in->bmiHeader.biClrUsed * sizeof(RGBQUAD);
if (in->bmiHeader.biBitCount != 8 && in->bmiHeader.biBitCount != 16)
return ICERR_BADFORMAT;
if( out )
{
memcpy( out, in, size );
out->bmiHeader.biWidth = in->bmiHeader.biWidth & ~1;
out->bmiHeader.biHeight = in->bmiHeader.biHeight & ~1;
out->bmiHeader.biCompression = BI_RGB;
out->bmiHeader.biSizeImage = in->bmiHeader.biHeight *
get_stride(out->bmiHeader.biWidth, out->bmiHeader.biBitCount);
out->bmiHeader.biSizeImage = in->bmiHeader.biHeight
* in->bmiHeader.biWidth *4;
return ICERR_OK;
}
@ -397,56 +380,21 @@ static LRESULT CRAM_DecompressBegin( Msvideo1Context *info, LPBITMAPINFO in, LPB
TRACE("bitmap is %d bpp\n", in->bmiHeader.biBitCount);
if( in->bmiHeader.biBitCount == 8 )
info->depth = 8;
info->mode_8bit = TRUE;
else if( in->bmiHeader.biBitCount == 16 )
info->depth = 16;
info->mode_8bit = FALSE;
else
{
info->depth = 0;
info->mode_8bit = FALSE;
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;
int stride_in = get_stride(out_hdr->biWidth, depth_in);
int stride_out = get_stride(out_hdr->biWidth, out_hdr->biBitCount);
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,
};
for (y = 0; y < out_hdr->biHeight; y++)
{
WORD *src_row = (WORD *)(input + y * stride_in);
char *out_row = output + y * stride_out;
for (x = 0; x < out_hdr->biWidth; x++)
{
WORD pixel = *src_row++;
*out_row++ = convert_5to8[(pixel & 0x7c00u) >> 10];
*out_row++ = convert_5to8[(pixel & 0x03e0u) >> 5];
*out_row++ = 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);
@ -457,33 +405,18 @@ static LRESULT CRAM_Decompress( Msvideo1Context *info, ICDECOMPRESS *icd, DWORD
width = icd->lpbiInput->biWidth;
height = icd->lpbiInput->biHeight;
stride = width; /* in bytes or 16bit words */
sz = icd->lpbiInput->biSizeImage;
output = icd->lpOutput;
if (icd->lpbiOutput->biBitCount != info->depth)
if (info->mode_8bit)
{
output = HeapAlloc(GetProcessHeap(), 0, icd->lpbiOutput->biWidth * icd->lpbiOutput->biHeight * info->depth / 8);
if (!output) return ICERR_MEMORY;
}
if (info->depth == 8)
{
stride = get_stride(width, 8);
msvideo1_decode_8bit( width, height, icd->lpInput, sz,
output, stride );
icd->lpOutput, stride);
}
else
{
stride = get_stride(width, 16) / 2;
msvideo1_decode_16bit( width, height, icd->lpInput, sz,
output, stride );
}
if (icd->lpbiOutput->biBitCount != info->depth)
{
convert_depth(output, info->depth, icd->lpOutput, icd->lpbiOutput);
HeapFree(GetProcessHeap(), 0, output);
icd->lpOutput, stride);
}
return ICERR_OK;
@ -492,7 +425,6 @@ 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);
@ -503,33 +435,18 @@ static LRESULT CRAM_DecompressEx( Msvideo1Context *info, ICDECOMPRESSEX *icd, DW
width = icd->lpbiSrc->biWidth;
height = icd->lpbiSrc->biHeight;
stride = width;
sz = icd->lpbiSrc->biSizeImage;
output = icd->lpDst;
if (icd->lpbiDst->biBitCount != info->depth)
if (info->mode_8bit)
{
output = HeapAlloc(GetProcessHeap(), 0, icd->lpbiDst->biWidth * icd->lpbiDst->biHeight * info->depth / 8);
if (!output) return ICERR_MEMORY;
}
if (info->depth == 8)
{
stride = get_stride(width, 8);
msvideo1_decode_8bit( width, height, icd->lpSrc, sz,
output, stride );
icd->lpDst, stride);
}
else
{
stride = get_stride(width, 16) / 2;
msvideo1_decode_16bit( width, height, icd->lpSrc, sz,
output, stride );
}
if (icd->lpbiDst->biBitCount != info->depth)
{
convert_depth(output, info->depth, icd->lpDst, icd->lpbiDst);
HeapFree(GetProcessHeap(), 0, output);
icd->lpDst, stride);
}
return ICERR_OK;

View File

@ -126,7 +126,7 @@ reactos/dll/win32/mstask # Synced to WineStaging-2.9
reactos/dll/win32/msvcrt20 # Out of sync
reactos/dll/win32/msvcrt40 # Out of sync
reactos/dll/win32/msvfw32 # Synced to Wine-3.0
reactos/dll/win32/msvidc32 # Synced to WineStaging-2.9
reactos/dll/win32/msvidc32 # Synced to Wine-3.0
reactos/dll/win32/msxml # Synced to WineStaging-2.9
reactos/dll/win32/msxml2 # Synced to WineStaging-2.9
reactos/dll/win32/msxml3 # Synced to WineStaging-2.9