[cvs] / xvidcore / dshow / src / config.c Repository:
ViewVC logotype

Diff of /xvidcore/dshow/src/config.c

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

revision 1.1, Sat Jan 31 13:44:33 2004 UTC revision 1.1.2.1, Sat Jan 31 13:44:33 2004 UTC
# Line 0  Line 1 
1    /*****************************************************************************
2     *
3     *  XVID MPEG-4 VIDEO CODEC
4     *  - Configuration processing -
5     *
6     *  Copyright(C) 2002-2004 Peter Ross <pross@xvid.org>
7     *
8     *  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
10     *  the Free Software Foundation ; either version 2 of the License, or
11     *  (at your option) any later version.
12     *
13     *  This program is distributed in the hope that it will be useful,
14     *  but WITHOUT ANY WARRANTY ; without even the implied warranty of
15     *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     *  GNU General Public License for more details.
17     *
18     *  You should have received a copy of the GNU General Public License
19     *  along with this program ; if not, write to the Free Software
20     *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21     *
22     * $Id$
23     *
24     ****************************************************************************/
25    
26    #include <windows.h>
27    #include <commctrl.h>
28    #include "config.h"
29    #include "debug.h"
30    #include "resource.h"
31    
32    
33    // -----------------------------------------
34    // global config structure
35    CONFIG g_config;
36    
37    
38    
39    void LoadRegistryInfo()
40    {
41            HKEY hKey;
42            DWORD size;
43            RegOpenKeyEx(XVID_REG_KEY, XVID_REG_SUBKEY, 0, KEY_READ, &hKey);
44    
45            // Set the default post-processing settings
46            REG_GET_N("Brightness", g_config.nBrightness, 25)
47            REG_GET_N("Deblock_Y",  g_config.nDeblock_Y, 0)
48            REG_GET_N("Deblock_UV", g_config.nDeblock_UV, 0)
49            REG_GET_N("Dering",  g_config.nDering, 0)
50            REG_GET_N("FilmEffect", g_config.nFilmEffect, 0)
51            REG_GET_N("ForceColorspace", g_config.nForceColorspace, 0)
52            REG_GET_N("FlipVideo",  g_config.nFlipVideo, 0)
53            REG_GET_N("Supported_4CC",  g_config.supported_4cc, 0)
54    
55            RegCloseKey(hKey);
56    }
57    
58    void SaveRegistryInfo()
59    {
60            HKEY hKey;
61            DWORD dispo;
62    
63            if (RegCreateKeyEx(
64                            XVID_REG_KEY,
65                            XVID_REG_SUBKEY,
66                            0,
67                            XVID_REG_CLASS,
68                            REG_OPTION_NON_VOLATILE,
69                            KEY_WRITE,
70                            0,
71                            &hKey,
72                            &dispo) != ERROR_SUCCESS)
73            {
74                    OutputDebugString("Couldn't create XVID_REG_SUBKEY");
75                    return;
76            }
77    
78            REG_SET_N("Brightness", g_config.nBrightness);
79            REG_SET_N("Deblock_Y",  g_config.nDeblock_Y);
80            REG_SET_N("Deblock_UV", g_config.nDeblock_UV);
81            REG_SET_N("Dering", g_config.nDering);
82            REG_SET_N("FilmEffect", g_config.nFilmEffect);
83            REG_SET_N("ForceColorspace", g_config.nForceColorspace);
84            REG_SET_N("FlipVideo", g_config.nFlipVideo);
85            REG_SET_N("Supported_4CC",  g_config.supported_4cc);
86    
87            RegCloseKey(hKey);
88    }
89    
90    
91    
92    BOOL CALLBACK adv_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
93    {
94            HWND hBrightness;
95    
96            switch ( uMsg )
97            {
98            case WM_DESTROY:
99                    {
100                            int nForceColorspace;
101                            nForceColorspace = SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_GETCURSEL, 0, 0);
102                            if ( g_config.nForceColorspace != nForceColorspace )
103                            {
104                                    MessageBox(0, "You have changed the output colorspace.\r\nClose the movie and open it for the new colorspace to take effect.", "XviD DShow", 0);
105                            }
106                            g_config.nForceColorspace = nForceColorspace;
107                            SaveRegistryInfo();
108                    }
109                    break;
110    
111            case WM_INITDIALOG:
112    
113                    // Load Force Colorspace Box
114                    SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"No Force");
115                    SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YV12");
116                    SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"YUY2");
117                    SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB24");
118                    SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_ADDSTRING, 0, (LPARAM)"RGB32");
119    
120                    // Select Colorspace
121                    SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
122    
123                    hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
124                    SendMessage(hBrightness, TBM_SETRANGE, (WPARAM) (BOOL) TRUE, (LPARAM) MAKELONG(0, 50));
125                    SendMessage(hBrightness, TBM_SETPOS, (WPARAM) (BOOL) TRUE, (LPARAM) g_config.nBrightness);
126    
127                    // Load Buttons
128                    SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
129                    SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
130                    SendMessage(GetDlgItem(hwnd, IDC_DERING), BM_SETCHECK, g_config.nDering, 0);
131                    SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
132                    SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
133    
134                    // 4CC checkbuttons
135                    SendMessage(GetDlgItem(hwnd, IDC_DIVX), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DIVX, 0);
136                    SendMessage(GetDlgItem(hwnd, IDC_DX50), BM_SETCHECK, g_config.supported_4cc & SUPPORT_DX50, 0);
137                    SendMessage(GetDlgItem(hwnd, IDC_MP4V), BM_SETCHECK, g_config.supported_4cc & SUPPORT_MP4V, 0);
138    
139                    // Set Date & Time of Compilation
140                    DPRINTF("(%s %s)", __DATE__, __TIME__);
141                    break;
142    
143            case WM_COMMAND:
144                    switch ( wParam )
145                    {
146                    case IDC_RESET:
147                            ZeroMemory(&g_config, sizeof(CONFIG));
148                            g_config.nBrightness = 25;
149                            hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
150                            SendMessage(hBrightness, TBM_SETPOS, (WPARAM) (BOOL) TRUE, (LPARAM) g_config.nBrightness);
151                            // Load Buttons
152                            SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_Y), BM_SETCHECK, g_config.nDeblock_Y, 0);
153                            SendMessage(GetDlgItem(hwnd, IDC_DEBLOCK_UV), BM_SETCHECK, g_config.nDeblock_UV, 0);
154                            SendMessage(GetDlgItem(hwnd, IDC_DERING), BM_SETCHECK, g_config.nDering, 0);
155                            SendMessage(GetDlgItem(hwnd, IDC_FILMEFFECT), BM_SETCHECK, g_config.nFilmEffect, 0);
156                            SendMessage(GetDlgItem(hwnd, IDC_FLIPVIDEO), BM_SETCHECK, g_config.nFlipVideo, 0);
157                            g_config.nForceColorspace = 0;
158                            SendMessage(GetDlgItem(hwnd, IDC_COLORSPACE), CB_SETCURSEL, g_config.nForceColorspace, 0);
159                            SaveRegistryInfo();
160    
161                            break;
162                    case IDC_DEBLOCK_Y:
163                            g_config.nDeblock_Y = !g_config.nDeblock_Y;
164                            SaveRegistryInfo();
165                            break;
166                    case IDC_DEBLOCK_UV:
167                            g_config.nDeblock_UV = !g_config.nDeblock_UV;
168                            SaveRegistryInfo();
169                            break;
170                    case IDC_DERING:
171                            g_config.nDering = !g_config.nDering;
172                            SaveRegistryInfo();
173                            break;
174                    case IDC_FILMEFFECT:
175                            g_config.nFilmEffect = !g_config.nFilmEffect;
176                            SaveRegistryInfo();
177                            break;
178                    case IDC_FLIPVIDEO:
179                            g_config.nFlipVideo = !g_config.nFlipVideo;
180                            SaveRegistryInfo();
181                            break;
182                    case IDC_DIVX:
183                            g_config.supported_4cc ^= SUPPORT_DIVX;
184                            SaveRegistryInfo();
185                            break;
186                    case IDC_DX50:
187                            g_config.supported_4cc ^= SUPPORT_DX50;
188                            SaveRegistryInfo();
189                            break;
190                    case IDC_MP4V:
191                            g_config.supported_4cc ^= SUPPORT_MP4V;
192                            SaveRegistryInfo();
193                            break;
194                    default :
195                            return FALSE;
196                    }
197                    break;
198            case WM_NOTIFY:
199                    hBrightness = GetDlgItem(hwnd, IDC_BRIGHTNESS);
200                    g_config.nBrightness = SendMessage(hBrightness, TBM_GETPOS, (WPARAM)NULL, (LPARAM)NULL);
201                    SaveRegistryInfo();
202                    break;
203            default :
204                    return FALSE;
205            }
206    
207            return TRUE; /* ok */
208    }
209    
210    
211    
212    
213    

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

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