[MPlayer-cvslog] r21596 - trunk/libvo/sub.c

reimar subversion at mplayerhq.hu
Mon Dec 11 23:29:08 CET 2006


Author: reimar
Date: Mon Dec 11 23:29:08 2006
New Revision: 21596

Modified:
   trunk/libvo/sub.c

Log:
Reuse utf8_get_char in subtitle rendering code.


Modified: trunk/libvo/sub.c
==============================================================================
--- trunk/libvo/sub.c	(original)
+++ trunk/libvo/sub.c	Mon Dec 11 23:29:08 2006
@@ -428,20 +428,13 @@
 	    x = 1;
 
 	    // reading the subtitle words from vo_sub->text[]
-	  for (j=0;j<=len;j++){
-	      if ((c=t[j])>=0x80){
-		 if (sub_utf8){
-		    if ((c & 0xe0) == 0xc0)    /* 2 bytes U+00080..U+0007FF*/
-		       c = (c & 0x1f)<<6 | (t[++j] & 0x3f);
-		    else if((c & 0xf0) == 0xe0){ /* 3 bytes U+00800..U+00FFFF*/
-		       c = (((c & 0x0f)<<6) | (t[++j] & 0x3f))<<6;
-		       c |= (t[++j] & 0x3f);
-		    }
-		 } else if (sub_unicode) 
-		       c = (c<<8) + t[++j]; 
-	      }
+          while (*t) {
+            if (sub_utf8)
+              c = utf8_get_char(&t);
+            else if ((c = *t++) >= 0x80 && sub_unicode)
+              c = (c<<8) + *t++;
 	      if (k==MAX_UCS){
-		 len=j; // end here
+		 t += strlen(t); // end here
 		 mp_msg(MSGT_OSD,MSGL_WARN,"\nMAX_UCS exceeded!\n");
 	      }
 	      if (!c) c++; // avoid UCS 0



More information about the MPlayer-cvslog mailing list