~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/cabac.h

  • Committer: Gauvain Pocentek
  • Date: 2012-03-06 11:59:12 UTC
  • mfrom: (66.1.15 precise)
  • Revision ID: gauvain@pocentek.net-20120306115912-h9d6kt9j0l532oo5
* Merge from Ubuntu:
  - put back faac support
  - recommends apport-hooks-medibuntu
  - change Maintainer, Uploaders & Vcs-* fields.
* New upstream snapshot
* upload to unstable
* Build against external libmpeg2
* drop 51_FTBFS_arm.patch again
* no longer build depend on libcdparanoia-dev on the Hurd
* Fix FTBFS on the hurd.
  Thanks to Samuel Thibault <sthibault@debian.org> (Closes: #654974)
* Fix FTBFS on arm
* New upstream snapshot, Closes: #650339, #643621, #481807
* Imported Upstream version 1.0~rc4+svn34492
* Bump standards version
* Bump dependency on libav >= 4:0.8~, Closes: #653887
* Fix build-indep
* Build mplayer-gui again, Closes: #568514
* Drop debian/all-lang-config-mak.sh, no longer needed
* include .dfsg1 in version number
* remove get-orig-source target
* no longer prune compiler flags from the environment
* No longer advertise nor build 3fdx, mga and dxr3 backends,
  Closes: #496106, #442181, #533546
* beautify mplayer version identification string
* Brown paperbag upload.
* Next try to fix build failure on sparce after recent binutils change.
* Brown paperbag upload.
* Really fix build failure on sparc after recent binutils change.
* Properly set Replaces/Conflicts on mplayer2{,-dbg} to avoid
  file overwrite errors.
* Adjust versioning of mplayer listed in the mplayer-dbg's Depends field.
* Fix build failure on sparc after recent binutils change.
* Urgency medium bumped because of RC-level bugfix
  and speeding up x264 transition.
* Update to my @debian.org email.
* Upload to unstable
* Enable joystick support on Linux only, Closes: #638408
* Rebuild fixes toolchain issue on arm, Closes: #637077
* New upstream snapshot
* following the discussion started by Diego Biurrun <diego@biurrun.de>
  in debian-devel, I have prepared a new packaging of 'mplayer'
  (with code that comes from CVS)
* the upstream tar.bz cannot be distributed by Debian, since it contains
   CSS code; so I am repackaging it 
* I have tried my best to address all known issues:
  - the package contains the detailed Copyright made by Diego Biurrun 
  - the package does not contain CSS code, or  AFAIK other code on which 
     there is active patent enforcement
  - there is a script  debian/cvs-changelog.sh  that shows all changes
     done to files included in this source.
    This should comply with GPLv2 sec 2.a  (in spirit if not in letter)
    For this reason, the source code contains CVS directories.
* needs   make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile

* some corrections, as suggested Diego Biurrun
  - binary codecs should go into /usr/lib/codecs (upstream default)
  - better template 'mplayer/install_codecs'
  - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected
* correction in 'mplayer/cfgnote'
* better mplayer.postinst and mplayer.config

* New upstream release
* better debian/copyright file
* do not ship a skin
* New upstream release
* changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE ,
  DEB_BUILD_OPTIONS is used as in debian policy
* use gcc-3.4
* changed xlibs-dev to a long list of dependencies, for Debian/etch
* try to adhere to  http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt
  (see README.Debian for details)
* removed dependency on xlibmesa-dev, disabled opengl
* New upstream release
* Simon McVittie <hacks@pseudorandom.co.uk> wonderful work:
- Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have
  conflicting uses for __vector) by re-ordering #includes
- Fix potential symlink attack in ./configure
- Disable support for binary codecs on platforms for which those codecs
  aren't available; also disable the corresponding Debconf note when it's
  inappropriate
- Changed Build-Depends: so it works in pbuilder
- Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev,
  libungif4-dev 
- Tweak debian/rules to avoid certain errors being ignored
- Use --language=all
* provide a target  'debian/rules get-orig-source' 
  that recreates the orig.tar.gz ; then use the above orig.tar.gz
* rewrote some parts of debian/rules
* don't clean and recompile docs if upstream ships them
* mplayer-doc was shipping too much stuff
* translated man pages where not installed properly
* compile with libdv4-dev
* correct README.Debian
* Forgot build-dep on libtheora
* Must not depend on libxvidcore
* New upstream release
* new release.
* rc1 to become 0.90
* new pre-release
* new pre-release
* gtk bug fixed.
* new release.
* version bumped
* 0.60 pre2 release
* 0.60 pre-release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    int low;
42
42
    int range;
43
43
    int outstanding_count;
44
 
#ifdef STRICT_LIMITS
45
 
    int symCount;
46
 
#endif
47
44
    const uint8_t *bytestream_start;
48
45
    const uint8_t *bytestream;
49
46
    const uint8_t *bytestream_end;
