msrle32/tests: Add uncompressed video tests using MRLE as codec (try 2)

Bruno Jesus 00cpxxx at gmail.com
Sun Oct 18 11:47:53 CDT 2015


Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>

try 2:
Create the required video file on runtime, I squeezed the avi file as
much as I could to make it still functional.

original:
While studying bug https://bugs.winehq.org/show_bug.cgi?id=33022 I
noticed that the game mouse cursors are stored in an uncompressed AVI
file, wine currently is not able to process such videos as ICLocate
will fail without finding a valid codec.

Windows always returns the MRLE codec in such cases so this test opens
an uncompressed video and use explicitly MRLE to check if it is able
to decompress the video and it does.
-------------- next part --------------

---
 dlls/msrle32/tests/Makefile.in      |  2 +-
 dlls/msrle32/tests/msrle.c          | 84 +++++++++++++++++++++++++++++++++++++
 dlls/msrle32/tests/msrle_testdata.h | 28 +++++++++++++
 3 files changed, 113 insertions(+), 1 deletion(-)
 create mode 100644 dlls/msrle32/tests/msrle_testdata.h

diff --git a/dlls/msrle32/tests/Makefile.in b/dlls/msrle32/tests/Makefile.in
index 5fe929a..4f99b4c 100644
--- a/dlls/msrle32/tests/Makefile.in
+++ b/dlls/msrle32/tests/Makefile.in
@@ -1,4 +1,4 @@
 TESTDLL   = msrle32.dll
-IMPORTS   = msvfw32
+IMPORTS   = msvfw32 avifil32
 
 C_SRCS    = msrle.c
diff --git a/dlls/msrle32/tests/msrle.c b/dlls/msrle32/tests/msrle.c
index 5ab0b6a..9a72813 100644
--- a/dlls/msrle32/tests/msrle.c
+++ b/dlls/msrle32/tests/msrle.c
@@ -23,6 +23,7 @@
 #include <stdio.h>
 
 #include "wine/test.h"
+#include "msrle_testdata.h"
 
 static void test_output(const BYTE *output, int out_size, const BYTE *expect, int size)
 {
@@ -99,7 +100,90 @@ static void test_encode(void)
     ICClose(hic);
 }
 
