PE_Clips.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:16k
源码类别:

DVD

开发平台:

Others

  1. /****************************************************************************************
  2.  *  Copyright (c) 2000 ZORAN Corporation, All Rights Reserved
  3.  *  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
  4.  *
  5.  *  File: $Workfile: PE_Clips.c $             
  6.  *   
  7.  * Description:
  8.  * ============
  9.  * PE for Clips Navigator
  10.  *
  11.  * Log:
  12.  * ====
  13.  ****************************************************************************************
  14.  * Updates:
  15.  ****************************************************************************************
  16.  * $Log: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/PE_Clips.c $
  17.  * 
  18.  * 52    1/14/04 11:09a Chaol
  19.  * correct JPEG ASID setting when enable digest
  20.  * 
  21.  * 51    1/13/04 12:11 Hamadk
  22.  * Merged with CES DB
  23.  * 
  24.  * 50    12/22/03 4:00p Chaol
  25.  * add JPEG copy to display buffer when new line  ready
  26.  * 
  27.  * 47    03-08-29 0:03 Leslie
  28.  * Add support for DVD-ROM Clips Discs
  29.  * 
  30.  * 46    03-05-16 14:41 Dingming
  31.  * kill zoom
  32.  * 
  33.  * 45    03-04-23 11:55 Jerryc
  34.  * fix pbe: mp3 play ->ffwd ->pause->play, behaviour is not as expected.
  35.  * 
  36.  * 44    03-04-11 14:08 Janeg
  37.  * JerryC: Fix PE_Clips_EnableClock().
  38.  * 
  39.  * 43    4/09/03 4:14p Lyncolnc
  40.  * For MP3 backward scan, fixed the problem of displaying the time 1:11:34
  41.  * between two successive tracks.
  42.  * 
  43.  * 42    03-03-24 16:03 Jerryc
  44.  * clear frame buffer before starting digest to hide some garbage.
  45.  * 
  46.  * 41    03-03-14 14:52 Jerryc
  47.  * display second logo only when SUPPORT_TWO_LOGOS is defined.
  48.  * 
  49.  * 40    03-03-12 17:57 Jerryc
  50.  * clean up
  51.  * 
  52.  * 39    03-03-12 16:41 Jerryc
  53.  * display logo with no "dvd video" icon in case of
  54.  * MANUAL_DIRECTORY_EXPLORER.
  55.  * 
  56.  * 38    03-02-21 13:53 Leslie
  57.  * 
  58.  * 37    03-02-06 14:20 Leslie
  59.  * Drive Clock Type supported
  60.  * 
  61.  * 36    03-01-27 23:57 Leslie
  62.  * Check clip type when getting clip bitrate
  63.  * 
  64.  * 35    03-01-14 1:42 Leslie
  65.  * Suuport MP3 Scan
  66.  * Add PE_Clip_Get_BitRate()
  67.  * 
  68.  * 34    03-01-10 12:21 Leslie
  69.  * Add wide-character strings support
  70.  * 
  71.  * 33    03-01-09 12:30 Leslie
  72.  * 
  73.  * 32    10/30/02 17:49 Rond
  74.  * 
  75.  * 4     11/09/02 15:49 Atai
  76.  * Vaddis 5e production update
  77.  * 
  78.  * 36    20/08/02 20:35 Nirm
  79.  * - Video Buffers are cleared only if the current Logo source is Frame.
  80.  * 
  81.  * 33    9/08/02 13:19 Nirm
  82.  * - Background is only presented if it isn't already selected.
  83.  * 
  84.  * 32    4/08/02 21:07 Nirm
  85.  * - Added PE_Clips_CaptureBackground() and PE_Clips_ClearBackground().
  86.  * 
  87.  * 31    2/08/02 14:51 Nirm
  88.  * - Renamed D_ENABLE_SETUP_JPG_VIEW -> D_ENABLE_SETUP_JPG_SIZE.
  89.  * 
  90.  * 
  91.  * 30    1/08/02 23:48 Nirm
  92.  * - JPEG-View Mode overriden during Digest.
  93.  * 
  94.  * 29    30/07/02 20:35 Nirm
  95.  * - Integrated Multi-Standard support for Clips.
  96.  * 
  97.  * 28    22/07/02 9:22 Nirm
  98.  * - Enable/Disable the time-measurement independently of the
  99.  * success/failure to acquire the SCR.
  100.  * 
  101.  * 27    21/07/02 22:43 Nirm
  102.  * - Switched all time-measurement to become SCR-based, to allow
  103.  * measurement of longer periods thanks to a lower counting frequency.
  104.  * 
  105.  * 26    18/06/02 20:07 Nirm
  106.  * - Playback-Range is reported to the Decoder just bebfore starting
  107.  * playback.
  108.  * 
  109.  * 25    16/05/02 12:23 Ettim
  110.  * Removed a debug message from PE_Clips_IsPlaybackFinished()
  111.  * 
  112.  * 24    10/05/02 14:51 Nirm
  113.  * - Increased precision of Clip-Time measurement -- based on the
  114.  * System-Clock.
  115.  * 
  116.  * 23    29/04/02 12:25 Nirm
  117.  * - Fixes for JPEG Digest.
  118.  * 
  119.  * 22    23/04/02 9:32 Nirm
  120.  * - Added dependency in "Config.h".
  121.  * 
  122.  * 21    11/04/02 13:47 Ettim
  123.  * Digest for JPEG updates
  124.  * 
  125.  * 20    11/04/02 9:47 Ettim
  126.  * Disabling some functions that are not used.
  127.  * 
  128.  * 19    10/04/02 12:30 Ettim
  129.  * Added jpeg support.
  130.  * 
  131.  * 18    3/31/02 11:24 Ettim
  132.  * Clearing the timer when presenting JPEG.
  133.  * 
  134.  * 17    3/27/02 13:18 Ettim
  135.  * Replaced D_PICTURE_CD_ENABLED with CLIPS_JPEG_SUPPORT
  136.  * 
  137.  * 16    27/03/02 9:18 Nirm
  138.  * - Changed CLIPS_TICKS_PER_SECOND -> KER_TICKS_PER_SECOND.
  139.  * 
  140.  * 15    3/26/02 19:14 Ettim
  141.  * Added new clips navigation support.
  142.  * 
  143.  * 14    3/13/02 2:59a Dingming
  144.  * support PCD by CDDSP loader,add MPEG start/end cmd for CDDSP driver
  145.  * 
  146.  * 13    3/12/02 2:55a Dingming
  147.  * add event for PCD
  148.  * 
  149.  * 12    3/08/02 3:58a Dingming
  150.  * change clip finish condition only for PCD
  151.  * 
  152.  * 11    3/06/02 4:07a Dingming
  153.  * support PCD rotate
  154.  * 
  155.  * 10    3/05/02 5:52a Dingming
  156.  * add two functions for PCD
  157.  * 
  158.  * 9     4/03/02 19:22 Nirm
  159.  * Integrated support for Full-Stop.
  160.  * 
  161.  * 8     3/01/02 4:18a Dingming
  162.  * PCD stream added
  163.  * 
  164.  * 7     2/28/02 2:50a Dingming
  165.  * code porting for picture cd
  166.  * 
  167.  * 6     21/02/02 16:52 Nirm
  168.  * Code Cleanup.
  169.  * 
  170.  * 5     20/02/02 17:36 Nirm
  171.  * Log Cleanup.
  172.  * 
  173.  * 4     18/02/02 11:26 Nirm
  174.  * Added MP3-ID3v1 support.
  175.  * 
  176.  * 3     15/02/02 0:19 Nirm
  177.  * - Temporarily disabled spindown of the drive.
  178.  * 
  179.  * 2     14/02/02 18:13 Nirm
  180.  * Integration of the Clips Navigator.
  181.  * 
  182.  * 1     7/02/02 7:49 Nirm
  183.  ****************************************************************************************/
  184. #include "Config.h" // Global Configuration - do not remove!
  185. #ifdef _DEBUG
  186. #undef IFTRACE
  187. #define IFTRACE if (gTracePe)
  188. #include "DebugDbgMain.h"
  189. #endif
  190. #include "IncludeSysDefs.h"
  191. #include "KernelKer_API.h"
  192. #include "DecoderDec_defs.h"
  193. #include "Decoderlow_leveldvp_api.h"
  194. #include "Drivedrv_api.h"
  195. #include "Drivedrv_defs.h"
  196. #include "LogoLogo.h"
  197. #include "PlaycoreNav_CDDAPE_CD.h"
  198. #include "PlaycoreNav_ClipsNav_Clips.h"
  199. #include "PlaycoreNav_ClipsPE_Clips.h"
  200. #include "PlaycoreCoremainCoreGDef.h"
  201. #include "PlaycorePSPS.h"
  202. #include "PlaycoreTimingTiming.h"
  203. #ifdef SUPPORT_FLASH_CARD
  204. #include "DriveFE_Manager.h"
  205. #endif
  206. /////////////////////////////////////////////////////////////////////////////
  207. // Global variables and Singletons
  208. static struct Clock_TAG {
  209. UINT8 eClockType;
  210. UINT8 bRunning;
  211. ULONG ulEpoch;
  212. ULONG ulOffset;
  213. } g_theClock;
  214. static struct Background_TAG {
  215. UINT8 uY_Component;
  216. UINT8 uU_Component;
  217. UINT8 uV_Component;
  218. } g_theBackground;
  219. /////////////////////////////////////////////////////////////////////////////
  220. // Private Time-Measurement Services
  221. #define SCR_RATE 90000L
  222. #define MAX_SCR 0xFFFFFFFFL
  223. #define SCR_DIFF(ulEpoch, ulCurr) ((ulCurr > ulEpoch) ? 
  224.  (ulCurr - ulEpoch) : 
  225.  ((MAX_SCR - ulEpoch) + ulCurr + 1))
  226. #define DRIVE_CLOCK_RATE 75L
  227. #define DRIVE_CLOCK_DIFF( ulEpoch, ulCurr) ((ulCurr > ulEpoch) ? 
  228. (ulCurr - ulEpoch) : 
  229.  0x000000)
  230.  
  231. void PE_Clips_SelectClock(enClockType eClockType)
  232. {
  233. g_theClock.eClockType= (UINT8)eClockType;
  234. g_theClock.bRunning= FALSE;
  235. return;
  236. }
  237. void PE_Clips_EnableClock(BOOL bEnable, BOOL bRestart, UINT16 uEpoch)
  238. {
  239. ULONG ulClockRate, ulCurrTime;
  240. // Enable/Disable only if the Clock isn't in the requested state,
  241. // and it is not being restarted.
  242. if (!bRestart && (g_theClock.bRunning == bEnable))
  243. return;
  244. g_theClock.bRunning= bEnable;
  245. switch ((enClockType)g_theClock.eClockType)
  246. {
  247. case eCT_Internal:
  248. ulClockRate= 1000000L;
  249. ulCurrTime= timing_get_clock();
  250. break;
  251. case eCT_Decoder:
  252. ulClockRate= SCR_RATE;
  253. if (!DEC_get_current_SCR(&ulCurrTime))
  254. ulCurrTime= g_theClock.ulEpoch;
  255.   break;
  256.   case eCT_Drive:
  257.   ulClockRate = DRIVE_CLOCK_RATE;
  258. //  ulCurrTime =PE_CD_GetCurrentLocation();
  259. ulCurrTime = uEpoch*ulClockRate;
  260.   break;
  261. }
  262. if (bRestart)
  263. g_theClock.ulOffset= (ulClockRate * uEpoch);
  264. if (bEnable) {
  265. g_theClock.ulEpoch= ulCurrTime;
  266. return;
  267. }
  268.    else
  269. if (bRestart)
  270. return;
  271. switch ((enClockType)g_theClock.eClockType)
  272. {
  273. case eCT_Internal:
  274. if ( PST_SCAN != gcs.pstate )
  275. g_theClock.ulOffset += timing_get_diff(g_theClock.ulEpoch, ulCurrTime);
  276. else
  277. {
  278.    LONG lTemp = g_theClock.ulOffset +
  279.               gns.clips.iScanSpeed*timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
  280.       g_theClock.ulOffset = (lTemp < 0) ? 0 : lTemp;
  281.         
  282. }
  283. break;
  284. case eCT_Decoder:
  285. g_theClock.ulOffset += SCR_DIFF(g_theClock.ulEpoch, ulCurrTime);
  286. break;
  287. case eCT_Drive:
  288. g_theClock.ulOffset = 0;
  289. // nothing else to do so far
  290. break;
  291. }
  292. return;
  293. }
  294. UINT16 PE_Clips_GetClock(void)
  295. {
  296. ULONG ulClockRate, ulTime;
  297. switch ((enClockType)g_theClock.eClockType)
  298. {
  299. case eCT_Internal:
  300. ulClockRate= 1000000L;
  301. break;
  302. case eCT_Decoder:
  303. ulClockRate= SCR_RATE;
  304. break;
  305. case eCT_Drive:
  306. ulClockRate = DRIVE_CLOCK_RATE;
  307. break;
  308. }
  309. if (!g_theClock.bRunning) {
  310. // Since the Clock is not running, its value is the Time-Offset
  311. ulTime= g_theClock.ulOffset;
  312. }
  313. else {
  314. switch ((enClockType)g_theClock.eClockType)
  315. {
  316. case eCT_Internal://Leon.He_1001_05: Since ulClockRate for internal clock is very big, divide it first for preventing overflow
  317. if ( PST_SCAN != gcs.pstate )
  318. {
  319. ulTime= (g_theClock.ulOffset + timing_get_diff(g_theClock.ulEpoch, timing_get_clock()))/ulClockRate;
  320. }
  321. else
  322. {
  323. ulTime = g_theClock.ulOffset/ulClockRate +
  324. gns.clips.iScanSpeed*(timing_get_diff(g_theClock.ulEpoch, timing_get_clock())/ulClockRate);
  325. }
  326. return (UINT16)ulTime;
  327. case eCT_Decoder:
  328. if (!DEC_get_current_SCR(&ulTime))
  329. ulTime= g_theClock.ulEpoch;
  330.  
  331. ulTime= g_theClock.ulOffset + SCR_DIFF(g_theClock.ulEpoch, ulTime);
  332. break;
  333. case eCT_Drive:
  334. ulTime = PE_CD_GetCurrentLocation();
  335. ulTime = DRIVE_CLOCK_DIFF(g_theClock.ulEpoch, ulTime);
  336. break;
  337. }
  338. }
  339. dbg_printf(("Time is %04xn", (UINT16)(ulTime / ulClockRate)));
  340. return (UINT16)(ulTime / ulClockRate);
  341. }
  342. /////////////////////////////////////////////////////////////////////////////
  343. // Public Services
  344. void PE_Clips_DisplayLogo(void)
  345. {
  346. enLogoSource eCurrSource= Logo_getCurrentSource();
  347. dbg_printf(("PE_Clips_DisplayLogo()n"));
  348. #ifdef SUPPORT_TWO_LOGOS
  349. if (eMenuBackground == eCurrSource)
  350. return;
  351. Logo_selectSource(eMenuBackground);
  352. #else
  353. if (eStartup == eCurrSource)
  354. return;
  355. #ifndef EXTERNAL_LOGO_SOURCE_SETTING
  356. Logo_selectSource(eStartup);
  357. #endif //EXTERNAL_LOGO_SOURCE_SETTING
  358. #endif
  359. #ifdef CLIPS_JPEG_SUPPORT
  360. if (eFrame == eCurrSource) {
  361. //JG_0407_2004:No need to kill zoom, using CPU scaling will not keep zoom ratio
  362. //DEC_SetZoomScale(NO_ZOOM);
  363. #ifdef D_ENABLE_JPEG_CACHE
  364. DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, FALSE);
  365. #else
  366. #if 0 //def SUPPORT_FLASH_CARD //fix no logo problem with stop while playing digest.
  367. if(IS_PLAYING_CARD)
  368. DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, FALSE);
  369. else
  370. #endif
  371. DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, TRUE);
  372. #endif //D_ENABLE_JPEG_CACHE
  373. }
  374. #endif //CLIPS_JPEG_SUPPORT
  375. Logo_display();
  376. return;
  377. }
  378. void PE_Clips_CaptureBackground(void)
  379. {
  380. Logo_getBackgroundColor(&g_theBackground.uY_Component,
  381. &g_theBackground.uU_Component,
  382. &g_theBackground.uV_Component);
  383. }
  384. void PE_Clips_ClearBackground(void)
  385. {
  386. Logo_clear();
  387. }
  388. void PE_Clips_DisplayBackground(void)
  389. {
  390. enLogoSource eCurrSource= Logo_getCurrentSource();
  391. dbg_printf(("PE_Clips_DisplayBackground()n"));
  392. #ifndef EXTERNAL_LOGO_SOURCE_SETTING
  393. Logo_selectSource(eBackground);
  394. #endif //EXTERNAL_LOGO_SOURCE_SETTING
  395. #ifdef CLIPS_JPEG_SUPPORT
  396. if (eFrame == eCurrSource) {
  397. DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, TRUE);
  398. }
  399. #endif //CLIPS_JPEG_SUPPORT
  400. Logo_setBackgroundColor(g_theBackground.uY_Component,
  401. g_theBackground.uU_Component,
  402. g_theBackground.uV_Component);
  403. if (eBackground != eCurrSource)
  404. Logo_display();
  405. return;
  406. }
  407. //////////////////////////////////////////////////////////////////////////////////
  408. // Function name : PE_Clips_EnableDigestMode
  409. //
  410. // Purpose : Selecting the appropriate source for the background before 
  411. // starting the digest operation.
  412. //
  413. // Input Parameters : 
  414. // BOOL bEnable - an indication whether to enable eFrame as the source or the 
  415. // background.
  416. // enClipType eClipType 
  417. //
  418. // Return Value : void 
  419. //
  420. // Description : 
  421. //////////////////////////////////////////////////////////////////////////////////
  422. #pragma argsused
  423. void PE_Clips_EnableDigestMode(BOOL bEnable, enClipType eClipType)
  424. {
  425. dbg_printf(("PE_Clips_EnableDigestMode bEnable = %dn", bEnable));
  426. #ifdef CLIPS_JPEG_SUPPORT
  427. if (eClipType_JPEG == eClipType) 
  428. {
  429. static UINT8 eOriginalViewMode= JPG_SIZE_ORIGINAL;
  430. DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, TRUE);
  431. DEC_SetDiskType(DEC_DISC_TYPE_JPG);
  432. DEC_SetSID(DEC_SID_TYPE_AUDIO, DEC_ASID_JPEG); 
  433. DEC_SetSID(DEC_SID_TYPE_VIDEO, NoVideo);
  434. if (bEnable) {
  435. Logo_selectSource(eFrame);
  436. Logo_display();
  437. // Force the JPEG-View Mode to Original during Digest
  438. eOriginalViewMode= PS_GET_JPEG_SIZE_SETTING();
  439. PS_Update(((DWORD)PS_UPDATE_JPG_VIEW_SETTING << 16) | JPG_SIZE_ORIGINAL);
  440. }
  441. else {
  442. // Restore the original JPEG-View Mode
  443. PS_Update(((DWORD)PS_UPDATE_JPG_VIEW_SETTING << 16) | eOriginalViewMode);
  444. }
  445. }
  446. #endif //CLIPS_JPEG_SUPPORT
  447. }
  448. void PE_Clips_SetPlaybackOffset(UINT16 uiStartOffset, UINT16 uiEndOffset)
  449. {
  450. DVP_API_SetStartOffset(uiStartOffset);
  451. DVP_API_SetEndOffset(uiEndOffset);
  452. }
  453. //<<<Leslie_0823-2003_A: Add new functions for Clips
  454. void PE_Clips_SetPlaybackRange(DWORD dwStartLBA, ULONG ulBlocksCnt, ULONG ulSize)
  455. {
  456. if (IS_CD_MEDIA)
  457. {
  458. DEC_CD_SetPlaybackRange(dwStartLBA, ulBlocksCnt, ulSize);
  459. }
  460. else if (IS_DVD_PHYSICAL_MEDIA)
  461. {
  462. DWORD sta = dwStartLBA;
  463. drv_lsn2psn(&sta);
  464. DEC_LL_SetDVDStartEndSector(sta, ulBlocksCnt);
  465. }
  466. }
  467. BOOL PE_Clips_Playback_Sectors(DWORD mode, DWORD dwStartLBA, ULONG ulBlocksCnt)
  468. {
  469. if ( IS_CD_MEDIA ){
  470. return drv_play_cd_logical(mode, dwStartLBA, ulBlocksCnt);
  471. }
  472. if ( IS_DVD_PHYSICAL_MEDIA ){
  473. return drv_play_dvd(dwStartLBA, ulBlocksCnt, DRVF_PLAY_DVD_AV_DATA);
  474. }
  475. }
  476. //Leslie_0823-2003_A>>>
  477. //For DVD-R/CD-R clips get the current location.
  478. DWORD PE_Clips_GetCurrLocation(void)
  479. {
  480. DWORD dwcurrlocation;
  481. if(IS_DVD_PHYSICAL_MEDIA)
  482. {
  483. drv_get_curr_psn(&dwcurrlocation);
  484. drv_psn2lsn(&dwcurrlocation);
  485. }
  486. else
  487. dwcurrlocation = PE_CD_GetCurrentLocation();
  488. return dwcurrlocation;
  489. }
  490. #ifdef USE_AUX_SUBTITLES
  491. UINT32 PE_Clips_GetClock_Raw(void)
  492. {
  493. ULONG ulTime;
  494. if (!g_theClock.bRunning) {
  495. // Since the Clock is not running, its value is the Time-Offset
  496. ulTime= g_theClock.ulOffset;
  497. }
  498. else {
  499. switch ((enClockType)g_theClock.eClockType)
  500. {
  501. case eCT_Internal:
  502. if ( PST_SCAN != gcs.pstate )
  503. ulTime= g_theClock.ulOffset +
  504. timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
  505. else{
  506. #if 0
  507. ulTime = g_theClock.ulOffset +
  508. gns.clips.iScanSpeed*timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
  509. #else //ZCO LC040903: when scanning backwards, ulTime may be negative, which becomes a very big number because it is unsigned long. Must adjust it.
  510. LONG lTemp = g_theClock.ulOffset +
  511. gns.clips.iScanSpeed*timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
  512.             ulTime = (lTemp < 0) ? 0 : lTemp;
  513. #endif
  514. }
  515. break;
  516. case eCT_Decoder:
  517. if (!DEC_get_current_SCR(&ulTime))
  518. ulTime= g_theClock.ulEpoch;
  519.  
  520. ulTime= g_theClock.ulOffset + SCR_DIFF(g_theClock.ulEpoch, ulTime);
  521. break;
  522. case eCT_Drive:
  523. ulTime = PE_CD_GetCurrentLocation();
  524. ulTime = DRIVE_CLOCK_DIFF(g_theClock.ulEpoch, ulTime);
  525. break;
  526. }
  527. }
  528. // <<< Robin_2004_0517_B, AuxSubtitle get clock in ms
  529. switch ((enClockType)g_theClock.eClockType)
  530. {
  531. case eCT_Internal:
  532. ulTime = ulTime/1000;
  533. break;
  534. case eCT_Decoder:
  535. ulTime= ulTime/90;
  536. break;
  537. case eCT_Drive:
  538. ulTime = (ulTime * 40) /3;
  539. break;
  540. }
  541. dbg_printf(("Time is %ld msn", ulTime));
  542. return ulTime;
  543. }
  544. #endif // USE_AUX_SUBTITLES