⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utl.c

📁 车载电子影音系统dvd播放系统原程序代码
💻 C
📖 第 1 页 / 共 5 页
字号:
        _dwUTLTemp*= 2;

///    _dwUTLTemp-= 150L;

    return _dwUTLTemp;
}

//  *********************************************************************
//  Function    :   UTL_SectorstoMSF
//  Description :       Convert the time format from HSG(sector) into mm:ss:ff
//  Arguments   :
//  Return      :   The converted mm:ss:ff value, 0f:sm
//  Side Effect :
//  *********************************************************************
DWORD       UTL_SectorstoMSF ( DWORD hsgTime )
{
//DVD_050SRAM
//    DWORD       dwTemp;

    if ( __wDiscType & BOOK_2X )
        _dwUTLTemp= hsgTime/ 150;
    else
        _dwUTLTemp= hsgTime/ 75;

    __bMin= (BYTE)(_dwUTLTemp/ 60);
    __bSec= (BYTE)(_dwUTLTemp% 60);     // MAX. is 59
    __bFrame= (BYTE)(hsgTime % 75);

    // convert mm:ss:ff into DWORD format xf:sm
    _dwUTLTemp= MAKE_MSF ( __bMin, __bSec, __bFrame );

    return _dwUTLTemp;
}

//  *********************************************************************
//  Function    :   UTL_GetCurrentTime
//  Description :   get the Time from MPEG or CDROM (for CDDA)
//  Arguments   :       NULL
//  Return      :   current time value
//  Side Effect :
//  *********************************************************************
DWORD UTL_GetCurrentTime ()
{
//DVD_046-1DVDIF
#ifdef  SUPPORT_CDIF
if (__bCurrentIF==BITSTREAM_CDIF)
{
//jyliu.scan, fix SCB/SCF time incorrect issue
#ifdef SUPPORT_ANTISHOCK
{
extern BYTE __bScanTime;
extern DWORD __dwScanTime;
	if(((__bModeCmd == KEY_SCB) || (__bModeCmd == KEY_SCF))&&!(__wDiscType&BOOK_CDDA))
	{
		if(__bScanTime)
		{
			__dwTimeNow = __dwScanTime;
			return __dwScanTime;
		}
	}
}
#endif
	// LLY.274p, check playing mode method has updated
    //if ( __bModePlay == MODE_PLAYCDDA )
    if(__bAttrPlay == ATTR_CDDA)
    {
        // CDDA couldn't get time from MPEG chip
        if ( ! SERVO_GetCurrentPos ( & __dwTemp ) )
            // request time from CD-ROM fail
            // can't set __dwTimeNow as __dwTimeBegin
            // it will cause time reset to 0(the VFD display)
            // so just return current time
            return __dwTimeNow;
    }
    else
    {
        __dwTemp=HAL_GetSectorID();
    }

    if (  __dwTemp > (__dwTimeEnd+ 2000L) )
    {
        // larger may be get the wrong MSF
    }
    else
        if ( __dwTemp < (__dwTimeBegin) )
        {
            // smaller set to lower bound
            // SCB usage
            // reset the current time as __dwTimeBegin
// f/w 0.45
// do not update __dwTimeNow, for some damaged disc, the loader
// will go to a out of range place
// but will go back to normal later
// so, we may ignore it, and do not assign the time.
//                __dwTimeNow= __dwTimeBegin;
                        return __dwTemp;
        }
        else
        {

// Micky, maybe it's necessary someday(06/29/99)
// for time circle problem
#ifdef    _TIME_CIRCLE

// update to new(BC)
// f/w 0.45, for time circle problem
// play A
// the loader will goto A- time(so the MPEG will decode A- time)
// but the loader still report A time
// now we check the torelence for the validity of time.
// time torelence is 10 sec.
// but it has the possibility that the time will stop update
// how to recover time???

#define TIME_CIRCLE_GAP     (75L*10)
#define TIME_NORMAL_GAP     (75L)
// 0.45, for time circle
//            if (__btPlaying)
            if (__btPlaying || __btPause)
            {
                DWORD   dwDifference;

                // 1. Check time update speed
                //    to prevent that time will not update
                if (__bNormalCount)    // there's once time update abnormal
                {
//                    dwDifference=DiffOfTwo(__dwTemp, __dwPreTimeCircle);
                    // if UTL_GetCurrentTime is called every sec.
// 0.45, for time circle
                    // genearlly, the value will increase 75 each time
                    if (__dwTemp > __dwPreTimeCircle)
                        if ((__dwTemp-__dwPreTimeCircle) <= TIME_NORMAL_GAP)
//                    if (dwDifference < TIME_NORMAL_GAP)
                    {
                        // save cuurent time
                        __dwPreTimeCircle=__dwTemp;
                        // increase normal time count
                        __bNormalCount++;
                        // time is changed normal for 10 times
                        // now UTL_GetCurrentTime is called every 0.3 sec.
                        // 10*0.3=3 sec.
                        if (__bNormalCount>=10)
                        {
                            if ( SERVO_GetCurrentPos ( & __dwPreTimeCircle) )
                            {
                                __dwTemp=__dwPreTimeCircle-__dwTimeTorelence;
                            }

                            if (__dwTemp < __dwTimeBegin)
                                return __dwTimeNow;
                            // the time update normally continue for 3 sec.
                            // the time is valid
                            __dwTimeNow=__dwTemp;

                            __bNormalCount=0;
                        }
                        return __dwTemp;
                    }
                    else
                    {
                        // the time update speed still not normal
                        __bNormalCount=0;
                    }
                }

                // 2. Check time update range too much
//DVD_050SRAM
//                dwDifference=DiffOfTwo(__dwTimeNow, __dwTemp);
                if (__dwTimeNow > __dwTemp)
                    dwDifference= __dwTimeNow-__dwTemp;
                else
                    dwDifference= __dwTemp-__dwTimeNow;
                if (dwDifference > TIME_CIRCLE_GAP)
                {
                    // record the first abnormal time value
                    // the next time value will compare with this value
                    // to see the time update speed is normal or not.
                    __dwPreTimeCircle=__dwTemp;
                    // increase count for indicate time abnormal
                    __bNormalCount=1;
                    // ignore this time value
                    return __dwTemp;
                }
            }

// 0.45, for time circle
            // when time turn to normal
            // must clear the count, just ignore the previous error time
            __bNormalCount=0;
#endif    // _TIME_CIRCLE

            // set current time value
            __dwTimeNow= __dwTemp;
        }

    return  __dwTemp;
}
#endif
//    if (__bCurrentIF != BITSTREAM_CDIF)
    {
//DVD_049Micky
// need check the validity of time
// the servo return gdwNextLBA-1, may less than __dwTimeBegin
/*
        SERVO_GetCurrentPos (&__dwTimeNow) ;
        return __dwTimeNow;
*/
        SERVO_GetCurrentPos (&__dwTemp) ;
        if (__dwTemp >= __dwTimeBegin)
            __dwTimeNow=__dwTemp;
        return __dwTemp;
    }
}
//  *********************************************************************
//  Function    :   UTL_DelayTime
//  Description :       Delay until time out
//  Arguments   :       wCount  : the delay time
//                      btBreak : FALSE, wait until time out
//                              : TRUE, leave immediately
//  Return      :   TRUE
//  Side Effect :
//  *********************************************************************
BIT   UTL_DelayTime ( WORD wCount, BIT btBreak )
{
    // *TCH** 97.6.30; need more testing
/// DVD_172Micky, use _dwTimeStart.
///DWORD   dwTemp;

// **** TCH0.99C-XQ, Begin...
///    __wTemp= wCount;
/// DVD_172Micky, use _dwTimeStart.
    _dwTimeStart = UTL_GetSysTimer();
    while ( ( UTL_GetSysTimer()- _dwTimeStart ) < wCount )
    {
//DVD_046-1DVDIF
//#ifndef  INPUT_PATH_HOSTIF
#ifdef  INPUT_PATH_ATAPIIF
        SERVO_Monitor ();
        // TCC276, need check overflow or it'll have block/noise when someone delay too long
//        if (__btPlaying && !__bServoAutoCtrl && !( W99AV_ReadRegW(DVDCTLR) & 0x000C ))  // Check overflow
        // TCC278, use HAL_CheckCDIF (HAL_CDIF_STOP) to check CDI open or not.
        if (__btPlaying && !__bServoAutoCtrl && !HAL_CheckCDIF(HAL_CDIF_STOP, NULL))  // Check overflow
        {
            __btTemp= FALSE ;
            W99AV_ReadInfo ( W99AV_INFO_VIDEO_REMAIN , &__dwTemp ); // DWORD unit
            if ( __dwTemp> __dwVOBuffer )  // check if video overflow
                __btTemp= TRUE;
            else    // ** TCH-.21, check if audio overflow;
            {
                __wTemp= W99AV_GetPSR ();
                if ( __wTemp & INT_AO )
                {
                    W99AV_ClearInterrupt(INT_AO);
                    __btTemp= TRUE;
                }
            }

            if ( __btTemp )
            {
                HAL_CheckCDIF ( HAL_CDIF_FREEZE_TIME, (BYTE)NULL );
            }
                }
#endif
// removed by MICKY 7/14
// must check if remove
// __btJumping will never be true
// and it's useless, should remove from cc.c
/*
        if ( btBreak )
        {
            if ( __btJumping )
                break;
        }
*/
    }

    return  TRUE;
}

