[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.4, Mon Jun 9 01:25:19 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 "resource.h"
39    
40    
41    BOOL WINAPI DllMain(
42            HANDLE hModule,
43            DWORD  ul_reason_for_call,
44            LPVOID lpReserved)
45    {
46            g_hInst = (HINSTANCE) hModule;
47        return TRUE;
48    }
49    
50    
51    
52    /* __declspec(dllexport) */ LRESULT WINAPI DriverProc(
53            DWORD dwDriverId,
54            HDRVR hDriver,
55            UINT uMsg,
56            LPARAM lParam1,
57            LPARAM lParam2)
58    {
59            CODEC * codec = (CODEC *)dwDriverId;
60    
61            switch(uMsg)
62            {
63    
64            /* driver primitives */
65    
66            case DRV_LOAD :
67            case DRV_FREE :
68                    return DRV_OK;
69    
70            case DRV_OPEN :
71                    DPRINTF("DRV_OPEN");
72                    {
73                            ICOPEN * icopen = (ICOPEN *)lParam2;
74    
75                            if (icopen != NULL && icopen->fccType != ICTYPE_VIDEO)
76                            {
77                                    return DRV_CANCEL;
78                            }
79    
80                            codec = malloc(sizeof(CODEC));
81    
82                            if (codec == NULL)
83                            {
84                                    if (icopen != NULL)
85                                    {
86                                            icopen->dwError = ICERR_MEMORY;
87                                    }
88                                    return 0;
89                            }
90    
91                codec->config.ci_valid = 0;
92                codec->ehandle = codec->dhandle = NULL;
93                codec->fbase = 25;
94                            codec->fincr = 1;
95                            config_reg_get(&codec->config);
96    
97    #if 0
98                            /* bad things happen if this piece of code is activated */
99                            if (lstrcmp(XVID_BUILD, codec->config.build))
100                            {
101                                    config_reg_default(&codec->config);
102                            }
103    #endif
104    
105                            if (icopen != NULL)
106                            {
107                                    icopen->dwError = ICERR_OK;
108                            }
109                            return (LRESULT)codec;
110                    }
111    
112            case DRV_CLOSE :
113                    DPRINTF("DRV_CLOSE");
114                    /* compress_end/decompress_end don't always get called */
115                    compress_end(codec);
116                    decompress_end(codec);
117                    free(codec);
118                    return DRV_OK;
119    
120            case DRV_DISABLE :
121            case DRV_ENABLE :
122                    return DRV_OK;
123    
124            case DRV_INSTALL :
125            case DRV_REMOVE :
126                    return DRV_OK;
127    
128            case DRV_QUERYCONFIGURE :
129            case DRV_CONFIGURE :
130                    return DRV_CANCEL;
131    
132    
133            /* info */
134    
135            case ICM_GETINFO :
136                    DPRINTF("ICM_GETINFO");
137                    {
138                            ICINFO *icinfo = (ICINFO *)lParam1;
139    
140                            icinfo->fccType = ICTYPE_VIDEO;
141                            icinfo->fccHandler = FOURCC_XVID;
142                            icinfo->dwFlags =
143                                    VIDCF_FASTTEMPORALC |
144                                    VIDCF_FASTTEMPORALD |
145                                    VIDCF_COMPRESSFRAMES;
146    
147                            icinfo->dwVersion = 0;
148                            icinfo->dwVersionICM = ICVERSION;
149    
150                            wcscpy(icinfo->szName, XVID_NAME_L);
151                            wcscpy(icinfo->szDescription, XVID_DESC_L);
152    
153                            return lParam2; /* size of struct */
154                    }
155    
156                    /* state control */
157    
158            case ICM_ABOUT :
159                    DPRINTF("ICM_ABOUT");
160                    DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0);
161                    return ICERR_OK;
162    
163            case ICM_CONFIGURE :
164                    DPRINTF("ICM_CONFIGURE");
165                    if (lParam1 != -1)
166                    {
167                            CONFIG temp;
168    
169                            codec->config.save = FALSE;
170                            memcpy(&temp, &codec->config, sizeof(CONFIG));
171    
172                            DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp);
173    
174                            if (temp.save)
175                            {
176                                    memcpy(&codec->config, &temp, sizeof(CONFIG));
177                                    config_reg_set(&codec->config);
178                            }
179                    }
180                    return ICERR_OK;
181    
182            case ICM_GETSTATE :
183                    DPRINTF("ICM_GETSTATE");
184                    if ((void*)lParam1 == NULL)
185                    {
186                            return sizeof(CONFIG);
187                    }
188                    memcpy((void*)lParam1, &codec->config, sizeof(CONFIG));
189                    return ICERR_OK;
190    
191            case ICM_SETSTATE :
192                    DPRINTF("ICM_SETSTATE");
193                    if ((void*)lParam1 == NULL)
194                    {
195                            DPRINTF("ICM_SETSTATE : DEFAULT");
196                            config_reg_get(&codec->config);
197                            return 0;
198                    }
199                    memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG));
200                    return 0; /* sizeof(CONFIG); */
201    
202            /* not sure the difference, private/public data? */
203    
204            case ICM_GET :
205            case ICM_SET :
206                    return ICERR_OK;
207    
208    
209            /* older-stype config */
210    
211            case ICM_GETDEFAULTQUALITY :
212            case ICM_GETQUALITY :
213            case ICM_SETQUALITY :
214            case ICM_GETBUFFERSWANTED :
215            case ICM_GETDEFAULTKEYFRAMERATE :
216                    return ICERR_UNSUPPORTED;
217    
218    
219            /* compressor */
220    
221            case ICM_COMPRESS_QUERY :
222                    DPRINTF("ICM_COMPRESS_QUERY");
223                    return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
224    
225            case ICM_COMPRESS_GET_FORMAT :
226                    DPRINTF("ICM_COMPRESS_GET_FORMAT");
227                    return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
228    
229            case ICM_COMPRESS_GET_SIZE :
230                    DPRINTF("ICM_COMPRESS_GET_SIZE");
231                    return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
232    
233            case ICM_COMPRESS_FRAMES_INFO :
234                    DPRINTF("ICM_COMPRESS_FRAMES_INFO");
235                    return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1);
236    
237            case ICM_COMPRESS_BEGIN :
238                    DPRINTF("ICM_COMPRESS_BEGIN");
239                    return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
240    
241            case ICM_COMPRESS_END :
242                    DPRINTF("ICM_COMPRESS_END");
243                    return compress_end(codec);
244    
245            case ICM_COMPRESS :
246                    DPRINTF("ICM_COMPRESS");
247                    return compress(codec, (ICCOMPRESS *)lParam1);
248    
249            /* decompressor */
250    
251            case ICM_DECOMPRESS_QUERY :
252                    DPRINTF("ICM_DECOMPRESS_QUERY");
253                    return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
254    
255            case ICM_DECOMPRESS_GET_FORMAT :
256                    DPRINTF("ICM_DECOMPRESS_GET_FORMAT");
257                    return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
258    
259            case ICM_DECOMPRESS_BEGIN :
260                    DPRINTF("ICM_DECOMPRESS_BEGIN");
261                    return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
262    
263            case ICM_DECOMPRESS_END :
264                    DPRINTF("ICM_DECOMPRESS_END");
265                    return decompress_end(codec);
266    
267            case ICM_DECOMPRESS :
268                    DPRINTF("ICM_DECOMPRESS");
269                    return decompress(codec, (ICDECOMPRESS *)lParam1);
270    
271            case ICM_DECOMPRESS_GET_PALETTE :
272            case ICM_DECOMPRESS_SET_PALETTE :
273            case ICM_DECOMPRESSEX_QUERY:
274            case ICM_DECOMPRESSEX_BEGIN:
275            case ICM_DECOMPRESSEX_END:
276            case ICM_DECOMPRESSEX:
277                    return ICERR_UNSUPPORTED;
278    
279        /* VFWEXT entry point */
280        case ICM_USER+0x0fff :
281            if (lParam1 == VFWEXT_CONFIGURE_INFO) {
282                VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2;
283                DPRINTF("%i %i %i %i %i %i",
284                    info->ciWidth, info->ciHeight,
285                    info->ciRate, info->ciScale,
286                    info->ciActiveFrame, info->ciFrameCount);
287    
288                codec->config.ci_valid = 1;
289                memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T));
290                return ICERR_OK;
291            }
292            return ICERR_UNSUPPORTED;
293    
294            default:
295                    return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2);
296            }
297    }
298    
299    
300    void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow)
301    {
302            DWORD dwDriverId;
303    
304            dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0);
305            if (dwDriverId != (DWORD)NULL)
306            {
307                    DriverProc(dwDriverId, 0, ICM_CONFIGURE, 0, 0);
308                    DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0);
309            }
310    }

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

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