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

DVD

开发平台:

C/C++

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *         Copyright (c) 2002 by Sunplus Technology Co., Ltd.             *
  4.  *                                                                        *
  5.  *  This software is copyrighted by and is the property of Sunplus        *
  6.  *  Technology Co., Ltd. All rights are reserved by Sunplus Technology    *
  7.  *  Co., Ltd. This software may only be used in accordance with the       *
  8.  *  corresponding license agreement. Any unauthorized use, duplication,   *
  9.  *  distribution, or disclosure of this software is expressly forbidden.  *
  10.  *                                                                        *
  11.  *  This Copyright notice MUST not be removed or modified without prior   *
  12.  *  written consent of Sunplus Technology Co., Ltd.                       *
  13.  *                                                                        *
  14.  *  Sunplus Technology Co., Ltd. reserves the right to modify this        *
  15.  *  software without notice.                                              *
  16.  *                                                                        *
  17.  *  Sunplus Technology Co., Ltd.                                          *
  18.  *  19, Innovation First Road, Science-Based Industrial Park,             *
  19.  *  Hsin-Chu, Taiwan, R.O.C.                                              *
  20.  **************************************************************************/
  21. /*--------------------------------------------------------------------------
  22. |  File Name   :  ircmd_subtitle.c
  23. |
  24. |  Description :  realize subtitle function in IR subtitle key.
  25. |
  26. |  Version    :  0.1  
  27. |  Rev Date         Author(s)      Status & Comments
  28. |---------------------------------------------------------------------------------
  29. |  0.1 2004/4/6        Terry         Creating
  30. |  0.2  2004/8/4        Terry         modified
  31. |--------------------------------------------------------------------------------*/
  32. extern void sup_select_subtitles(int n);
  33. extern void sup_select_channel_2(int chn);
  34. #ifdef TWO_KEY_SWITCH_TWO_SUBTITLE  //added by wangwei,2004-9-29 17:25
  35. extern int IDTWO;
  36. extern int twoSubTTFlag;
  37. #endif
  38. #if defined( AVI_INTERNAL_SUP ) || defined( SUPPORT_MP4_SUBTITLE )  // 2004/09/17 yltseng
  39. #include "avi_if.h"
  40. UINT8   g_uiSubtitleKeyPressed = FALSE;
  41. static inline void PrepareToLoadMP4InternalSubtitle()
  42. {
  43.     if( action_click && GetCurrentFileType() == CDROM_MP4 )
  44.     {
  45.         g_uiSubtitleKeyPressed = TRUE;
  46.     #ifdef AVI_INTERNAL_SUP
  47.         extern int file_set_supic_stream(int sup_strm_num);
  48.         
  49.         if( file_set_supic_stream( NP_SPSTN & 0x3f ) )
  50.             g_uiSubtitleKeyPressed = FALSE;
  51.         #ifndef SUPPORT_MP4_SUBTITLE
  52.         else    
  53.             NP_SPSTN &= (~0x40);
  54.         #endif
  55.     #endif
  56.     }
  57. }
  58. /**************************************************************************
  59.  *  Function Name: PrepareToLoadMP4ExternalSubtitle                       *               
  60.  *  Purposes:                                                             *
  61.  *     load external subtitle.                                            *
  62.  *  Descriptions:                                                         *                                                                       *
  63.  *  Arguments:                                                            *
  64.  *    NP_SPSTN: current subtitle number variable.                         *
  65.  *              numerical value from 0x40.                                *         
  66.  *                                                                        *
  67.  *  Returns:     NONE                                                     *
  68.  *  See also:    NONE                                                     *
  69.  **************************************************************************/
  70. void PrepareToLoadMP4ExternalSubtitle()
  71. {
  72.     #ifdef SUPPORT_MP4_SUBTITLE
  73.     // 2004/01/31 yltseng, if DiscType is CDROM, then we need to wait until current packet is finished,
  74.     // that is, we have to wait until !is_dvddsp_hw_busy() and ( do_cd == do_cd_sync )
  75.     // for DVDROM, it's easier, we just wait until !is_dvddsp_hw_busy()
  76.     
  77.     extern int do_cd_sync(void);
  78.     extern BYTE DiscType;
  79.     if( DiscType == CDDVD || do_cd == do_cd_sync )
  80.     {
  81.         if( g_uiSubtitleKeyPressed )
  82.         {
  83.             g_uiSubtitleKeyPressed = FALSE;     // 2004/09/19 yltseng, [note] don't change the code sequence
  84.             UINT32 uiStream = ( NP_SPSTN & 0x40 ) ? ( NP_SPSTN & 0x3f ) : 0xffff;
  85.             if( !SetAVISubTitleStream( uiStream ) )
  86.                 NP_SPSTN &= (~0x40);
  87.         }
  88.     }
  89.     #endif
  90. }
  91. /**************************************************************************
  92.  *  Function Name: set_sub_title_Ns                                       *
  93.  *  Purposes:                                                             *
  94.  *      get subtitle total number .                                       *
  95.  *  Descriptions:                                                         *
  96.  *  Arguments:                                                            *
  97.  *      dAv_SPST_Ns: subtitle total number variable.                      *
  98.  *                                                                        *
  99.  *  Returns:     NONE                                                     *
  100.  *  See also:    NONE                                                     *
  101.  **************************************************************************/
  102. void set_sub_title_Ns(UINT8 Ns)
  103. {
  104.     pDSV->dAv_SPST_Ns=Ns;
  105. }
  106. #else
  107. static inline void PrepareToLoadMP4InternalSubtitle()   {}
  108. inline void PrepareToLoadMP4ExternalSubtitle()          {}
  109. #endif
  110. /**************************************************************************
  111.  *  Function Name: sel_2nd_subtitle                                       *
  112.  *  Purposes:                                                             *
  113.  *       realize two subtitle switch.                                     * 
  114.  *  Descriptions:                                                         *
  115.  *       realize two subtitle switch,but there is a fixed connection      *
  116.  *       between subtitle 1and subtitle 2,unskillfully.                   *                      
  117.  *  Arguments:                                                            *
  118.  *       id: get subtitle number.  for example,0x40:ch1.                  *
  119.  *                                                                        *
  120.  *  Returns:     NONE                                                     *
  121.  *  See also:    NONE                                                     *
  122.  **************************************************************************/
  123. #ifdef TWO_SUBTITLE//terry,2004/8/4 09:39AM
  124. #ifndef TWO_KEY_SWITCH_TWO_SUBTITLE  //modified by wangwei,2004-9-29 17:04
  125. void sel_2nd_subtitle(int id2)
  126. {
  127.     int id1=NP_SPSTN&0x3f;
  128.     
  129.     id2=id2&0x3f;    
  130.     if(id2>=pDSV->dAv_SPST_Ns) id2=0;    
  131.     
  132.     if(pDSV->dAv_SPST_Ns>1)
  133.     {
  134.       if(id1 != id2)
  135.       {
  136.         sup_select_subtitles(2);            
  137.         sup_select_channel_2(0x20+id2);                
  138.       }else
  139.       {
  140.         sup_select_subtitles(1);            
  141.       }
  142.     }    
  143. }
  144. #endif //TWO_KEY_SWITCH_TWO_SUBTITLE
  145. #endif
  146. /**************************************************************************
  147.  *  Function Name: ircmd_sub_picture                                      *
  148.  *  Purposes:                                                             *
  149.  *     realize subtitle switch function in IR subtitle key.               *
  150.  *  Descriptions:                                                         *
  151.  *  Arguments:                                                            *
  152.  *    id     : subtitle number id.                                        *
  153.  *    timer  : fix time length that contents show on display.             *                                        *
  154.  *    id_str : str id.                                                    *
  155.  *                                                                        *
  156.  *  Returns:     NONE                                                     *
  157.  *  See also:    NONE                                                     *
  158.  **************************************************************************/
  159. void ircmd_sub_picture(void)
  160. {
  161.     int id=0,timer,id_str;
  162. #ifdef SUPPORT_MIDI_MENU_SEL  //xlluo for midi title 
  163.         if (Is_MIDI_STATE())
  164.         {
  165. invalid_key();
  166. return;
  167.         }
  168. #endif
  169. #ifdef SUPPORT_MIDIDISK_TITLE
  170.         if (bIsPlayMidiTitle)//xlluo for midi title
  171.         {
  172. invalid_key();
  173. return;
  174.         }
  175. #endif
  176. #ifdef INVALID_SUBPICTURE_WHEN_SVCD //wuxiaofeng 2004-03-23
  177. if(cd_type_loaded==CDSVCD)
  178. {
  179. invalid_key();
  180. return;
  181. }
  182. #endif//#ifdef INVALID_SUBPICTURE_WHEN_SVCD
  183.     /*
  184. #if defined(ADJUSTING_ACTION_VALID_RIGHT_NOW)
  185. #ifdef NEWSTYLE_WINDOW
  186. if ( (full_scrn&MESSAGE) && (action_click==2) ) // alan, 2003/8/28 05:32PM
  187. action_click = 0;
  188. else
  189. #endif
  190.     action_click = 1; //Jeff 20030506
  191.     #endif
  192.     */
  193. #ifdef JPEG_EFFECT_MODE_USE_SUBTITLE//zhaoyanhua add 2003-12-24 9:50
  194. if(cd_type_loaded == CDROM)
  195. {
  196. if (Is_JPEG_PLAY_STATE())
  197. {
  198. #ifdef JPG_EFFECT
  199. jpeg_effect_toggle();
  200. #endif
  201. }
  202. else
  203. invalid_key();
  204. return;
  205. }
  206. #endif
  207.     
  208. #ifdef SUPPORT_MP4//terry,2004/4/6 08:05PM
  209. #ifdef VOB_SUBTITLE
  210.     if( (cd_type_loaded==CDROM)&&(GetCurrentFileType()!=CDROM_MP4)&&(GetCurrentFileType()!=CDROM_MPG) )
  211. #else
  212.     if( (cd_type_loaded==CDROM)&&(GetCurrentFileType()!=CDROM_MP4) )
  213. #endif
  214.     {
  215. invalid_key();
  216. return;
  217.     }    
  218. #endif
  219.     
  220.     //Jeff change, 20031006, fix press IR(GOTO) sub-picture will be "automatic" toggled
  221.     #if defined(ADJUSTING_ACTION_VALID_RIGHT_NOW)
  222.      #ifdef NEWSTYLE_WINDOW
  223.          if ( (full_scrn&MESSAGE) && (action_click==2) )  
  224.          action_click = 0;
  225.          else
  226.        #endif
  227.         action_click = 1; //Jeff 20030506
  228.     #else
  229.         #ifdef NEWSTYLE_WINDOW
  230.     if ( (full_scrn&MESSAGE) && (action_click==2) ) // alan, 2003/8/28 05:32PM
  231.     action_click = 0;
  232.     #endif
  233.     #endif
  234. #ifdef VOB_SUBTITLE
  235. if(GetCurrentFileType()==CDROM_MPG) {
  236. id=Subp_stream_Chg_VOB(action_click);
  237. }
  238. else
  239. #endif    
  240.     if(bDiscType == CD_OKO) { //Jeff 20020610
  241.         invalid_key();
  242.         return;
  243.     } else
  244. //chg & check subtitle stream id
  245. if( !(!DVD_check_state()&&(cd_type_loaded==CDDVD)) )
  246. {
  247.             #ifdef NEW_SEARCH_OSD  //yw 021007
  248.             if(key_up_down==0)
  249. //id=Subp_stream_Chg(action_click,-1); //Jeff 20021008
  250. id=Subp_stream_Chg(action_click,1); //nono 2-11-22 11:19
  251.             else
  252.             #endif
  253. id=Subp_stream_Chg(action_click,1); //Jeff 20021008
  254.    printf("chg sub-titlen");
  255. }
  256.         printf("pDSV->dAv_SPST_Ns:%xn",pDSV->dAv_SPST_Ns);
  257. //setting osd data
  258.         //id : 0x40:Ch1, 0x41:Ch2, 0x42:Ch3, 0x43:Ch4, 0xbf:off
  259. if( (id&0x40)&&( (id&0x3f)<pDSV->dAv_SPST_Ns ) ) 
  260. {
  261.             timer=((id&0x3f)<<8)|0x01;
  262. #ifdef TWO_SUBTITLE//terry,2004/8/4 09:39AM
  263.         #ifndef TWO_KEY_SWITCH_TWO_SUBTITLE  //modified by wangwei,2004-9-29 17:02
  264.             sel_2nd_subtitle(id+1);
  265.         #else          
  266.         if(action_click)
  267.         {
  268.             if(IDTWO==(NP_SPSTN&0x3f))  //same one,close the 2nd subtitle.
  269.             {
  270.                 sup_select_subtitles(1);
  271.             twoSubTTFlag=1;
  272.         }
  273.             else if(IDTWO>=pDSV->dAv_SPST_Ns)  //off,close the 2nd subtitle.
  274.         {
  275.             sup_select_subtitles(1);
  276.                 twoSubTTFlag=0;
  277.         }
  278.             else if(IDTWO!=-1)
  279.         {
  280.                 sup_select_subtitles(2);
  281.                 twoSubTTFlag=2;
  282.             }
  283.         }
  284.         #endif//TWO_KEY_SWITCH_TWO_SUBTITLE
  285.         
  286. #endif            
  287.             id_str=0x20;       
  288. }else
  289. {
  290.             id_str=STR_OS_OFF;
  291.             timer=1;
  292. }
  293.         PrepareToLoadMP4InternalSubtitle();     // 2004/09/17 yltseng
  294. //show osd str
  295. if(id)
  296.         {
  297. #ifdef OSDISP //2004/10/21 wjzhang , sphe1000B(stb-dvd): osd display
  298.             if(id==0xbf|id==0x7e)
  299. OSD1000ISP_STATUS(OSDISP_TITLE_OFF, OSDIR_SUB_TITLE);
  300. else
  301.                 OSD1000ISP_STATUS(((pDSV->dAv_SPST_Ns)<<4)|(id+1&0x0f), OSDIR_SUB_TITLE);
  302. #endif
  303.             //PrintOsdMsg(STR_OS_SUBTITLE|(id_str<<8),REGION1,timer,4);
  304.             PrintOsdMsg(STR_OS_SUBTITLE|(id_str<<OSDSTR_ID_TOTL_BIT),REGION1,timer,4);
  305.         }
  306.         else {
  307.     #ifdef NEWSTYLE_WINDOW
  308. if(full_scrn&MESSAGE)//xyy 2003-7-29 15:08
  309. psprintf(linebuf,"%s",_OsdMessegeFont1[osd_font_mode][STR_OS_NONE]);
  310. else
  311.     #endif
  312.             invalid_key();
  313.         }
  314.     #ifdef NEWSTYLE_WINDOW
  315. if(full_scrn&MESSAGE)//xyy 2003-7-29 15:08
  316.             updateSubtitle();
  317.     #endif
  318. }
  319. #ifdef DOUBLE_TITLE //susu 2003-8-22 18:44
  320. void ircmd_double_picture(void)
  321. {
  322. if(full_scrn&DOUBLETITLE) 
  323. {
  324. exit_double_title();
  325. }
  326. else
  327. {
  328. if( !(!DVD_check_state()&&(cd_type_loaded==CDDVD)) )
  329. {
  330. full_scrn=DOUBLETITLE;
  331. exe_double_title();
  332. //Maoyong added for IR U/D/L/R/Sel proc func setting 2004-9-24 9:13
  333.             SetFullscrnCmdFuncPtr( double_title_func_up, double_title_func_down, double_title_func_left,
  334.                                    double_title_func_right, double_title_func_select);
  335. }
  336. else
  337.         invalid_key();
  338. }
  339. }
  340. #endif