PropPage.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. * LAME MP3 encoder for DirectShow
  3. * Basic property page
  4. *
  5. * Copyright (c) 2000-2005 Marie Orlova, Peter Gubanov, Vitaly Ivanov, Elecard Ltd.
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  20. * Boston, MA 02111-1307, USA.
  21. */
  22. #include <streams.h>
  23. #include <olectl.h>
  24. #include <commctrl.h>
  25. #include "iaudioprops.h"
  26. #include "mpegac.h"
  27. #include "resource.h"
  28. #include "PropPage.h"
  29. #include "Reg.h"
  30. // strings to appear in comboboxes
  31. const char * szBitRateString[2][14] = {
  32. {
  33. "32 kbps","40 kbps","48 kbps","56 kbps",
  34. "64 kbps","80 kbps","96 kbps","112 kbps",
  35. "128 kbps","160 kbps","192 kbps","224 kbps",
  36. "256 kbps","320 kbps"
  37. },
  38. {
  39. "8 kbps","16 kbps","24 kbps","32 kbps",
  40. "40 kbps","48 kbps","56 kbps","64 kbps",
  41. "80 kbps","96 kbps","112 kbps","128 kbps",
  42. "144 kbps","160 kbps"
  43. }
  44. };
  45. LPCSTR szQualityDesc[10] = {
  46. "High", "High", "High", "High", "High",
  47. "Medium", "Medium",
  48. "Low", "Low",
  49. "Fast mode"
  50. };
  51. LPCSTR szVBRqDesc[10] = {
  52. "0 - ~1:4",
  53. "1 - ~1:5",
  54. "2 - ~1:6",
  55. "3 - ~1:7",
  56. "4 - ~1:9",
  57. "5 - ~1:9",
  58. "6 - ~1:10",
  59. "7 - ~1:11",
  60. "8 - ~1:12",
  61. "9 - ~1:14"
  62. };
  63. struct SSampleRate {
  64. DWORD dwSampleRate;
  65. LPCSTR lpSampleRate;
  66. };
  67. SSampleRate srRates[9] = {
  68. // MPEG-1
  69. {48000, "48 kHz"},
  70. {44100, "44.1 kHz"},
  71. {32000, "32 kHz"},
  72. // MPEG-2
  73. {24000, "24 kHz"},
  74. {22050, "22.05 kHz"},
  75. {16000, "16 kHz"},
  76. // MPEG-2.5
  77. {12000, "12 kHz"},
  78. {11025, "11.025 kHz"},
  79. { 8000, "8 kHz"}
  80. };
  81. ////////////////////////////////////////////////////////////////
  82. // CreateInstance
  83. ////////////////////////////////////////////////////////////////
  84. CUnknown *CMpegAudEncPropertyPage::CreateInstance( LPUNKNOWN punk, HRESULT *phr )
  85. {
  86. CMpegAudEncPropertyPage *pNewObject
  87. = new CMpegAudEncPropertyPage( punk, phr );
  88. if( pNewObject == NULL )
  89. *phr = E_OUTOFMEMORY;
  90. return pNewObject;
  91. }
  92. ////////////////////////////////////////////////////////////////
  93. // Constructor
  94. ////////////////////////////////////////////////////////////////
  95. CMpegAudEncPropertyPage::CMpegAudEncPropertyPage(LPUNKNOWN punk, HRESULT *phr)
  96. : CBasePropertyPage(NAME("Encoder Property Page"),
  97. punk, IDD_AUDIOENCPROPS, IDS_AUDIO_PROPS_TITLE)
  98. , m_pAEProps(NULL)
  99. {
  100. ASSERT(phr);
  101. m_srIdx = 0;
  102. InitCommonControls();
  103. }
  104. //
  105. // OnConnect
  106. //
  107. // Give us the filter to communicate with
  108. HRESULT CMpegAudEncPropertyPage::OnConnect(IUnknown *pUnknown)
  109. {
  110. ASSERT(m_pAEProps == NULL);
  111. // Ask the filter for it's control interface
  112. HRESULT hr = pUnknown->QueryInterface(IID_IAudioEncoderProperties,(void **)&m_pAEProps);
  113. if (FAILED(hr))
  114. return E_NOINTERFACE;
  115. ASSERT(m_pAEProps);
  116. // Get current filter state
  117. m_pAEProps->get_Bitrate(&m_dwBitrate);
  118. m_pAEProps->get_Variable(&m_dwVariable);
  119. m_pAEProps->get_VariableMin(&m_dwMin);
  120. m_pAEProps->get_VariableMax(&m_dwMax);
  121. m_pAEProps->get_Quality(&m_dwQuality);
  122. m_pAEProps->get_VariableQ(&m_dwVBRq);
  123. m_pAEProps->get_SampleRate(&m_dwSampleRate);
  124. m_pAEProps->get_CRCFlag(&m_dwCRC);
  125. m_pAEProps->get_ForceMono(&m_dwForceMono);
  126. m_pAEProps->get_CopyrightFlag(&m_dwCopyright);
  127. m_pAEProps->get_OriginalFlag(&m_dwOriginal);
  128. return NOERROR;
  129. }
  130. //
  131. // OnDisconnect
  132. //
  133. // Release the interface
  134. HRESULT CMpegAudEncPropertyPage::OnDisconnect()
  135. {
  136. // Release the interface
  137. if (m_pAEProps == NULL)
  138. return E_UNEXPECTED;
  139. m_pAEProps->set_Bitrate(m_dwBitrate);
  140. m_pAEProps->set_Variable(m_dwVariable);
  141. m_pAEProps->set_VariableMin(m_dwMin);
  142. m_pAEProps->set_VariableMax(m_dwMax);
  143. m_pAEProps->set_Quality(m_dwQuality);
  144. m_pAEProps->set_VariableQ(m_dwVBRq);
  145. m_pAEProps->set_SampleRate(m_dwSampleRate);
  146. m_pAEProps->set_CRCFlag(m_dwCRC);
  147. m_pAEProps->set_ForceMono(m_dwForceMono);
  148. m_pAEProps->set_CopyrightFlag(m_dwCopyright);
  149. m_pAEProps->set_OriginalFlag(m_dwOriginal);
  150. m_pAEProps->SaveAudioEncoderPropertiesToRegistry();
  151. m_pAEProps->Release();
  152. m_pAEProps = NULL;
  153. return NOERROR;
  154. }
  155. //
  156. // OnActivate
  157. //
  158. // Called on dialog creation
  159. HRESULT CMpegAudEncPropertyPage::OnActivate(void)
  160. {
  161. InitPropertiesDialog(m_hwnd);
  162. return NOERROR;
  163. }
  164. //
  165. // OnDeactivate
  166. //
  167. // Called on dialog destruction
  168. HRESULT CMpegAudEncPropertyPage::OnDeactivate(void)
  169. {
  170. return NOERROR;
  171. }
  172. ////////////////////////////////////////////////////////////////
  173. // OnReceiveMessage - message handler function
  174. ////////////////////////////////////////////////////////////////
  175. BOOL CMpegAudEncPropertyPage::OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
  176. {
  177. switch (uMsg)
  178. {
  179. case WM_HSCROLL:
  180. if ((HWND)lParam == m_hwndQuality)
  181. {
  182. int pos = SendMessage(m_hwndQuality, TBM_GETPOS, 0, 0);
  183. if (pos >= 0 && pos < 10)
  184. {
  185. SetDlgItemText(hwnd,IDC_TEXT_QUALITY,szQualityDesc[pos]);
  186. m_pAEProps->set_Quality(pos);
  187. SetDirty();
  188. }
  189. }
  190. break;
  191. case WM_COMMAND:
  192. switch (LOWORD(wParam))
  193. {
  194. case IDC_COMBO_CBR:
  195. if (HIWORD(wParam) == CBN_SELCHANGE)
  196. {
  197. int nBitrate = SendDlgItemMessage(hwnd, IDC_COMBO_CBR, CB_GETCURSEL, 0, 0L);
  198. DWORD dwSampleRate;
  199. m_pAEProps->get_SampleRate(&dwSampleRate);
  200. DWORD dwBitrate;
  201. if (dwSampleRate >= 32000)
  202. {
  203. // Consider MPEG-1
  204. dwBitrate = dwBitRateValue[0][nBitrate];
  205. }
  206. else
  207. {
  208. // Consider MPEG-2/2.5
  209. dwBitrate = dwBitRateValue[1][nBitrate];
  210. }
  211. m_pAEProps->set_Bitrate(dwBitrate);
  212. SetDirty();
  213. }
  214. break;
  215. case IDC_COMBO_VBRMIN:
  216. if (HIWORD(wParam) == CBN_SELCHANGE)
  217. {
  218. int nVariableMin = SendDlgItemMessage(hwnd, IDC_COMBO_VBRMIN, CB_GETCURSEL, 0, 0L);
  219. DWORD dwSampleRate;
  220. m_pAEProps->get_SampleRate(&dwSampleRate);
  221. DWORD dwMin;
  222. if (dwSampleRate >= 32000)
  223. {
  224. // Consider MPEG-1
  225. dwMin = dwBitRateValue[0][nVariableMin];
  226. }
  227. else
  228. {
  229. // Consider MPEG-2/2.5
  230. dwMin = dwBitRateValue[1][nVariableMin];
  231. }
  232. m_pAEProps->set_VariableMin(dwMin);
  233. SetDirty();
  234. }
  235. break;
  236. case IDC_COMBO_VBRMAX:
  237. if (HIWORD(wParam) == CBN_SELCHANGE)
  238. {
  239. int nVariableMax = SendDlgItemMessage(hwnd, IDC_COMBO_VBRMAX, CB_GETCURSEL, 0, 0L);
  240. DWORD dwSampleRate;
  241. m_pAEProps->get_SampleRate(&dwSampleRate);
  242. DWORD dwMax;
  243. if (dwSampleRate >= 32000)
  244. {
  245. // Consider MPEG-1
  246. dwMax = dwBitRateValue[0][nVariableMax];
  247. }
  248. else
  249. {
  250. // Consider MPEG-2/2.5
  251. dwMax = dwBitRateValue[1][nVariableMax];
  252. }
  253. m_pAEProps->set_VariableMax(dwMax);
  254. SetDirty();
  255. }
  256. break;
  257. case IDC_COMBO_SAMPLE_RATE:
  258. if (HIWORD(wParam) == CBN_SELCHANGE)
  259. {
  260. int nSampleRate = SendDlgItemMessage(hwnd, IDC_COMBO_SAMPLE_RATE, CB_GETCURSEL, 0, 0L);
  261. if (nSampleRate < 0)
  262. nSampleRate = 0;
  263. else if (nSampleRate > 2)
  264. nSampleRate = 2;
  265. DWORD dwSampleRate = srRates[nSampleRate * 3 + m_srIdx].dwSampleRate;
  266. m_pAEProps->set_SampleRate(dwSampleRate);
  267. InitPropertiesDialog(hwnd);
  268. SetDirty();
  269. }
  270. break;
  271. case IDC_COMBO_VBRq:
  272. if (HIWORD(wParam) == CBN_SELCHANGE)
  273. {
  274. int nVBRq = SendDlgItemMessage(hwnd, IDC_COMBO_VBRq, CB_GETCURSEL, 0, 0L);
  275. if (nVBRq >=0 && nVBRq <=9)
  276. m_pAEProps->set_VariableQ(nVBRq);
  277. SetDirty();
  278. }
  279. break;
  280. case IDC_RADIO_CBR:
  281. case IDC_RADIO_VBR:
  282. m_pAEProps->set_Variable(LOWORD(wParam)-IDC_RADIO_CBR);
  283. SetDirty();
  284. break;
  285. case IDC_CHECK_PES:
  286. m_pAEProps->set_PESOutputEnabled(IsDlgButtonChecked(hwnd, IDC_CHECK_PES));
  287. SetDirty();
  288. break;
  289. case IDC_CHECK_COPYRIGHT:
  290. m_pAEProps->set_CopyrightFlag(IsDlgButtonChecked(hwnd, IDC_CHECK_COPYRIGHT));
  291. SetDirty();
  292. break;
  293. case IDC_CHECK_ORIGINAL:
  294. m_pAEProps->set_OriginalFlag(IsDlgButtonChecked(hwnd, IDC_CHECK_ORIGINAL));
  295. SetDirty();
  296. break;
  297. case IDC_CHECK_CRC:
  298. m_pAEProps->set_CRCFlag(IsDlgButtonChecked(hwnd, IDC_CHECK_CRC));
  299. SetDirty();
  300. break;
  301. case IDC_FORCE_MONO:
  302. m_pAEProps->set_ForceMono(IsDlgButtonChecked(hwnd, IDC_FORCE_MONO));
  303. SetDirty();
  304. break;
  305. }
  306. return TRUE;
  307. case WM_DESTROY:
  308. return TRUE;
  309. default:
  310. return FALSE;
  311. }
  312. return TRUE;
  313. }
  314. //
  315. // OnApplyChanges
  316. //
  317. HRESULT CMpegAudEncPropertyPage::OnApplyChanges()
  318. {
  319. m_pAEProps->get_Bitrate(&m_dwBitrate);
  320. m_pAEProps->get_Variable(&m_dwVariable);
  321. m_pAEProps->get_VariableMin(&m_dwMin);
  322. m_pAEProps->get_VariableMax(&m_dwMax);
  323. m_pAEProps->get_Quality(&m_dwQuality);
  324. m_pAEProps->get_VariableQ(&m_dwVBRq);
  325. m_pAEProps->get_SampleRate(&m_dwSampleRate);
  326. m_pAEProps->get_CRCFlag(&m_dwCRC);
  327. m_pAEProps->get_ForceMono(&m_dwForceMono);
  328. m_pAEProps->get_CopyrightFlag(&m_dwCopyright);
  329. m_pAEProps->get_OriginalFlag(&m_dwOriginal);
  330. m_pAEProps->SaveAudioEncoderPropertiesToRegistry();
  331. m_pAEProps->ApplyChanges();
  332. return S_OK;
  333. }
  334. //
  335. // Initialize dialogbox controls with proper values
  336. //
  337. void CMpegAudEncPropertyPage::InitPropertiesDialog(HWND hwndParent)
  338. {
  339. EnableControls(hwndParent, TRUE);
  340. m_hwndQuality = GetDlgItem(hwndParent,IDC_SLIDER_QUALITY);
  341. DWORD dwQuality;
  342. m_pAEProps->get_Quality(&dwQuality);
  343. SendDlgItemMessage(hwndParent, IDC_SLIDER_QUALITY, TBM_SETRANGE, 1, MAKELONG (2,9));
  344. SendDlgItemMessage(hwndParent, IDC_SLIDER_QUALITY, TBM_SETPOS, 1, dwQuality);
  345. if (dwQuality>=0 && dwQuality<10)
  346. SetDlgItemText(hwndParent,IDC_TEXT_QUALITY,szQualityDesc[dwQuality]);
  347. //
  348. // initialize sample rate selection
  349. //
  350. DWORD dwSourceSampleRate;
  351. m_pAEProps->get_SourceSampleRate(&dwSourceSampleRate);
  352. SendDlgItemMessage(hwndParent, IDC_COMBO_SAMPLE_RATE, CB_RESETCONTENT, 0, 0L);
  353. switch (dwSourceSampleRate)
  354. {
  355. case 48000:
  356. case 24000:
  357. case 12000:
  358. m_srIdx = 0;
  359. break;
  360. case 32000:
  361. case 16000:
  362. case 8000:
  363. m_srIdx = 2;
  364. break;
  365. case 44100:
  366. case 22050:
  367. case 11025:
  368. default:
  369. m_srIdx = 1;
  370. }
  371. for (int i = 0; i < 3; i++)
  372. SendDlgItemMessage(hwndParent, IDC_COMBO_SAMPLE_RATE, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)srRates[i * 3 + m_srIdx].lpSampleRate);
  373. DWORD dwSampleRate;
  374. m_pAEProps->get_SampleRate(&dwSampleRate);
  375. m_pAEProps->set_SampleRate(dwSampleRate);
  376. int nSR = 0;
  377. while (dwSampleRate != srRates[nSR * 3 + m_srIdx].dwSampleRate && nSR < 3)
  378. {
  379. nSR++;
  380. }
  381. if (nSR >= 3)
  382. nSR = 0;
  383. SendDlgItemMessage(hwndParent, IDC_COMBO_SAMPLE_RATE, CB_SETCURSEL, nSR, 0);
  384. DWORD dwChannels;
  385. m_pAEProps->get_SourceChannels(&dwChannels);
  386. //
  387. //initialize VBRq combo box
  388. //
  389. int k;
  390. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRq, CB_RESETCONTENT, 0, 0);
  391. for (k = 0; k < 10; k++)
  392. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRq, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szVBRqDesc[k]);
  393. DWORD dwVBRq;
  394. m_pAEProps->get_VariableQ(&dwVBRq);
  395. if (dwVBRq<0)
  396. dwVBRq = 0;
  397. if (dwVBRq>9)
  398. dwVBRq = 9;
  399. m_pAEProps->set_VariableQ(dwVBRq);
  400. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRq, CB_SETCURSEL, dwVBRq, 0);
  401. //////////////////////////////////////
  402. // initialize CBR selection
  403. //////////////////////////////////////
  404. int nSt;
  405. SendDlgItemMessage(hwndParent, IDC_COMBO_CBR, CB_RESETCONTENT, 0, 0);
  406. if (dwSampleRate >= 32000)
  407. {
  408. // If target sampling rate is less than 32000, consider
  409. // MPEG 1 audio
  410. nSt = 0;
  411. for (int i = 0; i < 14; i++)
  412. SendDlgItemMessage(hwndParent, IDC_COMBO_CBR, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szBitRateString[0][i]);
  413. }
  414. else
  415. {
  416. // Consider MPEG 2 / 2.5 audio
  417. nSt = 1;
  418. for (int i = 0; i < 14 ; i++)
  419. SendDlgItemMessage(hwndParent, IDC_COMBO_CBR, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szBitRateString[1][i]);
  420. }
  421. DWORD dwBitrate;
  422. m_pAEProps->get_Bitrate(&dwBitrate);
  423. int nBitrateSel = 0;
  424. // BitRateValue[][i] is in ascending order
  425. // We use this fact. We also know there are 14 bitrate values available.
  426. // We are going to use the closest possible, so we can limit loop with 13
  427. while (nBitrateSel < 13 && dwBitRateValue[nSt][nBitrateSel] < dwBitrate)
  428. nBitrateSel++;
  429. SendDlgItemMessage(hwndParent, IDC_COMBO_CBR, CB_SETCURSEL, nBitrateSel, 0);
  430. // check if the specified bitrate is found exactly and correct if not
  431. if (dwBitRateValue[nSt][nBitrateSel] != dwBitrate)
  432. {
  433. dwBitrate = dwBitRateValue[nSt][nBitrateSel];
  434. // we can change it, because it is independent of any other parameters
  435. // (but depends on some of them!)
  436. m_pAEProps->set_Bitrate(dwBitrate);
  437. }
  438. //
  439. // Check VBR/CBR radio button
  440. //
  441. DWORD dwVariable;
  442. m_pAEProps->get_Variable(&dwVariable);
  443. CheckRadioButton(hwndParent, IDC_RADIO_CBR, IDC_RADIO_VBR, IDC_RADIO_CBR + dwVariable);
  444. //////////////////////////////////////////////////
  445. // initialize VBR selection
  446. //////////////////////////////////////////////////
  447. //VBRMIN, VBRMAX
  448. int j, nST;
  449. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMIN, CB_RESETCONTENT, 0, 0);
  450. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMAX, CB_RESETCONTENT, 0, 0);
  451. if (dwSampleRate >= 32000)
  452. {
  453. nST = 0;
  454. for (j=0; j<14 ;j++) {
  455. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMIN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szBitRateString[0][j]);
  456. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMAX, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szBitRateString[0][j]);
  457. }
  458. }
  459. else
  460. {
  461. nST = 1;
  462. for (j = 0; j < 14; j++)
  463. {
  464. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMIN, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szBitRateString[1][j]);
  465. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMAX, CB_ADDSTRING, 0, (LPARAM)(LPCTSTR)szBitRateString[1][j]);
  466. }
  467. }
  468. DWORD dwMin,dwMax;
  469. m_pAEProps->get_VariableMin(&dwMin);
  470. m_pAEProps->get_VariableMax(&dwMax);
  471. int nVariableMinSel = 0;
  472. int nVariableMaxSel = 0;
  473. // BitRateValue[][i] is in ascending order
  474. // We use this fact. We also know there are 14 bitrate values available.
  475. // We are going to use the closest possible, so we can limit loop with 13
  476. while (nVariableMinSel<13 && dwBitRateValue[nST][nVariableMinSel] < dwMin)
  477. nVariableMinSel++;
  478. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMIN, CB_SETCURSEL, nVariableMinSel, 0);
  479. while (nVariableMaxSel<13 && dwBitRateValue[nST][nVariableMaxSel] < dwMax)
  480. nVariableMaxSel++;
  481. SendDlgItemMessage(hwndParent, IDC_COMBO_VBRMAX, CB_SETCURSEL, nVariableMaxSel, 0);
  482. // check if the specified bitrate is found exactly and correct if not
  483. if (dwBitRateValue[nST][nVariableMinSel] != dwMin)
  484. {
  485. dwMin = dwBitRateValue[nST][nVariableMinSel];
  486. // we can change it, because it is independent of any other parameters
  487. // (but depends on some of them!)
  488. m_pAEProps->set_VariableMin(dwMin);
  489. }
  490. // check if the specified bitrate is found exactly and correct if not
  491. if (dwBitRateValue[nST][nVariableMaxSel] != dwMax)
  492. {
  493. dwMax = dwBitRateValue[nST][nVariableMaxSel];
  494. // we can change it, because it is independent of any other parameters
  495. // (but depends on some of them!)
  496. m_pAEProps->set_VariableMax(dwMax);
  497. }
  498. //
  499. // initialize checkboxes
  500. //
  501. DWORD dwPES;
  502. m_pAEProps->get_PESOutputEnabled(&dwPES);
  503. dwPES = 0;
  504. CheckDlgButton(hwndParent, IDC_CHECK_PES, dwPES ? BST_CHECKED : BST_UNCHECKED);
  505. DWORD dwCRC;
  506. m_pAEProps->get_CRCFlag(&dwCRC);
  507. CheckDlgButton(hwndParent, IDC_CHECK_CRC, dwCRC ? BST_CHECKED : BST_UNCHECKED);
  508. DWORD dwForceMono;
  509. m_pAEProps->get_ForceMono(&dwForceMono);
  510. CheckDlgButton(hwndParent, IDC_FORCE_MONO, dwForceMono ? BST_CHECKED : BST_UNCHECKED);
  511. DWORD dwCopyright;
  512. m_pAEProps->get_CopyrightFlag(&dwCopyright);
  513. CheckDlgButton(hwndParent, IDC_CHECK_COPYRIGHT, dwCopyright ? BST_CHECKED : BST_UNCHECKED);
  514. DWORD dwOriginal;
  515. m_pAEProps->get_OriginalFlag(&dwOriginal);
  516. CheckDlgButton(hwndParent, IDC_CHECK_ORIGINAL, dwOriginal ? BST_CHECKED : BST_UNCHECKED);
  517. }
  518. ////////////////////////////////////////////////////////////////
  519. // EnableControls
  520. ////////////////////////////////////////////////////////////////
  521. void CMpegAudEncPropertyPage::EnableControls(HWND hwndParent, bool bEnable)
  522. {
  523. EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_PES), false);//bEnable);
  524. EnableWindow(GetDlgItem(hwndParent, IDC_RADIO_CBR), bEnable);
  525. EnableWindow(GetDlgItem(hwndParent, IDC_COMBO_CBR), bEnable);
  526. EnableWindow(GetDlgItem(hwndParent, IDC_RADIO_VBR), bEnable);
  527. EnableWindow(GetDlgItem(hwndParent, IDC_COMBO_VBRMIN), bEnable);
  528. EnableWindow(GetDlgItem(hwndParent, IDC_COMBO_VBRMAX), bEnable);
  529. EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_COPYRIGHT), bEnable);
  530. EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_ORIGINAL), bEnable);
  531. EnableWindow(GetDlgItem(hwndParent, IDC_CHECK_CRC), bEnable);
  532. EnableWindow(GetDlgItem(hwndParent, IDC_FORCE_MONO), bEnable);
  533. EnableWindow(GetDlgItem(hwndParent, IDC_SLIDER_QUALITY), bEnable);
  534. EnableWindow(GetDlgItem(hwndParent, IDC_COMBO_SAMPLE_RATE), bEnable);
  535. }
  536. //
  537. // SetDirty
  538. //
  539. // notifies the property page site of changes
  540. void CMpegAudEncPropertyPage::SetDirty()
  541. {
  542. m_bDirty = TRUE;
  543. if (m_pPageSite)
  544. m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
  545. }