+static void make_testfile(void)
+{
+    BOOL ret;
+    DWORD written;
+    HANDLE file = CreateFileA("rawvideo.avi", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+    ok(file != INVALID_HANDLE_VALUE, "CreateFile failed with error %d\n", GetLastError());
+    ret = WriteFile(file, rawavi_data, sizeof(rawavi_data), &written, NULL);
+    ok(ret, "Expected TRUE, got FALSE with error %d\n", GetLastError());
+    CloseHandle(file);
+}
+
+static void erase_testfile(void)
+{
+    DeleteFileA("rawvideo.avi");
+}
+
+static void test_raw_decode(void)
+{
+    int hr, size;
+    PAVIFILE avi = NULL;
+    PAVISTREAM stream = NULL;
+    AVISTREAMINFOA stream_info;
+    BITMAPINFOHEADER bmi;
+    PGETFRAME frame;
+    void *data;
+    HIC hic;
+    ICINFO codec_info;
+
+    /* MSRLE can also work on uncompressed video frames, to prove that
+     * we will open an uncompressed avi video and then check if MRLE
+     * is capable of decompressing it. */
+    make_testfile();
+    AVIFileInit();
+    hr = AVIFileOpenA(&avi, "rawvideo.avi", OF_READ, NULL);
+    ok(hr == 0, "Expected 0, got 0x%x\n", hr);
+    hr = AVIFileGetStream(avi, &stream, streamtypeVIDEO, 0);
+    ok(hr == 0, "Expected 0, got 0x%x\n", hr);
+    ok(stream != NULL, "Expected non-NULL stream\n");
+    memset(&stream_info, 0, sizeof(stream_info));
+    hr = AVIStreamInfoA(stream, &stream_info, sizeof(stream_info));
+    ok(hr == 0, "Expected 0, got 0x%x\n", hr);
+    ok(stream_info.fccType == streamtypeVIDEO, "Expected a video stream\n");
+    ok(stream_info.fccHandler == FCC('D', 'I', 'B', ' '), "Expected uncompressed video, got 0x%x\n",
+       stream_info.fccHandler);
+    size = sizeof(bmi);
+    hr = AVIStreamReadFormat(stream, 0, &bmi, &size);
+    ok(hr == 0, "Expected 0, got 0x%x\n", hr);
+
+    /* Ok, video is now loaded and we have the stream format. Now let's
+     * ask the system to get a codec that is able to parse uncompressed
+     * "DIB " format. */
+    hic = ICLocate(FCC('V', 'I', 'D', 'C'), stream_info.fccHandler, &bmi, NULL, ICMODE_DECOMPRESS);
+todo_wine
+    ok(hic != NULL, "Expected non-NULL return\n");
+
+    /* Which is this codec? Windows returns the MRLE codec for this case */
+    memset(&codec_info, 0x00, sizeof(codec_info));
+    hr = ICGetInfo(hic, &codec_info, sizeof(codec_info));
+todo_wine
+    ok(hr == sizeof(codec_info), "Incorrect amount of data returned\n");
+todo_wine
+    ok(codec_info.fccType == FCC('v', 'i', 'd', 'c'),
+       "Expected a video type, got 0x%x\n", codec_info.fccType);
+todo_wine
+    ok(codec_info.fccHandler == FCC('M', 'R', 'L', 'E'),
+       "Expected MRLE, got 0x%x\n", codec_info.fccHandler);
+
+    /* Get the frame data to be sure it works */
+    frame = AVIStreamGetFrameOpen(stream, NULL);
+    ok(frame != NULL, "Expected non-NULL frame\n");
+    data = AVIStreamGetFrame(frame, 0);
+    ok(data != NULL, "Expected non-NULL frame data\n");
+    data = AVIStreamGetFrame(frame, 1);
+    ok(data != NULL, "Expected non-NULL frame data\n");
+    hr = AVIStreamGetFrameClose(frame);
+    ok(hr == 0, "Expected 0, got 0x%x\n", hr);
+    hr = AVIFileRelease(avi);
+    ok(hr > 0, "Expected > 0, got %d\n", hr);
+    AVIFileExit();
+    erase_testfile();
+}
+
 START_TEST(msrle)
 {
     test_encode();
+    test_raw_decode();
 }
diff --git a/dlls/msrle32/tests/msrle_testdata.h b/dlls/msrle32/tests/msrle_testdata.h
new file mode 100644
index 0000000..0b3cb2f
--- /dev/null
+++ b/dlls/msrle32/tests/msrle_testdata.h
@@ -0,0 +1,28 @@
+static unsigned char rawavi_data[] = {
+    0x52, 0x49, 0x46, 0x46, 0xB0, 0x01, 0x00, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, 0xC8,
+    0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, 0x40, 0x42,
+    0x0F, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x05, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+    0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x7C, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74,
+    0x72, 0x68, 0x38, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x73, 0x74, 0x72, 0x66, 0x28, 0x00,
+    0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x69, 0x6E, 0x65, 0x00, 0x00, 0x00, 0x00, 0x4C,
+    0x49, 0x53, 0x54, 0x7C, 0x00, 0x00, 0x00, 0x6D, 0x6F, 0x76, 0x69, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01,
+    0x01, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x01,
+    0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x30, 0x30,
+    0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,
+    0x01, 0x01, 0x01, 0x01, 0x01, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+    0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x69, 0x64, 0x78, 0x31, 0x50,
+    0x00, 0x00, 0x00, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x10, 0x00,
+    0x00, 0x00, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
+    0x00, 0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+    0x30, 0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x30,
+    0x30, 0x64, 0x62, 0x10, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00
+};
-- 
2.1.4



More information about the wine-patches mailing list