Module: wine Branch: master Commit: cb767f738d636b23290220f5988e3724d619b64b URL: http://source.winehq.org/git/wine.git/?a=commit;h=cb767f738d636b23290220f598...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Jan 2 14:16:49 2014 +0100
msrle32: Append EOI instead of replacing EOL.
---
dlls/msrle32/msrle32.c | 10 ++++++---- dlls/msrle32/tests/msrle.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 5 deletions(-)
diff --git a/dlls/msrle32/msrle32.c b/dlls/msrle32/msrle32.c index 645e323..d22b412 100644 --- a/dlls/msrle32/msrle32.c +++ b/dlls/msrle32/msrle32.c @@ -256,7 +256,7 @@ static LONG MSRLE32_GetMaxCompressedSize(LPCBITMAPINFOHEADER lpbi) }
size = (2 + a * (2 + ((a + 2) & ~2)) + b * (2 + ((b + 2) & ~2))); - return size * lpbi->biHeight; + return size * lpbi->biHeight + 2; }
/* lpP => current pos in previous frame @@ -820,14 +820,16 @@ LRESULT MSRLE32_CompressRLE8(const CodecInfo *pi, LPCBITMAPINFOHEADER lpbiIn, } }
- /* add EOL -- will be changed to EOI */ + /* add EOL */ lpbiOut->biSizeImage += 2; *((LPWORD)lpOut) = 0; lpOut += sizeof(WORD); }
- /* change EOL to EOI -- end of image */ - lpOut[-1] = 1; + /* add EOI -- end of image */ + lpbiOut->biSizeImage += 2; + *lpOut++ = 0; + *lpOut++ = 1; assert(lpOut == (lpOutStart + lpbiOut->biSizeImage));
return ICERR_OK; diff --git a/dlls/msrle32/tests/msrle.c b/dlls/msrle32/tests/msrle.c index 58dcc41..1b7e680 100644 --- a/dlls/msrle32/tests/msrle.c +++ b/dlls/msrle32/tests/msrle.c @@ -24,13 +24,40 @@
#include "wine/test.h"
+static void test_output(const BYTE *output, int out_size, const BYTE *expect, int size) +{ + char buf[512], *ptr; + int i; + + i = out_size == size && !memcmp(output, expect, size); + ok(i, "Unexpected output\n"); + if(i) + return; + + for(i=0, ptr=buf; i<out_size; i++) + ptr += sprintf(ptr, "%x ", output[i]); + trace("Got: %s\n", buf); + for(i=0, ptr=buf; i<size; i++) + ptr += sprintf(ptr, "%x ", expect[i]); + trace("Exp: %s\n", buf); +} + static void test_encode(void) { - DWORD quality; + BITMAPINFOHEADER *output_header; + DWORD output_size, flags, quality; + BYTE buf[64]; ICINFO info; HIC hic; LRESULT res;
+ struct { BITMAPINFOHEADER header; RGBQUAD map[256]; } + input_header = { {sizeof(BITMAPINFOHEADER), 32, 1, 1, 8, 0, 32*8, 0, 0, 256, 256}, + {{255,0,0}, {0,255,0}, {0,0,255}, {255,255,255}}}; + + static BYTE input1[32] = {1,2,3,3,3,3,2,3,1}; + static const BYTE output1[] = {1,1,1,2,4,3,0,3,2,3,1,0,23,0,0,0,0,1}; + hic = ICOpen(FCC('V','I','D','C'), FCC('m','r','l','e'), ICMODE_COMPRESS); ok(hic != NULL, "ICOpen failed\n");
@@ -55,6 +82,20 @@ static void test_encode(void) res = ICSendMessage(hic, ICM_SETQUALITY, (DWORD_PTR)&quality, 0); ok(res == ICERR_UNSUPPORTED, "ICSendMessage(ICM_SETQUALITY) failed: %ld\n", res);
+ output_size = ICCompressGetFormatSize(hic, &input_header.header); + ok(output_size == 1064, "output_size = %d\n", output_size); + + output_header = HeapAlloc(GetProcessHeap(), 0, output_size); + ICCompressGetFormat(hic, &input_header.header, output_header); + + flags = 0; + res = ICCompress(hic, ICCOMPRESS_KEYFRAME, output_header, buf, &input_header.header, input1, 0, &flags, 0, 0, 0, NULL, NULL); + ok(res == ICERR_OK, "ICCompress failed: %ld\n", res); + test_output(buf, output_header->biSizeImage, output1, sizeof(output1)); + todo_wine ok(flags == (AVIIF_TWOCC|AVIIF_KEYFRAME), "flags = %x\n", flags); + + HeapFree(GetProcessHeap(), 0, output_header); + ICClose(hic); }