- Main Page
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

# PPageAudioDecoder.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 // PPageAudioDecoder.cpp : implementation file
    00023 //
    00024
    00025 #include "stdafx.h"
    00026 #include <math.h>
    00027 #include "mplayerc.h"
    00028 #include "PPageAudioDecoder.h"
    00029 #include ".\ppageaudiodecoder.h"
    00030
    00031 // CPPageAudioDecoder dialog
    00032
    00033 IMPLEMENT_DYNAMIC(CPPageAudioDecoder, CPPageBase)
    00034 CPPageAudioDecoder::CPPageAudioDecoder(IFilterGraph* pFG)
    00035         : CPPageBase(CPPageAudioDecoder::IDD, CPPageAudioDecoder::IDD)
    00036         , m_iSampleFormat(0)
    00037         , m_fNormalize(FALSE)
    00038         , m_fAc3SpeakerConfig(FALSE)
    00039         , m_iAc3SpeakerConfig(0)
    00040         , m_fAc3SpeakerConfigLFE(FALSE)
    00041         , m_fAc3DynamicRangeControl(FALSE)
    00042         , m_fDtsSpeakerConfig(FALSE)
    00043         , m_iDtsSpeakerConfig(0)
    00044         , m_fDtsSpeakerConfigLFE(FALSE)
    00045         , m_fDtsDynamicRangeControl(FALSE)
    00046         , m_iAacSpeakerConfig(0)
    00047         , m_boost(0)
    00048 {
    00049         BeginEnumFilters(pFG, pEF, pBF)
    00050                 if(CComQIPtr<IMpaDecFilter> pMpaDecFilter = pBF)
    00051                         m_pMDFs.AddTail(pMpaDecFilter);
    00052         EndEnumFilters
    00053 }
    00054
    00055 CPPageAudioDecoder::~CPPageAudioDecoder()
    00056 {
    00057 }
    00058
    00059 void CPPageAudioDecoder::DoDataExchange(CDataExchange* pDX)
    00060 {
    00061         __super::DoDataExchange(pDX);
    00062         DDX_Radio(pDX, IDC_RADIO1, m_iSampleFormat);
    00063         DDX_Check(pDX, IDC_CHECK3, m_fNormalize);
    00064         DDX_Radio(pDX, IDC_RADIO5, m_fAc3SpeakerConfig);
    00065         DDX_CBIndex(pDX, IDC_COMBO1, m_iAc3SpeakerConfig);
    00066         DDX_Check(pDX, IDC_CHECK1, m_fAc3SpeakerConfigLFE);
    00067         DDX_Check(pDX, IDC_CHECK2, m_fAc3DynamicRangeControl);
    00068         DDX_Control(pDX, IDC_COMBO1, m_ac3sclist);
    00069         DDX_Radio(pDX, IDC_RADIO12, m_fDtsSpeakerConfig);
    00070         DDX_CBIndex(pDX, IDC_COMBO2, m_iDtsSpeakerConfig);
    00071         DDX_Check(pDX, IDC_CHECK17, m_fDtsSpeakerConfigLFE);
    00072         DDX_Check(pDX, IDC_CHECK4, m_fDtsDynamicRangeControl);
    00073         DDX_Control(pDX, IDC_COMBO2, m_dtssclist);
    00074         DDX_Check(pDX, IDC_CHECK5, m_iAacSpeakerConfig);
    00075         DDX_Slider(pDX, IDC_SLIDER1, m_boost);
    00076         DDX_Control(pDX, IDC_SLIDER1, m_boostctrl);
    00077 }
    00078
    00079
    00080 BEGIN_MESSAGE_MAP(CPPageAudioDecoder, CPPageBase)
    00081         ON_WM_HSCROLL()
    00082 END_MESSAGE_MAP()
    00083
    00084
    00085 // CPPageAudioDecoder message handlers
    00086
    00087 BOOL CPPageAudioDecoder::OnInitDialog()
    00088 {
    00089         __super::OnInitDialog();
    00090
    00091         AppSettings& s = AfxGetAppSettings();
    00092
    00093         m_iSampleFormat = s.mpasf;
    00094         m_fNormalize = s.mpanormalize;
    00095         m_fAc3SpeakerConfig = s.ac3sc < 0;
    00096         m_iAc3SpeakerConfig = A52_STEREO;
    00097         m_fAc3SpeakerConfigLFE = !!(abs(s.ac3sc)&A52_LFE);
    00098         m_fAc3DynamicRangeControl = s.ac3drc;
    00099         m_fDtsSpeakerConfig = s.dtssc < 0;
    00100         m_iDtsSpeakerConfig = DTS_STEREO;
    00101         m_fDtsSpeakerConfigLFE = !!(abs(s.dtssc)&DTS_LFE);
    00102         m_fDtsDynamicRangeControl = s.dtsdrc;
    00103         m_iAacSpeakerConfig = s.aacsc; // FIXME
    00104         m_boost = (int)(50.0f*log10(s.mpaboost));
    00105         m_boostctrl.SetRange(0, 100);
    00106
    00107         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("Mono")), A52_MONO);
    00108         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("Dual Mono")), A52_CHANNEL);
    00109         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("Stereo")), A52_STEREO);
    00110         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("Dolby Stereo")), A52_DOLBY);
    00111         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("3 Front")), A52_3F);
    00112         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("2 Front + 1 Rear")), A52_2F1R);
    00113         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("3 Front + 1 Rear")), A52_3F1R);
    00114         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("2 Front + 2 Rear")), A52_2F2R);
    00115         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("3 Front + 2 Rear")), A52_3F2R);
    00116         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("Channel 1")), A52_CHANNEL1);
    00117         m_ac3sclist.SetItemData(m_ac3sclist.AddString(_T("Channel 2")), A52_CHANNEL2);
    00118
    00119         for(int i = 0, j = abs(s.ac3sc)&A52_CHANNEL_MASK; i < m_ac3sclist.GetCount(); i++)
    00120         {
    00121                 if(m_ac3sclist.GetItemData(i) == j)
    00122                 {
    00123                         m_iAc3SpeakerConfig = i;
    00124                         break;
    00125                 }
    00126         }
    00127
    00128         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("Mono")), DTS_MONO);
    00129         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("Dual Mono")), DTS_CHANNEL);
    00130         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("Stereo")), DTS_STEREO);
    00131         //m_dtssclist.SetItemData(m_dtssclist.AddString(_T("Stereo ..")), DTS_STEREO_SUMDIFF);
    00132         //m_dtssclist.SetItemData(m_dtssclist.AddString(_T("Stereo ..")), DTS_STEREO_TOTAL);
    00133         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("3 Front")), DTS_3F);
    00134         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("2 Front + 1 Rear")), DTS_2F1R);
    00135         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("3 Front + 1 Rear")), DTS_3F1R);
    00136         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("2 Front + 2 Rear")), DTS_2F2R);
    00137         m_dtssclist.SetItemData(m_dtssclist.AddString(_T("3 Front + 2 Rear")), DTS_3F2R);
    00138
    00139         for(int i = 0, j = abs(s.dtssc)&DTS_CHANNEL_MASK; i < m_dtssclist.GetCount(); i++)
    00140         {
    00141                 if(m_dtssclist.GetItemData(i) == j)
    00142                 {
    00143                         m_iDtsSpeakerConfig = i;
    00144                         break;
    00145                 }
    00146         }
    00147
    00148         UpdateData(FALSE);
    00149
    00150         return TRUE;  // return TRUE unless you set the focus to a control
    00151         // EXCEPTION: OCX Property Pages should return FALSE
    00152 }
    00153
    00154 BOOL CPPageAudioDecoder::OnApply()
    00155 {
    00156         UpdateData();
    00157
    00158         AppSettings& s = AfxGetAppSettings();
    00159
    00160         s.mpasf = m_iSampleFormat;
    00161         s.mpanormalize = !!m_fNormalize;
    00162         s.ac3sc = m_ac3sclist.GetItemData(m_ac3sclist.GetCurSel());
    00163         s.ac3sc |= m_fAc3SpeakerConfigLFE?A52_LFE:0;
    00164         s.ac3sc *= m_fAc3SpeakerConfig?-1:1;
    00165         s.ac3drc = !!m_fAc3DynamicRangeControl;
    00166         s.dtssc = m_dtssclist.GetItemData(m_dtssclist.GetCurSel());
    00167         s.dtssc |= m_fDtsSpeakerConfigLFE?DTS_LFE:0;
    00168         s.dtssc *= m_fDtsSpeakerConfig?-1:1;
    00169         s.dtsdrc = !!m_fDtsDynamicRangeControl;
    00170         s.aacsc = !!m_iAacSpeakerConfig;
    00171         s.mpaboost = (float)pow(10.0, (double)m_boost/50);
    00172
    00173         POSITION pos = m_pMDFs.GetHeadPosition();
    00174         while(pos)
    00175         {
    00176                 CComPtr<IMpaDecFilter> pMpaDecFilter = m_pMDFs.GetNext(pos);
    00177                 pMpaDecFilter->SetSampleFormat((SampleFormat)s.mpasf);
    00178                 pMpaDecFilter->SetNormalize(s.mpanormalize);
    00179                 pMpaDecFilter->SetSpeakerConfig(IMpaDecFilter::ac3, s.ac3sc);
    00180                 pMpaDecFilter->SetDynamicRangeControl(IMpaDecFilter::ac3, s.ac3drc);
    00181                 pMpaDecFilter->SetSpeakerConfig(IMpaDecFilter::dts, s.dtssc);
    00182                 pMpaDecFilter->SetDynamicRangeControl(IMpaDecFilter::dts, s.dtsdrc);
    00183                 pMpaDecFilter->SetSpeakerConfig(IMpaDecFilter::aac, s.aacsc);
    00184                 pMpaDecFilter->SetBoost(s.mpaboost);
    00185         }
    00186
    00187         return __super::OnApply();
    00188 }
    00189
    00190 void CPPageAudioDecoder::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
    00191 {
    00192         SetModified();
    00193
    00194         CPPageBase::OnHScroll(nSBCode, nPos, pScrollBar);
    00195 }