fdfe54657602128d423944dfc6d52d40b3b9a8fc
2 * Copyright 2013 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #define WIN32_LEAN_AND_MEAN
25 #include <wine/test.h>
27 static void test_output(const BYTE
*output
, int out_size
, const BYTE
*expect
, int size
)
32 i
= out_size
== size
&& !memcmp(output
, expect
, size
);
33 ok(i
, "Unexpected output\n");
37 for(i
=0, ptr
=buf
; i
<out_size
; i
++)
38 ptr
+= sprintf(ptr
, "%x ", output
[i
]);
39 trace("Got: %s\n", buf
);
40 for(i
=0, ptr
=buf
; i
<size
; i
++)
41 ptr
+= sprintf(ptr
, "%x ", expect
[i
]);
42 trace("Exp: %s\n", buf
);
45 static void test_encode(void)
47 BITMAPINFOHEADER
*output_header
;
48 DWORD output_size
, flags
, quality
;
54 struct { BITMAPINFOHEADER header
; RGBQUAD map
[256]; }
55 input_header
= { {sizeof(BITMAPINFOHEADER
), 32, 1, 1, 8, 0, 32*8, 0, 0, 256, 256},
56 {{255,0,0}, {0,255,0}, {0,0,255}, {255,255,255}}};
58 static BYTE input1
[32] = {1,2,3,3,3,3,2,3,1};
59 static const BYTE output1
[] = {1,1,1,2,4,3,0,3,2,3,1,0,23,0,0,0,0,1};
61 hic
= ICOpen(FCC('V','I','D','C'), FCC('m','r','l','e'), ICMODE_COMPRESS
);
62 ok(hic
!= NULL
, "ICOpen failed\n");
64 res
= ICGetInfo(hic
, &info
, sizeof(info
));
65 ok(res
== sizeof(info
), "res = %ld\n", res
);
66 ok(info
.dwSize
== sizeof(info
), "dwSize = %d\n", info
.dwSize
);
67 ok(info
.fccHandler
== FCC('M','R','L','E'), "fccHandler = %x\n", info
.fccHandler
);
68 todo_wine
ok(info
.dwFlags
== (VIDCF_QUALITY
|VIDCF_CRUNCH
|VIDCF_TEMPORAL
), "dwFlags = %x\n", info
.dwFlags
);
69 ok(info
.dwVersionICM
== ICVERSION
, "dwVersionICM = %d\n", info
.dwVersionICM
);
72 res
= ICSendMessage(hic
, ICM_GETDEFAULTQUALITY
, (DWORD_PTR
)&quality
, 0);
73 ok(res
== ICERR_OK
, "ICSendMessage(ICM_GETDEFAULTQUALITY) failed: %ld\n", res
);
74 ok(quality
== 8500, "quality = %d\n", quality
);
77 res
= ICSendMessage(hic
, ICM_GETQUALITY
, (DWORD_PTR
)&quality
, 0);
78 ok(res
== ICERR_UNSUPPORTED
, "ICSendMessage(ICM_GETQUALITY) failed: %ld\n", res
);
79 ok(quality
== 0xdeadbeef, "quality = %d\n", quality
);
81 quality
= ICQUALITY_HIGH
;
82 res
= ICSendMessage(hic
, ICM_SETQUALITY
, (DWORD_PTR
)&quality
, 0);
83 ok(res
== ICERR_UNSUPPORTED
, "ICSendMessage(ICM_SETQUALITY) failed: %ld\n", res
);
85 output_size
= ICCompressGetFormatSize(hic
, &input_header
.header
);
86 ok(output_size
== 1064, "output_size = %d\n", output_size
);
88 output_header
= HeapAlloc(GetProcessHeap(), 0, output_size
);
89 ICCompressGetFormat(hic
, &input_header
.header
, output_header
);
92 res
= ICCompress(hic
, ICCOMPRESS_KEYFRAME
, output_header
, buf
, &input_header
.header
, input1
, 0, &flags
, 0, 0, 0, NULL
, NULL
);
93 ok(res
== ICERR_OK
, "ICCompress failed: %ld\n", res
);
94 test_output(buf
, output_header
->biSizeImage
, output1
, sizeof(output1
));
95 ok(flags
== (AVIIF_TWOCC
|AVIIF_KEYFRAME
), "flags = %x\n", flags
);
97 HeapFree(GetProcessHeap(), 0, output_header
);