msvideo1.c 20.7 KB
Newer Older
1 2 3 4
/*
 * Microsoft Video-1 Decoder
 * Copyright (C) 2003 the ffmpeg project
 *
5
 * Portions Copyright (C) 2004 Mike McCormack for CodeWeavers
6 7 8 9
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 2.1 of the License, or (at your option) any later version.
11 12 13 14 15 16 17 18
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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
20 21 22 23 24 25 26 27 28 29 30 31 32 33
 *
 */

/**
 * @file msvideo1.c
 * Microsoft Video-1 Decoder by Mike Melanson (melanson@pcisys.net)
 * For more information about the MS Video-1 format, visit:
 *   http://www.pcisys.net/~melanson/codecs/
 *
 * This decoder outputs either PAL8 or RGB555 data, depending on the
 * whether a RGB palette was passed through palctrl;
 * if it's present, then the data is PAL8; RGB555 otherwise.
 */

34
#include <stdarg.h>
35 36 37 38 39 40 41
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h" 
#include "commdlg.h"
#include "vfw.h"
#include "mmsystem.h"
42
#include "msvidc32_private.h"
43 44 45 46 47
 
#include "wine/debug.h"
 
WINE_DEFAULT_DEBUG_CHANNEL(msvidc32); 

48 49
static HINSTANCE MSVIDC32_hModule;

50 51 52
#define CRAM_MAGIC mmioFOURCC('C', 'R', 'A', 'M')
#define MSVC_MAGIC mmioFOURCC('M', 'S', 'V', 'C')
#define WHAM_MAGIC mmioFOURCC('W', 'H', 'A', 'M')
53
#define compare_fourcc(fcc1, fcc2) (((fcc1)^(fcc2))&~0x20202020)
54 55

#define PALETTE_COUNT 256
56
#define LE_16(x)  ((((const uint8_t *)(x))[1] << 8) | ((const uint8_t *)(x))[0])
57 58 59 60 61 62 63 64 65 66 67 68 69

/* FIXME - check the stream size */
#define CHECK_STREAM_PTR(n) \
  if ((stream_ptr + n) > buf_size ) { \
    WARN("stream_ptr out of bounds (%d >= %d)\n", \
      stream_ptr + n, buf_size); \
    return; \
  }

typedef BYTE uint8_t;

typedef struct Msvideo1Context {
    DWORD dwMagic;
70
    int depth;
71 72
} Msvideo1Context;

73 74 75 76 77
static inline int get_stride(int width, int depth)
{
    return ((depth * width + 31) >> 3) & ~3;
}

78
static void 
79
msvideo1_decode_8bit( int width, int height, const unsigned char *buf, int buf_size,
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
                      unsigned char *pixels, int stride)
{
    int block_ptr, pixel_ptr;
    int total_blocks;
    int pixel_x, pixel_y;  /* pixel width and height iterators */
    int block_x, block_y;  /* block width and height iterators */
    int blocks_wide, blocks_high;  /* width and height in 4x4 blocks */
    int block_inc;
    int row_dec;

    /* decoding parameters */
    int stream_ptr;
    unsigned char byte_a, byte_b;
    unsigned short flags;
    int skip_blocks;
    unsigned char colors[8];

    stream_ptr = 0;
    skip_blocks = 0;
    blocks_wide = width / 4;
    blocks_high = height / 4;
    total_blocks = blocks_wide * blocks_high;
    block_inc = 4;
103
#ifdef ORIGINAL
104
    row_dec = stride + 4;
105 106 107
#else
    row_dec = - (stride - 4); /* such that -row_dec > 0 */
#endif
108 109

    for (block_y = blocks_high; block_y > 0; block_y--) {
110
#ifdef ORIGINAL
111
        block_ptr = ((block_y * 4) - 1) * stride;
112 113 114
#else
        block_ptr = ((blocks_high - block_y) * 4) * stride;
#endif
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
        for (block_x = blocks_wide; block_x > 0; block_x--) {
            /* check if this block should be skipped */
            if (skip_blocks) {
                block_ptr += block_inc;
                skip_blocks--;
                total_blocks--;
                continue;
            }

            pixel_ptr = block_ptr;

            /* get the next two bytes in the encoded data stream */
            CHECK_STREAM_PTR(2);
            byte_a = buf[stream_ptr++];
            byte_b = buf[stream_ptr++];

            /* check if the decode is finished */
            if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0))
                return;
            else if ((byte_b & 0xFC) == 0x84) {
                /* skip code, but don't count the current block */
                skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
            } else if (byte_b < 0x80) {
                /* 2-color encoding */
                flags = (byte_b << 8) | byte_a;

                CHECK_STREAM_PTR(2);
                colors[0] = buf[stream_ptr++];
                colors[1] = buf[stream_ptr++];

                for (pixel_y = 0; pixel_y < 4; pixel_y++) {
                    for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
                        pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
                    pixel_ptr -= row_dec;
                }
            } else if (byte_b >= 0x90) {
                /* 8-color encoding */
                flags = (byte_b << 8) | byte_a;

                CHECK_STREAM_PTR(8);
                memcpy(colors, &buf[stream_ptr], 8);
                stream_ptr += 8;

                for (pixel_y = 0; pixel_y < 4; pixel_y++) {
                    for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
160 161
                        pixels[pixel_ptr++] =
                            colors[((pixel_y & 0x2) << 1) +
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
                                (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
                    pixel_ptr -= row_dec;
                }
            } else {
                /* 1-color encoding */
                colors[0] = byte_a;

                for (pixel_y = 0; pixel_y < 4; pixel_y++) {
                    for (pixel_x = 0; pixel_x < 4; pixel_x++)
                        pixels[pixel_ptr++] = colors[0];
                    pixel_ptr -= row_dec;
                }
            }

            block_ptr += block_inc;
            total_blocks--;
        }
    }
}

