Revision 9d82b0dd

View differences:

libavcodec/flac.c
85 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)
89
{
90
    uint64_t val;
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
    }
88
static int64_t get_utf8(GetBitContext *gb){
89
    int64_t val;
90
    GET_UTF8(val, get_bits(gb, 8), return -1;)
109 91
    return val;
110 92
}
111 93

  
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

  
135 94
static void metadata_streaminfo(FLACContext *s);
136 95
static void dump_headers(FLACContext *s);
137 96

  
libavutil/common.h
503 503
            level= (level^mask)-mask;
504 504
#endif
505 505

  
506
#define GET_UTF8(val, GET_BYTE, ERROR)\
507
    val= GET_BYTE;\
508
    {\
509
        int ones= 7 - av_log2(val ^ 255);\
510
        if(ones==1)\
511
            ERROR\
512
        val&= 127>>ones;\
513
        while(--ones > 0){\
514
            int tmp= GET_BYTE - 128;\
515
            if(tmp>>6)\
516
                ERROR\
517
            val= (val<<6) + tmp;\
518
        }\
519
    }
506 520

  
507 521
#if __CPU__ >= 686 && !defined(RUNTIME_CPUDETECT)
508 522
#define COPY3_IF_LT(x,y,a,b,c,d)\

Also available in: Unified diff