home *** CD-ROM | disk | FTP | other *** search
/ Spidla DivX / DivX.bin / LocoCodec / drvproc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2003-03-29  |  6.8 KB  |  210 lines

  1. //
  2. // lococodec v0.1 based on:
  3. //
  4. // Huffyuv v2.1.1, by Ben Rudiak-Gould.
  5. // http://www.math.berkeley.edu/~benrg/huffyuv.html
  6. //
  7. // Based on MSYUV sample code, which is:
  8. // Copyright (c) 1993 Microsoft Corporation.
  9. // All Rights Reserved.
  10. //
  11. // Changes copyright 2000 Ben Rudiak-Gould, and distributed under
  12. // the terms of the GNU General Public License, v2 or later.  See
  13. // http://www.gnu.org/copyleft/gpl.html.
  14. //
  15. // I edit these files in 10-point Verdana, a proportionally-spaced font.
  16. // You may notice formatting oddities if you use a monospaced font.
  17. //
  18.  
  19.  
  20. #include "lococodec.h"
  21.  
  22.  
  23. /***************************************************************************
  24.  * DriverProc  -  The entry point for an installable driver.
  25.  *
  26.  * PARAMETERS
  27.  * dwDriverId:  For most messages, <dwDriverId> is the DWORD
  28.  *     value that the driver returns in response to a <DRV_OPEN> message.
  29.  *     Each time that the driver is opened, through the <DrvOpen> API,
  30.  *     the driver receives a <DRV_OPEN> message and can return an
  31.  *     arbitrary, non-zero value. The installable driver interface
  32.  *     saves this value and returns a unique driver handle to the
  33.  *     application. Whenever the application sends a message to the
  34.  *     driver using the driver handle, the interface routes the message
  35.  *     to this entry point and passes the corresponding <dwDriverId>.
  36.  *     This mechanism allows the driver to use the same or different
  37.  *     identifiers for multiple opens but ensures that driver handles
  38.  *     are unique at the application interface layer.
  39.  *
  40.  *     The following messages are not related to a particular open
  41.  *     instance of the driver. For these messages, the dwDriverId
  42.  *     will always be zero.
  43.  *
  44.  *         DRV_LOAD, DRV_FREE, DRV_ENABLE, DRV_DISABLE, DRV_OPEN
  45.  *
  46.  * hDriver: This is the handle returned to the application by the
  47.  *    driver interface.
  48.  *
  49.  * uiMessage: The requested action to be performed. Message
  50.  *     values below <DRV_RESERVED> are used for globally defined messages.
  51.  *     Message values from <DRV_RESERVED> to <DRV_USER> are used for
  52.  *     defined driver protocols. Messages above <DRV_USER> are used
  53.  *     for driver specific messages.
  54.  *
  55.  * lParam1: Data for this message.  Defined separately for
  56.  *     each message
  57.  *
  58.  * lParam2: Data for this message.  Defined separately for
  59.  *     each message
  60.  *
  61.  * RETURNS
  62.  *   Defined separately for each message.
  63.  *
  64.  ***************************************************************************/
  65. LRESULT PASCAL DriverProc(DWORD dwDriverID, HDRVR hDriver, UINT uiMessage, LPARAM lParam1, LPARAM lParam2) {
  66.   CodecInst* pi = (CodecInst*)(UINT)dwDriverID;
  67.   switch (uiMessage) {
  68.     case DRV_LOAD:
  69.       return (LRESULT)1L;
  70.  
  71.     case DRV_FREE:
  72.       return (LRESULT)1L;
  73.  
  74.     case DRV_OPEN:
  75.       // GAAH! This used to return a pointer to 0xFFFF0000 when lParam==0!
  76.       return (LRESULT)(DWORD)(UINT) Open((ICOPEN*) lParam2);
  77.  
  78.     case DRV_CLOSE:
  79.       if (pi) Close(pi);
  80.       return (LRESULT)1L;
  81.  
  82.     /*********************************************************************
  83.  
  84.       state messages
  85.  
  86.     *********************************************************************/
  87.  
  88.     // cwk
  89.     case DRV_QUERYCONFIGURE:    // configuration from drivers applet
  90.       return (LRESULT)1L;
  91.  
  92.     case DRV_CONFIGURE:
  93.       pi->Configure((HWND)lParam1);
  94.       return DRV_OK;
  95.  
  96.     case ICM_CONFIGURE:
  97.       //
  98.       //  return ICERR_OK if you will do a configure box, error otherwise
  99.       //
  100.       if (lParam1 == -1)
  101.         return pi->QueryConfigure() ? ICERR_OK : ICERR_UNSUPPORTED;
  102.       else
  103.         return pi->Configure((HWND)lParam1);
  104.  
  105.     case ICM_ABOUT:
  106.       //
  107.       //  return ICERR_OK if you will do a about box, error otherwise
  108.       //
  109.       if (lParam1 == -1)
  110.         return pi->QueryAbout() ? ICERR_OK : ICERR_UNSUPPORTED;
  111.       else
  112.         return pi->About((HWND)lParam1);
  113.  
  114.     case ICM_GETSTATE:
  115.       return pi->GetState((LPVOID)lParam1, (DWORD)lParam2);
  116.  
  117.     case ICM_SETSTATE:
  118.       return pi->SetState((LPVOID)lParam1, (DWORD)lParam2);
  119.  
  120.     case ICM_GETINFO:
  121.       return pi->GetInfo((ICINFO*)lParam1, (DWORD)lParam2);
  122.  
  123.     case ICM_GETDEFAULTQUALITY:
  124.         if (lParam1) {
  125.         *((LPDWORD)lParam1) = 7500;
  126.         return ICERR_OK;
  127.       }
  128.       break;
  129.  
  130.     /*********************************************************************
  131.  
  132.       compression messages
  133.  
  134.     *********************************************************************/
  135.  
  136.     case ICM_COMPRESS_QUERY:
  137.       return pi->CompressQuery((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  138.  
  139.     case ICM_COMPRESS_BEGIN:
  140.       return pi->CompressBegin((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  141.  
  142.     case ICM_COMPRESS_GET_FORMAT:
  143.       return pi->CompressGetFormat((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  144.  
  145.     case ICM_COMPRESS_GET_SIZE:
  146.       return pi->CompressGetSize((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  147.  
  148.     case ICM_COMPRESS:
  149.       return pi->Compress((ICCOMPRESS*)lParam1, (DWORD)lParam2);
  150.  
  151.     case ICM_COMPRESS_END:
  152.       return pi->CompressEnd();
  153.  
  154.     /*********************************************************************
  155.  
  156.       decompress messages
  157.  
  158.     *********************************************************************/
  159.  
  160.     case ICM_DECOMPRESS_QUERY:
  161.       return pi->DecompressQuery((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  162.  
  163.     // ICM_DECOMPRESSEX_QUERY for ccesp added by wanton, correct parameter-handling added by bastel
  164.     case ICM_DECOMPRESSEX_QUERY:
  165.       return pi->DecompressQuery(((ICDECOMPRESSEX*)lParam1)->lpbiSrc, ((ICDECOMPRESSEX*)lParam1)->lpbiDst);
  166.  
  167.     case ICM_DECOMPRESS_BEGIN:
  168.       return pi->DecompressBegin((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  169.  
  170.     case ICM_DECOMPRESS_GET_FORMAT:
  171.       return pi->DecompressGetFormat((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  172.  
  173.     case ICM_DECOMPRESS_GET_PALETTE:
  174.       return pi->DecompressGetPalette((LPBITMAPINFOHEADER)lParam1, (LPBITMAPINFOHEADER)lParam2);
  175.  
  176.     case ICM_DECOMPRESS:
  177.       return pi->Decompress((ICDECOMPRESS*)lParam1, (DWORD)lParam2);
  178.  
  179.     case ICM_DECOMPRESS_END:
  180.       return pi->DecompressEnd();
  181.  
  182.     /*********************************************************************
  183.  
  184.       standard driver messages
  185.  
  186.     *********************************************************************/
  187.  
  188.     case DRV_DISABLE:
  189.     case DRV_ENABLE:
  190.       return (LRESULT)1L;
  191.  
  192.     case DRV_INSTALL:
  193.     case DRV_REMOVE:
  194.       return (LRESULT)DRV_OK;
  195.   }
  196.  
  197.   if (uiMessage < DRV_USER)
  198.     return DefDriverProc(dwDriverID, hDriver, uiMessage, lParam1, lParam2);
  199.   else
  200.     return ICERR_UNSUPPORTED;
  201. }
  202.  
  203.  
  204. HMODULE hmoduleLocoCodec=0;
  205.  
  206. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD, LPVOID) {
  207.   hmoduleLocoCodec = (HMODULE) hinstDLL;
  208.   return TRUE;
  209. }
  210.