static void
183
msvideo1_decode_16bit( int width, int height, const unsigned char *buf, int buf_size,
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
                       unsigned short *pixels, int stride)
{
    int block_ptr, pixel_ptr;
    int total_blocks;
    int pixel_x, pixel_y;  /* pixel width and height iterators */
    int block_x, block_y;  /* block width and height iterators */
    int blocks_wide, blocks_high;  /* width and height in 4x4 blocks */
    int block_inc;
    int row_dec;

    /* decoding parameters */
    int stream_ptr;
    unsigned char byte_a, byte_b;
    unsigned short flags;
    int skip_blocks;
    unsigned short colors[8];

    stream_ptr = 0;
    skip_blocks = 0;
    blocks_wide = width / 4;
    blocks_high = height / 4;
    total_blocks = blocks_wide * blocks_high;
    block_inc = 4;
207
#ifdef ORIGINAL
208
    row_dec = stride + 4;
209 210 211
#else
    row_dec = - (stride - 4); /* such that -row_dec > 0 */
#endif
212 213

    for (block_y = blocks_high; block_y > 0; block_y--) {
214
#ifdef ORIGINAL
215
        block_ptr = ((block_y * 4) - 1) * stride;
216 217 218
#else
        block_ptr = ((blocks_high - block_y) * 4) * stride;
#endif
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
        for (block_x = blocks_wide; block_x > 0; block_x--) {
            /* check if this block should be skipped */
            if (skip_blocks) {
                block_ptr += block_inc;
                skip_blocks--;
                total_blocks--;
                continue;
            }

            pixel_ptr = block_ptr;

            /* get the next two bytes in the encoded data stream */
            CHECK_STREAM_PTR(2);
            byte_a = buf[stream_ptr++];
            byte_b = buf[stream_ptr++];

            /* check if the decode is finished */
            if ((byte_a == 0) && (byte_b == 0) && (total_blocks == 0)) {
                return;
            } else if ((byte_b & 0xFC) == 0x84) {
                /* skip code, but don't count the current block */
                skip_blocks = ((byte_b - 0x84) << 8) + byte_a - 1;
            } else if (byte_b < 0x80) {
                /* 2- or 8-color encoding modes */
                flags = (byte_b << 8) | byte_a;

                CHECK_STREAM_PTR(4);
                colors[0] = LE_16(&buf[stream_ptr]);
                stream_ptr += 2;
                colors[1] = LE_16(&buf[stream_ptr]);
                stream_ptr += 2;

                if (colors[0] & 0x8000) {
                    /* 8-color encoding */
                    CHECK_STREAM_PTR(12);
                    colors[2] = LE_16(&buf[stream_ptr]);
                    stream_ptr += 2;
                    colors[3] = LE_16(&buf[stream_ptr]);
                    stream_ptr += 2;
                    colors[4] = LE_16(&buf[stream_ptr]);
                    stream_ptr += 2;
                    colors[5] = LE_16(&buf[stream_ptr]);
                    stream_ptr += 2;
                    colors[6] = LE_16(&buf[stream_ptr]);
                    stream_ptr += 2;
                    colors[7] = LE_16(&buf[stream_ptr]);
                    stream_ptr += 2;

                    for (pixel_y = 0; pixel_y < 4; pixel_y++) {
                        for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
269 270
                            pixels[pixel_ptr++] =
                                colors[((pixel_y & 0x2) << 1) +
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306
                                    (pixel_x & 0x2) + ((flags & 0x1) ^ 1)];
                        pixel_ptr -= row_dec;
                    }
                } else {
                    /* 2-color encoding */
                    for (pixel_y = 0; pixel_y < 4; pixel_y++) {
                        for (pixel_x = 0; pixel_x < 4; pixel_x++, flags >>= 1)
                            pixels[pixel_ptr++] = colors[(flags & 0x1) ^ 1];
                        pixel_ptr -= row_dec;
                    }
                }
            } else {
                /* otherwise, it's a 1-color block */
                colors[0] = (byte_b << 8) | byte_a;

                for (pixel_y = 0; pixel_y < 4; pixel_y++) {
                    for (pixel_x = 0; pixel_x < 4; pixel_x++)
                        pixels[pixel_ptr++] = colors[0];
                    pixel_ptr -= row_dec;
                }
            }

            block_ptr += block_inc;
            total_blocks--;
        }
    }
}

