[cvs] / xvidcore / vfw / src / driverproc.c Repository:
ViewVC logotype

Diff of /xvidcore/vfw/src/driverproc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.1, Sat Feb 22 08:24:01 2003 UTC revision 1.12, Thu Dec 2 06:46:07 2010 UTC
# Line 1  Line 1 
1  /**************************************************************************  /*****************************************************************************
2   *   *
3   *      XVID VFW FRONTEND   *      XVID MPEG-4 VFW FRONTEND
4   *      driverproc main   *      - driverproc main -
5     *
6     *  Copyright(C) Peter Ross <pross@xvid.org>
7   *   *
8   *      This program is free software; you can redistribute it and/or modify   *      This program is free software; you can redistribute it and/or modify
9   *      it under the terms of the GNU General Public License as published by   *      it under the terms of the GNU General Public License as published by
# Line 15  Line 17 
17   *   *
18   *      You should have received a copy of the GNU General Public License   *      You should have received a copy of the GNU General Public License
19   *      along with this program; if not, write to the Free Software   *      along with this program; if not, write to the Free Software
20   *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *  
  *************************************************************************/  
   
 /**************************************************************************  
  *  
  *      History:  
21   *   *
22   *      31.08.2002      Configure() export   * $Id$
  *      01.12.2001      inital version; (c)2001 peter ross <pross@xvid.org>  
23   *   *
24   *************************************************************************/   ****************************************************************************/
25    
26  #include <windows.h>  #include <windows.h>
27  #include <vfw.h>  #include <vfw.h>
28    #include "vfwext.h"
29    
30    #include "debug.h"
31  #include "codec.h"  #include "codec.h"
32  #include "config.h"  #include "config.h"
33    #include "status.h"
34  #include "resource.h"  #include "resource.h"
35    
36    static int clean_dll_bindings(CODEC* codec);
37    
38  BOOL WINAPI DllMain(  INT_PTR WINAPI DllMain(
39          HANDLE hModule,          HANDLE hModule,
40          DWORD  ul_reason_for_call,          DWORD  ul_reason_for_call,
41          LPVOID lpReserved)          LPVOID lpReserved)
42  {  {
43          hInst = (HINSTANCE) hModule;          g_hInst = (HINSTANCE) hModule;
44      return TRUE;      return TRUE;
45  }  }
46    
   
   
47  /* __declspec(dllexport) */ LRESULT WINAPI DriverProc(  /* __declspec(dllexport) */ LRESULT WINAPI DriverProc(
48          DWORD dwDriverId,          DWORD_PTR dwDriverId,
49          HDRVR hDriver,          HDRVR hDriver,
50          UINT uMsg,          UINT uMsg,
51          LPARAM lParam1,          LPARAM lParam1,
# Line 63  Line 60 
60    
61          case DRV_LOAD :          case DRV_LOAD :
62          case DRV_FREE :          case DRV_FREE :
63                  return DRV_OK;                  return DRVCNF_OK;
64    
65          case DRV_OPEN :          case DRV_OPEN :
66                  DEBUG("DRV_OPEN");                  DPRINTF("DRV_OPEN");
67    
68                  {                  {
69                          ICOPEN * icopen = (ICOPEN *)lParam2;                          ICOPEN * icopen = (ICOPEN *)lParam2;
70    
71                          if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO)                          if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO)
72                          {                          {
73                                  return DRV_CANCEL;                                  return DRVCNF_CANCEL;
74                          }                          }
75    
76                          codec = malloc(sizeof(CODEC));                          codec = malloc(sizeof(CODEC));
# Line 86  Line 84 
84                                  return 0;                                  return 0;
85                          }                          }
86    
87                            memset(codec, 0, sizeof(CODEC));
88    
89                codec->status.hDlg = NULL;
90                codec->config.ci_valid = 0;
91                          codec->ehandle = codec->dhandle = NULL;                          codec->ehandle = codec->dhandle = NULL;
92                          codec->fbase = 25;                          codec->fbase = 25;
93                          codec->fincr = 1;                          codec->fincr = 1;
94                          config_reg_get(&codec->config);                          config_reg_get(&codec->config);
95    
96                          /* bad things happen if this is uncommented  #if 0
97                            /* bad things happen if this piece of code is activated */
98                          if (lstrcmp(XVID_BUILD, codec->config.build))                          if (lstrcmp(XVID_BUILD, codec->config.build))
99                          {                          {
100                                  config_reg_default(&codec->config);                                  config_reg_default(&codec->config);
101                          }                          }
102                          */  #endif
103    
104                          if (icopen != NULL)                          if (icopen != NULL)
105                          {                          {
# Line 106  Line 109 
109                  }                  }
110    
111          case DRV_CLOSE :          case DRV_CLOSE :
112                  DEBUG("DRV_CLOSE");                  DPRINTF("DRV_CLOSE");
113                  // compress_end/decompress_end don't always get called                  /* compress_end/decompress_end don't always get called */
114                  compress_end(codec);                  compress_end(codec);
115                  decompress_end(codec);                  decompress_end(codec);
116                    clean_dll_bindings(codec);
117            status_destroy_always(&codec->status);
118                  free(codec);                  free(codec);
119                  return DRV_OK;                  return DRVCNF_OK;
120    
121          case DRV_DISABLE :          case DRV_DISABLE :
122          case DRV_ENABLE :          case DRV_ENABLE :
123                  return DRV_OK;                  return DRVCNF_OK;
124    
125          case DRV_INSTALL :          case DRV_INSTALL :
126          case DRV_REMOVE :          case DRV_REMOVE :
127                  return DRV_OK;                  return DRVCNF_OK;
128    
129          case DRV_QUERYCONFIGURE :          case DRV_QUERYCONFIGURE :
130          case DRV_CONFIGURE :          case DRV_CONFIGURE :
131                  return DRV_CANCEL;                  return DRVCNF_CANCEL;
132    
133    
134          /* info */          /* info */
135    
136          case ICM_GETINFO :          case ICM_GETINFO :
137                  DEBUG("ICM_GETINFO");                  DPRINTF("ICM_GETINFO");
138                  {  
139                    if (lParam1 && lParam2 >= sizeof(ICINFO)) {
140                          ICINFO *icinfo = (ICINFO *)lParam1;                          ICINFO *icinfo = (ICINFO *)lParam1;
141    
142                          icinfo->fccType = ICTYPE_VIDEO;                          icinfo->fccType = ICTYPE_VIDEO;
# Line 141  Line 147 
147                                  VIDCF_COMPRESSFRAMES;                                  VIDCF_COMPRESSFRAMES;
148    
149                          icinfo->dwVersion = 0;                          icinfo->dwVersion = 0;
150    #if !defined(ICVERSION)
151    #define ICVERSION       0x0104
152    #endif
153                          icinfo->dwVersionICM = ICVERSION;                          icinfo->dwVersionICM = ICVERSION;
154    
155                          wcscpy(icinfo->szName, XVID_NAME_L);                          wcscpy(icinfo->szName, XVID_NAME_L);
# Line 149  Line 158 
158                          return lParam2; /* size of struct */                          return lParam2; /* size of struct */
159                  }                  }
160    
161                    return 0;       /* error */
162    
163                  /* state control */                  /* state control */
164    
165          case ICM_ABOUT :          case ICM_ABOUT :
166                  DEBUG("ICM_ABOUT");                  DPRINTF("ICM_ABOUT");
167                  DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0);                  DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0);
168                  return ICERR_OK;                  return ICERR_OK;
169    
170          case ICM_CONFIGURE :          case ICM_CONFIGURE :
171                  DEBUG("ICM_CONFIGURE");                  DPRINTF("ICM_CONFIGURE");
172                  if (lParam1 != -1)                  if (lParam1 != -1)
173                  {                  {
174                          CONFIG temp;                          CONFIG temp;
# Line 165  Line 176 
176                          codec->config.save = FALSE;                          codec->config.save = FALSE;
177                          memcpy(&temp, &codec->config, sizeof(CONFIG));                          memcpy(&temp, &codec->config, sizeof(CONFIG));
178    
179                          DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp);                          DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp);
180    
181                          if (temp.save)                          if (temp.save)
182                          {                          {
# Line 176  Line 187 
187                  return ICERR_OK;                  return ICERR_OK;
188    
189          case ICM_GETSTATE :          case ICM_GETSTATE :
190                  DEBUG("ICM_GETSTATE");                  DPRINTF("ICM_GETSTATE");
191                  if ((void*)lParam1 == NULL)                  if ((void*)lParam1 == NULL)
192                  {                  {
193                          return sizeof(CONFIG);                          return sizeof(CONFIG);
# Line 185  Line 196 
196                  return ICERR_OK;                  return ICERR_OK;
197    
198          case ICM_SETSTATE :          case ICM_SETSTATE :
199                  DEBUG("ICM_SETSTATE");                  DPRINTF("ICM_SETSTATE");
200                  if ((void*)lParam1 == NULL)                  if ((void*)lParam1 == NULL)
201                  {                  {
202                          DEBUG("ICM_SETSTATE : DEFAULT");                          DPRINTF("ICM_SETSTATE : DEFAULT");
203                          config_reg_get(&codec->config);                          config_reg_get(&codec->config);
204                          return 0;                          return 0;
205                  }                  }
206                  memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG));                  memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG));
207                  return 0; // sizeof(CONFIG);                  return 0; /* sizeof(CONFIG); */
208    
209          /* not sure the difference, private/public data? */          /* not sure the difference, private/public data? */
210    
# Line 215  Line 226 
226          /* compressor */          /* compressor */
227    
228          case ICM_COMPRESS_QUERY :          case ICM_COMPRESS_QUERY :
229                  DEBUG("ICM_COMPRESS_QUERY");                  DPRINTF("ICM_COMPRESS_QUERY");
230                  return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
231    
232          case ICM_COMPRESS_GET_FORMAT :          case ICM_COMPRESS_GET_FORMAT :
233                  DEBUG("ICM_COMPRESS_GET_FORMAT");                  DPRINTF("ICM_COMPRESS_GET_FORMAT");
234                  return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
235    
236          case ICM_COMPRESS_GET_SIZE :          case ICM_COMPRESS_GET_SIZE :
237                  DEBUG("ICM_COMPRESS_GET_SIZE");                  DPRINTF("ICM_COMPRESS_GET_SIZE");
238                  return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
239    
240          case ICM_COMPRESS_FRAMES_INFO :          case ICM_COMPRESS_FRAMES_INFO :
241                  DEBUG("ICM_COMPRESS_FRAMES_INFO");                  DPRINTF("ICM_COMPRESS_FRAMES_INFO");
242                  return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1);                  return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1);
243    
244          case ICM_COMPRESS_BEGIN :          case ICM_COMPRESS_BEGIN :
245                  DEBUG("ICM_COMPRESS_BEGIN");                  DPRINTF("ICM_COMPRESS_BEGIN");
246                  return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
247    
248          case ICM_COMPRESS_END :          case ICM_COMPRESS_END :
249                  DEBUG("ICM_COMPRESS_END");                  DPRINTF("ICM_COMPRESS_END");
250                  return compress_end(codec);                  return compress_end(codec);
251    
252          case ICM_COMPRESS :          case ICM_COMPRESS :
253                  DEBUG("ICM_COMPRESS");                  DPRINTF("ICM_COMPRESS");
254                  return compress(codec, (ICCOMPRESS *)lParam1);                  return compress(codec, (ICCOMPRESS *)lParam1);
255    
256          /* decompressor */          /* decompressor */
257    
258          case ICM_DECOMPRESS_QUERY :          case ICM_DECOMPRESS_QUERY :
259                  DEBUG("ICM_DECOMPRESS_QUERY");                  DPRINTF("ICM_DECOMPRESS_QUERY");
260                  return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
261    
262          case ICM_DECOMPRESS_GET_FORMAT :          case ICM_DECOMPRESS_GET_FORMAT :
263                  DEBUG("ICM_DECOMPRESS_GET_FORMAT");                  DPRINTF("ICM_DECOMPRESS_GET_FORMAT");
264                  return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
265    
266          case ICM_DECOMPRESS_BEGIN :          case ICM_DECOMPRESS_BEGIN :
267                  DEBUG("ICM_DECOMPRESS_BEGIN");                  DPRINTF("ICM_DECOMPRESS_BEGIN");
268                  return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);                  return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
269    
270          case ICM_DECOMPRESS_END :          case ICM_DECOMPRESS_END :
271                  DEBUG("ICM_DECOMPRESS_END");                  DPRINTF("ICM_DECOMPRESS_END");
272                  return decompress_end(codec);                  return decompress_end(codec);
273    
274          case ICM_DECOMPRESS :          case ICM_DECOMPRESS :
275                  DEBUG("ICM_DECOMPRESS");                  DPRINTF("ICM_DECOMPRESS");
276                  return decompress(codec, (ICDECOMPRESS *)lParam1);                  return decompress(codec, (ICDECOMPRESS *)lParam1);
277    
278          case ICM_DECOMPRESS_GET_PALETTE :          case ICM_DECOMPRESS_GET_PALETTE :
# Line 272  Line 283 
283          case ICM_DECOMPRESSEX:          case ICM_DECOMPRESSEX:
284                  return ICERR_UNSUPPORTED;                  return ICERR_UNSUPPORTED;
285    
286        /* VFWEXT entry point */
287        case ICM_USER+0x0fff :
288            if (lParam1 == VFWEXT_CONFIGURE_INFO) {
289                VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2;
290                DPRINTF("%i %i %i %i %i %i",
291                    info->ciWidth, info->ciHeight,
292                    info->ciRate, info->ciScale,
293                    info->ciActiveFrame, info->ciFrameCount);
294    
295                codec->config.ci_valid = 1;
296                memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T));
297                return ICERR_OK;
298            }
299            return ICERR_UNSUPPORTED;
300    
301          default:          default:
302                    if (uMsg < DRV_USER)
303                  return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2);                  return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2);
304                    else
305                            return ICERR_UNSUPPORTED;
306          }          }
307  }  }
308    
   
