ReactOS 0.4.16-dev-92-g0c2cdca
msrle.c File Reference
#include <windows.h>
#include <vfw.h>
#include <aviriff.h>
#include <stdio.h>
#include "wine/test.h"
Include dependency graph for msrle.c:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 

Functions

static void test_output (const BYTE *output, int out_size, const BYTE *expect, int size)
 
static void test_encode (void)
 
static void test_raw_decompress (void)
 
 START_TEST (msrle)
 

Macro Definition Documentation

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 19 of file msrle.c.

Function Documentation

◆ START_TEST()

START_TEST ( msrle  )

Definition at line 162 of file msrle.c.

163{
164 test_encode();
166}
static void test_raw_decompress(void)
Definition: msrle.c:102
static void test_encode(void)
Definition: msrle.c:45

◆ test_encode()

static void test_encode ( void  )
static

Definition at line 45 of file msrle.c.

46{
48 DWORD output_size, flags, quality;
49 BYTE buf[64];
51 HIC hic;
53
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}}};
57
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};
60
61 hic = ICOpen(FCC('V','I','D','C'), FCC('m','r','l','e'), ICMODE_COMPRESS);
62 ok(hic != NULL, "ICOpen failed\n");
63
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);
70
71 quality = 0xdeadbeef;
73 ok(res == ICERR_OK, "ICSendMessage(ICM_GETDEFAULTQUALITY) failed: %ld\n", res);
74 ok(quality == 8500, "quality = %d\n", quality);
75
76 quality = 0xdeadbeef;
78 ok(res == ICERR_UNSUPPORTED, "ICSendMessage(ICM_GETQUALITY) failed: %ld\n", res);
79 ok(quality == 0xdeadbeef, "quality = %d\n", quality);
80
83 ok(res == ICERR_UNSUPPORTED, "ICSendMessage(ICM_SETQUALITY) failed: %ld\n", res);
84
85 output_size = ICCompressGetFormatSize(hic, &input_header.header);
86 ok(output_size == 1064, "output_size = %d\n", output_size);
87
88 output_header = HeapAlloc(GetProcessHeap(), 0, output_size);
89 ICCompressGetFormat(hic, &input_header.header, output_header);
90
91 flags = 0;
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);
96
98
99 ICClose(hic);
100}
#define ok(value,...)
Definition: atltest.h:57
#define AVIIF_KEYFRAME
Definition: aviriff.h:131
#define FCC(ch0, ch1, ch2, ch3)
Definition: aviriff.h:38
static int output_header(const WCHAR *prop, ULONG column_width)
Definition: main.c:150
Definition: _map.h:48
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
ULONG RGBQUAD
Definition: precomp.h:59
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint res
Definition: glext.h:9613
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLbitfield flags
Definition: glext.h:7161
int quality
Definition: jpeglib.h:992
#define todo_wine
Definition: custom.c:89
static void test_output(const BYTE *output, int out_size, const BYTE *expect, int size)
Definition: msrle.c:27
HIC VFWAPI ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
Definition: msvideo_main.c:441
LRESULT VFWAPI ICSendMessage(HIC hic, UINT msg, DWORD_PTR lParam1, DWORD_PTR lParam2)
LRESULT VFWAPI ICGetInfo(HIC hic, ICINFO *picinfo, DWORD cb)
Definition: msvideo_main.c:594
DWORD VFWAPIV ICCompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiOutput, LPVOID lpData, LPBITMAPINFOHEADER lpbiInput, LPVOID lpBits, LPDWORD lpckid, LPDWORD lpdwFlags, LONG lFrameNum, DWORD dwFrameSize, DWORD dwQuality, LPBITMAPINFOHEADER lpbiPrev, LPVOID lpPrev)
Definition: msvideo_main.c:797
LRESULT WINAPI ICClose(HIC hic)
Definition: vfw.h:280
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define VIDCF_CRUNCH
Definition: vfw.h:298
#define ICVERSION
Definition: vfw.h:45
#define ICERR_OK
Definition: vfw.h:50
#define VIDCF_QUALITY
Definition: vfw.h:297
#define ICQUALITY_HIGH
Definition: vfw.h:277
#define ICM_GETQUALITY
Definition: vfw.h:89
#define ICCompressGetFormat(hic, lpbiInput, lpbiOutput)
Definition: vfw.h:204
#define ICERR_UNSUPPORTED
Definition: vfw.h:56
#define ICMODE_COMPRESS
Definition: vfw.h:268
#define ICCOMPRESS_KEYFRAME
Definition: vfw.h:170
#define VIDCF_TEMPORAL
Definition: vfw.h:299
#define ICM_SETQUALITY
Definition: vfw.h:90
#define ICM_GETDEFAULTQUALITY
Definition: vfw.h:88
#define AVIIF_TWOCC
Definition: vfw.h:977
#define ICCompressGetFormatSize(hic, lpbi)
Definition: vfw.h:210
LONG_PTR LRESULT
Definition: windef.h:209
unsigned char BYTE
Definition: xxhash.c:193

Referenced by START_TEST().

◆ test_output()

static void test_output ( const BYTE output,
int  out_size,
const BYTE expect,
int  size 
)
static

Definition at line 27 of file msrle.c.

28{
29 char buf[512], *ptr;
30 int i;
31
32 i = out_size == size && !memcmp(output, expect, size);
33 ok(i, "Unexpected output\n");
34 if(i)
35 return;
36
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);
43}
#define expect(EXPECTED, GOT)
Definition: SystemMenu.c:483
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define trace
Definition: atltest.h:70
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
#define sprintf(buf, format,...)
Definition: sprintf.c:55
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:100

Referenced by test_encode().

◆ test_raw_decompress()

static void test_raw_decompress ( void  )
static

Definition at line 102 of file msrle.c.

103{
104 DWORD codecs[] = {FCC('D', 'I', 'B', ' '), FCC('R', 'A', 'W', ' '),
105 FCC('M', 'R', 'L', 'E'), BI_RGB}, i, hr;
106 BITMAPINFO bi;
107 BITMAPINFOHEADER *bih, biho;
108 HIC hic;
110 void *bits, *outbits;
111
112 /* Create an uncompressed 200x200 bitmap */
113 bih = &bi.bmiHeader;
114 bih->biSize = sizeof(*bih);
115 bih->biWidth = 200;
116 bih->biHeight = 200;
117 bih->biPlanes = 1;
118 bih->biBitCount = 24;
119 bih->biCompression = BI_RGB;
120 bih->biSizeImage = bih->biWidth * (bih->biBitCount / 8) * bih->biHeight;
121 bih->biXPelsPerMeter = 10000;
122 bih->biYPelsPerMeter = 10000;
123 bih->biClrUsed = 0;
124 bih->biClrImportant = 0;
125 biho = *bih;
126
128 ok(bits != NULL, "Expected non-NULL value\n");
129 outbits = HeapAlloc(GetProcessHeap(), 0, bih->biSizeImage);
130 ok(outbits != NULL, "Expected non-NULL value\n");
131
132 for (i = 0; i < ARRAY_SIZE(codecs); i++)
133 {
134 memset(bits, i + 0xAF, bih->biSizeImage);
135
136 /* Check which codec is able to decompress uncompressed data */
137 hic = ICLocate(FCC('V', 'I', 'D', 'C'), codecs[i], bih, NULL, ICMODE_DECOMPRESS);
138 ok(hic != NULL, "Test[%d]: Expected non-NULL return\n", i);
139
140 /* Now which is this codec? Windows returns MRLE for uncompressed cases */
141 memset(&codec_info, 0, sizeof(codec_info));
142 hr = ICGetInfo(hic, &codec_info, sizeof(codec_info));
143 ok(hr == sizeof(codec_info), "Test[%d]: Incorrect amount of data returned\n", i);
144 ok(codec_info.fccType == FCC('v', 'i', 'd', 'c'),
145 "Test[%d]: Expected a video type, got 0x%x\n", i, codec_info.fccType);
146 ok(codec_info.fccHandler == FCC('M', 'R', 'L', 'E'),
147 "Test[%d]: Expected MRLE, got 0x%x\n", i, codec_info.fccHandler);
148
149 /* Decompress the frame and check if we get the same output */
150 memset(outbits, 0, bih->biSizeImage);
151 hr = ICDecompress(hic, 0, bih, bits, &biho, outbits);
152 ok(hr == ICERR_OK, "Test[%d]: Expected ICERR_OK, got %d\n", i, hr);
153 ok(!memcmp(bits, outbits, bih->biSizeImage), "Test[%d]: Image contents do not match!\n", i);
154
155 hr = ICClose(hic);
156 ok(hr == ICERR_OK, "Test[%d]: Expected ICERR_OK, got %d\n", i, hr);
157 }
159 HeapFree(GetProcessHeap(), 0, outbits);
160}
#define ARRAY_SIZE(A)
Definition: main.h:20
static const struct image_codec codecs[NUM_CODECS]
Definition: image.c:4283
#define BI_RGB
Definition: precomp.h:56
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
#define bits
Definition: infblock.c:15
DWORD VFWAPIV ICDecompress(HIC hic, DWORD dwFlags, LPBITMAPINFOHEADER lpbiFormat, LPVOID lpData, LPBITMAPINFOHEADER lpbi, LPVOID lpBits)
Definition: msvideo_main.c:827
HIC VFWAPI ICLocate(DWORD type, DWORD handler, BITMAPINFOHEADER *in, BITMAPINFOHEADER *out, WORD mode)
Definition: msvideo_main.c:633
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
LONG biYPelsPerMeter
Definition: amvideo.idl:38
DWORD biCompression
Definition: amvideo.idl:35
DWORD biClrImportant
Definition: amvideo.idl:40
LONG biXPelsPerMeter
Definition: amvideo.idl:37
DWORD biSizeImage
Definition: amvideo.idl:36
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1476
#define ICMODE_DECOMPRESS
Definition: vfw.h:269

Referenced by START_TEST().