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

📄 subtitle.c

📁 dvd里面的一个文件系统的代码
💻 C
📖 第 1 页 / 共 5 页
字号:
          c[j]=a[j]-0x20;
         else c[j]=a[j];
         
         if(b[j]>='a'&&b[j]<='z')    
          d[j]=b[j]-0x20;
         else d[j]=b[j];
   
    } 
    return strncmp( (const char*) c,(const char*)d , i );
}
//********************************************************************************************//
#ifdef SUPPORT_SMI_MultiLanguage//2005-8-16 20:38 zhoulin

static int read_lang_info(BYTE **cbufptr)
{   
    BYTE *pbufptr;
    UINT8 cnt=0;
    BYTE langbuf[15];
    pbufptr=*cbufptr;
    
    while(!(*pbufptr==' '||*pbufptr==0x7D))
    {   langbuf[cnt]=*pbufptr;
        cnt++;
        pbufptr++;
        if(cnt>=15)  //exit,if the string >=20
          return 0;
    }
    langbuf[cnt]='\0';
    
    
    if(lang_num<MAX_langs)
    { 
         strcpy(lang_temp[lang_num],(const char*)langbuf);
         lang_num++;
    }
    
    
    *cbufptr=pbufptr;
    return 1;
}

#endif
//*****************************************************************************************//
#ifdef  SUPPORT_SMI_MultiColor//2005-8-16 20:38 zhoulin
UINT32 transRGB2GBRA(UINT32 clrvalue)
{
    return ((clrvalue<<16)&0xffff0000)|((clrvalue>>8)&0x0000ff00)|0x000000ff;
}

//read the color
//input:mode=1 for reading default color
//      mode=0 for reading the color in the main body
//return:1  success
//       0  false

extern  int  read_color(BYTE **cbufptr,BYTE mode)
{   
    BYTE *pbufptr;
    UINT8 cnt=0;
    UINT8  num_letter=0;
    UINT8  num_num;
    UINT8  clrmatch=0;
    BYTE clrbuf[20];
    UINT32 clrvalue=0;
    pbufptr=*cbufptr;
    BYTE clr_identFlg=0;
    
    //check the first number or letter(0-9 or a-z or A-Z)
    while(!((*pbufptr>='0'&&*pbufptr<='9')||(*pbufptr>='a'&&*pbufptr<='z')||(*pbufptr>='A'&&*pbufptr<='Z')))
    {   
        pbufptr++;
        cnt++;
        if(cnt>10)    //exit ,if no number or letter in 10 characters
          return 0;
      
    }
    cnt=0;
   
    //get the real string of string ;end with the first non-number or non-letter char
    while((*pbufptr>='0'&&*pbufptr<='9')||(*pbufptr>='a'&&*pbufptr<='z')||(*pbufptr>='A'&&*pbufptr<='Z'))
    {   if(*pbufptr>='A'&&*pbufptr<='Z')// uppercase to lowercase
            clrbuf[cnt]=*pbufptr+0x20;
        else  clrbuf[cnt]=*pbufptr;
        if(clrbuf[cnt]>'f'&&clrbuf[cnt]<='z') // have one char(f-z) indicate that string is color name ,not RGB value
          num_letter=1;
        cnt++;
        pbufptr++;  
        if(cnt>=20)  //exit,if the string >=20
          return 0;
    }
    
    clrbuf[cnt]='\0';
    num_num=strlen((const char*)clrbuf);
    UINT8  k;
    if( num_letter==0)  //if the string indicate RGB value,transform the string to value 
    {  
        if(num_num<=6)
        {
            for(cnt=0;cnt<num_num;cnt++)
            {  if(clrbuf[cnt]>='0'&&clrbuf[cnt]<='9')
                     k=clrbuf[cnt]-0x30;
               else  k=clrbuf[cnt]-0x61+10;      
               clrvalue=clrvalue*16+k;
            }
            clrmatch=1;
        }
    }  
    else       //if the string indicate color name,get value from the color table defined 
    {
        for(cnt=0;cnt<MAX_color_mapping_Nm;cnt++)
        {
            if(strncmpIgnoreCase(color_mapping_table[cnt].name,clrbuf,num_num)==0)
             {   clrvalue=color_mapping_table[cnt].value;
                 clrmatch=1;
                 break;     
             }
        }
    }
    if(clrmatch==0)//if the string  match neither RGB value type nor color name type,return
        return 0;
    
    if(mode)  //for default color 
    {     
           strcpy(color_temp[1],(const char*)clrbuf);
           palette_16color_MP4_SUB[1]=transRGB2GBRA(clrvalue) ;
        }
    else  //other color
    {   
           if(palette_color_num<MAX_palette_colors)
            {   for(cnt=1;cnt<palette_color_num;cnt++)
                {  if(strncmpIgnoreCase( color_temp[cnt], clrbuf,num_num)==0)
                       clr_identFlg=1;     
                }
                if(!clr_identFlg)
                {   strcpy(color_temp[palette_color_num],(const char*)clrbuf);
                    palette_16color_MP4_SUB[palette_color_num]=transRGB2GBRA(clrvalue) ;
                    palette_color_num++;
                }
            }     
    
    }
    
    
    *cbufptr=pbufptr;
    return 1;
}    

