赞助论坛
  • 3671阅读
  • 0回复

U盤播放AVI+SRT字幕 一行顯示改成最多7行 [复制链接]

楼层直达
发帖
22
精华
1
金币
88
威望
3
贡献
0
好评
12
注册
2009-02-10
楼主    yinglung 发表于: 2010-04-08 15:17:30 
改成下面的code
void ShowOSDText( const UINT8* p, UINT16 size )
{
     // 2004/09/03 yltseng
     #define MAX_WORD   50
   #ifdef SDRAM_16Mb_Mode
     #define MAX_LINE   2
   #else
   #define MAX_LINE    7
   #endif
   
   BYTE*pStr = (BYTE *)p;
   BYTE c,c1;
   
   BYTE *old_pStr;
   int old_i_len;
   
   int show_line = -1;
   int show_word = 0;
   UINT16 nsize=0;
   int i_len;
   int xstart,ystart;
   int len[MAX_LINE];
   int i;
   int count;//ASCII count in a line

   int   width;
   int   height;

   width=(int) region[3].osd_visible_w;
   height=(int) region[3].osd_h/MAX_LINE; // 2004/09/03 yltseng
   
   //All char will be put into this str array
   //if string long,it will newline
   BYTE str[MAX_LINE][MAX_WORD];

   osd_tog_region(3,OSD_ON);
   
   //Read and parse each char,display them on osd
   //include function:display more lines,newline,
   //when string length>276,it will newline
   while(nsize<size)
   {
       show_word = 0;
       i_len = 0;
       count = 0;
       show_line++;
         if( show_line > MAX_LINE - 1 )//most displayed line is 7 line
         {
               show_line = MAX_LINE - 1;
               break;
         }

       //read string to string buffer,except "return","next line"
       while(((*pStr) != '\r')&& ((*pStr)!='\n') )
       {    
           c = *pStr;
           c1 = *(pStr + 1);

           //Double ASCII code            
           #if defined(USE_GB2312_FONT) || defined(USE_RUSSIAN_LANGUAGE)||defined(USE_BIG5_FONT)||defined(USE_BIG5_COMMON_FONT)||defined(USE_JAPANESE_FONT)||defined(USE_KOREAN_FONT)
           
             #if defined(USE_GB2312_FONT) || defined(USE_RUSSIAN_LANGUAGE)            
           if (((c >= 0xA1) && (c <= 0xF8)) && ((c1 >= 0xA1) && (c1 < 0xFF)))    //gb2312        

             #elif defined(USE_BIG5_FONT) || defined( USE_BIG5_COMMON_FONT )
           if(((c >= 0xA1) && (c <= 0xF9)) && ((c1 >= 0x40 && c1 <= 0x7E) || (c1 >= 0xA1 && c1 <= 0xFE))) // big5

             #elif defined(USE_JAPANESE_FONT)
               if (((c >= 0x81 && c <= 0x9F)||(c >= 0xE0 && c <= 0xFC)) && ((c1 >= 0x40) && (c1 <= 0xFC)))        

             #elif defined(USE_KOREAN_FONT)
               if(((c >= 0x81) && (c <= 0xFE)) && ((c1 >= 0x41 && c1 <= 0x5A) || (c1 >= 0x61 && c1 <= 0x7A)|| (c1 >= 0x81 && c1 <= 0xFE)))          

             #endif            
           {
               str[show_line][show_word]=c;
               str[show_line][show_word+1]=c1;
               show_word+= 2;
               i_len+= 18;
               nsize+= 2;
               pStr += 2;
               if((((i_len-count*9)%2==0)&&(i_len>275))||(((i_len-count*9)%2==0)&&(i_len>276)))
                   break;
           }
           else
           #endif

           //Single ASCII code
           #if defined(EUROPE_FOREIGN_LANGUAGES) || defined(MIDDLE_EUROPE_LANGUAGES) || defined (SUPPORT_TURKISH_LANGUAGES)
           if (((c >= 32) && (c <= 126)) ||((c >= 160) && (c <= 255)))// ISO 8859-1 code
           #else
               if ((c >= 32) && (c <= 126))
           #endif
           {
               old_pStr = pStr;
                 old_i_len = i_len;
               str[show_line][show_word]=c;
               show_word += 1;
               i_len += 9;//len
               nsize += 1;
               pStr += 1;
               
               if(c == 32) //not to cut off a long word,according to space's position
               {
                       do
                       {
                           old_pStr ++;
                           old_i_len += 9;//len
                           if((*old_pStr == 32)|| (*old_pStr == '\r')||(old_i_len > 276))
                                 break;
           
                       }while(1);
             
                       if (old_i_len > 276)
                           break;
               }
               else
               {
                  count++;
                  if (i_len>276)
                      break;    
                 }
           }                

           //other code
           else
           {
               c = '_';
               str[show_line][show_word]=c;
               show_word+= 1;
               nsize+= 1;
               i_len+= 9;
               pStr += 1;
               count++;
               if (i_len>276)
                   break;
           }
               
       }//while(((*pStr) != '\r')&& ((*pStr)!='\n') )
       
       if(((*pStr) == '\r')||((*pStr) == '\n'))//count nsize,'\r':when "return",'\n':next line is blank
       {
           pStr++;
           nsize++;
       }

       len[show_line]=i_len;
       
       str[show_line][show_word]='\0';
       
       if( show_word <= 0 )//if blank line,string line will skip
           show_line--;        
   }//while(nsize<size)

     for(i=show_line;i>=0;i--)//display each line srt title
     {
       xstart=(width-len[i])/2;
         ystart=height*(MAX_LINE-(show_line-i)-1);
         OSD_ShowString(xstart,ystart,str[i],2,3);
     }
}
本帖最近评分记录: 2 条评分