//  *********************************************************************
//  Function    :   UTL_SetPlayItemMode
//  Description :   First check the mode of the play item, then set relative
//                  command to MPEG chip
//  Arguments   :   nItem   : The play item number
//  Return      :   bTemp   : return the play mode for this play item
//  Side Effect :
//  *********************************************************************
// LLY.276p-4, only need BYTE unit for return value
//WORD UTL_SetPlayItemMode ( WORD nItem )
BYTE UTL_SetPlayItemMode ( WORD nItem )
{
    BYTE        bTemp;

    // bTemp will contain the play item mode
    // MODE_PLAYMOTION, _PLAYCDDA, _PLAYSTILLNTSC/PAL, _PLAYSTILLSTILLHNTSC/PAL
    // MODE_PLAYMP3

    // LLY.274p-1, must consider MP3 and JPG file together.
    // And, merge to UTL_CheckPlayItemMode()
    // Let all "playing item mode checking" into UTL_CheckPlayItemMode
    bTemp= UTL_CheckPlayItemMode ( nItem );

    // ** DVD-TCH0.19;
    // set the relative programming for different play mode
    UTL_SetPlayMode ( bTemp );

    // LLY.276p-4, set playing item mode configure
    UTL_SetPlayItemConfig(nItem);

    return bTemp;
}

