PPageMpegDecoder.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 
00023 // CPPageMpegDecoder.cpp : implementation file
00024 //
00025 
00026 #include "stdafx.h"
00027 #include "mplayerc.h"
00028 #include "PPageMpegDecoder.h"
00029 #include "..\..\filters\transform\Mpeg2DecFilter\Mpeg2DecFilter.h"
00030 
00031 // CPPageMpegDecoder dialog
00032 
00033 IMPLEMENT_DYNAMIC(CPPageMpegDecoder, CPPageBase)
00034 CPPageMpegDecoder::CPPageMpegDecoder(IFilterGraph* pFG)
00035         : CPPageBase(CPPageMpegDecoder::IDD, CPPageMpegDecoder::IDD)
00036         , m_fForcedSubs(FALSE)
00037         , m_fPlanarYUV(FALSE)
00038 {
00039         m_pMpeg2DecFilter = FindFilter(__uuidof(CMpeg2DecFilter), pFG);
00040 }
00041 
00042 CPPageMpegDecoder::~CPPageMpegDecoder()
00043 {
00044 }
00045 
00046 void CPPageMpegDecoder::DoDataExchange(CDataExchange* pDX)
00047 {
00048         __super::DoDataExchange(pDX);
00049         DDX_Control(pDX, IDC_COMBO2, m_dilist);
00050         DDX_Control(pDX, IDC_SLIDER1, m_brightctrl);
00051         DDX_Control(pDX, IDC_SLIDER2, m_contctrl);
00052         DDX_Control(pDX, IDC_SLIDER3, m_huectrl);
00053         DDX_Control(pDX, IDC_SLIDER4, m_satctrl);
00054         DDX_Check(pDX, IDC_CHECK1, m_fForcedSubs);
00055         DDX_Check(pDX, IDC_CHECK2, m_fPlanarYUV);
00056 }
00057 
00058 
00059 BEGIN_MESSAGE_MAP(CPPageMpegDecoder, CPPageBase)
00060         ON_CBN_SELCHANGE(IDC_COMBO2, OnCbnSelchangeCombo2)
00061         ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
00062         ON_WM_HSCROLL()
00063         ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
00064         ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
00065         ON_BN_CLICKED(IDC_CHECK2, OnBnClickedCheck2)
00066         ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
00067 END_MESSAGE_MAP()
00068 
00069 
00070 // CPPageMpegDecoder message handlers
00071 
00072 BOOL CPPageMpegDecoder::OnInitDialog()
00073 {
00074         __super::OnInitDialog();
00075 
00076         AppSettings& s = AfxGetAppSettings();
00077 
00078         m_dilist.SetItemData(m_dilist.AddString(_T("Auto")), (DWORD)DIAuto);
00079         m_dilist.SetItemData(m_dilist.AddString(_T("Weave")), (DWORD)DIWeave);
00080         m_dilist.SetItemData(m_dilist.AddString(_T("Blend")), (DWORD)DIBlend);
00081         m_dilist.SetItemData(m_dilist.AddString(_T("Bob")), (DWORD)DIBob);
00082         m_dilist.SetCurSel(0);
00083         for(int i = 0; i < m_dilist.GetCount(); i++)
00084                 if((int)m_dilist.GetItemData(i) == s.mpegdi)
00085                         m_dilist.SetCurSel(i);
00086         m_brightctrl.SetRange(0, 2*128);
00087         m_brightctrl.SetTic(128);
00088         m_brightctrl.SetPos((int)(s.mpegbright)+128);
00089         m_contctrl.SetRange(0, 200);
00090         m_contctrl.SetTic(100);
00091         m_contctrl.SetPos((int)(100*s.mpegcont));
00092         m_huectrl.SetRange(0, 2*180);
00093         m_huectrl.SetTic(180);
00094         m_huectrl.SetPos((int)(s.mpeghue)+180);
00095         m_satctrl.SetRange(0, 200);
00096         m_satctrl.SetTic(100);
00097         m_satctrl.SetPos((int)(100*s.mpegsat));
00098         m_fForcedSubs = s.mpegforcedsubs;
00099         m_fPlanarYUV = s.mpegplanaryuv;
00100 
00101         UpdateData(FALSE);
00102 
00103         return TRUE;  // return TRUE unless you set the focus to a control
00104         // EXCEPTION: OCX Property Pages should return FALSE
00105 }
00106 
00107 BOOL CPPageMpegDecoder::OnApply()
00108 {
00109         UpdateData();
00110 
00111         AppSettings& s = AfxGetAppSettings();
00112 
00113         s.mpegdi = (int)m_dilist.GetItemData(m_dilist.GetCurSel());
00114         s.mpegbright = (double)m_brightctrl.GetPos()-128;
00115         s.mpegcont = (double)m_contctrl.GetPos() / 100;
00116         s.mpeghue = (double)m_huectrl.GetPos()-180;
00117         s.mpegsat = (double)m_satctrl.GetPos() / 100;
00118         s.mpegforcedsubs = !!m_fForcedSubs;
00119         s.mpegplanaryuv = !!m_fPlanarYUV;
00120 
00121         if(m_pMpeg2DecFilter)
00122         {
00123                 m_pMpeg2DecFilter->SetDeinterlaceMethod((ditype)s.mpegdi);
00124                 m_pMpeg2DecFilter->SetBrightness(s.mpegbright);
00125                 m_pMpeg2DecFilter->SetContrast(s.mpegcont);
00126                 m_pMpeg2DecFilter->SetHue(s.mpeghue);
00127                 m_pMpeg2DecFilter->SetSaturation(s.mpegsat);
00128                 m_pMpeg2DecFilter->EnableForcedSubtitles(s.mpegforcedsubs);
00129                 m_pMpeg2DecFilter->EnablePlanarYUV(s.mpegplanaryuv);
00130         }
00131 
00132         return __super::OnApply();
00133 }
00134 
00135 void CPPageMpegDecoder::OnCbnSelchangeCombo2()
00136 {
00137         SetModified();
00138 
00139         if(m_pMpeg2DecFilter)
00140                 m_pMpeg2DecFilter->SetDeinterlaceMethod((ditype)m_dilist.GetItemData(m_dilist.GetCurSel()));
00141 }
00142 
00143 void CPPageMpegDecoder::OnCbnSelchangeCombo1()
00144 {
00145         SetModified();
00146 }
00147 
00148 void CPPageMpegDecoder::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
00149 {
00150         SetModified();
00151 
00152         if(m_pMpeg2DecFilter)
00153         {
00154                 if(*pScrollBar == m_brightctrl)
00155                         m_pMpeg2DecFilter->SetBrightness((double)m_brightctrl.GetPos()-128);
00156                 else if(*pScrollBar == m_contctrl)
00157                         m_pMpeg2DecFilter->SetContrast((double)m_contctrl.GetPos() / 100);
00158                 else if(*pScrollBar == m_huectrl)
00159                         m_pMpeg2DecFilter->SetHue((double)m_huectrl.GetPos()-180);
00160                 else if(*pScrollBar == m_satctrl)
00161                         m_pMpeg2DecFilter->SetSaturation((double)m_satctrl.GetPos() / 100);
00162         }
00163 
00164         CPPageBase::OnHScroll(nSBCode, nPos, pScrollBar);
00165 }
00166 
00167 void CPPageMpegDecoder::OnBnClickedCheck1()
00168 {
00169         SetModified();
00170 
00171         UpdateData();
00172 
00173         if(m_pMpeg2DecFilter)
00174                 m_pMpeg2DecFilter->EnableForcedSubtitles(!!m_fForcedSubs);
00175 }
00176 
00177 void CPPageMpegDecoder::OnBnClickedButton1()
00178 {
00179         SetModified();
00180 
00181         m_brightctrl.SetPos(128);
00182         m_contctrl.SetPos(100);
00183         m_huectrl.SetPos(180);
00184         m_satctrl.SetPos(100);
00185 
00186         if(m_pMpeg2DecFilter)
00187         {
00188                 m_pMpeg2DecFilter->SetBrightness((double)m_brightctrl.GetPos()-128);
00189                 m_pMpeg2DecFilter->SetContrast((double)m_contctrl.GetPos() / 100);
00190                 m_pMpeg2DecFilter->SetHue((double)m_huectrl.GetPos()-180);
00191                 m_pMpeg2DecFilter->SetSaturation((double)m_satctrl.GetPos() / 100);
00192         }
00193 }
00194 
00195 void CPPageMpegDecoder::OnBnClickedCheck2()
00196 {
00197         SetModified();
00198 
00199         UpdateData();
00200 
00201         if(m_pMpeg2DecFilter)
00202                 m_pMpeg2DecFilter->EnablePlanarYUV(!!m_fPlanarYUV);
00203 }
00204 
00205 void CPPageMpegDecoder::OnBnClickedButton2()
00206 {
00207         SetModified();
00208 
00209         m_brightctrl.SetPos(128-16);
00210         m_contctrl.SetPos(100*255/(235-16));
00211 
00212         if(m_pMpeg2DecFilter)
00213         {
00214                 m_pMpeg2DecFilter->SetBrightness((double)m_brightctrl.GetPos()-128);
00215                 m_pMpeg2DecFilter->SetContrast((double)m_contctrl.GetPos() / 100);
00216         }
00217 }

Generated on Tue Dec 13 14:47:01 2005 for guliverkli by  doxygen 1.4.5