65
62
void ff_init_cabac_states(CABACContext *c);
66
63
 
67
64
 
68
 
static inline void put_cabac_bit(CABACContext *c, int b){
69
 
    put_bits(&c->pb, 1, b);
70
 
    for(;c->outstanding_count; c->outstanding_count--){
71
 
        put_bits(&c->pb, 1, 1-b);
72
 
    }
73
 
}
74
 
 
75
 
static inline void renorm_cabac_encoder(CABACContext *c){
76
 
    while(c->range < 0x100){
77
 
        //FIXME optimize
78
 
        if(c->low<0x100){
79
 
            put_cabac_bit(c, 0);
80
 
        }else if(c->low<0x200){
81
 
            c->outstanding_count++;
82
 
            c->low -= 0x100;
83
 
        }else{
84
 
            put_cabac_bit(c, 1);
85
 
            c->low -= 0x200;
86
 
        }
87
 
 
88
 
        c->range+= c->range;
89
 
        c->low += c->low;
90
 
    }
91
 
}
92
 
 
93
 
#ifdef TEST
94
 
static void put_cabac(CABACContext *c, uint8_t * const state, int bit){
95
 
    int RangeLPS= ff_h264_lps_range[2*(c->range&0xC0) + *state];
96
 
 
97
 
    if(bit == ((*state)&1)){
98
 
        c->range -= RangeLPS;
99
 
        *state= ff_h264_mps_state[*state];
100
 
    }else{
101
 
        c->low += c->range - RangeLPS;
102
 
        c->range = RangeLPS;
103
 
        *state= ff_h264_lps_state[*state];
104
 
    }
105
 
 
106
 
    renorm_cabac_encoder(c);
107
 
 
108
 
#ifdef STRICT_LIMITS
109
 
    c->symCount++;
110
 
#endif
111
 
}
112
 
 
113
 
static void put_cabac_static(CABACContext *c, int RangeLPS, int bit){
114
 
    assert(c->range > RangeLPS);
115
 
 
116
 
    if(!bit){
117
 
        c->range -= RangeLPS;
118
 
    }else{
119
 
        c->low += c->range - RangeLPS;
120
 
        c->range = RangeLPS;
121
 
    }
122
 
 
123
 
    renorm_cabac_encoder(c);
124
 
 
125
 
#ifdef STRICT_LIMITS
126
 
    c->symCount++;
127
 
#endif
128
 
}
129
 
 
130
 
/**
131
 
 * @param bit 0 -> write zero bit, !=0 write one bit
132
 
 */
133
 
static void put_cabac_bypass(CABACContext *c, int bit){
134
 
    c->low += c->low;
135
 
 
136
 
    if(bit){
137
 
        c->low += c->range;
138
 
    }
139
 
//FIXME optimize
140
 
    if(c->low<0x200){
141
 
        put_cabac_bit(c, 0);
142
 
    }else if(c->low<0x400){
143
 
        c->outstanding_count++;
144
 
        c->low -= 0x200;
145
 
    }else{
146
 
        put_cabac_bit(c, 1);
147
 
        c->low -= 0x400;
148
 
    }
149
 
 
150
 
#ifdef STRICT_LIMITS
151
 
    c->symCount++;
152
 
#endif
153
 
}
154
 
 
155
 
/**
156
 
 *
157
 
 * @return the number of bytes written
158
 
 */
159
 
static int put_cabac_terminate(CABACContext *c, int bit){
160
 
    c->range -= 2;
161
 
 
162
 
    if(!bit){
163
 
        renorm_cabac_encoder(c);
164
 
    }else{
165
 
        c->low += c->range;
166
 
        c->range= 2;
167
 
 
168
 
        renorm_cabac_encoder(c);
169
 
 
170
 
        assert(c->low <= 0x1FF);
171
 
        put_cabac_bit(c, c->low>>9);
172
 
        put_bits(&c->pb, 2, ((c->low>>7)&3)|1);
173
 
 
174
 
        flush_put_bits(&c->pb); //FIXME FIXME FIXME XXX wrong
175
 
    }
176
 
 
177
 
#ifdef STRICT_LIMITS
178
 
    c->symCount++;
179
 
#endif
180
 
 
181
 
    return (put_bits_count(&c->pb)+7)>>3;
182
 
}
183
 
 
184
 
/**
185
 
 * put (truncated) unary binarization.
186
 
 */
187
 