309  void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow)  void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow)
310  {  {
311          DWORD dwDriverId;          LRESULT dwDriverId;
312    
313          dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0);          dwDriverId = (LRESULT) DriverProc(0, 0, DRV_OPEN, 0, 0);
314          if (dwDriverId != (DWORD)NULL)          if (dwDriverId != (LRESULT)NULL)
315          {          {
316                  DriverProc(dwDriverId, 0, ICM_CONFIGURE, 0, 0);                  if (lstrcmpi(lpCmdLine, "about")==0) {
317                            DriverProc(dwDriverId, 0, ICM_ABOUT, (LPARAM)GetDesktopWindow(), 0);
318                    }else{
319                            DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0);
320                    }
321                  DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0);                  DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0);
322          }          }
323  }  }
324    
325    static int clean_dll_bindings(CODEC* codec)
326    {
327            if(codec->m_hdll)
328            {
329                    FreeLibrary(codec->m_hdll);
330                    codec->m_hdll = NULL;
331                    codec->xvid_global_func = NULL;
332                    codec->xvid_encore_func = NULL;
333                    codec->xvid_decore_func = NULL;
334                    codec->xvid_plugin_single_func = NULL;
335                    codec->xvid_plugin_2pass1_func = NULL;
336                    codec->xvid_plugin_2pass2_func = NULL;
337                    codec->xvid_plugin_lumimasking_func = NULL;
338                    codec->xvid_plugin_psnr_func = NULL;
339            }
340            return 0;
341    }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.12

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4