iccvid: Fix calculation of stride and size.

Signed-off-by: Vijay Kiran Kamuju <infyquest@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit bc389cff39)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
Michael Müller 2019-03-06 08:57:38 +01:00 committed by Michael Stefaniuc
parent 14a0ed92fb
commit 0c2e7e2d5b
2 changed files with 52 additions and 3 deletions

View File

@ -169,6 +169,10 @@ int x, y;
}
}
static inline int get_stride(int width, int depth)
{
return ((depth * width + 31) >> 3) & ~3;
}
/* ------------------------------------------------------------------------ */
static void cvid_v4_32(unsigned char *frm, unsigned char *limit, int stride, BOOL inverted,
@ -450,7 +454,7 @@ static void decode_cinepak(cinepak_info *cvinfo, unsigned char *buf, int size,
break;
}
frm_stride = out_width * bpp;
frm_stride = get_stride(out_width, bpp * 8);
frm_ptr = output;
if(frame.length != size)
@ -835,9 +839,9 @@ static LRESULT ICCVID_DecompressGetFormat( ICCVID_Info *info, LPBITMAPINFO in, L
if( out )
{
memcpy( out, in, size );
out->bmiHeader.biBitCount = 24;
out->bmiHeader.biCompression = BI_RGB;
out->bmiHeader.biSizeImage = in->bmiHeader.biHeight
* in->bmiHeader.biWidth *4;
out->bmiHeader.biSizeImage = get_stride(in->bmiHeader.biWidth, 24) * in->bmiHeader.biHeight;
return ICERR_OK;
}
return size;

View File

@ -25,6 +25,11 @@
#include "wine/test.h"
static inline int get_stride(int width, int depth)
{
return ((depth * width + 31) >> 3) & ~3;
}
static void test_OpenCase(void)
{
HIC h;
@ -88,6 +93,7 @@ static void test_Locate(void)
{
static BITMAPINFOHEADER bi = {sizeof(BITMAPINFOHEADER),32,8, 1,8, BI_RLE8, 0,100000,100000, 0,0};
static BITMAPINFOHEADER bo = {sizeof(BITMAPINFOHEADER),32,8, 1,8, BI_RGB, 0,100000,100000, 0,0};
BITMAPINFOHEADER tmp = {sizeof(BITMAPINFOHEADER)};
HIC h;
DWORD err;
@ -123,6 +129,45 @@ static void test_Locate(void)
ok(err == ICERR_OK, "Query cvid->RGB32 height<0: %d\n", err);
bo.biHeight = -bo.biHeight;
bi.biWidth = 17;
bi.biBitCount = 8;
err = ICDecompressGetFormat(h, &bi, &tmp);
ok(err == ICERR_OK, "Query cvid output format: %d\n", err);
ok(tmp.biBitCount == 24, "Expected 24 bit, got %d bit\n", tmp.biBitCount);
ok(tmp.biSizeImage == get_stride(17, 24) * 8, "Expected size %d, got %d\n",
get_stride(17, 24) * 8, tmp.biSizeImage);
bi.biBitCount = 15;
err = ICDecompressGetFormat(h, &bi, &tmp);
ok(err == ICERR_OK, "Query cvid output format: %d\n", err);
ok(tmp.biBitCount == 24, "Expected 24 bit, got %d bit\n", tmp.biBitCount);
ok(tmp.biSizeImage == get_stride(17, 24) * 8, "Expected size %d, got %d\n",
get_stride(17, 24) * 8, tmp.biSizeImage);
bi.biBitCount = 16;
err = ICDecompressGetFormat(h, &bi, &tmp);
ok(err == ICERR_OK, "Query cvid output format: %d\n", err);
ok(tmp.biBitCount == 24, "Expected 24 bit, got %d bit\n", tmp.biBitCount);
ok(tmp.biSizeImage == get_stride(17, 24) * 8, "Expected size %d, got %d\n",
get_stride(17, 24) * 8, tmp.biSizeImage);
bi.biBitCount = 24;
err = ICDecompressGetFormat(h, &bi, &tmp);
ok(err == ICERR_OK, "Query cvid output format: %d\n", err);
ok(tmp.biBitCount == 24, "Expected 24 bit, got %d bit\n", tmp.biBitCount);
ok(tmp.biSizeImage == get_stride(17, 24) * 8, "Expected size %d, got %d\n",
get_stride(17, 24) * 8, tmp.biSizeImage);
bi.biBitCount = 32;
err = ICDecompressGetFormat(h, &bi, &tmp);
ok(err == ICERR_OK, "Query cvid output format: %d\n", err);
ok(tmp.biBitCount == 24, "Expected 24 bit, got %d bit\n", tmp.biBitCount);
ok(tmp.biSizeImage == get_stride(17, 24) * 8, "Expected size %d, got %d\n",
get_stride(17, 24) * 8, tmp.biSizeImage);
bi.biWidth = 32;
ok(ICClose(h) == ICERR_OK,"ICClose failed\n");
bo.biBitCount = bi.biBitCount = 8;