//get the index num in the palette ,return the index
//return=0,read color info error 
extern  int  read_color_index(BYTE **cbufptr)
{   
    BYTE *pbufptr;
    UINT8 cnt=0;
    UINT8  num_letter=0;
    UINT8  num_num;
    BYTE clrbuf[20];
    pbufptr=*cbufptr;
    
    //check the first number or letter(0-9 or a-z or A-Z)
    while(!((*pbufptr>='0'&&*pbufptr<='9')||(*pbufptr>='a'&&*pbufptr<='z')||(*pbufptr>='A'&&*pbufptr<='Z')))
    {   
        pbufptr++;
        cnt++;
        if(cnt>10)    //exit ,if no number or letter in 10 characters
          return 0;
      
    }
    cnt=0;
   
    //get the real string of string ;end with the first non-number or non-letter char
    while((*pbufptr>='0'&&*pbufptr<='9')||(*pbufptr>='a'&&*pbufptr<='z')||(*pbufptr>='A'&&*pbufptr<='Z'))
    {   if(*pbufptr>='A'&&*pbufptr<='Z')// uppercase to lowercase
            clrbuf[cnt]=*pbufptr+0x20;
        else  clrbuf[cnt]=*pbufptr;
        
        if(clrbuf[cnt]>'f'&&clrbuf[cnt]<='z') // have one char(f-z) indicate that string is color name ,not RGB value
          num_letter=1;
        cnt++;
        pbufptr++;  
        if(cnt>=20)  //exit,if the string >=20
          return 0;
    }
    
    clrbuf[cnt]='\0';
 
    num_num=strlen((const char*)clrbuf);
 
    
    for(cnt=1;cnt<palette_color_num;cnt++)
    {
        if(strncmpIgnoreCase( color_temp[cnt], clrbuf,num_num)==0)
        {    
            *cbufptr=pbufptr;
            return cnt;  //return the color palette index
        }
    }
        
    
    *cbufptr=pbufptr;
    return 1;//if the color is not in the palette,use thr default color
}

#endif
// **************************************************************************************** //
static inline int supGetSubtitleCount( int iAVIFile )
{
    if( iAVIFile < 0 )
        return 0;

    int i                   = 0;
    int j                   = 0;
    int iSubCntOfCurFile    = 0;

    for( ; i < s_uiSupCnt; i++ )
    {
        for(j = 0; j < NUM_OF_BELONGTO; j++)
        {
            if( subtitle_array[i].uiBelongTo[j] == iAVIFile )
            //if( subtitle_array[i].uiBelongTo == iAVIFile )
            iSubCntOfCurFile++;
    }
    }
    return iSubCntOfCurFile;
}

// **************************************************************************************** //
extern int supInitSubtitle()
{
    // use the internal subpicture of AVI first
    
    if( FILE_HAS_SUPIC() )
    {
        g_pfnPollingSubtitle = NULL;
		#ifndef TOUCH_KEYBOARD//frank.huang 050926 add to make keyboard display when play cdrom
        osd_tog_region( 3, OSD_OFF );
		#endif
        return FALSE;
    }
    
    int iCurFile = pFsJpeg->fsnav_trk_now + pFsJpeg->first_mp3_entry;
    
    #ifdef PMP_UI  //////////////yangli add for PMP_UI with subtitle 20050517 //kenny 2005/9/5 modify
    iCurFile = CurrentFiles1[pFsJpeg->file_index_in_dir]+pFsJpeg->first_mp3_entry;
    #endif
    
    set_sub_title_Ns( supGetSubtitleCount( iCurFile ) );
    supSetSubtitleDataBuffer( (BYTE*) file_extsub_buf, file_extsub_bufsize );
    supSetSubtitleIdxBuffer( (UINT32*) file_extsub_idx_buf, file_extsub_idx_bufsize );

    if( supSetSubtitleStream( 0 ) )
    {
        NP_SPSTN = 0x40 | 0;
        return TRUE;
    }
    NP_SPSTN = 0xffbf;
    return FALSE;
}

