[Ffmpeg-cvslog] r5664 - in trunk: libavcodec/flac.c libavutil/common.h

michael subversion
Sat Jul 8 00:43:32 CEST 2006


Author: michael
Date: Sat Jul  8 00:43:32 2006
New Revision: 5664

Modified:
   trunk/libavcodec/flac.c
   trunk/libavutil/common.h

Log:
moving utf8 reading function to libavutil


Modified: trunk/libavcodec/flac.c
==============================================================================
--- trunk/libavcodec/flac.c	(original)
+++ trunk/libavcodec/flac.c	Sat Jul  8 00:43:32 2006
@@ -85,53 +85,12 @@
 256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
 };
 
-static int64_t get_utf8(GetBitContext *gb)
-{
-    uint64_t val;
-    int ones=0, bytes;
-
-    while(get_bits1(gb))
-        ones++;
-
-    if     (ones==0) bytes=0;
-    else if(ones==1) return -1;
-    else             bytes= ones - 1;
-
-    val= get_bits(gb, 7-ones);
-    while(bytes--){
-        const int tmp = get_bits(gb, 8);
-
-        if((tmp>>6) != 2)
-            return -1;
-        val<<=6;
-        val|= tmp&0x3F;
-    }
+static int64_t get_utf8(GetBitContext *gb){
+    int64_t val;
+    GET_UTF8(val, get_bits(gb, 8), return -1;)
     return val;
 }
 
-#if 0
-static int skip_utf8(GetBitContext *gb)
-{
-    int ones=0, bytes;
-
-    while(get_bits1(gb))
-        ones++;
-
-    if     (ones==0) bytes=0;
-    else if(ones==1) return -1;
-    else             bytes= ones - 1;
-
-    skip_bits(gb, 7-ones);
-    while(bytes--){
-        const int tmp = get_bits(gb, 8);
-
-        if((tmp>>6) != 2)
-            return -1;
-    }
-    return 0;
-}
-#endif
-
 static void metadata_streaminfo(FLACContext *s);
 static void dump_headers(FLACContext *s);
 

Modified: trunk/libavutil/common.h
==============================================================================
--- trunk/libavutil/common.h	(original)
+++ trunk/libavutil/common.h	Sat Jul  8 00:43:32 2006
@@ -503,6 +503,20 @@
             level= (level^mask)-mask;
 #endif
 
+#define GET_UTF8(val, GET_BYTE, ERROR)\
+    val= GET_BYTE;\
+    {\
+        int ones= 7 - av_log2(val ^ 255);\
+        if(ones==1)\
+            ERROR\
+        val&= 127>>ones;\
+        while(--ones > 0){\
+            int tmp= GET_BYTE - 128;\
+            if(tmp>>6)\
+                ERROR\
+            val= (val<<6) + tmp;\
+        }\
+    }
 
 #if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
 #define COPY3_IF_LT(x,y,a,b,c,d)\




More information about the ffmpeg-cvslog mailing list