Digest.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:28k
- /* **************************************************************************************
- * Copyright (c) 2002 ZORAN Corporation, All Rights Reserved
- * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
- *
- * File: $Workfile: Digest.c $
- *
- *
- * Description:
- * ============
- * Implementation of the digest mechanism.
- *
- * Log:
- * ====
- * $Revision: 20 $
- * Last Modified by $Author: $ at $Modtime: $
- ****************************************************************************************
- * Updates:
- ****************************************************************************************
- * $Log: /I76/I76_Common/I76_Reference/Playcore/Digest/Digest.c $
- *
- **************************************************************************************** */
- #include "Config.h" // Global Configuration - do not remove!
- #ifdef _DEBUG
- #undef IFTRACE
- #define IFTRACE if (gTraceCore)
- #include "DebugDbgMain.h"
- #endif //_DEBUG
- #if (defined(SVCD_DIGEST_SUPPORT) ||
- defined(DVD_DIGEST_SUPPORT) ||
- defined(CLIPS_JPEG_DIGEST_SUPPORT))
- #include "Includecpu_address.h"
- #include "KernelEventdef.h"
- #include "KernelKer_API.h"
- #include "PlaycoreDigestDigest.h"
- #include "DriveDrv_Defs.h"
- #include "DriveDrv_API.h"
- #include "DecoderDEC_Defs.h"
- #include "DecoderDecoder.h"
- #include "Decoderlow_levelDEC_LL_Cmd.h"
- #include "Decoderlow_levelDEC_LL_API.h"
- #include "Decoderlow_levelDEC_LL_Def.h"
- #include "PlaycoreCoremainCoremain.h"
- #include "PlaycoreCoremainCoreGDef.h"
- #include "PlaycorePSPS.h"
- #include "PlaycoreTimingTiming.h"
- /////////////////////////////////////////////////////////////////////////////
- // Constants
- #define UNINITIALIZED 0xFFFF
- #define TIMER_INTERVAL_MS 50
- typedef enum { eStateReady, eStateBusy } enDisplayState;
- typedef enum
- {
- eDigestNext, eDigestPrev, eDigestStop,
- eDigestFocus, eDigestSelection
- } enPendingEvent;
- typedef enum
- {
- eFrameNotValid,
- eFrameNextTickValid,
- eFrameValid
- } enFrameState;
- /////////////////////////////////////////////////////////////////////////////
- //Global variables
- typedef struct Digest_Info_TAG
- {
- CallbackFuncPtr pfCallback;
- UINT16 uUnitsCnt;
- UINT8 uIntroFramesCount; //the number of frames that will be displayed per digest item
- // on the first time the frame is displayed.
- UINT16 uCurrAnimatedItem; //The item that is being animated
- UINT16 uFirstVisibleItem; //The first item to be displayed in the current digest screen
- UINT16 uLastVisibleItem; //The last item to be displayed in the current digest screen
- UINT16 uItemOnFocus; //The item being focused
- UINT16 uLastFocusedItem; //The last item to gain focus
- UINT8 hTimer; //A Timer
- int hDigest_handler; //The event handler
- struct
- {
- unsigned int eDigestMode :2; //Indication whether this is a track digest (or disc digest)
- unsigned int eCurrState :2; //The current display state
- unsigned int bIsPendingEvent :1; //An indication whether there is a pending event
- unsigned int ePendingEvent :3; //Holds the pending event
- unsigned int eValidOp :2; //Holds the current available operations: Next/Prev
- unsigned int eFrameState :2; //The current state for the focus frame - can it be
- // displayed already or not.
- unsigned int reserved :4;
- } stateInfo;
- } Digest_Info;
- Digest_Info *g_DigestInfo = NULL;
- UINT8 g_uFramesToAnimate = 0; //The number of frames left to animate the current item
- extern BYTE g_DigestReadDiscError; //mikex_0827_2003_a
- /////////////////////////////////////////////////////////////////////////////
- // Forward declarations
- static void _stopDigestItem(UINT16 i_uItemToStop);
- static void _onTimer(UINT8 hTimer);
- static int _eventHandler(HDLR_OP Op, EVENT Event, void *Param);
- static void _onTick(void);
- static void OnDigestnext(void);
- static void OnDigestprev(void);
- /////////////////////////////////////////////////////////////////////////////
- // Digest Interface Implementation
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_init
- //
- // Purpose : Initializations required for digest mode.
- //
- // Input Parameters :
- // CallbackFuncPtr i_pfCallback - pointer to a callback function that will handle the
- // presentation of the item. This function is specific for each navigator.
- // UINT16 i_uDigestUnitsCnt - The number of units to be displayed.
- // enDigestMode i_eDigestMode - digest mode: Track view or Disc view.
- // UINT8 i_uIntroFramesCount - number of animation frames in the first digest screen.
- //
- // Return Value : BOOL - true in case all the given parameters are valid.
- //
- // Description : Insatlling the the digest as an event handler, and setting
- // the decoder to the right state for digest.
- //////////////////////////////////////////////////////////////////////////////////
- BOOL Digest_init(CallbackFuncPtr i_pfCallback, UINT16 i_uDigestUnitsCnt,
- enDigestMode i_eDigestMode, UINT8 i_uIntroFramesCount)
- {
- dbg_printf(("Digest_init()n"));
- g_DigestInfo = (Digest_Info *)malloc(sizeof(Digest_Info));
- if(NULL == g_DigestInfo)
- {
- tr_printf(("WARNING: Digest_init() failed - alloc memory for g_DigestInfo failedn"));
- return(FALSE);
- }
- //safety checks
- if (NULL == i_pfCallback)
- {
- tr_printf(("WARNING: Digest_init() failed - given callback value invalidn"));
- return(FALSE);
- }
- if (0 == i_uDigestUnitsCnt)
- {
- tr_printf(("WARNING: Digest_init() failed - Invalid digest units size valuen"));
- return(FALSE);
- }
- //installing the System-Events Handler
- g_DigestInfo->hDigest_handler = install_core_event_handler(_eventHandler);
- if (-1 == g_DigestInfo->hDigest_handler)
- {
- tr_printf(("WARNING: Digest_init() failed - failed to install event handlern"));
- return FALSE;
- }
- //creating a Timer
- g_DigestInfo->hTimer= timer_service_create(_onTimer, TIMER_INTERVAL_MS,
- (TIMER_ENABLED | TIMER_REPEAT));
- if (NULL == g_DigestInfo->hTimer)
- {
- tr_printf(("WARNING: Digest_init() failed - failed to create a timern"));
- return FALSE;
- }
- //initializing the Digest Information
- g_DigestInfo->pfCallback = i_pfCallback;
- g_DigestInfo->uUnitsCnt = i_uDigestUnitsCnt;
- g_DigestInfo->stateInfo.eDigestMode = i_eDigestMode;
-
- if (0 == i_uIntroFramesCount)
- {
- tr_printf(("WARNING: Digest_init() - intro frames count is 0, using default value 1n"));
- i_uIntroFramesCount = 1;
- }
- g_DigestInfo->uIntroFramesCount = i_uIntroFramesCount;
- g_DigestInfo->uCurrAnimatedItem = UNINITIALIZED;
- g_DigestInfo->uLastVisibleItem = UNINITIALIZED;
- g_DigestInfo->uItemOnFocus = UNINITIALIZED;
- g_DigestInfo->uLastFocusedItem = UNINITIALIZED;
- g_DigestInfo->stateInfo.eCurrState = eStateReady;
- g_DigestInfo->stateInfo.bIsPendingEvent = FALSE;
- g_DigestInfo->stateInfo.eValidOp = eDIGEST_OP_NONE;
- g_DigestInfo->stateInfo.eFrameState = eFrameNotValid;
-
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, NULL);
- //setting the decoder to digest mode
- DEC_Digest_start();
- return(TRUE);
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_start
- //
- // Purpose : Displaying the first digest screen.
- //
- // Input Parameters : i_uInitialItem - The index of the Initial item, which will
- // be displayed at the upper-left corner.
- //
- // Return Value : void.
- // Description : Just setting the current and the last displayed items so that
- // on the next tick the updated information will be displayed.
- // Setting the available operations from this point: Prev/Next
- //////////////////////////////////////////////////////////////////////////////////
- void Digest_start(UINT16 i_uInitialItem)
- {
- UINT16 uLastVisible;
- dbg_printf(("Digest_start(%d)n", i_uInitialItem));
- uLastVisible= (i_uInitialItem + DIGEST_MAX_FRAMES_ON_SCREEN - 1);
- if (uLastVisible >= g_DigestInfo->uUnitsCnt)
- uLastVisible= (g_DigestInfo->uUnitsCnt - 1);
- if (0 == i_uInitialItem)
- g_DigestInfo->uCurrAnimatedItem = UNINITIALIZED;
- else
- g_DigestInfo->uCurrAnimatedItem = (i_uInitialItem - 1);
- g_DigestInfo->uFirstVisibleItem= i_uInitialItem;
- g_DigestInfo->uLastVisibleItem = uLastVisible;
- g_DigestInfo->stateInfo.eValidOp = eDIGEST_OP_NONE;
- if (i_uInitialItem > 0)
- g_DigestInfo->stateInfo.eValidOp |= eDIGEST_OP_PREV;
- if (uLastVisible < (g_DigestInfo->uUnitsCnt - 1))
- g_DigestInfo->stateInfo.eValidOp |= eDIGEST_OP_NEXT;
- return;
- }
- /*for use by UI thread*/
- void Digest_next(void)
- {
- dbg_printf(("Digest_next()n"));
- if (g_DigestInfo->uLastVisibleItem == (g_DigestInfo->uUnitsCnt - 1))
- return;
- g_DigestInfo->stateInfo.bIsPendingEvent = TRUE;
- g_DigestInfo->stateInfo.ePendingEvent = eDigestNext;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : OnDigestnext
- //
- // Purpose : Displaying the next digest screen.
- //
- // Return Value : void
- //
- // Description : Just setting the current and the last displayed items so that
- // on the next tick the updated information will be displayed.
- // Setting the available operations from this point: Prev/Next
- //////////////////////////////////////////////////////////////////////////////////
- static void OnDigestnext(void)
- {
- dbg_printf(("OnDigestnext()n"));
- if (g_DigestInfo->uLastVisibleItem == (g_DigestInfo->uUnitsCnt - 1))
- return;
- //checking if the command is a pending command
- if (eStateBusy == (enDisplayState)g_DigestInfo->stateInfo.eCurrState)
- {
- g_DigestInfo->stateInfo.bIsPendingEvent = TRUE;
- g_DigestInfo->stateInfo.ePendingEvent = eDigestNext;
- }
- else
- {
- //resetting the indication for the first frame presentation
- g_DigestInfo->stateInfo.eFrameState = eFrameNotValid;
- // First of all, stop the current Item
- _stopDigestItem(g_DigestInfo->uCurrAnimatedItem);
- //setting the current item to be the last item from the previous digest screen
- g_DigestInfo->uCurrAnimatedItem = g_DigestInfo->uLastVisibleItem;
- //setting the visible range
- g_DigestInfo->uFirstVisibleItem += DIGEST_MAX_FRAMES_ON_SCREEN;
- g_DigestInfo->uLastVisibleItem += DIGEST_MAX_FRAMES_ON_SCREEN;
- if (g_DigestInfo->uLastVisibleItem >= g_DigestInfo->uUnitsCnt)
- g_DigestInfo->uLastVisibleItem = (g_DigestInfo->uUnitsCnt - 1);
- //stop any on-going animation
- g_uFramesToAnimate = 0;
- g_DigestInfo->uItemOnFocus = UNINITIALIZED;
- g_DigestInfo->stateInfo.eValidOp = eDIGEST_OP_NONE;
- //is prev available
- if (g_DigestInfo->uFirstVisibleItem > 0)
- g_DigestInfo->stateInfo.eValidOp |= eDIGEST_OP_PREV;
- //is next available
- if (g_DigestInfo->uLastVisibleItem < (g_DigestInfo->uUnitsCnt - 1))
- g_DigestInfo->stateInfo.eValidOp |= eDIGEST_OP_NEXT;
- }
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_prev
- //
- // Purpose : Displaying the previous digest screen.
- //
- // Return Value : void
- //
- // Description : Just setting the current and the last displayed items so that
- // on the next tick the updated information will be displayed.
- // Setting the available operations from this point: Prev/Next
- //////////////////////////////////////////////////////////////////////////////////
- void Digest_prev(void)
- {
- dbg_printf(("Digest_prev()n"));
- if ((DIGEST_MAX_FRAMES_ON_SCREEN - 1) == g_DigestInfo->uLastVisibleItem)
- return;
- g_DigestInfo->stateInfo.bIsPendingEvent = TRUE;
- g_DigestInfo->stateInfo.ePendingEvent = eDigestPrev;
- }
- static void OnDigestprev(void)
- {
- dbg_printf(("OnDigestprev()n"));
- if ((DIGEST_MAX_FRAMES_ON_SCREEN - 1) == g_DigestInfo->uLastVisibleItem)
- return;
- //checking if the command is a pending command
- if (eStateBusy == (enDisplayState)g_DigestInfo->stateInfo.eCurrState)
- {
- g_DigestInfo->stateInfo.bIsPendingEvent = TRUE;
- g_DigestInfo->stateInfo.ePendingEvent = eDigestPrev;
- }
- else
- {
- //resetting the indication for the first frame presentation
- g_DigestInfo->stateInfo.eFrameState = eFrameNotValid;
- // First of all, stop the current Item
- _stopDigestItem(g_DigestInfo->uCurrAnimatedItem);
- //calculating the appropriate visible range
- //the current Item is always set to 1 less than the first, so that onTick it will be increased
- if (g_DigestInfo->uFirstVisibleItem > DIGEST_MAX_FRAMES_ON_SCREEN) {
- g_DigestInfo->uFirstVisibleItem -= DIGEST_MAX_FRAMES_ON_SCREEN;
- g_DigestInfo->uCurrAnimatedItem = (g_DigestInfo->uFirstVisibleItem - 1);
- }
- else {
- g_DigestInfo->uFirstVisibleItem = 0;
- g_DigestInfo->uCurrAnimatedItem = UNINITIALIZED;
- }
- g_DigestInfo->uLastVisibleItem= (g_DigestInfo->uFirstVisibleItem +
- DIGEST_MAX_FRAMES_ON_SCREEN - 1);
- if (g_DigestInfo->uLastVisibleItem >= (g_DigestInfo->uUnitsCnt))
- g_DigestInfo->uLastVisibleItem = (g_DigestInfo->uUnitsCnt - 1);
- //stop any on going animation
- g_uFramesToAnimate = 0;
- g_DigestInfo->uItemOnFocus = UNINITIALIZED;
- g_DigestInfo->stateInfo.eValidOp = eDIGEST_OP_NONE;
- //is prev available
- if (g_DigestInfo->uFirstVisibleItem > 0)
- g_DigestInfo->stateInfo.eValidOp |= eDIGEST_OP_PREV;
- //is next available
- if (g_DigestInfo->uLastVisibleItem < (g_DigestInfo->uUnitsCnt - 1))
- g_DigestInfo->stateInfo.eValidOp |= eDIGEST_OP_NEXT;
- }
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_onItemFocus
- //
- // Purpose : Start animate the item that got focus.
- //
- // Input Parameters :
- // UINT16 i_uItem - zero based index of the item that got the focus.
- //
- // Return Value : BOOL - an indication whether the given index is valid.
- //
- // Description : Setting the item that is being focused.
- //////////////////////////////////////////////////////////////////////////////////
- BOOL Digest_setFocus(UINT16 i_uItem)
- {
- dbg_printf(("Digest_setFocus(%d)n", i_uItem));
- //safty check for the index
- if ((i_uItem < g_DigestInfo->uFirstVisibleItem) ||
- (i_uItem > g_DigestInfo->uLastVisibleItem))
- {
- dbg_printf(("Digest: given index is out of current range.n"));
- return(FALSE);
- }
- if ((eStateBusy == (enDisplayState)g_DigestInfo->stateInfo.eCurrState) || //busy
- (0 != g_uFramesToAnimate)) //or still has intro frames to display
- {
- g_DigestInfo->stateInfo.bIsPendingEvent = TRUE;
- g_DigestInfo->stateInfo.ePendingEvent = eDigestFocus;
- g_DigestInfo->uItemOnFocus = i_uItem;
- }
- else
- {
- g_DigestInfo->uItemOnFocus = i_uItem;
- }
- return(TRUE);
- }
- #ifdef _DEBUG
- //this function is only used by the debug menu on the terminal
- void Digest_onItemLostFocus(void)
- {
- dbg_printf(("Digest_onItemLostFocus()n"));
- g_DigestInfo->uItemOnFocus = UNINITIALIZED;
- g_DigestInfo->uLastFocusedItem = UNINITIALIZED;
- g_uFramesToAnimate = 0;
- }
- #endif //_DEBUG
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_getCurrentDisplayed
- //
- // Purpose : Returning the 1-based index of the current displayed item.
- //
- // Input Parameters : none
- //
- // Return Value : UINT8 - zero-based index of the item currently being displayed.
- //
- // Description : returning the member variable that holds the currently
- // displayed item.
- //////////////////////////////////////////////////////////////////////////////////
- UINT16 Digest_getCurrentDisplayed(void)
- {
- return (g_DigestInfo->uCurrAnimatedItem);
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_getVisibleRange
- //
- // Purpose : Providing a mean to get the currently displayed digest items.
- //
- // Output Parameters :
- // UINT16 *p_uFirstItem - Zero-based index of the first displayed item on screen.
- // UINT16 *p_uLastItem - Zero-based index of the last displayed item on screen.
- //
- // Return Value : void
- //
- // Description : Calculating the indexes of the first and the last displayed items.
- //////////////////////////////////////////////////////////////////////////////////
- void Digest_getVisibleRange(UINT16 *o_pFirstItem, UINT16 *o_pLastItem)
- {
- dbg_printf(("Digest_getVisibleRange()n"));
- if(NULL != g_DigestInfo)
- {
- *o_pFirstItem = g_DigestInfo->uFirstVisibleItem;
- if (UNINITIALIZED == g_DigestInfo->uCurrAnimatedItem)
- *o_pLastItem = g_DigestInfo->uFirstVisibleItem;
- else
- *o_pLastItem = g_DigestInfo->uCurrAnimatedItem;
- }
- else
- {
- //return 0 if g_DigestInfo unmalloced
- *o_pFirstItem = 0;
- *o_pLastItem = 0;
- }
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_getDigestMode
- //
- // Purpose : Getting the current digest mode.
- //
- // Input Parameters : none
- //
- // Return Value : enDigestMode - the current digest mode: disc view or Track view
- //
- // Description : returning the internal indication for the digest mode.
- //////////////////////////////////////////////////////////////////////////////////
- enDigestMode Digest_getDigestMode(void)
- {
- dbg_printf(("Digest_getDigestMode()n"));
- return (enDigestMode)g_DigestInfo->stateInfo.eDigestMode;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_getValidOp
- //
- // Purpose : Getting the current valid operations: Prev / Next / None.
- //
- // Input Parameters : none
- //
- // Return Value : enDIGEST_VALID_OP
- //
- // Description : Returning the internal variable that holds the available
- // navigation operations considering the current displayed
- // digest screen.
- //////////////////////////////////////////////////////////////////////////////////
- enDIGEST_VALID_OP Digest_getValidOp(void)
- {
- dbg_printf(("Digest_getValidOp()n"));
- return (enDIGEST_VALID_OP)g_DigestInfo->stateInfo.eValidOp;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_firstItemDisplayed
- //
- // Purpose : Getting an indication whether the first item has already
- // been displayed, cause if so then for example the focus
- // frame can be displayed by the UI.
- //
- // Input Parameters : none
- //
- // Return Value : BOOL - TRUE in case the frame can be displayed, FALSE otherwise.
- //
- // Description : Checking the internal indication that indicates whether or not
- // the first frame of the first item on screen has been displayed.
- //////////////////////////////////////////////////////////////////////////////////
- BOOL Digest_firstItemDisplayed(void)
- {
- dbg_printf(("Digest_firstItemDisplayed()n"));
- if(NULL != g_DigestInfo)
- {
- if (eFrameValid == (enFrameState)g_DigestInfo->stateInfo.eFrameState)
- return(TRUE);
- }
- return(FALSE);
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_terminate
- //
- // Purpose : Terminating the digest operation.
- //
- // Input Parameters : none
- //
- // Return Value : void
- //
- // Description : stop the decoder from running on digest mode.
- //////////////////////////////////////////////////////////////////////////////////
- void Digest_terminate(void)
- {
- dbg_printf(("Digest_terminate()n"));
- // Terminate the current Item, if it is not in Ready state
- if (eStateReady != g_DigestInfo->stateInfo.eCurrState) {
- _stopDigestItem(g_DigestInfo->uCurrAnimatedItem);
- }
- g_DigestInfo->stateInfo.eFrameState = eFrameNotValid;
- //resetting the decoder mode
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, NULL);
- DEC_Digest_stop();
- drv_abort_play();
- //destroying the Timer
- timer_service_disable(g_DigestInfo->hTimer);
- timer_service_delete(g_DigestInfo->hTimer);
- //removing the event handler
- remove_core_event_handler(g_DigestInfo->hDigest_handler);
- g_DigestInfo->hDigest_handler = -1;
- //resetting the indexes
- g_DigestInfo->uCurrAnimatedItem = UNINITIALIZED;
- g_DigestInfo->uFirstVisibleItem = UNINITIALIZED;
- g_DigestInfo->uLastVisibleItem = UNINITIALIZED;
- g_uFramesToAnimate = 0;
- if(NULL != g_DigestInfo)
- {
- free(g_DigestInfo);
- g_DigestInfo = NULL;
- }
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Internal functions
- static void _stopDigestItem(UINT16 i_uItemToStop)
- {
- if (UNINITIALIZED != i_uItemToStop)
- (*(g_DigestInfo->pfCallback))(i_uItemToStop, eDigestQuery_Stop);
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : _displayDigestItem
- //
- // Purpose : Displaying an item.
- //
- // Input Parameters : UINT16 i_uItemToAnimate - the index of the item to be annimated.
- // BOOL bFirstFrame - an indication whether th first frame of
- // a Digest item is being displayed. After the first frame is
- // displayed the drive should keep on playing.
- //
- // Return Value : static void
- //
- // Description : Setting the decoder to the digest mode and displayng the
- // current item.
- //////////////////////////////////////////////////////////////////////////////////
- static void _displayDigestItem(UINT16 i_uItemToAnimate, BOOL bFirstFrame)
- {
- dbg_printf(("Digest: _displayDigestItem - item = %d, bFirst=%d n",
- i_uItemToAnimate, bFirstFrame));
- g_DigestInfo->stateInfo.eCurrState = eStateBusy;
- //clearing the screen upon displaying the first frame
- if ( (g_DigestInfo->uFirstVisibleItem == i_uItemToAnimate) &&
- bFirstFrame &&
- (UNINITIALIZED == g_DigestInfo->uItemOnFocus) ) //not in focus mode
- {
- DEC_Digest_clearScreen();
- }
- else {
- DEC_Digest_keepScreen();
- }
- // Select the Widnow-Position for the current Item
- DEC_Digest_setWindowPosition(i_uItemToAnimate - g_DigestInfo->uFirstVisibleItem);
- //presenting the item by using the callback function which is specific to each navigator
- if (bFirstFrame) {
- (*g_DigestInfo->pfCallback)(i_uItemToAnimate, eDigestQuery_Start);
- }
- else {
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_PLAY, NULL);
- }
-
- return;
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : _onTimer
- //
- // Purpose : Handling a Timer event.
- //
- // Input Parameters : None
- //
- // Return Value : None
- //
- // Description : Generates a TICK_100 Event, in order to allow processing
- // without restrictions.
- //////////////////////////////////////////////////////////////////////////////////
- #pragma argsused
- static void _onTimer(UINT8 hTimer)
- {
- send_tick(IE_CORE_TICK_100);
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : _eventHandler
- //
- // Purpose : Handling the received events.
- //
- // Input Parameters :
- // HDLR_OP Op
- // EVENT Event
- // void *Param
- //
- // Return Value : int
- //
- // Description : Handling only the TICK event.
- //////////////////////////////////////////////////////////////////////////////////
- #pragma argsused
- static int _eventHandler(HDLR_OP Op, EVENT Event, void *Param)
- {
- if ((HDLR_EVENT == Op) && (IE_CORE_TICK_100 == Event)) {
- _onTick();
- }
- return(0);
- }
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : _onTick
- //
- // Purpose : Checking on each tick if the last digest operation has
- // finished.
- //
- // Input Parameters : none
- //
- // Return Value : static void
- //
- // Description : Verifying that the Decoder is Idle, and if it is - invoking
- // the next appropriate action.
- //////////////////////////////////////////////////////////////////////////////////
- static void _onTick(void)
- {
- if ((eStateReady == g_DigestInfo->stateInfo.eCurrState) ||
- DEC_Digest_isIdle())
- {
- g_DigestInfo->stateInfo.eCurrState = eStateReady;
- if (eFrameNextTickValid == (enFrameState)g_DigestInfo->stateInfo.eFrameState)
- {
- g_DigestInfo->stateInfo.eFrameState = eFrameValid;
- if(g_DigestInfo->uFirstVisibleItem == g_DigestInfo->uLastVisibleItem)
- {
- _stopDigestItem(g_DigestInfo->uCurrAnimatedItem);
- }
- }
-
- //checking if there is a pending command cause it should be performed first
- if (g_DigestInfo->stateInfo.bIsPendingEvent)
- {
- //switch on the pending event
- switch ((enPendingEvent)g_DigestInfo->stateInfo.ePendingEvent)
- {
- case eDigestNext:
- OnDigestnext();
- break;
- case eDigestPrev:
- OnDigestprev();
- break;
- case eDigestStop:
- Digest_terminate();
- break;
- case eDigestFocus:
- Digest_setFocus(g_DigestInfo->uItemOnFocus);
- break;
- }
- g_DigestInfo->stateInfo.bIsPendingEvent = FALSE;
- }
- //The following order of the checks is crucial:
- //Are there more intro frames to animate for the current item?
- else if (g_uFramesToAnimate > 0)
- {
- //decoding next picture only if it's the first item or last picture copy done
- if((g_DigestInfo->uCurrAnimatedItem == (g_DigestInfo->uFirstVisibleItem-1))||
- DEC_Digest_IsCopyDone() )
- {
- //is this the first animation frame for the item?
- if (g_uFramesToAnimate == g_DigestInfo->uIntroFramesCount)
- {
- // First of all, stop the current Item
- _stopDigestItem(g_DigestInfo->uCurrAnimatedItem);
- g_DigestInfo->uCurrAnimatedItem++;
-
- _displayDigestItem(g_DigestInfo->uCurrAnimatedItem, TRUE);
- //If this is the first item on screen then setting the indication
- if (g_DigestInfo->uCurrAnimatedItem == g_DigestInfo->uFirstVisibleItem)
- {
- g_DigestInfo->stateInfo.eFrameState = eFrameNextTickValid;
- }
- }
- else
- {
- _displayDigestItem(g_DigestInfo->uCurrAnimatedItem, FALSE);
- }
- g_uFramesToAnimate--;
- }
- }
- //are there more digest items to display in the current screen?
- else if ((g_DigestInfo->uCurrAnimatedItem < g_DigestInfo->uLastVisibleItem) ||
- (UNINITIALIZED == g_DigestInfo->uCurrAnimatedItem))
- {
- g_uFramesToAnimate = g_DigestInfo->uIntroFramesCount;
- }
- //is there an item being focused?
- else if (UNINITIALIZED != g_DigestInfo->uItemOnFocus)
- {
- //is this a new focused item?
- if ((g_DigestInfo->uItemOnFocus != g_DigestInfo->uLastFocusedItem) ||
- (UNINITIALIZED == g_DigestInfo->uLastFocusedItem))
- {
- _stopDigestItem(g_DigestInfo->uCurrAnimatedItem);
- g_DigestInfo->uLastFocusedItem = g_DigestInfo->uItemOnFocus;
-
- _displayDigestItem(g_DigestInfo->uItemOnFocus, TRUE);
- }
- else
- _displayDigestItem(g_DigestInfo->uItemOnFocus, FALSE);
- }
- }
- else if (TRUE == (*g_DigestInfo->pfCallback)(g_DigestInfo->uCurrAnimatedItem, eDigestQuery_IsFinished))
- {
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, NULL);
- g_DigestInfo->uLastFocusedItem = UNINITIALIZED;
- }
- //<<<mikex_0827_2003_a: add the recovery error mechanism in digest mode
- else if(g_DigestReadDiscError > 0 )
- {
- DEC_PlaybackCommand(DEC_PLAYBACK_CMD_STOP, NULL);
- g_DigestReadDiscError =0;
- }//mikex_0827_2003_a>>>
-
- return;
- }
- UINT16 DigestGetFirstItem(void)
- {
- return g_DigestInfo->uFirstVisibleItem;
- }
- #ifdef S1_GUI // ZKR GLV778
- BOOL digest_pending(void)
- {
- return g_DigestInfo->stateInfo.bIsPendingEvent;
- }
- #endif
- //////////////////////////////////////////////////////////////////////////////////
- // Function name : Digest_IsFirstDigestWindow
- //
- // Purpose : Check if current display window is the first one on the screen
- //
- // Input Parameters :
- //
- // Return Value : TRUE: Yes
- // : FALSE: No
- //
- // Description :
- //////////////////////////////////////////////////////////////////////////////////
- BOOL Digest_IsFirstDigestWindow()
- {
- return ( 0 == ( ( g_DigestInfo->uCurrAnimatedItem - g_DigestInfo->uFirstVisibleItem ) % DIGEST_MAX_FRAMES_ON_SCREEN ) );
- }
- #endif //#if (defined(SVCD_DIGEST_SUPPORT) || defined(DVD_DIGEST_SUPPORT))