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

reimar subversion at mplayerhq.hu
Sat Aug 12 17:28:01 CEST 2006


Author: reimar
Date: Sat Aug 12 17:28:01 2006
New Revision: 19372

Modified:
   trunk/libvo/sub.c

Log:
Reuse UTF-8 reading code in libavutil


Modified: trunk/libvo/sub.c
==============================================================================
--- trunk/libvo/sub.c	(original)
+++ trunk/libvo/sub.c	Sat Aug 12 17:28:01 2006
@@ -14,6 +14,7 @@
 #include "font_load.h"
 #include "sub.h"
 #include "spudec.h"
+#include "libavutil/common.h"
 
 #define NEW_SPLITTING
 
@@ -142,23 +143,8 @@
 
 unsigned utf8_get_char(char **str) {
   uint8_t *strp = (uint8_t *)*str;
-  unsigned c = *strp++;
-  unsigned mask = 0x80;
-  int len = -1;
-  while (c & mask) {
-    mask >>= 1;
-    len++;
-  }
-  if (len <= 0 || len > 4)
-    goto no_utf8;
-  c &= mask - 1;
-  while ((*strp & 0xc0) == 0x80) {
-    if (len-- <= 0)
-      goto no_utf8;
-    c = (c << 6) | (*strp++ & 0x3f);
-  }
-  if (len)
-    goto no_utf8;
+  unsigned c;
+  GET_UTF8(c, *strp++, goto no_utf8;);
   *str = (char *)strp;
   return c;
 



More information about the MPlayer-cvslog mailing list