//  *********************************************************************
//  Function    :   UTL_PlayItem        // ** TCH0.27;
//  Description :   Get the play item playing range, and issue command, then
//                  start input data by the specified time
//  Arguments   :   nItem       : PIN as def. in VCD2.0 if NO-DVD
//                              : NO-Use in DVD, Refer __bTitle/ __wChapter
//                  dwTime      : 0 means from start point of [nItem]
//                              : other value will play from the specified time
//  Return      :   TRUE
//  Side Effect :
//  *********************************************************************
WORD UTL_PlayItem ( WORD nItem, DWORD dwTime )
{
    extern BIT          __btNewTime;

    // for auto pause re-entry
    BYTE    bEX1;

    // only get __dwTimeBegin/__dwTimeEnd when starting play from beginning
    // For fast or goto time, can't get __dwTimeEnd again
    // Because in VCD 2.0, the __dwTimeEnd will be adjusted
    // slove JVC play time test will play over range in fast mode
    // Micky0.85, The condition (!dwTime) means play from track begin.
    // the necessary setting before playing each track can put here
    if ( ! dwTime )
    {
        // f/w 0.34
        // the place that play a new item must do.
        // reset audio channel to ID 0
        // ** TCH0.38; begin... Only CVD/ SVCD/ DVD has Multiple Audio/
        // DVD should not re-set the Audio Channel. Need to keep same...
        // LLY.104, reset the OGT ID to same as Audio channel
        if ( __wDiscType & BOOK_2X )
        {
            __bASTNO=0;         // ** TCH0.451;
            __bASTID= __bASTNO; // ** TCH0.451;
            __bSPSTNO=0;
            __bSPSTID=__bSPSTNO;
        }
        // ** TCH0.38; end...

#if defined(WMA_DEBUG) || defined(MP3_DEBUG) //Kevin1.22a, add
        _printf(" played time = %lx", __dwPlayFileTime);
        __dwPlayFileTime=0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -