PE_Clips.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:16k
- /****************************************************************************************
- * Copyright (c) 2000 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: PE_Clips.c $
- *
- * Description:
- * ============
- * PE for Clips Navigator
- *
- * Log:
- * ====
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/Nav_Clips/PE_Clips.c $
- *
- * 52 1/14/04 11:09a Chaol
- * correct JPEG ASID setting when enable digest
- *
- * 51 1/13/04 12:11 Hamadk
- * Merged with CES DB
- *
- * 50 12/22/03 4:00p Chaol
- * add JPEG copy to display buffer when new line ready
- *
- * 47 03-08-29 0:03 Leslie
- * Add support for DVD-ROM Clips Discs
- *
- * 46 03-05-16 14:41 Dingming
- * kill zoom
- *
- * 45 03-04-23 11:55 Jerryc
- * fix pbe: mp3 play ->ffwd ->pause->play, behaviour is not as expected.
- *
- * 44 03-04-11 14:08 Janeg
- * JerryC: Fix PE_Clips_EnableClock().
- *
- * 43 4/09/03 4:14p Lyncolnc
- * For MP3 backward scan, fixed the problem of displaying the time 1:11:34
- * between two successive tracks.
- *
- * 42 03-03-24 16:03 Jerryc
- * clear frame buffer before starting digest to hide some garbage.
- *
- * 41 03-03-14 14:52 Jerryc
- * display second logo only when SUPPORT_TWO_LOGOS is defined.
- *
- * 40 03-03-12 17:57 Jerryc
- * clean up
- *
- * 39 03-03-12 16:41 Jerryc
- * display logo with no "dvd video" icon in case of
- * MANUAL_DIRECTORY_EXPLORER.
- *
- * 38 03-02-21 13:53 Leslie
- *
- * 37 03-02-06 14:20 Leslie
- * Drive Clock Type supported
- *
- * 36 03-01-27 23:57 Leslie
- * Check clip type when getting clip bitrate
- *
- * 35 03-01-14 1:42 Leslie
- * Suuport MP3 Scan
- * Add PE_Clip_Get_BitRate()
- *
- * 34 03-01-10 12:21 Leslie
- * Add wide-character strings support
- *
- * 33 03-01-09 12:30 Leslie
- *
- * 32 10/30/02 17:49 Rond
- *
- * 4 11/09/02 15:49 Atai
- * Vaddis 5e production update
- *
- * 36 20/08/02 20:35 Nirm
- * - Video Buffers are cleared only if the current Logo source is Frame.
- *
- * 33 9/08/02 13:19 Nirm
- * - Background is only presented if it isn't already selected.
- *
- * 32 4/08/02 21:07 Nirm
- * - Added PE_Clips_CaptureBackground() and PE_Clips_ClearBackground().
- *
- * 31 2/08/02 14:51 Nirm
- * - Renamed D_ENABLE_SETUP_JPG_VIEW -> D_ENABLE_SETUP_JPG_SIZE.
- *
- *
- * 30 1/08/02 23:48 Nirm
- * - JPEG-View Mode overriden during Digest.
- *
- * 29 30/07/02 20:35 Nirm
- * - Integrated Multi-Standard support for Clips.
- *
- * 28 22/07/02 9:22 Nirm
- * - Enable/Disable the time-measurement independently of the
- * success/failure to acquire the SCR.
- *
- * 27 21/07/02 22:43 Nirm
- * - Switched all time-measurement to become SCR-based, to allow
- * measurement of longer periods thanks to a lower counting frequency.
- *
- * 26 18/06/02 20:07 Nirm
- * - Playback-Range is reported to the Decoder just bebfore starting
- * playback.
- *
- * 25 16/05/02 12:23 Ettim
- * Removed a debug message from PE_Clips_IsPlaybackFinished()
- *
- * 24 10/05/02 14:51 Nirm
- * - Increased precision of Clip-Time measurement -- based on the
- * System-Clock.
- *
- * 23 29/04/02 12:25 Nirm
- * - Fixes for JPEG Digest.
- *
- * 22 23/04/02 9:32 Nirm
- * - Added dependency in "Config.h".
- *
- * 21 11/04/02 13:47 Ettim
- * Digest for JPEG updates
- *
- * 20 11/04/02 9:47 Ettim
- * Disabling some functions that are not used.
- *
- * 19 10/04/02 12:30 Ettim
- * Added jpeg support.
- *
- * 18 3/31/02 11:24 Ettim
- * Clearing the timer when presenting JPEG.
- *
- * 17 3/27/02 13:18 Ettim
- * Replaced D_PICTURE_CD_ENABLED with CLIPS_JPEG_SUPPORT
- *
- * 16 27/03/02 9:18 Nirm
- * - Changed CLIPS_TICKS_PER_SECOND -> KER_TICKS_PER_SECOND.
- *
- * 15 3/26/02 19:14 Ettim
- * Added new clips navigation support.
- *
- * 14 3/13/02 2:59a Dingming
- * support PCD by CDDSP loader,add MPEG start/end cmd for CDDSP driver
- *
- * 13 3/12/02 2:55a Dingming
- * add event for PCD
- *
- * 12 3/08/02 3:58a Dingming
- * change clip finish condition only for PCD
- *
- * 11 3/06/02 4:07a Dingming
- * support PCD rotate
- *
- * 10 3/05/02 5:52a Dingming
- * add two functions for PCD
- *
- * 9 4/03/02 19:22 Nirm
- * Integrated support for Full-Stop.
- *
- * 8 3/01/02 4:18a Dingming
- * PCD stream added
- *
- * 7 2/28/02 2:50a Dingming
- * code porting for picture cd
- *
- * 6 21/02/02 16:52 Nirm
- * Code Cleanup.
- *
- * 5 20/02/02 17:36 Nirm
- * Log Cleanup.
- *
- * 4 18/02/02 11:26 Nirm
- * Added MP3-ID3v1 support.
- *
- * 3 15/02/02 0:19 Nirm
- * - Temporarily disabled spindown of the drive.
- *
- * 2 14/02/02 18:13 Nirm
- * Integration of the Clips Navigator.
- *
- * 1 7/02/02 7:49 Nirm
- ****************************************************************************************/
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef _DEBUG
- #undef IFTRACE
- #define IFTRACE if (gTracePe)
- #include "DebugDbgMain.h"
- #endif
- #include "IncludeSysDefs.h"
- #include "KernelKer_API.h"
- #include "DecoderDec_defs.h"
- #include "Decoderlow_leveldvp_api.h"
- #include "Drivedrv_api.h"
- #include "Drivedrv_defs.h"
- #include "LogoLogo.h"
- #include "PlaycoreNav_CDDAPE_CD.h"
- #include "PlaycoreNav_ClipsNav_Clips.h"
- #include "PlaycoreNav_ClipsPE_Clips.h"
- #include "PlaycoreCoremainCoreGDef.h"
- #include "PlaycorePSPS.h"
- #include "PlaycoreTimingTiming.h"
- #ifdef SUPPORT_FLASH_CARD
- #include "DriveFE_Manager.h"
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Global variables and Singletons
- static struct Clock_TAG {
- UINT8 eClockType;
- UINT8 bRunning;
- ULONG ulEpoch;
- ULONG ulOffset;
- } g_theClock;
- static struct Background_TAG {
- UINT8 uY_Component;
- UINT8 uU_Component;
- UINT8 uV_Component;
- } g_theBackground;
- /////////////////////////////////////////////////////////////////////////////
- // Private Time-Measurement Services
- #define SCR_RATE 90000L
- #define MAX_SCR 0xFFFFFFFFL
- #define SCR_DIFF(ulEpoch, ulCurr) ((ulCurr > ulEpoch) ?
- (ulCurr - ulEpoch) :
- ((MAX_SCR - ulEpoch) + ulCurr + 1))
- #define DRIVE_CLOCK_RATE 75L
- #define DRIVE_CLOCK_DIFF( ulEpoch, ulCurr) ((ulCurr > ulEpoch) ?
- (ulCurr - ulEpoch) :
- 0x000000)
-
- void PE_Clips_SelectClock(enClockType eClockType)
- {
- g_theClock.eClockType= (UINT8)eClockType;
- g_theClock.bRunning= FALSE;
- return;
- }
- void PE_Clips_EnableClock(BOOL bEnable, BOOL bRestart, UINT16 uEpoch)
- {
- ULONG ulClockRate, ulCurrTime;
- // Enable/Disable only if the Clock isn't in the requested state,
- // and it is not being restarted.
- if (!bRestart && (g_theClock.bRunning == bEnable))
- return;
- g_theClock.bRunning= bEnable;
- switch ((enClockType)g_theClock.eClockType)
- {
- case eCT_Internal:
- ulClockRate= 1000000L;
- ulCurrTime= timing_get_clock();
- break;
- case eCT_Decoder:
- ulClockRate= SCR_RATE;
-
- if (!DEC_get_current_SCR(&ulCurrTime))
- ulCurrTime= g_theClock.ulEpoch;
- break;
- case eCT_Drive:
- ulClockRate = DRIVE_CLOCK_RATE;
- // ulCurrTime =PE_CD_GetCurrentLocation();
- ulCurrTime = uEpoch*ulClockRate;
- break;
- }
- if (bRestart)
- g_theClock.ulOffset= (ulClockRate * uEpoch);
- if (bEnable) {
- g_theClock.ulEpoch= ulCurrTime;
- return;
- }
- else
- if (bRestart)
- return;
- switch ((enClockType)g_theClock.eClockType)
- {
- case eCT_Internal:
- if ( PST_SCAN != gcs.pstate )
- g_theClock.ulOffset += timing_get_diff(g_theClock.ulEpoch, ulCurrTime);
- else
- {
- LONG lTemp = g_theClock.ulOffset +
- gns.clips.iScanSpeed*timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
- g_theClock.ulOffset = (lTemp < 0) ? 0 : lTemp;
-
- }
-
- break;
- case eCT_Decoder:
- g_theClock.ulOffset += SCR_DIFF(g_theClock.ulEpoch, ulCurrTime);
- break;
- case eCT_Drive:
- g_theClock.ulOffset = 0;
- // nothing else to do so far
- break;
- }
- return;
- }
- UINT16 PE_Clips_GetClock(void)
- {
- ULONG ulClockRate, ulTime;
- switch ((enClockType)g_theClock.eClockType)
- {
- case eCT_Internal:
- ulClockRate= 1000000L;
- break;
- case eCT_Decoder:
- ulClockRate= SCR_RATE;
- break;
- case eCT_Drive:
- ulClockRate = DRIVE_CLOCK_RATE;
- break;
- }
- if (!g_theClock.bRunning) {
- // Since the Clock is not running, its value is the Time-Offset
- ulTime= g_theClock.ulOffset;
- }
- else {
- switch ((enClockType)g_theClock.eClockType)
- {
- case eCT_Internal://Leon.He_1001_05: Since ulClockRate for internal clock is very big, divide it first for preventing overflow
- if ( PST_SCAN != gcs.pstate )
- {
- ulTime= (g_theClock.ulOffset + timing_get_diff(g_theClock.ulEpoch, timing_get_clock()))/ulClockRate;
- }
- else
- {
- ulTime = g_theClock.ulOffset/ulClockRate +
- gns.clips.iScanSpeed*(timing_get_diff(g_theClock.ulEpoch, timing_get_clock())/ulClockRate);
- }
- return (UINT16)ulTime;
- case eCT_Decoder:
- if (!DEC_get_current_SCR(&ulTime))
- ulTime= g_theClock.ulEpoch;
-
- ulTime= g_theClock.ulOffset + SCR_DIFF(g_theClock.ulEpoch, ulTime);
- break;
- case eCT_Drive:
- ulTime = PE_CD_GetCurrentLocation();
- ulTime = DRIVE_CLOCK_DIFF(g_theClock.ulEpoch, ulTime);
-
- break;
- }
- }
- dbg_printf(("Time is %04xn", (UINT16)(ulTime / ulClockRate)));
- return (UINT16)(ulTime / ulClockRate);
- }
- /////////////////////////////////////////////////////////////////////////////
- // Public Services
- void PE_Clips_DisplayLogo(void)
- {
- enLogoSource eCurrSource= Logo_getCurrentSource();
- dbg_printf(("PE_Clips_DisplayLogo()n"));
- #ifdef SUPPORT_TWO_LOGOS
- if (eMenuBackground == eCurrSource)
- return;
- Logo_selectSource(eMenuBackground);
- #else
- if (eStartup == eCurrSource)
- return;
- #ifndef EXTERNAL_LOGO_SOURCE_SETTING
- Logo_selectSource(eStartup);
- #endif //EXTERNAL_LOGO_SOURCE_SETTING
- #endif
- #ifdef CLIPS_JPEG_SUPPORT
- if (eFrame == eCurrSource) {
- //JG_0407_2004:No need to kill zoom, using CPU scaling will not keep zoom ratio
- //DEC_SetZoomScale(NO_ZOOM);
- #ifdef D_ENABLE_JPEG_CACHE
- DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, FALSE);
- #else
- #if 0 //def SUPPORT_FLASH_CARD //fix no logo problem with stop while playing digest.
- if(IS_PLAYING_CARD)
- DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, FALSE);
- else
- #endif
- DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, TRUE);
- #endif //D_ENABLE_JPEG_CACHE
- }
- #endif //CLIPS_JPEG_SUPPORT
- Logo_display();
- return;
- }
- void PE_Clips_CaptureBackground(void)
- {
- Logo_getBackgroundColor(&g_theBackground.uY_Component,
- &g_theBackground.uU_Component,
- &g_theBackground.uV_Component);
- }
- void PE_Clips_ClearBackground(void)
- {
- Logo_clear();
- }
- void PE_Clips_DisplayBackground(void)
- {
- enLogoSource eCurrSource= Logo_getCurrentSource();
- dbg_printf(("PE_Clips_DisplayBackground()n"));
- #ifndef EXTERNAL_LOGO_SOURCE_SETTING
- Logo_selectSource(eBackground);
- #endif //EXTERNAL_LOGO_SOURCE_SETTING
- #ifdef CLIPS_JPEG_SUPPORT
- if (eFrame == eCurrSource) {
- DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, TRUE);
- }
- #endif //CLIPS_JPEG_SUPPORT
- Logo_setBackgroundColor(g_theBackground.uY_Component,
- g_theBackground.uU_Component,
- g_theBackground.uV_Component);
- if (eBackground != eCurrSource)
- Logo_display();
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : PE_Clips_EnableDigestMode
- //
- // Purpose : Selecting the appropriate source for the background before
- // starting the digest operation.
- //
- // Input Parameters :
- // BOOL bEnable - an indication whether to enable eFrame as the source or the
- // background.
- // enClipType eClipType
- //
- // Return Value : void
- //
- // Description :
- //////////////////////////////////////////////////////////////////////////////////
- #pragma argsused
- void PE_Clips_EnableDigestMode(BOOL bEnable, enClipType eClipType)
- {
- dbg_printf(("PE_Clips_EnableDigestMode bEnable = %dn", bEnable));
- #ifdef CLIPS_JPEG_SUPPORT
- if (eClipType_JPEG == eClipType)
- {
- static UINT8 eOriginalViewMode= JPG_SIZE_ORIGINAL;
-
- DEC_JPEG_clearDisplayBuffers(TRUE, TRUE, TRUE);
-
- DEC_SetDiskType(DEC_DISC_TYPE_JPG);
- DEC_SetSID(DEC_SID_TYPE_AUDIO, DEC_ASID_JPEG);
- DEC_SetSID(DEC_SID_TYPE_VIDEO, NoVideo);
- if (bEnable) {
- Logo_selectSource(eFrame);
- Logo_display();
- // Force the JPEG-View Mode to Original during Digest
- eOriginalViewMode= PS_GET_JPEG_SIZE_SETTING();
- PS_Update(((DWORD)PS_UPDATE_JPG_VIEW_SETTING << 16) | JPG_SIZE_ORIGINAL);
- }
- else {
- // Restore the original JPEG-View Mode
- PS_Update(((DWORD)PS_UPDATE_JPG_VIEW_SETTING << 16) | eOriginalViewMode);
- }
- }
- #endif //CLIPS_JPEG_SUPPORT
- }
- void PE_Clips_SetPlaybackOffset(UINT16 uiStartOffset, UINT16 uiEndOffset)
- {
- DVP_API_SetStartOffset(uiStartOffset);
- DVP_API_SetEndOffset(uiEndOffset);
- }
- //<<<Leslie_0823-2003_A: Add new functions for Clips
- void PE_Clips_SetPlaybackRange(DWORD dwStartLBA, ULONG ulBlocksCnt, ULONG ulSize)
- {
- if (IS_CD_MEDIA)
- {
- DEC_CD_SetPlaybackRange(dwStartLBA, ulBlocksCnt, ulSize);
- }
- else if (IS_DVD_PHYSICAL_MEDIA)
- {
- DWORD sta = dwStartLBA;
- drv_lsn2psn(&sta);
-
- DEC_LL_SetDVDStartEndSector(sta, ulBlocksCnt);
- }
- }
- BOOL PE_Clips_Playback_Sectors(DWORD mode, DWORD dwStartLBA, ULONG ulBlocksCnt)
- {
- if ( IS_CD_MEDIA ){
- return drv_play_cd_logical(mode, dwStartLBA, ulBlocksCnt);
- }
- if ( IS_DVD_PHYSICAL_MEDIA ){
- return drv_play_dvd(dwStartLBA, ulBlocksCnt, DRVF_PLAY_DVD_AV_DATA);
- }
- }
- //Leslie_0823-2003_A>>>
- //For DVD-R/CD-R clips get the current location.
- DWORD PE_Clips_GetCurrLocation(void)
- {
- DWORD dwcurrlocation;
-
- if(IS_DVD_PHYSICAL_MEDIA)
- {
- drv_get_curr_psn(&dwcurrlocation);
- drv_psn2lsn(&dwcurrlocation);
- }
- else
- dwcurrlocation = PE_CD_GetCurrentLocation();
- return dwcurrlocation;
- }
- #ifdef USE_AUX_SUBTITLES
- UINT32 PE_Clips_GetClock_Raw(void)
- {
- ULONG ulTime;
- if (!g_theClock.bRunning) {
- // Since the Clock is not running, its value is the Time-Offset
- ulTime= g_theClock.ulOffset;
- }
- else {
- switch ((enClockType)g_theClock.eClockType)
- {
- case eCT_Internal:
- if ( PST_SCAN != gcs.pstate )
- ulTime= g_theClock.ulOffset +
- timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
- else{
- #if 0
- ulTime = g_theClock.ulOffset +
- gns.clips.iScanSpeed*timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
- #else //ZCO LC040903: when scanning backwards, ulTime may be negative, which becomes a very big number because it is unsigned long. Must adjust it.
- LONG lTemp = g_theClock.ulOffset +
- gns.clips.iScanSpeed*timing_get_diff(g_theClock.ulEpoch, timing_get_clock());
- ulTime = (lTemp < 0) ? 0 : lTemp;
- #endif
- }
- break;
- case eCT_Decoder:
- if (!DEC_get_current_SCR(&ulTime))
- ulTime= g_theClock.ulEpoch;
-
- ulTime= g_theClock.ulOffset + SCR_DIFF(g_theClock.ulEpoch, ulTime);
- break;
- case eCT_Drive:
- ulTime = PE_CD_GetCurrentLocation();
- ulTime = DRIVE_CLOCK_DIFF(g_theClock.ulEpoch, ulTime);
-
- break;
- }
- }
- // <<< Robin_2004_0517_B, AuxSubtitle get clock in ms
- switch ((enClockType)g_theClock.eClockType)
- {
- case eCT_Internal:
- ulTime = ulTime/1000;
- break;
- case eCT_Decoder:
- ulTime= ulTime/90;
- break;
- case eCT_Drive:
- ulTime = (ulTime * 40) /3;
- break;
- }
- dbg_printf(("Time is %ld msn", ulTime));
- return ulTime;
- }
- #endif // USE_AUX_SUBTITLES