PPageMpegDecoder.cpp
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:6k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. /* 
  2.  * Copyright (C) 2003-2005 Gabest
  3.  * http://www.gabest.org
  4.  *
  5.  *  This Program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2, or (at your option)
  8.  *  any later version.
  9.  *   
  10.  *  This Program is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13.  *  GNU General Public License for more details.
  14.  *   
  15.  *  You should have received a copy of the GNU General Public License
  16.  *  along with GNU Make; see the file COPYING.  If not, write to
  17.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  18.  *  http://www.gnu.org/copyleft/gpl.html
  19.  *
  20.  */
  21. // CPPageMpegDecoder.cpp : implementation file
  22. //
  23. #include "stdafx.h"
  24. #include "mplayerc.h"
  25. #include "PPageMpegDecoder.h"
  26. #include "....filterstransformMpeg2DecFilterMpeg2DecFilter.h"
  27. // CPPageMpegDecoder dialog
  28. IMPLEMENT_DYNAMIC(CPPageMpegDecoder, CPPageBase)
  29. CPPageMpegDecoder::CPPageMpegDecoder(IFilterGraph* pFG)
  30. : CPPageBase(CPPageMpegDecoder::IDD, CPPageMpegDecoder::IDD)
  31. , m_fForcedSubs(FALSE)
  32. , m_fPlanarYUV(FALSE)
  33. {
  34. m_pMpeg2DecFilter = FindFilter(__uuidof(CMpeg2DecFilter), pFG);
  35. }
  36. CPPageMpegDecoder::~CPPageMpegDecoder()
  37. {
  38. }
  39. void CPPageMpegDecoder::DoDataExchange(CDataExchange* pDX)
  40. {
  41. __super::DoDataExchange(pDX);
  42. DDX_Control(pDX, IDC_COMBO2, m_dilist);
  43. DDX_Control(pDX, IDC_SLIDER1, m_brightctrl);
  44. DDX_Control(pDX, IDC_SLIDER2, m_contctrl);
  45. DDX_Control(pDX, IDC_SLIDER3, m_huectrl);
  46. DDX_Control(pDX, IDC_SLIDER4, m_satctrl);
  47. DDX_Check(pDX, IDC_CHECK1, m_fForcedSubs);
  48. DDX_Check(pDX, IDC_CHECK2, m_fPlanarYUV);
  49. }
  50. BEGIN_MESSAGE_MAP(CPPageMpegDecoder, CPPageBase)
  51. ON_CBN_SELCHANGE(IDC_COMBO2, OnCbnSelchangeCombo2)
  52. ON_CBN_SELCHANGE(IDC_COMBO1, OnCbnSelchangeCombo1)
  53. ON_WM_HSCROLL()
  54. ON_BN_CLICKED(IDC_CHECK1, OnBnClickedCheck1)
  55. ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
  56. ON_BN_CLICKED(IDC_CHECK2, OnBnClickedCheck2)
  57. ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
  58. END_MESSAGE_MAP()
  59. // CPPageMpegDecoder message handlers
  60. BOOL CPPageMpegDecoder::OnInitDialog()
  61. {
  62. __super::OnInitDialog();
  63. AppSettings& s = AfxGetAppSettings();
  64. m_dilist.SetItemData(m_dilist.AddString(_T("Auto")), (DWORD)DIAuto);
  65. m_dilist.SetItemData(m_dilist.AddString(_T("Weave")), (DWORD)DIWeave);
  66. m_dilist.SetItemData(m_dilist.AddString(_T("Blend")), (DWORD)DIBlend);
  67. m_dilist.SetItemData(m_dilist.AddString(_T("Bob")), (DWORD)DIBob);
  68. m_dilist.SetCurSel(0);
  69. for(int i = 0; i < m_dilist.GetCount(); i++)
  70. if((int)m_dilist.GetItemData(i) == s.mpegdi)
  71. m_dilist.SetCurSel(i);
  72. m_brightctrl.SetRange(0, 2*128);
  73. m_brightctrl.SetTic(128);
  74. m_brightctrl.SetPos((int)(s.mpegbright)+128);
  75. m_contctrl.SetRange(0, 200);
  76. m_contctrl.SetTic(100);
  77. m_contctrl.SetPos((int)(100*s.mpegcont));
  78. m_huectrl.SetRange(0, 2*180);
  79. m_huectrl.SetTic(180);
  80. m_huectrl.SetPos((int)(s.mpeghue)+180);
  81. m_satctrl.SetRange(0, 200);
  82. m_satctrl.SetTic(100);
  83. m_satctrl.SetPos((int)(100*s.mpegsat));
  84. m_fForcedSubs = s.mpegforcedsubs;
  85. m_fPlanarYUV = s.mpegplanaryuv;
  86. UpdateData(FALSE);
  87. return TRUE;  // return TRUE unless you set the focus to a control
  88. // EXCEPTION: OCX Property Pages should return FALSE
  89. }
  90. BOOL CPPageMpegDecoder::OnApply()
  91. {
  92. UpdateData();
  93. AppSettings& s = AfxGetAppSettings();
  94. s.mpegdi = (int)m_dilist.GetItemData(m_dilist.GetCurSel());
  95. s.mpegbright = (double)m_brightctrl.GetPos()-128;
  96. s.mpegcont = (double)m_contctrl.GetPos() / 100;
  97. s.mpeghue = (double)m_huectrl.GetPos()-180;
  98. s.mpegsat = (double)m_satctrl.GetPos() / 100;
  99. s.mpegforcedsubs = !!m_fForcedSubs;
  100. s.mpegplanaryuv = !!m_fPlanarYUV;
  101. if(m_pMpeg2DecFilter)
  102. {
  103. m_pMpeg2DecFilter->SetDeinterlaceMethod((ditype)s.mpegdi);
  104. m_pMpeg2DecFilter->SetBrightness(s.mpegbright);
  105. m_pMpeg2DecFilter->SetContrast(s.mpegcont);
  106. m_pMpeg2DecFilter->SetHue(s.mpeghue);
  107. m_pMpeg2DecFilter->SetSaturation(s.mpegsat);
  108. m_pMpeg2DecFilter->EnableForcedSubtitles(s.mpegforcedsubs);
  109. m_pMpeg2DecFilter->EnablePlanarYUV(s.mpegplanaryuv);
  110. }
  111. return __super::OnApply();
  112. }
  113. void CPPageMpegDecoder::OnCbnSelchangeCombo2()
  114. {
  115. SetModified();
  116. if(m_pMpeg2DecFilter)
  117. m_pMpeg2DecFilter->SetDeinterlaceMethod((ditype)m_dilist.GetItemData(m_dilist.GetCurSel()));
  118. }
  119. void CPPageMpegDecoder::OnCbnSelchangeCombo1()
  120. {
  121. SetModified();
  122. }
  123. void CPPageMpegDecoder::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
  124. {
  125. SetModified();
  126. if(m_pMpeg2DecFilter)
  127. {
  128. if(*pScrollBar == m_brightctrl)
  129. m_pMpeg2DecFilter->SetBrightness((double)m_brightctrl.GetPos()-128);
  130. else if(*pScrollBar == m_contctrl)
  131. m_pMpeg2DecFilter->SetContrast((double)m_contctrl.GetPos() / 100);
  132. else if(*pScrollBar == m_huectrl)
  133. m_pMpeg2DecFilter->SetHue((double)m_huectrl.GetPos()-180);
  134. else if(*pScrollBar == m_satctrl)
  135. m_pMpeg2DecFilter->SetSaturation((double)m_satctrl.GetPos() / 100);
  136. }
  137. CPPageBase::OnHScroll(nSBCode, nPos, pScrollBar);
  138. }
  139. void CPPageMpegDecoder::OnBnClickedCheck1()
  140. {
  141. SetModified();
  142. UpdateData();
  143. if(m_pMpeg2DecFilter)
  144. m_pMpeg2DecFilter->EnableForcedSubtitles(!!m_fForcedSubs);
  145. }
  146. void CPPageMpegDecoder::OnBnClickedButton1()
  147. {
  148. SetModified();
  149. m_brightctrl.SetPos(128);
  150. m_contctrl.SetPos(100);
  151. m_huectrl.SetPos(180);
  152. m_satctrl.SetPos(100);
  153. if(m_pMpeg2DecFilter)
  154. {
  155. m_pMpeg2DecFilter->SetBrightness((double)m_brightctrl.GetPos()-128);
  156. m_pMpeg2DecFilter->SetContrast((double)m_contctrl.GetPos() / 100);
  157. m_pMpeg2DecFilter->SetHue((double)m_huectrl.GetPos()-180);
  158. m_pMpeg2DecFilter->SetSaturation((double)m_satctrl.GetPos() / 100);
  159. }
  160. }
  161. void CPPageMpegDecoder::OnBnClickedCheck2()
  162. {
  163. SetModified();
  164. UpdateData();
  165. if(m_pMpeg2DecFilter)
  166. m_pMpeg2DecFilter->EnablePlanarYUV(!!m_fPlanarYUV);
  167. }
  168. void CPPageMpegDecoder::OnBnClickedButton2()
  169. {
  170. SetModified();
  171. m_brightctrl.SetPos(128-16);
  172. m_contctrl.SetPos(100*255/(235-16));
  173. if(m_pMpeg2DecFilter)
  174. {
  175. m_pMpeg2DecFilter->SetBrightness((double)m_brightctrl.GetPos()-128);
  176. m_pMpeg2DecFilter->SetContrast((double)m_contctrl.GetPos() / 100);
  177. }
  178. }