comparison flac.c @ 3436:3ccec186532f libavcodec

moving utf8 reading function to libavutil
author michael
date Fri, 07 Jul 2006 22:43:32 +0000
parents d42ab8824434
children 3335f51b6cd3
comparison
equal deleted inserted replaced
3435:ffa9e863f3be 3436:3ccec186532f
83 static int blocksize_table[] = { 83 static int blocksize_table[] = {
84 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0, 84 0, 192, 576<<0, 576<<1, 576<<2, 576<<3, 0, 0,
85 256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7 85 256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
86 }; 86 };
87 87
88 static int64_t get_utf8(GetBitContext *gb) 88 static int64_t get_utf8(GetBitContext *gb){
89 { 89 int64_t val;
90 uint64_t val; 90 GET_UTF8(val, get_bits(gb, 8), return -1;)
91 int ones=0, bytes;
92
93 while(get_bits1(gb))
94 ones++;
95
96 if (ones==0) bytes=0;
97 else if(ones==1) return -1;
98 else bytes= ones - 1;
99
100 val= get_bits(gb, 7-ones);
101 while(bytes--){
102 const int tmp = get_bits(gb, 8);
103
104 if((tmp>>6) != 2)
105 return -1;
106 val<<=6;
107 val|= tmp&0x3F;
108 }
109 return val; 91 return val;
110 } 92 }
111
112 #if 0
113 static int skip_utf8(GetBitContext *gb)
114 {
115 int ones=0, bytes;
116
117 while(get_bits1(gb))
118 ones++;
119
120 if (ones==0) bytes=0;
121 else if(ones==1) return -1;
122 else bytes= ones - 1;
123
124 skip_bits(gb, 7-ones);
125 while(bytes--){
126 const int tmp = get_bits(gb, 8);
127
128 if((tmp>>6) != 2)
129 return -1;
130 }
131 return 0;
132 }
133 #endif
134 93
135 static void metadata_streaminfo(FLACContext *s); 94 static void metadata_streaminfo(FLACContext *s);
136 static void dump_headers(FLACContext *s); 95 static void dump_headers(FLACContext *s);
137 96
138 static int flac_decode_init(AVCodecContext * avctx) 97 static int flac_decode_init(AVCodecContext * avctx)