time.c
上传用户:poi891205
上传日期:2013-07-15
资源大小:9745k
文件大小:26k
源码类别:

DVD

开发平台:

C/C++

  1. /*
  2. * terry,2003/8/18 04:19PM
  3. * Maintain this file
  4. * Terry,2004/3/25 06:29PM
  5. */
  6. #include "config.h"
  7. #include "regmap.h"
  8. #include "global.h"
  9. #include "macro.h"
  10. #include "func.h"
  11. #include "util.h"
  12. #include "stdlib.h"    //huo 2000.12.14
  13. #include "cdfunc.h"
  14. #include "cfont.h"
  15. #include "sio.h"
  16. #include "vfdfunc.h"
  17. #include "ringbuf.h"
  18. #include "ircmd.h"
  19. #include "ircode.h"
  20. #include "cd.h"
  21. #include "auctrl.h"
  22. #include "user_init.h"  //terry,2001/1/9 03:29PM
  23. #include "avd.h"
  24. #include "dvdpe.h"
  25. #include "fs96602.h"
  26. #include "osd.h"
  27. #include "framebuf.h"
  28. #include "cderr.h"
  29. #include "vpp.h"
  30. #include "user_if.h"
  31. #include "dsp3_if.h"
  32. #include "atapi_if.h"
  33. #include "dma.h" //Jeff 20010919
  34. #include "auddrv.h" //2004AUDDRV oliver 20041004 for using audio driver purpose
  35. //#include "audif.h"
  36. #include "setup.h"
  37. #include "fsGUI.h"
  38. #include "drv.h"
  39. #include "auddac.h"
  40. #include "fsNAV.h"
  41. #include "asf_if.h"
  42. #include "iop.h"//2-7-9 9:40
  43. #include "UartTxd.h"
  44. #ifdef TUNER_T988
  45. #include "radio_t988.h"  //jinping 2-6-20 14:04
  46. #elif defined(SUPPORT_TUNER_MV114) || defined(SUPPORT_TUNER_ALPS)//xyy 2004-5-28
  47. #include "radio_mv114_kst.h"  //jinping 2002-7-1 20:30
  48. #endif
  49. #if defined(PT2322)||defined(PT2320)
  50. #include "audctrl.h"
  51. #endif 
  52. #if defined(TAS3001_AMP)   //use TI 3001 amplifier  jason ych add 2-8-9 10:10
  53. #include "ti3001.h"
  54. #endif 
  55. #if defined(TAS5026_AMP)   //use TI 3001 amplifier  jason ych add 2-8-9 10:10
  56. #include "ti5026.h"
  57. #endif 
  58. #ifdef SUPPORT_CDG  //Jeff 20020824
  59. #include "cdg.h"
  60. #endif
  61. #ifdef SUPPORT_MP4  // 2004/04/20 yltseng, to show remain time
  62. #include "avi_if.h"
  63. #endif
  64. #include "kinf.h"   // 2004/08/11 yltseng
  65. #include "bit_rate.h"
  66. #if ( defined(SUPPORT_CARD_STORAGE) || defined(SUPPORT_USB) || defined(SPHE8202_CARD_STORAGE) )
  67. #include "cardfs.h"
  68. #endif
  69. // **************************************************************************************** //
  70. extern UINT8    DVD_show_time(void);    //Jeff 20010717
  71. extern UINT16   Is_MP3_STATE(void);
  72. extern void     vfd_set_showtime(void);
  73. extern void     DispPolling(BYTE bReset);
  74. extern void     DispCookOSD0(BYTE bChange);
  75. extern UINT32   mp3ReadLen;             //Jeff 20010919
  76. extern UINT32   myTime;                 //Jeff 20020902
  77. extern UINT32   oldmp3ReadLen;          //Jeff 20020917
  78. extern BYTE     bASFHeaderFinish;
  79. #ifdef SUPPORT_OSDID3                   //suqiaoli add 2004-3-26 
  80. extern void     show_id3_song(void);
  81. #endif
  82. extern UINT8    avd_search_header(void);
  83. extern UINT32   PlayBackLength;
  84. #ifdef SUPPORT_SCORE        //gerry modified,2004-3-6 9:37
  85. UINT32          score_disp_flag;
  86. #endif
  87. // **************************************************************************************** //
  88. #ifndef DVDRELEASE
  89.     //#define DBG_TIME
  90. #endif
  91. #ifdef DBG_TIME
  92.     #define printf_time printf
  93. #else
  94.     #undef printf
  95.     #undef print_block
  96.     #define printf(f, a...) do {} while (0)
  97.     #define print_block(x,y) do {} while (0)
  98.     #define printf_time(f, a...) do {} while (0)
  99. #endif
  100. // **************************************************************************************** //
  101. /*
  102. ** showtime
  103. */
  104. void show_time(void)
  105. {
  106.     switch(play_state)
  107.     {
  108.     case VCD_STATE_POWER:
  109.         return;
  110.         
  111.     case VCD_STATE_OPEN:    // terry 891002
  112.     case VCD_STATE_CLOSE:   // terry 891002
  113.     case VCD_STATE_IDLE:    // terry 891002
  114.     case VCD_STATE_READTOC: // terry 891002
  115.         disp_trk_now=0;
  116.         disp_time=0;        // terry 891002
  117.         break;
  118.         
  119.     case VCD_STATE_STOP:    // terry 891002
  120.         if(cd_type_loaded!=CDROM)
  121.         {
  122.             if(cd_type_loaded!=CDDVD)
  123.                 disp_trk_now = cd_total_trk();
  124.             
  125.             disp_time=disc_time;
  126.             
  127.             if(cd_type_loaded==CDSVCD)
  128.                 disp_time=disp_time/PLAY_SPEED;
  129.         }
  130.         break;
  131.     } //end case
  132.     
  133.     if( ((goto_active)||(sys_cmd))&&(play_state!=VCD_STATE_STOP) )//2-5-25 22:42 to avoid AB show "00" quickly.
  134.     {
  135.         printf_time("goto_active:%x sys_cmd:%x play_state:%xn",goto_active,sys_cmd,play_state);
  136.         return;
  137.     }
  138.     
  139.     if( (disp_time < 0)||((disp_time > (100*3600))) )
  140.     {
  141.         printf_time("time<0n");
  142.         return;
  143.     }
  144.     if ( (cd_type_loaded!=CDROM) && (disp_trk_now > 99) ) 
  145.     {
  146.         printf_time("trk>99n");
  147.         return;
  148.     }
  149.     
  150. #if !defined( SUPPORT_FILE_DISPLAY_TM ) && defined( SUPPORT_FILE_SYSTEM_MODE )
  151.     if ((cd_type_loaded == CDROM) && (GetCurrentFileType() == CDROM_MPG)) // Robert 021125
  152.         disp_time = 0;
  153. #endif
  154. #ifdef  NOCHANGE_DISPLAY_WHEN_PRESTOP
  155.     if((play_state!=VCD_STATE_STOP)||(resumeMSF==0))//wuxiaofeng added 2004-03-05
  156. #endif  
  157.     {
  158.     show_time_hh = disp_time / 3600;
  159.     show_time_mm = (disp_time % 3600) / 60;
  160.     show_time_ss = (disp_time % 3600) % 60;
  161.     }
  162.     
  163.     if(
  164.         (play_state!=VCD_STATE_CLOSE)&&
  165.         (play_state!=VCD_STATE_OPEN)&&
  166.         (play_state!=VCD_STATE_READTOC)&&
  167.         (play_state!=VCD_STATE_IDLE)
  168.         )
  169.     {
  170. #ifdef FUSS_DVD//nono 2-6-22 15:41
  171.     #if defined(FUSS_PANEL)||defined(FUSS2_PANEL)
  172.         if( (cd_type_loaded==CDDA)&&(full_scrn&MARK) )
  173.         {
  174.             vfd_set_showmark();
  175.         }
  176.         else
  177.     #endif
  178. #endif
  179. #ifdef NEW_UART_COMMAND   //lijinhai for fuss updata time normal
  180.             if(timeout_vfd) return;
  181.             else
  182.                 vfd_set_showtime();
  183. #endif
  184.             //=========================================================================================
  185.             //  freyman, 2002-07-03,
  186. #if defined(SUPPORT_VFD)&&defined(SUPPORT_VFD_PANEL)//nono 2003-11-24 12:09//lijd 2004-12-4 11:38
  187.     #ifndef VFD_VOLUME_DISPLAY
  188.         #ifndef TEST_VFD//nono 2-8-9 14:39
  189.             #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
  190.             if(play_state!=VCD_STATE_STOP) 
  191.             #endif 
  192.             vfd_set_showtime();//2-5-15 16:09 add it to avoid vcd/cd vfd showing time irregularly.
  193.         #endif 
  194.     #endif 
  195. #endif//SUPPORT_VFD
  196.             //==========================================================================================
  197.     }
  198.     
  199.     if(t_disp)
  200.     {       
  201.         #ifdef SUPPORT_FUNCTION_MENU
  202.         if((full_scrn==SETUP) || (full_scrn==SETUP_PLUS))        
  203. #else
  204.         if(full_scrn==SETUP)        
  205.         #endif //end #ifdef SUPPORT_FUNCTION_MENU
  206.             return;
  207.         
  208.         //printf_time("<%d>",disp_time);
  209.         if(t_disp>10)
  210.         {
  211.             DispCookOSD0(1);
  212.         } else {
  213.             DispCookOSD0(0);
  214.         }
  215.         
  216.         DispPolling(0);  
  217.         // 2004/07/26 yltseng
  218.         sample_bit_rate_per_sec();
  219.     } //if(full_scrn&GOTO)
  220. #ifdef NEWSTYLE_WINDOW
  221.     if(full_scrn&MESSAGE)
  222.     {
  223.         UpdateTT_CHP_info();    
  224.     }
  225. #endif
  226. }
  227. // **************************************************************************************** //
  228. inline void MPx_ChkSmpRate()
  229. {
  230. // 2004/07/28 yltseng    
  231. #ifdef REMAIN_TIME
  232.     if( remain == NO_REMAIN_TIME )
  233. #endif
  234.         //if this MP3 file is variable bitrate, the timeing display will be incorrect
  235.         Mp3_kbitrate    = ( *(bpcm_ya_ptr+44) | ( *(bpcm_ya_ptr+43) << 8) );     //3*14
  236.     
  237.     BYTE smpIndex   = *(bpcm_ya_ptr+47); //3*15+2;
  238.     //smpIndex= 0 ~ 8
  239.     //0: 44.1K(MPEG-I)
  240.     //3: 22.05K(MPEG-II)
  241.     //6: 11.025K(MPEG-II.V)
  242.     //1: 48K(MPEG-I)
  243.     //4: 24K(MPEG-II)
  244.     //7: 12K(MPEG-II.V)
  245.     //2: 32K(MPEG-I)
  246.     //5: 16K(MPEG-II)
  247.     //8: 8K(MPEG-II.V)
  248.     if(smpIndex<=8)
  249.     {//Get Sampling Rate success
  250.     
  251.         const BYTE tab[3] = {2, 4, 1};
  252.         
  253.         smpIndex=tab[smpIndex%3];
  254.         
  255.         if (smpIndex != smp_rate_now)
  256.         {
  257.             //set new sampling rate
  258.             printf("smpIndex: %dn", smpIndex);
  259.             AUDIF_Set_SampleRate(smpIndex);//2004AUDDRV audif_set_sample_rate(smpIndex);
  260.         }
  261.     }
  262. }
  263. // **************************************************************************************** //
  264. UINT32  _mp3ReadLen,_myTime; 
  265. UINT32  oldBitRate=0;
  266. //terry,2002/4/29 07:16PM
  267. //debug: remain time , display error
  268. //cause: recursive setting disp_time.
  269. //assign default MP3BitRate(128b/s) to caculate time, Jeff 20020531
  270. void Mp3_ChkSkipData(void)
  271. {
  272.     UINT32 tmpBitRate;
  273.     int nDiff;
  274.     if ( (play_state!=VCD_STATE_NORMAL) && (adv_search_time==0) )   return;
  275.        
  276.     tmpBitRate = Mp3_kbitrate;
  277.     if (tmpBitRate) 
  278.     {   
  279.         int totaltime;
  280.         
  281.         if (adv_search_time >= 0) 
  282.         {
  283.             p_msf=s_msf;
  284.             
  285.             //printf("mp3ReadLen:%x oldmp3ReadLen:%xn",mp3ReadLen,oldmp3ReadLen);
  286.             if (mp3ReadLen < oldmp3ReadLen) {
  287.                 oldmp3ReadLen = 0;
  288.                 myTime = 0;             
  289.                   
  290.                 //printf("myTime:%xn",myTime);
  291.             }
  292.             //playback in normal sequence
  293.             if ( (oldBitRate>0) && (tmpBitRate>0) &&
  294.                 (mp3ReadLen>0) && (oldmp3ReadLen>0) && (mp3ReadLen!=oldmp3ReadLen)
  295.                 )
  296.             {
  297.                 UINT32 len = mp3ReadLen - oldmp3ReadLen;
  298.                 
  299.                 if (len > 0) 
  300.                 {
  301.                     myTime = myTime + (len<<9)/oldBitRate;
  302.                     old_disp_time = myTime>>16;
  303.                     //printf("myTime:%xn",myTime);
  304.                 }
  305.             }
  306.             
  307.             oldBitRate = tmpBitRate;
  308.         } else {
  309.             //if (msf>p_msf) {
  310.             //when backward playback, we just show time displaying in descending sequence
  311.             //so, we skip it during it's neighboorhood when time is in descending sequence
  312.             if (  //( (s_msf>p_msf) && (s_msf < (p_msf+20) ) ) ||
  313.                 ( (oldmp3ReadLen<mp3ReadLen) && (oldmp3ReadLen>0) )
  314.                 )
  315.             {
  316.                 if (mp3ReadLen > (oldmp3ReadLen+20000) ) {
  317.                     oldmp3ReadLen = mp3ReadLen;
  318.                 }
  319.                 return;
  320.             }
  321.             
  322.             old_disp_time=(mp3ReadLen>>(11-4))/tmpBitRate; //time-now
  323.             
  324.             p_msf=s_msf;
  325.             
  326.             myTime = old_disp_time << 16;
  327.         }
  328.         oldmp3ReadLen = mp3ReadLen;
  329.         
  330.         //old_disp_time=((M2I(e_msf)*75+msf_ff(e_msf))-(M2I(p_msf)*75+msf_ff(p_msf)))*16/tmpBitRate; //time-remain
  331.         if (remain > NO_REMAIN_TIME) {
  332.             totaltime = PlayBackLength * 16 / tmpBitRate;
  333.             nDiff = disp_time - (totaltime - old_disp_time);
  334.             //printf("..%d, %d, %dn", disp_time, totaltime - old_disp_time, nDiff);
  335.             if (adv_search_time)
  336.             {
  337.                 if (adv_search_time>0)
  338.                 {
  339.                     if ((nDiff<adv_search_time) && (nDiff > 0))
  340.                         return;
  341.                 }
  342.                 else if (nDiff>adv_search_time)
  343.                 {
  344.                     return;
  345.                 }
  346.             }
  347.             disp_time = totaltime - old_disp_time;
  348.             //printf("totaltime:%d old_disp_time:%d disp_time:%dn",totaltime,old_disp_time,disp_time);
  349.         }else
  350.         {
  351.             nDiff = old_disp_time - disp_time;
  352.             //printf("..%d, %d, %dn", disp_time, old_disp_time, nDiff);
  353.             if (adv_search_time)
  354.             {
  355.                 if (adv_search_time>0)
  356.                 { 
  357.                     if (nDiff<adv_search_time)
  358.                         return;
  359.                 }
  360.                 else if ((nDiff>adv_search_time) && (nDiff < 0))
  361.                 {
  362.                     return;
  363.                 }
  364.             }
  365.             disp_time = old_disp_time;                        
  366.         }
  367.        
  368. #ifdef DISP_TIME_NOT_CHANGE_WINDOW_PROGESS//zhaoyanhua add 2004-2-5 13:59       
  369.         track_play_time = old_disp_time;
  370. #endif //DISP_TIME_NOT_CHANGE_WINDOW_PROGESS        
  371.         
  372. #ifdef  SUPPORT_ID3                      
  373.         show_id3_song();
  374. #endif
  375. #ifdef SUPPORT_OSDID3//liweihua add 2004-1-14 10:52
  376.         show_osd_id3_song();
  377. #endif
  378.         return;
  379.     }
  380.     
  381.     if( (rep_ab_mode != REPEAT_FIND_B)&&(goto_time==0) )
  382.     {//terry,2003/6/24 10:57