Revision 9df4ce5e

View differences:

libavcodec/golomb.c
153 153
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
154 154
  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
155 155
};
156

  
157
const uint8_t ff_interleaved_dirac_golomb_vlc_code[256]={
158
0, 1, 0, 0, 2, 3, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
159
4, 5, 2, 2, 6, 7, 3, 3, 1, 1, 1, 1, 1, 1, 1, 1,
160
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
162
8, 9, 4, 4, 10,11,5, 5, 2, 2, 2, 2, 2, 2, 2, 2,
163
12,13,6, 6, 14,15,7, 7, 3, 3, 3, 3, 3, 3, 3, 3,
164
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
165
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
166
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
167
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
169
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
170
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
171
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
172
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
173
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,};
libavcodec/golomb.h
43 43
extern const uint8_t ff_interleaved_golomb_vlc_len[256];
44 44
extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
45 45
extern const  int8_t ff_interleaved_se_golomb_vlc_code[256];
46
extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256];
46 47

  
47 48

  
48 49
 /**
......
75 76

  
76 77
static inline int svq3_get_ue_golomb(GetBitContext *gb){
77 78
    uint32_t buf;
78
    int log;
79 79

  
80 80
    OPEN_READER(re, gb);
81 81
    UPDATE_CACHE(re, gb);
......
88 88

  
89 89
        return ff_interleaved_ue_golomb_vlc_code[buf];
90 90
    }else{
91
        LAST_SKIP_BITS(re, gb, 8);
92
        UPDATE_CACHE(re, gb);
93
        buf |= 1 | (GET_CACHE(re, gb) >> 8);
91
        int ret = 1;
94 92

  
95
        if((buf & 0xAAAAAAAA) == 0)
96
            return INVALID_VLC;
93
        while (1) {
94
            buf >>= 32 - 8;
95
            LAST_SKIP_BITS(re, gb, FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
97 96

  
98
        for(log=31; (buf & 0x80000000) == 0; log--){
99
            buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
97
            if (ff_interleaved_golomb_vlc_len[buf] != 9){
98
                ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
99
                ret |= ff_interleaved_dirac_golomb_vlc_code[buf];
100
                break;
101
            }
102
            ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
103
            UPDATE_CACHE(re, gb);
104
            buf = GET_CACHE(re, gb);
100 105
        }
101 106

  
102
        LAST_SKIP_BITS(re, gb, 63 - 2*log - 8);
103 107
        CLOSE_READER(re, gb);
104

  
105
        return ((buf << log) >> log) - 1;
108
        return ret - 1;
106 109
    }
107 110
}
108 111

  
......
192 195
    }
193 196
}
194 197

  
198
static inline int dirac_get_se_golomb(GetBitContext *gb){
199
    uint32_t buf;
200
    uint32_t ret;
201

  
202
    ret = svq3_get_ue_golomb(gb);
203

  
204
    if (ret) {
205
        OPEN_READER(re, gb);
206
        UPDATE_CACHE(re, gb);
207
        buf = SHOW_SBITS(re, gb, 1);
208
        LAST_SKIP_BITS(re, gb, 1);
209
        ret = (ret ^ buf) - buf;
210
        CLOSE_READER(re, gb);
211
    }
212

  
213
    return ret;
214
}
215

  
195 216
/**
196 217
 * read unsigned golomb rice code (ffv1).
197 218
 */

Also available in: Unified diff