extern int supSetSubtitleStream( UINT32 uiStream )
{
    if( uiStream >= pDSV->dAv_SPST_Ns )
    {
        g_pfnPollingSubtitle = NULL;
       	#ifndef TOUCH_KEYBOARD//frank.huang 050926 add to make keyboard display when play cdrom
        osd_tog_region( 3, OSD_OFF );
		#endif
        return 0;
    }

#ifdef DVD_SERVO        // 2005/04/30 yltseng
    extern UINT8 cServoWrongDataPass;
    cServoWrongDataPass = 0;
#endif
    #ifdef PMP_UI  //////////////yangli add for PMP_UI with subtitle 20050517
    pFsJpeg->fsnav_trk_now = CurrentFiles1[pFsJpeg->file_index_in_dir];
    #endif
    int iCurFile    = pFsJpeg->fsnav_trk_now + pFsJpeg->first_mp3_entry;
    int iType       = supParseSubtitle( iCurFile, uiStream );

#ifdef DVD_SERVO
    cServoWrongDataPass = 1;
#endif

    switch( iType )
    {
    case EXT_SUBTITLE_TXT:
 		supOpenSubtitle();
        return 1;
        break;

//    case EXT_SUBTITLE_IMG:  // unsupport now
//        break;

    case EXT_SUBTITLE_UNKNOWN:
    default:
        g_pfnPollingSubtitle    = NULL;
        s_pPrevSup              = NULL;
        osd_tog_region( 3, OSD_OFF );
        return 0;
        break;
    }

    return 0;
}

#include "fsNav.h"
static inline int supPollingSubtitleSRT()
{

    UINT32  stc_in;
    void*   pData   = NULL;
    UINT32  uiSize  = 0;

    if( IsAVDMediaTimeout() )
    {
        osd_tog_region( 3, OSD_OFF );
        TURNOFF_EXT_SUP();
        return 0;
    }

	if(!is_stc_valid() || (pFsJpeg->gifsFuncBtn == FS_FUNC_MP3))
        stc_in  = disp_time*90000;
    else
        stc_in  = get_stc_32();

    //printf_w("get_stc_32():%d\n",get_stc_32()); 

    s_pfnGetSubtitleData( stc_in, &pData, &uiSize );

    if( pData != s_pPrevSup )
    {
        if( pData )
        {
            osd_ClearOneRegion( 3, 0 );
            
            #ifdef SUPPORT_UNICODE_FONT//2005/9/2

               show_osd_uni_text((char*) pData, uiSize);                
            #else
            ShowOSDText( (char*) pData, uiSize );
            #endif
            
            osd_tog_region( 3, OSD_ON );
            DISPLAY_EXT_SUP();
        }
        else
        {
            osd_tog_region( 3, OSD_OFF );
            TURNOFF_EXT_SUP();
        }

        s_pPrevSup = pData;
    }

    return 1;
}

// **************************************************************************************** //
extern void supClearSubtitle()      //liumzhi 20041204  // 2005/07/12 yltseng
{
    RESET_EXT_SUP();
    g_pfnPollingSubtitle    = NULL;
    s_pPrevSup              = NULL;
// When Changing subtitle initiallization flowchart.
// we should parser two times and check s_supParseAgain.
    //s_supParseAgain         = 0;
}
// **************************************************************************************** //
extern void supOpenSubtitle()       //caoh 2005-7-18 20:41
{
	//supInitSubtitle();		//yaowh add 2005-12-5 10:00
    g_pfnPollingSubtitle    = supPollingSubtitleSRT;
	s_pPrevSup              = NULL;
	ACTIVATE_EXT_SUP();
	osd_init_OSDSRT();
	DispCookOSD0(1);    //joshua, 2005.6.9, for refreshing all display bar
}
// **************************************************************************************** //
static inline void supSetSubtitleDataBuffer( BYTE* pBufAddr, UINT32 uiSize )
{
    s_pSupBufPtr        = pBufAddr;
    //yltseng 2005/07/20 the size of subtitle should be 2k aligned, 
    //otherwise it would be a little hard to handle buffer control.
    s_uiSupBufSize      = (uiSize & ~0x01) << 10;
    s_pSupBufEndPtr     = pBufAddr + s_uiSupBufSize;

⌨️ 快捷键说明

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