[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, Sat Feb 22 08:24:01 2003 UTC revision 1.1.2.5, Tue Jun 10 10:07:03 2003 UTC
# Line 0  Line 1 
1    /**************************************************************************
2     *
3     *      XVID VFW FRONTEND
4     *      driverproc main
5     *
6     *      This program is free software; you can redistribute it and/or modify
7     *      it under the terms of the GNU General Public License as published by
8     *      the Free Software Foundation; either version 2 of the License, or
9     *      (at your option) any later version.
10     *
11     *      This program is distributed in the hope that it will be useful,
12     *      but WITHOUT ANY WARRANTY; without even the implied warranty of
13     *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     *      GNU General Public License for more details.
15     *
16     *      You should have received a copy of the GNU General Public License
17     *      along with this program; if not, write to the Free Software
18     *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19     *
20     *************************************************************************/
21    
22    /**************************************************************************
23     *
24     *      History:
25     *
26     *      31.08.2002      Configure() export
27     *      01.12.2001      inital version; (c)2001 peter ross <pross@xvid.org>
28     *
29     *************************************************************************/
30    
31    #include <windows.h>
32    #include <vfw.h>
33    #include "vfwext.h"
34    
35    #include "debug.h"
36    #include "codec.h"
37    #include "config.h"
38    #include "status.h"
39    #include "resource.h"
40    
41    
42    BOOL WINAPI DllMain(
43            HANDLE hModule,
44            DWORD  ul_reason_for_call,
45            LPVOID lpReserved)
46    {
47            g_hInst = (HINSTANCE) hModule;
48        return TRUE;
49    }
50    
51    
52    
53    /* __declspec(dllexport) */ LRESULT WINAPI DriverProc(
54            DWORD dwDriverId,
55            HDRVR hDriver,
56            UINT uMsg,
57            LPARAM lParam1,
58            LPARAM lParam2)
59    {
60            CODEC * codec = (CODEC *)dwDriverId;
61    
62            switch(uMsg)
63            {
64    
65            /* driver primitives */
66    
67            case DRV_LOAD :
68            case DRV_FREE :
69                    return DRV_OK;
70    
71            case DRV_OPEN :
72                    DPRINTF("DRV_OPEN");
73                    {
74                            ICOPEN * icopen = (ICOPEN *)lParam2;
75    
76                            if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO)
77                            {
78                                    return DRV_CANCEL;
79                            }
80    
81                            codec = malloc(sizeof(CODEC));
82    
83                            if (codec == NULL)
84                            {
85                                    if (icopen != NULL)
86                                    {
87                                            icopen->dwError = ICERR_MEMORY;
88                                    }
89                                    return 0;
90                            }
91    
92    
93                codec->status.hDlg = NULL;
94                codec->config.ci_valid = 0;
95                codec->ehandle = codec->dhandle = NULL;
96                codec->fbase = 25;
97                            codec->fincr = 1;
98                            config_reg_get(&codec->config);
99    
100    #if 0
101                            /* bad things happen if this piece of code is activated */
102                            if (lstrcmp(XVID_BUILD, codec->config.build))
103                            {
104                                    config_reg_default(&codec->config);
105                            }
106    #endif
107    
108                            if (icopen != NULL)
109                            {
110                                    icopen->dwError = ICERR_OK;
111                            }
112                            return (LRESULT)codec;
113                    }
114    
115            case DRV_CLOSE :
116                    DPRINTF("DRV_CLOSE");
117                    /* compress_end/decompress_end don't always get called */
118                    compress_end(codec);
119                    decompress_end(codec);
120            status_destroy_always(&codec->status);
121                    free(codec);
122                    return DRV_OK;
123    
124            case DRV_DISABLE :
125            case DRV_ENABLE :
126                    return DRV_OK;
127    
128            case DRV_INSTALL :
129            case DRV_REMOVE :
130                    return DRV_OK;
131    
132            case DRV_QUERYCONFIGURE :
133            case DRV_CONFIGURE :
134                    return DRV_CANCEL;
135    
136    
137            /* info */
138    
139            case ICM_GETINFO :
140                    DPRINTF("ICM_GETINFO");
141                    {
142                            ICINFO *icinfo = (ICINFO *)lParam1;
143    
144                            icinfo->fccType = ICTYPE_VIDEO;
145                            icinfo->fccHandler = FOURCC_XVID;
146                            icinfo->dwFlags =
147                                    VIDCF_FASTTEMPORALC |
148                                    VIDCF_FASTTEMPORALD |
149                                    VIDCF_COMPRESSFRAMES;
150    
151                            icinfo->dwVersion = 0;
152                            icinfo->dwVersionICM = ICVERSION;
153    
154                            wcscpy(icinfo->szName, XVID_NAME_L);
155                            wcscpy(icinfo->szDescription, XVID_DESC_L);
156    
157                            return lParam2; /* size of struct */
158                    }
159    
160                    /* state control */
161    
162            case ICM_ABOUT :
163                    DPRINTF("ICM_ABOUT");
164                    DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0);
165                    return ICERR_OK;
166    
167            case ICM_CONFIGURE :
168                    DPRINTF("ICM_CONFIGURE");
169                    if (lParam1 != -1)
170                    {
171                            CONFIG temp;
172    
173                            codec->config.save = FALSE;
174                            memcpy(&temp, &codec->config, sizeof(CONFIG));
175    
176                            DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp);
177    
178                            if (temp.save)
179                            {
180                                    memcpy(&codec->config, &temp, sizeof(CONFIG));
181                                    config_reg_set(&codec->config);
182                            }
183                    }
184                    return ICERR_OK;
185    
186            case ICM_GETSTATE :
187                    DPRINTF("ICM_GETSTATE");
188                    if ((void*)lParam1 == NULL)
189                    {
190                            return sizeof(CONFIG);
191                    }
192                    memcpy((void*)lParam1, &codec->config, sizeof(CONFIG));
193                    return ICERR_OK;
194    
195            case ICM_SETSTATE :
196                    DPRINTF("ICM_SETSTATE");
197                    if ((void*)lParam1 == NULL)
198                    {
199                            DPRINTF("ICM_SETSTATE : DEFAULT");
200                            config_reg_get(&codec->config);
201                            return 0;
202                    }
203                    memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG));
204                    return 0; /* sizeof(CONFIG); */
205    
206            /* not sure the difference, private/public data? */
207    
208            case ICM_GET :
209            case ICM_SET :
210                    return ICERR_OK;
211    
212    
213            /* older-stype config */
214    
215            case ICM_GETDEFAULTQUALITY :
216            case ICM_GETQUALITY :
217            case ICM_SETQUALITY :
218            case ICM_GETBUFFERSWANTED :
219            case ICM_GETDEFAULTKEYFRAMERATE :
220                    return ICERR_UNSUPPORTED;
221    
222    
223            /* compressor */
224    
225            case ICM_COMPRESS_QUERY :
226                    DPRINTF("ICM_COMPRESS_QUERY");
227                    return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
228    
229            case ICM_COMPRESS_GET_FORMAT :
230                    DPRINTF("ICM_COMPRESS_GET_FORMAT");
231                    return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
232    
233            case ICM_COMPRESS_GET_SIZE :
234                    DPRINTF("ICM_COMPRESS_GET_SIZE");
235                    return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
236    
237            case ICM_COMPRESS_FRAMES_INFO :
238                    DPRINTF("ICM_COMPRESS_FRAMES_INFO");
239                    return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1);
240    
241            case ICM_COMPRESS_BEGIN :
242                    DPRINTF("ICM_COMPRESS_BEGIN");
243                    return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
244    
245            case ICM_COMPRESS_END :
246                    DPRINTF("ICM_COMPRESS_END");
247                    return compress_end(codec);
248    
249            case ICM_COMPRESS :
250                    DPRINTF("ICM_COMPRESS");
251                    return compress(codec, (ICCOMPRESS *)lParam1);
252    
253            /* decompressor */
254    
255            case ICM_DECOMPRESS_QUERY :
256                    DPRINTF("ICM_DECOMPRESS_QUERY");
257                    return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
258    
259            case ICM_DECOMPRESS_GET_FORMAT :
260                    DPRINTF("ICM_DECOMPRESS_GET_FORMAT");
261                    return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
262    
263            case ICM_DECOMPRESS_BEGIN :
264                    DPRINTF("ICM_DECOMPRESS_BEGIN");
265                    return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
266    
267            case ICM_DECOMPRESS_END :
268                    DPRINTF("ICM_DECOMPRESS_END");
269                    return decompress_end(codec);
270    
271            case ICM_DECOMPRESS :
272                    DPRINTF("ICM_DECOMPRESS");
273                    return decompress(codec, (ICDECOMPRESS *)lParam1);
274    
275            case ICM_DECOMPRESS_GET_PALETTE :
276            case ICM_DECOMPRESS_SET_PALETTE :
277            case ICM_DECOMPRESSEX_QUERY:
278            case ICM_DECOMPRESSEX_BEGIN:
279            case ICM_DECOMPRESSEX_END:
280            case ICM_DECOMPRESSEX:
281                    return ICERR_UNSUPPORTED;
282    
283        /* VFWEXT entry point */
284        case ICM_USER+0x0fff :
285            if (lParam1 == VFWEXT_CONFIGURE_INFO) {
286                VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2;
287                DPRINTF("%i %i %i %i %i %i",
288                    info->ciWidth, info->ciHeight,
289                    info->ciRate, info->ciScale,
290                    info->ciActiveFrame, info->ciFrameCount);
291    
292                codec->config.ci_valid = 1;
293                memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T));
294                return ICERR_OK;
295            }
296            return ICERR_UNSUPPORTED;
297    
298            default:
299                    return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2);
300            }
301    }
302    
303    
304    void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow)
305    {
306            DWORD dwDriverId;
307    
308            dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0);
309            if (dwDriverId != (DWORD)NULL)
310            {
311                    DriverProc(dwDriverId, 0, ICM_CONFIGURE, (LPARAM)GetDesktopWindow(), 0);
312                    DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0);
313            }
314    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.5

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