2 * Unit tests for video playback
4 * Copyright 2008,2010 Jörg Höhle
5 * Copyright 2008 Austin English
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #define WIN32_LEAN_AND_MEAN
26 #include "wine/test.h"
28 static void test_OpenCase(void)
32 /* Check if default handler works */
33 h
= ICOpen(mmioFOURCC('v','i','d','c'),0,ICMODE_DECOMPRESS
);
34 ok(0!=h
,"ICOpen(vidc.0) failed\n");
36 info
.dwSize
= sizeof(info
);
38 ICGetInfo(h
, &info
, sizeof(info
));
39 trace("The default decompressor is %s\n", wine_dbgstr_w(info
.szName
));
40 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
42 h
= ICOpen(mmioFOURCC('v','i','d','c'),0,ICMODE_COMPRESS
);
43 ok(0!=h
|| broken(h
== 0),"ICOpen(vidc.0) failed\n"); /* Not present in Win8 */
45 info
.dwSize
= sizeof(info
);
47 ICGetInfo(h
, &info
, sizeof(info
));
48 trace("The default compressor is %s\n", wine_dbgstr_w(info
.szName
));
49 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
52 /* Open a compressor with combinations of lowercase
53 * and uppercase compressortype and handler.
55 h
= ICOpen(mmioFOURCC('v','i','d','c'),mmioFOURCC('m','s','v','c'),ICMODE_DECOMPRESS
);
56 ok(0!=h
,"ICOpen(vidc.msvc) failed\n");
58 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
60 h
= ICOpen(mmioFOURCC('v','i','d','c'),mmioFOURCC('M','S','V','C'),ICMODE_DECOMPRESS
);
61 ok(0!=h
,"ICOpen(vidc.MSVC) failed\n");
63 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
65 h
= ICOpen(mmioFOURCC('V','I','D','C'),mmioFOURCC('m','s','v','c'),ICMODE_DECOMPRESS
);
66 ok(0!=h
,"ICOpen(VIDC.msvc) failed\n");
68 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
70 h
= ICOpen(mmioFOURCC('V','I','D','C'),mmioFOURCC('M','S','V','C'),ICMODE_DECOMPRESS
);
71 ok(0!=h
,"ICOpen(VIDC.MSVC) failed\n");
73 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
75 h
= ICOpen(mmioFOURCC('v','i','d','c'),mmioFOURCC('m','S','v','C'),ICMODE_DECOMPRESS
);
76 ok(0!=h
,"ICOpen(vidc.mSvC) failed\n");
78 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
80 h
= ICOpen(mmioFOURCC('v','I','d','C'),mmioFOURCC('m','s','v','c'),ICMODE_DECOMPRESS
);
81 ok(0!=h
,"ICOpen(vIdC.msvc) failed\n");
83 ok(ICClose(h
)==ICERR_OK
,"ICClose failed\n");
87 static void test_Locate(void)
89 static BITMAPINFOHEADER bi
= {sizeof(BITMAPINFOHEADER
),32,8, 1,8, BI_RLE8
, 0,100000,100000, 0,0};
90 static BITMAPINFOHEADER bo
= {sizeof(BITMAPINFOHEADER
),32,8, 1,8, BI_RGB
, 0,100000,100000, 0,0};
94 /* Oddly, MSDN documents that ICLocate takes BITMAPINFOHEADER
95 * pointers, while ICDecompressQuery takes the larger
96 * BITMAPINFO. Probably it's all the same as long as the
97 * variable length color quads are present when they are
100 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
101 ok(h
!= 0, "RLE8->RGB failed\n");
102 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
104 bo
.biHeight
= - bo
.biHeight
;
105 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
106 ok(h
== 0, "RLE8->RGB height<0 succeeded\n");
107 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
108 bo
.biHeight
= - bo
.biHeight
;
110 bi
.biCompression
= mmioFOURCC('c','v','i','d'); /* Cinepak */
111 h
= ICOpen(ICTYPE_VIDEO
, mmioFOURCC('c','v','i','d'), ICMODE_DECOMPRESS
);
112 if (h
== 0) win_skip("Cinepak/ICCVID codec not found\n");
114 bo
.biBitCount
= bi
.biBitCount
= 32;
115 err
= ICDecompressQuery(h
, &bi
, &bo
);
116 ok(err
== ICERR_OK
, "Query cvid->RGB32: %d\n", err
);
118 err
= ICDecompressQuery(h
, &bi
, NULL
);
119 ok(err
== ICERR_OK
, "Query cvid 32: %d\n", err
);
121 bo
.biHeight
= -bo
.biHeight
;
122 err
= ICDecompressQuery(h
, &bi
, &bo
);
123 ok(err
== ICERR_OK
, "Query cvid->RGB32 height<0: %d\n", err
);
124 bo
.biHeight
= -bo
.biHeight
;
126 ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
128 bo
.biBitCount
= bi
.biBitCount
= 8;
129 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
130 todo_wine
ok(h
!= 0, "cvid->RGB8 failed\n");
131 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
132 bo
.biHeight
= - bo
.biHeight
;
133 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
134 todo_wine
ok(h
!= 0, "cvid->RGB8 height<0 failed\n");
135 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
136 bo
.biHeight
= - bo
.biHeight
;
138 bo
.biBitCount
= bi
.biBitCount
= 16;
139 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
140 ok(h
!= 0, "cvid->RGB16 failed\n");
141 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
142 bo
.biHeight
= - bo
.biHeight
;
143 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
144 ok(h
!= 0, "cvid->RGB16 height<0 failed\n");
145 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
146 bo
.biHeight
= - bo
.biHeight
;
148 bo
.biBitCount
= bi
.biBitCount
= 32;
149 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
150 ok(h
!= 0, "cvid->RGB32 failed\n");
151 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
152 bo
.biHeight
= - bo
.biHeight
;
153 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
154 ok(h
!= 0, "cvid->RGB32 height<0 failed\n");
155 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
156 bo
.biHeight
= - bo
.biHeight
;
158 bi
.biCompression
= mmioFOURCC('C','V','I','D');
159 /* Unlike ICOpen, upper case fails with ICLocate. */
160 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
161 ok(h
== 0, "CVID->RGB32 upper case succeeded\n");
162 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
165 bi
.biCompression
= mmioFOURCC('M','S','V','C'); /* MS Video 1 */
167 bo
.biBitCount
= bi
.biBitCount
= 16;
168 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
169 ok(h
!= 0, "MSVC->RGB16 failed\n");
170 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
172 bo
.biHeight
= - bo
.biHeight
;
173 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
174 todo_wine
ok(h
!= 0, "MSVC->RGB16 height<0 failed\n");
175 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
176 bo
.biHeight
= - bo
.biHeight
;
179 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
180 ok(h
== 0, "MSVC->RGB16 height too small succeeded\n");
181 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
184 /* ICLocate wants upper case MSVC */
185 bi
.biCompression
= mmioFOURCC('m','s','v','c');
186 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
187 ok(h
== 0, "msvc->RGB16 succeeded\n");
188 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
190 bi
.biCompression
= mmioFOURCC('M','S','V','C');
191 h
= ICOpen(ICTYPE_VIDEO
, mmioFOURCC('M','S','V','C'), ICMODE_DECOMPRESS
);
192 ok(h
!= 0, "No MSVC codec installed!?\n");
194 err
= ICDecompressQuery(h
, &bi
, &bo
);
195 ok(err
== ICERR_OK
, "Query MSVC->RGB16: %d\n", err
);
197 err
= ICDecompressQuery(h
, &bi
, NULL
);
198 ok(err
== ICERR_OK
, "Query MSVC 16: %d\n", err
);
200 bo
.biHeight
= -bo
.biHeight
;
201 err
= ICDecompressQuery(h
, &bi
, &bo
);
202 todo_wine
ok(err
== ICERR_OK
, "Query MSVC->RGB16 height<0: %d\n", err
);
203 bo
.biHeight
= -bo
.biHeight
;
205 bi
.biCompression
= mmioFOURCC('m','s','v','c');
206 err
= ICDecompressQuery(h
, &bi
, &bo
);
207 ok(err
== ICERR_BADFORMAT
, "Query msvc->RGB16: %d\n", err
);
209 ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
212 bi
.biCompression
= BI_RGB
;
213 bo
.biBitCount
= bi
.biBitCount
= 8;
214 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
215 ok(h
!= 0, "RGB8->RGB identity failed\n");
216 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
218 bi
.biCompression
= BI_RLE8
;
219 h
= ICLocate(ICTYPE_VIDEO
, 0, &bi
, &bo
, ICMODE_DECOMPRESS
);
220 ok(h
!= 0, "RLE8->RGB again failed\n");
221 if (h
) ok(ICClose(h
) == ICERR_OK
,"ICClose failed\n");
224 static void test_ICSeqCompress(void)
226 /* The purpose of this test is to validate sequential frame compressing
227 * functions. The MRLE codec will be used because Wine supports it and
228 * it is present in any Windows.
231 DWORD err
, vidc
= mmioFOURCC('v','i','d','c'), mrle
= mmioFOURCC('m', 'r', 'l', 'e');
237 struct { BITMAPINFOHEADER header
; RGBQUAD map
[256]; }
238 input_header
= { {sizeof(BITMAPINFOHEADER
), 32, 1, 1, 8, 0, 32*8, 0, 0, 256, 256},
239 {{255,0,0}, {0,255,0}, {0,0,255}, {255,255,255}}};
240 PBITMAPINFO bitmap
= (PBITMAPINFO
) &input_header
;
241 static BYTE input
[32] = {1,2,3,3,3,3,2,3,1};
242 static const BYTE output_kf
[] = {1,1,1,2,4,3,0,3,2,3,1,0,23,0,0,0,0,1}, /* key frame*/
243 output_nkf
[] = {0,0,0,1}; /* non key frame */
245 h
= ICOpen(vidc
, mrle
, ICMODE_COMPRESS
);
246 ok(h
!= NULL
, "Expected non-NULL\n");
248 pc
.cbSize
= sizeof(pc
);
249 pc
.dwFlags
= ICMF_COMPVARS_VALID
;
251 pc
.fccHandler
= mrle
;
255 pc
.lpBitsOut
= pc
.lpBitsPrev
= pc
.lpState
= NULL
;
256 pc
.lQ
= ICQUALITY_DEFAULT
;
262 ret
= ICSeqCompressFrameStart(&pc
, bitmap
);
263 ok(ret
== TRUE
, "Expected TRUE\n");
264 /* Check that reserved pointers were allocated */
265 ok(pc
.lpbiIn
!= NULL
, "Expected non-NULL\n");
266 ok(pc
.lpbiOut
!= NULL
, "Expected non-NULL\n");
268 for(i
= 0; i
< 9; i
++)
271 frame
= ICSeqCompressFrame(&pc
, 0, input
, &key_frame
, &frame_len
);
272 ok(frame
!= NULL
, "Frame[%d]: Expected non-NULL\n", i
);
273 if (frame_len
== sizeof(output_nkf
))
274 ok(!memcmp(output_nkf
, frame
, frame_len
), "Frame[%d]: Contents do not match\n", i
);
275 else if (frame_len
== sizeof(output_kf
))
276 ok(!memcmp(output_kf
, frame
, frame_len
), "Frame[%d]: Contents do not match\n", i
);
278 ok(0, "Unknown frame size of %d byten\n", frame_len
);
281 ICSeqCompressFrameEnd(&pc
);
282 ICCompressorFree(&pc
);
283 /* ICCompressorFree already closed the HIC */
285 ok(err
== ICERR_BADHANDLE
, "Expected -8, got %d\n", err
);
292 test_ICSeqCompress();