[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.3, Wed May 14 11:44:29 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                            /* bad things happen if this is uncommented
98                            if (lstrcmp(XVID_BUILD, codec->config.build))
99                            {
100                                    config_reg_default(&codec->config);
101                            }
102                            */
103    
104                            if (icopen != NULL)
105                            {
106                                    icopen->dwError = ICERR_OK;
107                            }
108                            return (LRESULT)codec;
109                    }
110    
111            case DRV_CLOSE :
112                    DPRINTF("DRV_CLOSE");
113                    // compress_end/decompress_end don't always get called
114                    compress_end(codec);
115                    decompress_end(codec);
116                    free(codec);
117                    return DRV_OK;
118    
119            case DRV_DISABLE :
120            case DRV_ENABLE :
121                    return DRV_OK;
122    
123            case DRV_INSTALL :
124            case DRV_REMOVE :
125                    return DRV_OK;
126    
127            case DRV_QUERYCONFIGURE :
128            case DRV_CONFIGURE :
129                    return DRV_CANCEL;
130    
131    
132            /* info */
133    
134            case ICM_GETINFO :
135                    DPRINTF("ICM_GETINFO");
136                    {
137                            ICINFO *icinfo = (ICINFO *)lParam1;
138    
139                            icinfo->fccType = ICTYPE_VIDEO;
140                            icinfo->fccHandler = FOURCC_XVID;
141                            icinfo->dwFlags =
142                                    VIDCF_FASTTEMPORALC |
143                                    VIDCF_FASTTEMPORALD |
144                                    VIDCF_COMPRESSFRAMES;
145    
146                            icinfo->dwVersion = 0;
147                            icinfo->dwVersionICM = ICVERSION;
148    
149                            wcscpy(icinfo->szName, XVID_NAME_L);
150                            wcscpy(icinfo->szDescription, XVID_DESC_L);
151    
152                            return lParam2; /* size of struct */
153                    }
154    
155                    /* state control */
156    
157            case ICM_ABOUT :
158                    DPRINTF("ICM_ABOUT");
159                    DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_ABOUT), (HWND)lParam1, about_proc, 0);
160                    return ICERR_OK;
161    
162            case ICM_CONFIGURE :
163                    DPRINTF("ICM_CONFIGURE");
164                    if (lParam1 != -1)
165                    {
166                            CONFIG temp;
167    
168                            codec->config.save = FALSE;
169                            memcpy(&temp, &codec->config, sizeof(CONFIG));
170    
171                            DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_MAIN), (HWND)lParam1, main_proc, (LPARAM)&temp);
172    
173                            if (temp.save)
174                            {
175                                    memcpy(&codec->config, &temp, sizeof(CONFIG));
176                                    config_reg_set(&codec->config);
177                            }
178                    }
179                    return ICERR_OK;
180    
181            case ICM_GETSTATE :
182                    DPRINTF("ICM_GETSTATE");
183                    if ((void*)lParam1 == NULL)
184                    {
185                            return sizeof(CONFIG);
186                    }
187                    memcpy((void*)lParam1, &codec->config, sizeof(CONFIG));
188                    return ICERR_OK;
189    
190            case ICM_SETSTATE :
191                    DPRINTF("ICM_SETSTATE");
192                    if ((void*)lParam1 == NULL)
193                    {
194                            DPRINTF("ICM_SETSTATE : DEFAULT");
195                            config_reg_get(&codec->config);
196                            return 0;
197                    }
198                    memcpy(&codec->config,(void*)lParam1, sizeof(CONFIG));
199                    return 0; // sizeof(CONFIG);
200    
201            /* not sure the difference, private/public data? */
202    
203            case ICM_GET :
204            case ICM_SET :
205                    return ICERR_OK;
206    
207    
208            /* older-stype config */
209    
210            case ICM_GETDEFAULTQUALITY :
211            case ICM_GETQUALITY :
212            case ICM_SETQUALITY :
213            case ICM_GETBUFFERSWANTED :
214            case ICM_GETDEFAULTKEYFRAMERATE :
215                    return ICERR_UNSUPPORTED;
216    
217    
218            /* compressor */
219    
220            case ICM_COMPRESS_QUERY :
221                    DPRINTF("ICM_COMPRESS_QUERY");
222                    return compress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
223    
224            case ICM_COMPRESS_GET_FORMAT :
225                    DPRINTF("ICM_COMPRESS_GET_FORMAT");
226                    return compress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
227    
228            case ICM_COMPRESS_GET_SIZE :
229                    DPRINTF("ICM_COMPRESS_GET_SIZE");
230                    return compress_get_size(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
231    
232            case ICM_COMPRESS_FRAMES_INFO :
233                    DPRINTF("ICM_COMPRESS_FRAMES_INFO");
234                    return compress_frames_info(codec, (ICCOMPRESSFRAMES *)lParam1);
235    
236            case ICM_COMPRESS_BEGIN :
237                    DPRINTF("ICM_COMPRESS_BEGIN");
238                    return compress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
239    
240            case ICM_COMPRESS_END :
241                    DPRINTF("ICM_COMPRESS_END");
242                    return compress_end(codec);
243    
244            case ICM_COMPRESS :
245                    DPRINTF("ICM_COMPRESS");
246                    return compress(codec, (ICCOMPRESS *)lParam1);
247    
248            /* decompressor */
249    
250            case ICM_DECOMPRESS_QUERY :
251                    DPRINTF("ICM_DECOMPRESS_QUERY");
252                    return decompress_query(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
253    
254            case ICM_DECOMPRESS_GET_FORMAT :
255                    DPRINTF("ICM_DECOMPRESS_GET_FORMAT");
256                    return decompress_get_format(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
257    
258            case ICM_DECOMPRESS_BEGIN :
259                    DPRINTF("ICM_DECOMPRESS_BEGIN");
260                    return decompress_begin(codec, (BITMAPINFO *)lParam1, (BITMAPINFO *)lParam2);
261    
262            case ICM_DECOMPRESS_END :
263                    DPRINTF("ICM_DECOMPRESS_END");
264                    return decompress_end(codec);
265    
266            case ICM_DECOMPRESS :
267                    DPRINTF("ICM_DECOMPRESS");
268                    return decompress(codec, (ICDECOMPRESS *)lParam1);
269    
270            case ICM_DECOMPRESS_GET_PALETTE :
271            case ICM_DECOMPRESS_SET_PALETTE :
272            case ICM_DECOMPRESSEX_QUERY:
273            case ICM_DECOMPRESSEX_BEGIN:
274            case ICM_DECOMPRESSEX_END:
275            case ICM_DECOMPRESSEX:
276                    return ICERR_UNSUPPORTED;
277    
278        /* VFWEXT entry point */
279        case ICM_USER+0x0fff :
280            if (lParam1 == VFWEXT_CONFIGURE_INFO) {
281                VFWEXT_CONFIGURE_INFO_T * info = (VFWEXT_CONFIGURE_INFO_T*)lParam2;
282                DPRINTF("%i %i %i %i %i %i",
283                    info->ciWidth, info->ciHeight,
284                    info->ciRate, info->ciScale,
285                    info->ciActiveFrame, info->ciFrameCount);
286    
287                codec->config.ci_valid = 1;
288                memcpy(&codec->config.ci, (void*)lParam2, sizeof(VFWEXT_CONFIGURE_INFO_T));
289                return ICERR_OK;
290            }
291            return ICERR_UNSUPPORTED;
292    
293            default:
294                    return DefDriverProc(dwDriverId, hDriver, uMsg, lParam1, lParam2);
295            }
296    }
297    
298    
299    void WINAPI Configure(HWND hwnd, HINSTANCE hinst, LPTSTR lpCmdLine, int nCmdShow)
300    {
301            DWORD dwDriverId;
302    
303            dwDriverId = DriverProc(0, 0, DRV_OPEN, 0, 0);
304            if (dwDriverId != (DWORD)NULL)
305            {
306                    DriverProc(dwDriverId, 0, ICM_CONFIGURE, 0, 0);
307                    DriverProc(dwDriverId, 0, DRV_CLOSE, 0, 0);
308            }
309    }

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

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