static LRESULT
CRAM_DecompressQuery( Msvideo1Context *info, LPBITMAPINFO in, LPBITMAPINFO out )
{
    TRACE("ICM_DECOMPRESS_QUERY %p %p %p\n", info, in, out);

    if( (info==NULL) || (info->dwMagic!=CRAM_MAGIC) )
        return ICERR_BADPARAM;

307 308 309 310 311
    TRACE("in->planes  = %d\n", in->bmiHeader.biPlanes );
    TRACE("in->bpp     = %d\n", in->bmiHeader.biBitCount );
    TRACE("in->height  = %d\n", in->bmiHeader.biHeight );
    TRACE("in->width   = %d\n", in->bmiHeader.biWidth );
    TRACE("in->compr   = 0x%x\n", in->bmiHeader.biCompression );
312 313 314 315

    if( ( in->bmiHeader.biCompression != CRAM_MAGIC ) &&
        ( in->bmiHeader.biCompression != MSVC_MAGIC ) &&
        ( in->bmiHeader.biCompression != WHAM_MAGIC ) )
316 317
    {
        TRACE("can't do 0x%x compression\n", in->bmiHeader.biCompression);
318
        return ICERR_BADFORMAT;
319
    }
320 321 322 323 324

    if( ( in->bmiHeader.biBitCount != 16 ) &&
        ( in->bmiHeader.biBitCount != 8 ) )
    {
        TRACE("can't do %d bpp\n", in->bmiHeader.biBitCount );
325
        return ICERR_BADFORMAT;
326 327 328 329 330
    }

    /* output must be same dimensions as input */
    if( out )
    {
331 332 333 334
        TRACE("out->planes = %d\n", out->bmiHeader.biPlanes );
        TRACE("out->bpp    = %d\n", out->bmiHeader.biBitCount );
        TRACE("out->height = %d\n", out->bmiHeader.biHeight );
        TRACE("out->width  = %d\n", out->bmiHeader.biWidth );
335 336 337 338 339 340 341 342 343

        if ((in->bmiHeader.biBitCount != out->bmiHeader.biBitCount) &&
            (in->bmiHeader.biBitCount != 16 || out->bmiHeader.biBitCount != 24))
        {
            TRACE("incompatible depth requested\n");
            return ICERR_BADFORMAT;
        }

        if(( in->bmiHeader.biPlanes != out->bmiHeader.biPlanes ) ||
344 345 346 347
          ( in->bmiHeader.biHeight != out->bmiHeader.biHeight ) ||
          ( in->bmiHeader.biWidth != out->bmiHeader.biWidth ))
        {
            TRACE("incompatible output requested\n");
348
            return ICERR_BADFORMAT;
349
        }
350 351 352 353 354 355 356 357 358
    }

    TRACE("OK!\n");
    return ICERR_OK;
}