static void put_cabac_u(CABACContext *c, uint8_t * state, int v, int max, int max_index, int truncated){
188
 
    int i;
189
 
 
190
 
    assert(v <= max);
191
 
 
192
 
#if 1
193
 
    for(i=0; i<v; i++){
194
 
        put_cabac(c, state, 1);
195
 
        if(i < max_index) state++;
196
 
    }
197
 
    if(truncated==0 || v<max)
198
 
        put_cabac(c, state, 0);
199
 
#else
200
 
    if(v <= max_index){
201
 
        for(i=0; i<v; i++){
202
 
            put_cabac(c, state+i, 1);
203
 
        }
204
 
        if(truncated==0 || v<max)
205
 
            put_cabac(c, state+i, 0);
206
 
    }else{
207
 
        for(i=0; i<=max_index; i++){
208
 
            put_cabac(c, state+i, 1);
209
 
        }
210
 
        for(; i<v; i++){
211
 
            put_cabac(c, state+max_index, 1);
212
 
        }
213
 
        if(truncated==0 || v<max)
214
 
            put_cabac(c, state+max_index, 0);
215
 
    }
216
 
#endif
217
 
}
218
 
 
219
 
/**
220
 
 * put unary exp golomb k-th order binarization.
221
 
 */
222
 
static void put_cabac_ueg(CABACContext *c, uint8_t * state, int v, int max, int is_signed, int k, int max_index){
223
 
    int i;
224
 
 
225
 
    if(v==0)
226
 
        put_cabac(c, state, 0);
227
 
    else{
228
 
        const int sign= v < 0;
229
 
 
230
 
        if(is_signed) v= FFABS(v);
231
 
 
232
 
        if(v<max){
233
 
            for(i=0; i<v; i++){
234
 
                put_cabac(c, state, 1);
235
 
                if(i < max_index) state++;
236
 
            }
237
 
 
238
 
            put_cabac(c, state, 0);
239
 
        }else{
240
 
            int m= 1<<k;
241
 
 
242
 
            for(i=0; i<max; i++){
243
 
                put_cabac(c, state, 1);
244
 
                if(i < max_index) state++;
245
 
            }
246
 
 
247
 
            v -= max;
248
 
            while(v >= m){ //FIXME optimize
249
 
                put_cabac_bypass(c, 1);
250
 
                v-= m;
251
 
                m+= m;
252
 
            }
253
 
            put_cabac_bypass(c, 0);
254
 
            while(m>>=1){
255
 
                put_cabac_bypass(c, v&m);
256
 
            }
257
 
        }
258
 
 
259
 
        if(is_signed)
260
 
            put_cabac_bypass(c, sign);
261
 
    }
262
 
}
263
 
#endif /* TEST */
264
 
 
265
65
static void refill(CABACContext *c){
266
66
#if CABAC_BITS == 16
267
67
        c->low+= (c->bytestream[0]<<9) + (c->bytestream[1]<<1);
272
72
    c->bytestream+= CABAC_BITS/8;
273
73
}
274
74
 
275
 
static inline void renorm_cabac_decoder(CABACContext *c){
276
 
    while(c->range < 0x100){
277
 
        c->range+= c->range;
278
 
        c->low+= c->low;
279
 
        if(!(c->low & CABAC_MASK))
280
 
            refill(c);
281
 
    }
282
 
}
283
 
 
284
75
static inline void renorm_cabac_decoder_once(CABACContext *c){
285
76
    int shift= (uint32_t)(c->range - 0x100)>>31;
286
77
    c->range<<= shift;
388
179
    }
389
180
}
390
181
 
391
 
#if 0
392
 
/**
393
 
 * Get (truncated) unary binarization.
394
 
 */
395
 
static int get_cabac_u(CABACContext *c, uint8_t * state, int max, int max_index, int truncated){
396
 
    int i;
397
 
 
398
 
    for(i=0; i<max; i++){
399
 
        if(get_cabac(c, state)==0)
400
 
            return i;
401
 
 
402
 
        if(i< max_index) state++;
403
 
    }
404
 
 
405
 
    return truncated ? max : -1;
406
 
}
407
 
 
408
 
/**
409
 
 * get unary exp golomb k-th order binarization.
410
 
 */
411
 
static int get_cabac_ueg(CABACContext *c, uint8_t * state, int max, int is_signed, int k, int max_index){
412
 
    int i, v;
413
 
    int m= 1<<k;
414
 
 
415
 
    if(get_cabac(c, state)==0)
416
 
        return 0;
417
 
 
418
 
    if(0 < max_index) state++;
419
 
 
420
 
    for(i=1; i<max; i++){
421
 
        if(get_cabac(c, state)==0){
422
 
            if(is_signed && get_cabac_bypass(c)){
423
 
                return -i;
424
 
            }else
425
 
                return i;
426
 
        }
427
 
 
428
 
        if(i < max_index) state++;
429
 
    }
430
 
 
431
 
    while(get_cabac_bypass(c)){
432
 
        i+= m;
433
 
        m+= m;
434
 
    }
435
 
 
436
 
    v=0;
437
 
    while(m>>=1){
438
 
        v+= v + get_cabac_bypass(c);
439
 
    }
440
 
    i += v;
441
 
 
442
 
    if(is_signed && get_cabac_bypass(c)){
443
 
        return -i;
444
 
    }else
445
 
        return i;
446
 
}
447
 
#endif /* 0 */
448
 
 
449
182
#endif /* AVCODEC_CABAC_H */