1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
|
/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "resource.h"
#include "Mpeg2DecSettingsWnd.h"
#include "../../../DSUtil/DSUtil.h"
// ==>>> Resource identifier from "resource.h" present in mplayerc project!
#define ResStr(id) CString(MAKEINTRESOURCE(id))
//
// CMpeg2DecSettingsWnd
//
static TCHAR m_strBrightness[100];
static TCHAR m_strContrast[100];
static TCHAR m_strHue[100];
static TCHAR m_strSaturation[100];
CMpeg2DecSettingsWnd::CMpeg2DecSettingsWnd()
{
wcscpy (m_strBrightness, ResStr(IDS_MPEG2_BRIGHTNESS));
wcscpy (m_strContrast, ResStr(IDS_MPEG2_CONTRAST));
wcscpy (m_strHue, ResStr(IDS_MPEG2_HUE));
wcscpy (m_strSaturation, ResStr(IDS_MPEG2_SATURATION));
}
bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
ASSERT(!m_pM2DF);
m_pM2DF.Release();
POSITION pos = pUnks.GetHeadPosition();
while(pos && !(m_pM2DF = pUnks.GetNext(pos)));
if(!m_pM2DF) return false;
m_ditype = m_pM2DF->GetDeinterlaceMethod();
m_procamp[0] = m_pM2DF->GetBrightness();
m_procamp[1] = m_pM2DF->GetContrast();
m_procamp[2] = m_pM2DF->GetHue();
m_procamp[3] = m_pM2DF->GetSaturation();
m_forcedsubs = m_pM2DF->IsForcedSubtitlesEnabled();
m_planaryuv = m_pM2DF->IsPlanarYUVEnabled();
m_interlaced = m_pM2DF->IsInterlacedEnabled();
return true;
}
void CMpeg2DecSettingsWnd::OnDisconnect()
{
m_pM2DF.Release();
}
bool CMpeg2DecSettingsWnd::OnActivate()
{
DWORD dwStyle = WS_VISIBLE|WS_CHILD|WS_TABSTOP;
CPoint p(10, 10);
m_planaryuv_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_0), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK1);
m_planaryuv_check.SetCheck(m_planaryuv ? BST_CHECKED : BST_UNCHECKED);
p.y += m_fontheight + 5;
m_interlaced_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_1), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK2);
m_interlaced_check.SetCheck(m_interlaced ? BST_CHECKED : BST_UNCHECKED);
p.y += m_fontheight + 5;
m_forcedsubs_check.Create(ResStr(IDS_MPEG2DECSETTINGSWND_2), dwStyle|BS_AUTOCHECKBOX, CRect(p, CSize(300, m_fontheight)), this, IDC_PP_CHECK3);
m_forcedsubs_check.SetCheck(m_forcedsubs ? BST_CHECKED : BST_UNCHECKED);
p.y += m_fontheight + 5;
p.y += 10;
m_ditype_static.Create(ResStr(IDS_MPEG2_DEINTERLACING), dwStyle, CRect(p, CSize(70, m_fontheight)), this);
m_ditype_combo.Create(dwStyle|CBS_DROPDOWNLIST, CRect(p + CSize(85, -3), CSize(100, 200)), this, IDC_PP_COMBO1);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Auto")), (DWORD)DIAuto);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Weave")), (DWORD)DIWeave);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Blend")), (DWORD)DIBlend);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Bob")), (DWORD)DIBob);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("Field Shift")), (DWORD)DIFieldShift);
m_ditype_combo.SetItemData(m_ditype_combo.AddString(_T("ELA")), (DWORD)DIELA);
m_ditype_combo.SetCurSel(0);
for(int i = 0; i < m_ditype_combo.GetCount(); i++)
if((int)m_ditype_combo.GetItemData(i) == m_ditype)
m_ditype_combo.SetCurSel(i);
m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
p.y += m_fontheight + 20;
for(int i = 0, h = max(20, m_fontheight)+1; i < countof(m_procamp_slider); i++, p.y += h)
{
static const TCHAR* labels[] = {m_strBrightness, m_strContrast, m_strHue, m_strSaturation};
m_procamp_static[i].Create(labels[i], dwStyle, CRect(p, CSize(70, h)), this);
m_procamp_slider[i].Create(dwStyle, CRect(p + CPoint(80, 0), CSize(200, h)), this, IDC_PP_SLIDER1+i);
m_procamp_value[i].Create(_T(""), dwStyle, CRect(p + CPoint(280, 0), CSize(40, h)), this);
}
m_procamp_slider[0].SetRange(0, 2*128);
m_procamp_slider[0].SetTic(128);
m_procamp_slider[0].SetPos((int)(m_procamp[0] + (m_procamp[0] >= 0 ? 0.5f : -0.5f)) + 128);
m_procamp_slider[1].SetRange(0, 200);
m_procamp_slider[1].SetTic(100);
m_procamp_slider[1].SetPos((int)(100*m_procamp[1] + 0.5f));
m_procamp_slider[2].SetRange(0, 2*180);
m_procamp_slider[2].SetTic(180);
m_procamp_slider[2].SetPos((int)(m_procamp[2] + (m_procamp[2] >= 0 ? 0.5f : -0.5f)) + 180);
m_procamp_slider[3].SetRange(0, 200);
m_procamp_slider[3].SetTic(100);
m_procamp_slider[3].SetPos((int)(100*m_procamp[3] + 0.5f));
p.y += 5;
m_procamp_tv2pc.Create(_T("TV->PC"), dwStyle, CRect(p + CPoint(50 + 200/2 - 55, 0), CSize(80, 20)), this, IDC_PP_BUTTON1);
m_procamp_reset.Create(ResStr(IDS_MPEG2_RESET), dwStyle, CRect(p + CPoint(80 + 200/2 + 5, 0), CSize(80, 20)), this, IDC_PP_BUTTON2);
p.y += 30;
UpdateProcampValues();
m_note_static.Create(
ResStr(IDS_MPEG2DECSETTINGSWND_7) +
ResStr(IDS_MPEG2DECSETTINGSWND_8),
dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
pWnd->SetFont(&m_font, FALSE);
return true;
}
void CMpeg2DecSettingsWnd::OnDeactivate()
{
m_ditype = (ditype)m_ditype_combo.GetItemData(m_ditype_combo.GetCurSel());
m_procamp[0] = (float)m_procamp_slider[0].GetPos() - 128;
m_procamp[1] = (float)m_procamp_slider[1].GetPos() / 100;
m_procamp[2] = (float)m_procamp_slider[2].GetPos() - 180;
m_procamp[3] = (float)m_procamp_slider[3].GetPos() / 100;
m_planaryuv = !!IsDlgButtonChecked(m_planaryuv_check.GetDlgCtrlID());
m_interlaced = !!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID());
m_forcedsubs = !!IsDlgButtonChecked(m_forcedsubs_check.GetDlgCtrlID());
}
bool CMpeg2DecSettingsWnd::OnApply()
{
OnDeactivate();
if(m_pM2DF)
{
m_pM2DF->SetDeinterlaceMethod(m_ditype);
m_pM2DF->SetBrightness(m_procamp[0]);
m_pM2DF->SetContrast(m_procamp[1]);
m_pM2DF->SetHue(m_procamp[2]);
m_pM2DF->SetSaturation(m_procamp[3]);
m_pM2DF->EnableForcedSubtitles(m_forcedsubs);
m_pM2DF->EnablePlanarYUV(m_planaryuv);
m_pM2DF->EnableInterlaced(m_interlaced);
}
return true;
}
void CMpeg2DecSettingsWnd::UpdateProcampValues()
{
CString str;
str.Format(_T("%d"), m_procamp_slider[0].GetPos() - 128);
m_procamp_value[0].SetWindowText(str);
str.Format(_T("%d%%"), m_procamp_slider[1].GetPos());
m_procamp_value[1].SetWindowText(str);
str.Format(_T("%d"), m_procamp_slider[2].GetPos() - 180);
m_procamp_value[2].SetWindowText(str);
str.Format(_T("%d%%"), m_procamp_slider[3].GetPos());
m_procamp_value[3].SetWindowText(str);
}
BEGIN_MESSAGE_MAP(CMpeg2DecSettingsWnd, CInternalPropertyPageWnd)
ON_BN_CLICKED(IDC_PP_BUTTON1, OnButtonProcampPc2Tv)
ON_BN_CLICKED(IDC_PP_BUTTON2, OnButtonProcampReset)
ON_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
ON_WM_HSCROLL()
END_MESSAGE_MAP()
void CMpeg2DecSettingsWnd::OnButtonProcampPc2Tv()
{
m_procamp_slider[0].SetPos(128 - 16);
m_procamp_slider[1].SetPos(100 * 255/(235-16));
UpdateProcampValues();
}
void CMpeg2DecSettingsWnd::OnButtonProcampReset()
{
m_procamp_slider[0].SetPos(128);
m_procamp_slider[1].SetPos(100);
m_procamp_slider[2].SetPos(180);
m_procamp_slider[3].SetPos(100);
UpdateProcampValues();
}
void CMpeg2DecSettingsWnd::OnButtonInterlaced()
{
m_ditype_combo.EnableWindow(!IsDlgButtonChecked(m_interlaced_check.GetDlgCtrlID()));
}
void CMpeg2DecSettingsWnd::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
UpdateProcampValues();
__super::OnHScroll(nSBCode, nPos, pScrollBar);
}
|