time.c
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:26k
- /*
- * terry,2003/8/18 04:19PM
- * Maintain this file
- * Terry,2004/3/25 06:29PM
- */
- #include "config.h"
- #include "regmap.h"
- #include "global.h"
- #include "macro.h"
- #include "func.h"
- #include "util.h"
- #include "stdlib.h" //huo 2000.12.14
- #include "cdfunc.h"
- #include "cfont.h"
- #include "sio.h"
- #include "vfdfunc.h"
- #include "ringbuf.h"
- #include "ircmd.h"
- #include "ircode.h"
- #include "cd.h"
- #include "auctrl.h"
- #include "user_init.h" //terry,2001/1/9 03:29PM
- #include "avd.h"
- #include "dvdpe.h"
- #include "fs96602.h"
- #include "osd.h"
- #include "framebuf.h"
- #include "cderr.h"
- #include "vpp.h"
- #include "user_if.h"
- #include "dsp3_if.h"
- #include "atapi_if.h"
- #include "dma.h" //Jeff 20010919
- #include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
- //#include "audif.h"
- #include "setup.h"
- #include "fsGUI.h"
- #include "drv.h"
- #include "auddac.h"
- #include "fsNAV.h"
- #include "asf_if.h"
- #include "iop.h"//2-7-9 9:40
- #include "UartTxd.h"
- #ifdef TUNER_T988
- #include "radio_t988.h" //jinping 2-6-20 14:04
- #elif defined(SUPPORT_TUNER_MV114) || defined(SUPPORT_TUNER_ALPS)//xyy 2004-5-28
- #include "radio_mv114_kst.h" //jinping 2002-7-1 20:30
- #endif
- #if defined(PT2322)||defined(PT2320)
- #include "audctrl.h"
- #endif
- #if defined(TAS3001_AMP) //use TI 3001 amplifier jason ych add 2-8-9 10:10
- #include "ti3001.h"
- #endif
- #if defined(TAS5026_AMP) //use TI 3001 amplifier jason ych add 2-8-9 10:10
- #include "ti5026.h"
- #endif
- #ifdef SUPPORT_CDG //Jeff 20020824
- #include "cdg.h"
- #endif
- #ifdef SUPPORT_MP4 // 2004/04/20 yltseng, to show remain time
- #include "avi_if.h"
- #endif
- #include "kinf.h" // 2004/08/11 yltseng
- #include "bit_rate.h"
- #if ( defined(SUPPORT_CARD_STORAGE) || defined(SUPPORT_USB) || defined(SPHE8202_CARD_STORAGE) )
- #include "cardfs.h"
- #endif
- // **************************************************************************************** //
- extern UINT8 DVD_show_time(void); //Jeff 20010717
- extern UINT16 Is_MP3_STATE(void);
- extern void vfd_set_showtime(void);
- extern void DispPolling(BYTE bReset);
- extern void DispCookOSD0(BYTE bChange);
- extern UINT32 mp3ReadLen; //Jeff 20010919
- extern UINT32 myTime; //Jeff 20020902
- extern UINT32 oldmp3ReadLen; //Jeff 20020917
- extern BYTE bASFHeaderFinish;
- #ifdef SUPPORT_OSDID3 //suqiaoli add 2004-3-26
- extern void show_id3_song(void);
- #endif
- extern UINT8 avd_search_header(void);
- extern UINT32 PlayBackLength;
- #ifdef SUPPORT_SCORE //gerry modified,2004-3-6 9:37
- UINT32 score_disp_flag;
- #endif
- // **************************************************************************************** //
- #ifndef DVDRELEASE
- //#define DBG_TIME
- #endif
- #ifdef DBG_TIME
- #define printf_time printf
- #else
- #undef printf
- #undef print_block
- #define printf(f, a...) do {} while (0)
- #define print_block(x,y) do {} while (0)
- #define printf_time(f, a...) do {} while (0)
- #endif
- // **************************************************************************************** //
- /*
- ** showtime
- */
- void show_time(void)
- {
- switch(play_state)
- {
- case VCD_STATE_POWER:
- return;
-
- case VCD_STATE_OPEN: // terry 891002
- case VCD_STATE_CLOSE: // terry 891002
- case VCD_STATE_IDLE: // terry 891002
- case VCD_STATE_READTOC: // terry 891002
- disp_trk_now=0;
- disp_time=0; // terry 891002
- break;
-
- case VCD_STATE_STOP: // terry 891002
- if(cd_type_loaded!=CDROM)
- {
- if(cd_type_loaded!=CDDVD)
- disp_trk_now = cd_total_trk();
-
- disp_time=disc_time;
-
- if(cd_type_loaded==CDSVCD)
- disp_time=disp_time/PLAY_SPEED;
- }
- break;
- } //end case
-
- if( ((goto_active)||(sys_cmd))&&(play_state!=VCD_STATE_STOP) )//2-5-25 22:42 to avoid AB show "00" quickly.
- {
- printf_time("goto_active:%x sys_cmd:%x play_state:%xn",goto_active,sys_cmd,play_state);
- return;
- }
-
- if( (disp_time < 0)||((disp_time > (100*3600))) )
- {
- printf_time("time<0n");
- return;
- }
- if ( (cd_type_loaded!=CDROM) && (disp_trk_now > 99) )
- {
- printf_time("trk>99n");
- return;
- }
-
- #if !defined( SUPPORT_FILE_DISPLAY_TM ) && defined( SUPPORT_FILE_SYSTEM_MODE )
- if ((cd_type_loaded == CDROM) && (GetCurrentFileType() == CDROM_MPG)) // Robert 021125
- disp_time = 0;
- #endif
- #ifdef NOCHANGE_DISPLAY_WHEN_PRESTOP
- if((play_state!=VCD_STATE_STOP)||(resumeMSF==0))//wuxiaofeng added 2004-03-05
- #endif
- {
- show_time_hh = disp_time / 3600;
- show_time_mm = (disp_time % 3600) / 60;
- show_time_ss = (disp_time % 3600) % 60;
- }
-
- if(
- (play_state!=VCD_STATE_CLOSE)&&
- (play_state!=VCD_STATE_OPEN)&&
- (play_state!=VCD_STATE_READTOC)&&
- (play_state!=VCD_STATE_IDLE)
- )
- {
- #ifdef FUSS_DVD//nono 2-6-22 15:41
- #if defined(FUSS_PANEL)||defined(FUSS2_PANEL)
- if( (cd_type_loaded==CDDA)&&(full_scrn&MARK) )
- {
- vfd_set_showmark();
- }
- else
- #endif
- #endif
- #ifdef NEW_UART_COMMAND //lijinhai for fuss updata time normal
- if(timeout_vfd) return;
- else
- vfd_set_showtime();
- #endif
- //=========================================================================================
- // freyman, 2002-07-03,
- #if defined(SUPPORT_VFD)&&defined(SUPPORT_VFD_PANEL)//nono 2003-11-24 12:09//lijd 2004-12-4 11:38
- #ifndef VFD_VOLUME_DISPLAY
- #ifndef TEST_VFD//nono 2-8-9 14:39
- #if defined(BBK_PANNEL)||defined(BBK_DSS_555_PANNEL)//fengjl 3-12-26 9:24 to avoid VFD refresh successive when play WMA/MP3/DVD
- if(play_state!=VCD_STATE_STOP)
- #endif
- vfd_set_showtime();//2-5-15 16:09 add it to avoid vcd/cd vfd showing time irregularly.
- #endif
- #endif
- #endif//SUPPORT_VFD
- //==========================================================================================
- }
-
- if(t_disp)
- {
- #ifdef SUPPORT_FUNCTION_MENU
- if((full_scrn==SETUP) || (full_scrn==SETUP_PLUS))
- #else
- if(full_scrn==SETUP)
- #endif //end #ifdef SUPPORT_FUNCTION_MENU
- return;
-
- //printf_time("<%d>",disp_time);
- if(t_disp>10)
- {
- DispCookOSD0(1);
- } else {
- DispCookOSD0(0);
- }
-
- DispPolling(0);
- // 2004/07/26 yltseng
- sample_bit_rate_per_sec();
- } //if(full_scrn&GOTO)
- #ifdef NEWSTYLE_WINDOW
- if(full_scrn&MESSAGE)
- {
- UpdateTT_CHP_info();
- }
- #endif
- }
- // **************************************************************************************** //
- inline void MPx_ChkSmpRate()
- {
- // 2004/07/28 yltseng
- #ifdef REMAIN_TIME
- if( remain == NO_REMAIN_TIME )
- #endif
- //if this MP3 file is variable bitrate, the timeing display will be incorrect
- Mp3_kbitrate = ( *(bpcm_ya_ptr+44) | ( *(bpcm_ya_ptr+43) << 8) ); //3*14
-
- BYTE smpIndex = *(bpcm_ya_ptr+47); //3*15+2;
- //smpIndex= 0 ~ 8
- //0: 44.1K(MPEG-I)
- //3: 22.05K(MPEG-II)
- //6: 11.025K(MPEG-II.V)
- //1: 48K(MPEG-I)
- //4: 24K(MPEG-II)
- //7: 12K(MPEG-II.V)
- //2: 32K(MPEG-I)
- //5: 16K(MPEG-II)
- //8: 8K(MPEG-II.V)
- if(smpIndex<=8)
- {//Get Sampling Rate success
-
- const BYTE tab[3] = {2, 4, 1};
-
- smpIndex=tab[smpIndex%3];
-
- if (smpIndex != smp_rate_now)
- {
- //set new sampling rate
- printf("smpIndex: %dn", smpIndex);
- AUDIF_Set_SampleRate(smpIndex);//2004AUDDRV audif_set_sample_rate(smpIndex);
- }
- }
- }
- // **************************************************************************************** //
- UINT32 _mp3ReadLen,_myTime;
- UINT32 oldBitRate=0;
- //terry,2002/4/29 07:16PM
- //debug: remain time , display error
- //cause: recursive setting disp_time.
- //assign default MP3BitRate(128b/s) to caculate time, Jeff 20020531
- void Mp3_ChkSkipData(void)
- {
- UINT32 tmpBitRate;
- int nDiff;
- if ( (play_state!=VCD_STATE_NORMAL) && (adv_search_time==0) ) return;
-
- tmpBitRate = Mp3_kbitrate;
- if (tmpBitRate)
- {
- int totaltime;
-
- if (adv_search_time >= 0)
- {
- p_msf=s_msf;
-
- //printf("mp3ReadLen:%x oldmp3ReadLen:%xn",mp3ReadLen,oldmp3ReadLen);
- if (mp3ReadLen < oldmp3ReadLen) {
- oldmp3ReadLen = 0;
- myTime = 0;
-
- //printf("myTime:%xn",myTime);
- }
- //playback in normal sequence
- if ( (oldBitRate>0) && (tmpBitRate>0) &&
- (mp3ReadLen>0) && (oldmp3ReadLen>0) && (mp3ReadLen!=oldmp3ReadLen)
- )
- {
- UINT32 len = mp3ReadLen - oldmp3ReadLen;
-
- if (len > 0)
- {
- myTime = myTime + (len<<9)/oldBitRate;
- old_disp_time = myTime>>16;
- //printf("myTime:%xn",myTime);
- }
- }
-
- oldBitRate = tmpBitRate;
- } else {
- //if (msf>p_msf) {
- //when backward playback, we just show time displaying in descending sequence
- //so, we skip it during it's neighboorhood when time is in descending sequence
- if ( //( (s_msf>p_msf) && (s_msf < (p_msf+20) ) ) ||
- ( (oldmp3ReadLen<mp3ReadLen) && (oldmp3ReadLen>0) )
- )
- {
- if (mp3ReadLen > (oldmp3ReadLen+20000) ) {
- oldmp3ReadLen = mp3ReadLen;
- }
- return;
- }
-
- old_disp_time=(mp3ReadLen>>(11-4))/tmpBitRate; //time-now
-
- p_msf=s_msf;
-
- myTime = old_disp_time << 16;
- }
- oldmp3ReadLen = mp3ReadLen;
-
- //old_disp_time=((M2I(e_msf)*75+msf_ff(e_msf))-(M2I(p_msf)*75+msf_ff(p_msf)))*16/tmpBitRate; //time-remain
- if (remain > NO_REMAIN_TIME) {
- totaltime = PlayBackLength * 16 / tmpBitRate;
- nDiff = disp_time - (totaltime - old_disp_time);
- //printf("..%d, %d, %dn", disp_time, totaltime - old_disp_time, nDiff);
- if (adv_search_time)
- {
- if (adv_search_time>0)
- {
- if ((nDiff<adv_search_time) && (nDiff > 0))
- return;
- }
- else if (nDiff>adv_search_time)
- {
- return;
- }
- }
- disp_time = totaltime - old_disp_time;
- //printf("totaltime:%d old_disp_time:%d disp_time:%dn",totaltime,old_disp_time,disp_time);
- }else
- {
- nDiff = old_disp_time - disp_time;
- //printf("..%d, %d, %dn", disp_time, old_disp_time, nDiff);
- if (adv_search_time)
- {
- if (adv_search_time>0)
- {
- if (nDiff<adv_search_time)
- return;
- }
- else if ((nDiff>adv_search_time) && (nDiff < 0))
- {
- return;
- }
- }
- disp_time = old_disp_time;
- }
-
- #ifdef DISP_TIME_NOT_CHANGE_WINDOW_PROGESS//zhaoyanhua add 2004-2-5 13:59
- track_play_time = old_disp_time;
- #endif //DISP_TIME_NOT_CHANGE_WINDOW_PROGESS
-
- #ifdef SUPPORT_ID3
- show_id3_song();
- #endif
- #ifdef SUPPORT_OSDID3//liweihua add 2004-1-14 10:52
- show_osd_id3_song();
- #endif
- return;
- }
-
- if( (rep_ab_mode != REPEAT_FIND_B)&&(goto_time==0) )
- {//terry,2003/6/24 10:57