static LRESULT 
CRAM_DecompressGetFormat( Msvideo1Context *info, LPBITMAPINFO in, LPBITMAPINFO out )
{
359 360
    DWORD size;

361 362 363 364 365
    TRACE("ICM_DECOMPRESS_GETFORMAT %p %p %p\n", info, in, out);

    if( (info==NULL) || (info->dwMagic!=CRAM_MAGIC) )
        return ICERR_BADPARAM;

366 367 368 369
    size = in->bmiHeader.biSize;
    if (in->bmiHeader.biBitCount <= 8)
        size += in->bmiHeader.biClrUsed * sizeof(RGBQUAD);

370 371 372
    if (in->bmiHeader.biBitCount != 8 && in->bmiHeader.biBitCount != 16)
        return ICERR_BADFORMAT;

373 374
    if( out )
    {
375
        memcpy( out, in, size );
376 377
        out->bmiHeader.biWidth = in->bmiHeader.biWidth & ~1;
        out->bmiHeader.biHeight = in->bmiHeader.biHeight & ~1;
378
        out->bmiHeader.biCompression = BI_RGB;
379 380
        out->bmiHeader.biSizeImage = in->bmiHeader.biHeight *
                                     get_stride(out->bmiHeader.biWidth, out->bmiHeader.biBitCount);
381
        return ICERR_OK;
382 383
    }

384
    return size;
385 386
}

387
static LRESULT CRAM_DecompressBegin( Msvideo1Context *info, LPBITMAPINFO in, LPBITMAPINFO out )
388 389 390 391 392 393 394 395
{
    TRACE("ICM_DECOMPRESS_BEGIN %p %p %p\n", info, in, out);

    if( (info==NULL) || (info->dwMagic!=CRAM_MAGIC) )
        return ICERR_BADPARAM;

    TRACE("bitmap is %d bpp\n", in->bmiHeader.biBitCount);
    if( in->bmiHeader.biBitCount == 8 )
396
        info->depth = 8;
397
    else if( in->bmiHeader.biBitCount == 16 )
398
        info->depth = 16;
399 400
    else
    {
401
        info->depth = 0;
402
        FIXME("Unsupported output format %i\n", in->bmiHeader.biBitCount);
403 404 405 406 407
    }

    return ICERR_OK;
}

408 409 410
static void convert_depth(char *input, int depth_in, char *output, BITMAPINFOHEADER *out_hdr)
{
    int x, y;
411 412
    int stride_in  = get_stride(out_hdr->biWidth, depth_in);
    int stride_out = get_stride(out_hdr->biWidth, out_hdr->biBitCount);
413 414 415 416 417 418 419 420 421 422 423 424 425

    if (depth_in == 16 && out_hdr->biBitCount == 24)
    {
        static const unsigned char convert_5to8[] =
        {
            0x00, 0x08, 0x10, 0x19, 0x21, 0x29, 0x31, 0x3a,
            0x42, 0x4a, 0x52, 0x5a, 0x63, 0x6b, 0x73, 0x7b,
            0x84, 0x8c, 0x94, 0x9c, 0xa5, 0xad, 0xb5, 0xbd,
            0xc5, 0xce, 0xd6, 0xde, 0xe6, 0xef, 0xf7, 0xff,
        };

        for (y = 0; y < out_hdr->biHeight; y++)
        {
426 427 428
            WORD *src_row = (WORD *)(input + y * stride_in);
            char *out_row = output + y * stride_out;

429 430
            for (x = 0; x < out_hdr->biWidth; x++)
            {
431 432 433 434
                WORD pixel = *src_row++;
                *out_row++ = convert_5to8[(pixel & 0x7c00u) >> 10];
                *out_row++ = convert_5to8[(pixel & 0x03e0u) >> 5];
                *out_row++ = convert_5to8[(pixel & 0x001fu)];
435 436 437 438 439 440 441
            }
        }
    }
    else
        FIXME("Conversion from %d to %d bit unimplemented\n", depth_in, out_hdr->biBitCount);
}

442
static LRESULT CRAM_Decompress( Msvideo1Context *info, ICDECOMPRESS *icd, DWORD size )
443 444
{
    LONG width, height, stride, sz;
445
    void *output;
446

447
    TRACE("ICM_DECOMPRESS %p %p %d\n", info, icd, size);
448 449 450 451 452 453 454 455 456 457

    if( (info==NULL) || (info->dwMagic!=CRAM_MAGIC) )
        return ICERR_BADPARAM;

    /* FIXME: flags are ignored */

    width  = icd->lpbiInput->biWidth;
    height = icd->lpbiInput->biHeight;
    sz = icd->lpbiInput->biSizeImage;

458 459 460 461 462 463 464 465 466
    output = icd->lpOutput;

    if (icd->lpbiOutput->biBitCount != info->depth)
    {
        output = HeapAlloc(GetProcessHeap(), 0, icd->lpbiOutput->biWidth * icd->lpbiOutput->biHeight * info->depth / 8);
        if (!output) return ICERR_MEMORY;
    }

    if (info->depth == 8)
467
    {
468
        stride = get_stride(width, 8);
469
        msvideo1_decode_8bit( width, height, icd->lpInput, sz,
470
                              output, stride );
471 472 473
    }
    else
    {
474
        stride = get_stride(width, 16) / 2;
475
        msvideo1_decode_16bit( width, height, icd->lpInput, sz,
476 477 478 479 480 481 482
                               output, stride );
    }

    if (icd->lpbiOutput->biBitCount != info->depth)
    {
        convert_depth(output, info->depth, icd->lpOutput, icd->lpbiOutput);
        HeapFree(GetProcessHeap(), 0, output);
483 484 485 486 487
    }

    return ICERR_OK;
}

488
static LRESULT CRAM_DecompressEx( Msvideo1Context *info, ICDECOMPRESSEX *icd, DWORD size )
489 490
{
    LONG width, height, stride, sz;
491
    void *output;
492

493
    TRACE("ICM_DECOMPRESSEX %p %p %d\n", info, icd, size);
494 495 496 497 498 499 500 501 502 503

    if( (info==NULL) || (info->dwMagic!=CRAM_MAGIC) )
        return ICERR_BADPARAM;

    /* FIXME: flags are ignored */

    width  = icd->lpbiSrc->biWidth;
    height = icd->lpbiSrc->biHeight;
    sz = icd->lpbiSrc->biSizeImage;

504 505 506 507 508 509 510 511 512
    output = icd->lpDst;

    if (icd->lpbiDst->biBitCount != info->depth)
    {
        output = HeapAlloc(GetProcessHeap(), 0, icd->lpbiDst->biWidth * icd->lpbiDst->biHeight * info->depth / 8);
        if (!output) return ICERR_MEMORY;
    }

    if (info->depth == 8)
513
    {
514
        stride = get_stride(width, 8);
515
        msvideo1_decode_8bit( width, height, icd->lpSrc, sz, 
516
                              output, stride );
517 518 519
    }
    else
    {
520
        stride = get_stride(width, 16) / 2;
521
        msvideo1_decode_16bit( width, height, icd->lpSrc, sz,
522 523 524 525 526 527 528
                               output, stride );
    }

    if (icd->lpbiDst->biBitCount != info->depth)
    {
        convert_depth(output, info->depth, icd->lpDst, icd->lpbiDst);
        HeapFree(GetProcessHeap(), 0, output);
529 530 531 532 533
    }

    return ICERR_OK;
}

534
static LRESULT CRAM_GetInfo( const Msvideo1Context *info, ICINFO *icinfo, DWORD dwSize )
535 536 537 538 539 540 541 542
{
    if (!icinfo) return sizeof(ICINFO);
    if (dwSize < sizeof(ICINFO)) return 0;

    icinfo->dwSize = sizeof(ICINFO);
    icinfo->fccType = ICTYPE_VIDEO;
    icinfo->fccHandler = info ? info->dwMagic : CRAM_MAGIC;
    icinfo->dwFlags = 0;
543 544
    icinfo->dwVersion = ICVERSION;
    icinfo->dwVersionICM = ICVERSION;
545

546 547
    LoadStringW(MSVIDC32_hModule, IDS_NAME, icinfo->szName, ARRAY_SIZE(icinfo->szName));
    LoadStringW(MSVIDC32_hModule, IDS_DESCRIPTION, icinfo->szDescription, ARRAY_SIZE(icinfo->szDescription));
548 549 550 551 552
    /* msvfw32 will fill icinfo->szDriver for us */

    return sizeof(ICINFO);
}

553 554 555
/***********************************************************************
 *		DriverProc (MSVIDC32.@)
 */
556
LRESULT WINAPI CRAM_DriverProc( DWORD_PTR dwDriverId, HDRVR hdrvr, UINT msg,
557
                                LPARAM lParam1, LPARAM lParam2 )
558 559
{
    Msvideo1Context *info = (Msvideo1Context *) dwDriverId;
560
    LRESULT r = ICERR_UNSUPPORTED;
561

562
    TRACE("%ld %p %04x %08lx %08lx\n", dwDriverId, hdrvr, msg, lParam1, lParam2);
563 564 565 566 567 568 569 570 571 572 573 574

    switch( msg )
    {
    case DRV_LOAD:
        TRACE("Loaded\n");
        r = 1;
        break;

    case DRV_ENABLE:
        break;

    case DRV_OPEN:
575 576 577
    {
        ICINFO *icinfo = (ICINFO *)lParam2;

578
        TRACE("Opened\n");
579

580
        if (icinfo && compare_fourcc(icinfo->fccType, ICTYPE_VIDEO)) return 0;
581

582 583 584
        info = HeapAlloc( GetProcessHeap(), 0, sizeof (Msvideo1Context) );
        if( info )
        {
585
            memset( info, 0, sizeof *info );
586 587 588 589
            info->dwMagic = CRAM_MAGIC;
        }
        r = (LRESULT) info;
        break;
590
    }
591

592 593 594 595 596 597 598 599 600 601
    case DRV_CLOSE:
        HeapFree( GetProcessHeap(), 0, info );
        break;

    case DRV_DISABLE:
        break;

    case DRV_FREE:
        break;

602 603 604 605
    case ICM_GETINFO:
        r = CRAM_GetInfo( info, (ICINFO *)lParam1, (DWORD)lParam2 );
        break;

606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638
    case ICM_DECOMPRESS_QUERY:
        r = CRAM_DecompressQuery( info, (LPBITMAPINFO) lParam1,
                                       (LPBITMAPINFO) lParam2 );
        break;

    case ICM_DECOMPRESS_GET_FORMAT:
        r = CRAM_DecompressGetFormat( info, (LPBITMAPINFO) lParam1,
                                       (LPBITMAPINFO) lParam2 );
        break;

    case ICM_DECOMPRESS_GET_PALETTE:
        FIXME("ICM_DECOMPRESS_GET_PALETTE\n");
        break;

    case ICM_DECOMPRESSEX_QUERY:
        FIXME("ICM_DECOMPRESSEX_QUERY\n");
        break;

    case ICM_DECOMPRESS:
        r = CRAM_Decompress( info, (ICDECOMPRESS*) lParam1,
                                  (DWORD) lParam2 );
        break;

    case ICM_DECOMPRESS_BEGIN:
        r = CRAM_DecompressBegin( info, (LPBITMAPINFO) lParam1,
                                       (LPBITMAPINFO) lParam2 );
        break;

    case ICM_DECOMPRESSEX:
        r = CRAM_DecompressEx( info, (ICDECOMPRESSEX*) lParam1,
                                  (DWORD) lParam2 );
        break;

639 640 641 642
    case ICM_DECOMPRESS_END:
        r = ICERR_OK;
        break;

643 644
    case ICM_COMPRESS_QUERY:
        r = ICERR_BADFORMAT;
645 646 647 648 649
        /* fall through */
    case ICM_COMPRESS_GET_FORMAT:
    case ICM_COMPRESS_END:
    case ICM_COMPRESS:
        FIXME("compression not implemented\n");
650 651
        break;

652 653 654
    case ICM_CONFIGURE:
        break;

655 656 657 658 659 660
    default:
        FIXME("Unknown message: %04x %ld %ld\n", msg, lParam1, lParam2);
    }

    return r;
}
661

662 663 664
/***********************************************************************
 *		DllMain
 */
665 666
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved)
{
667
    TRACE("(%p,%d,%p)\n", hModule, dwReason, lpReserved);
668 669 670 671 672 673 674 675 676 677

    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hModule);
        MSVIDC32_hModule = hModule;
        break;
    }
    return TRUE;
}