~medibuntu-maintainers/mplayer/medibuntu.precise

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/get_bits.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:
27
27
#define AVCODEC_GET_BITS_H
28
28
 
29
29
#include <stdint.h>
30
 
#include <stdlib.h>
31
 
#include <assert.h>
32
 
#include "libavutil/bswap.h"
33
30
#include "libavutil/common.h"
34
31
#include "libavutil/intreadwrite.h"
35
32
#include "libavutil/log.h"
36
33
#include "mathops.h"
37
34
 
38
 
#if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER)
39
 
#   define ALT_BITSTREAM_READER
40
 
#endif
41
 
 
42
 
#if !defined(A32_BITSTREAM_READER) && !defined(ALT_BITSTREAM_READER)
43
 
#   if ARCH_ARM && !HAVE_FAST_UNALIGNED
44
 
#       define A32_BITSTREAM_READER
45
 
#   else
46
 
#       define ALT_BITSTREAM_READER
47
 
//#define A32_BITSTREAM_READER
48
 
#   endif
49
 
#endif
50
 
 
51
 
/* bit input */
52
 
/* buffer, buffer_end and size_in_bits must be present and used by every reader */
 
35
/*
 
36
 * Safe bitstream reading:
 
37
 * optionally, the get_bits API can check to ensure that we
 
38
 * don't read past input buffer boundaries. This is protected
 
39
 * with CONFIG_SAFE_BITSTREAM_READER at the global level, and
 
40
 * then below that with UNCHECKED_BITSTREAM_READER at the per-
 
41
 * decoder level. This means that decoders that check internally
 
42
 * can "#define UNCHECKED_BITSTREAM_READER 1" to disable
 
43
 * overread checks.
 
44
 * Boundary checking causes a minor performance penalty so for
 
45
 * applications that won't want/need this, it can be disabled
 
46
 * globally using "#define CONFIG_SAFE_BITSTREAM_READER 0".
 
47
 */
 
48
#ifndef UNCHECKED_BITSTREAM_READER
 
49
#define UNCHECKED_BITSTREAM_READER !CONFIG_SAFE_BITSTREAM_READER
 
50
#endif
 
51
 
53
52
typedef struct GetBitContext {
54
53
    const uint8_t *buffer, *buffer_end;
55
 
#ifdef ALT_BITSTREAM_READER
56
54
    int index;
57
 
#elif defined A32_BITSTREAM_READER
58
 
    uint32_t *buffer_ptr;
59
 
    uint32_t cache0;
60
 
    uint32_t cache1;
61
 
    int bit_count;
62
 
#endif
63
55
    int size_in_bits;
 
56
#if !UNCHECKED_BITSTREAM_READER
 
57
    int size_in_bits_plus8;
 
58
#endif
64
59
} GetBitContext;
65
60
 
66
61
#define VLC_TYPE int16_t
85
80
    getbitcontext
86
81
 
87
82
OPEN_READER(name, gb)
88
 
    loads gb into local variables
 
83
    load gb into local variables
89
84
 
90
85
CLOSE_READER(name, gb)
91
 
    stores local vars in gb
 
86
    store local vars in gb
92
87
 
93
88
UPDATE_CACHE(name, gb)
94
 
    refills the internal cache from the bitstream
 
89
    refill the internal cache from the bitstream
95
90
    after this call at least MIN_CACHE_BITS will be available,
96
91
 
97
92
GET_CACHE(name, gb)
113
108
SKIP_COUNTER(name, gb, num)
114
109
    will increment the internal bit counter (see SKIP_CACHE & SKIP_BITS)
115
110
 
116
 
LAST_SKIP_CACHE(name, gb, num)
117
 
    will remove the next num bits from the cache if it is needed for UPDATE_CACHE otherwise it will do nothing
118
 
 
119
111
LAST_SKIP_BITS(name, gb, num)
120
 
    is equivalent to LAST_SKIP_CACHE; SKIP_COUNTER
 
112
    like SKIP_BITS, to be used if next call is UPDATE_CACHE or CLOSE_READER
121
113
 
122
114
for examples see get_bits, show_bits, skip_bits, get_vlc
123
115
*/
124
116
 
125
 
#ifdef ALT_BITSTREAM_READER
 
117
#ifdef LONG_BITSTREAM_READER
 
118
#   define MIN_CACHE_BITS 32
 
119
#else
126
120
#   define MIN_CACHE_BITS 25
 
121
#endif
127
122
 
128
 
#   define OPEN_READER(name, gb)                \
 
123
#define OPEN_READER(name, gb)                   \
129
124
    unsigned int name##_index = (gb)->index;    \
130
125
    unsigned int av_unused name##_cache = 0
131
126
 
132
 
#   define CLOSE_READER(name, gb) (gb)->index = name##_index
133
 
 
134
 
# ifdef ALT_BITSTREAM_READER_LE
135
 
#   define UPDATE_CACHE(name, gb) \
136
 
    name##_cache = AV_RL32(((const uint8_t *)(gb)->buffer)+(name##_index>>3)) >> (name##_index&0x07)
137
 
 
138
 
#   define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
139
 
# else
140
 
#   define UPDATE_CACHE(name, gb) \
141
 
    name##_cache = AV_RB32(((const uint8_t *)(gb)->buffer)+(name##_index>>3)) << (name##_index&0x07)
142
 
 
143
 
#   define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
144
 
# endif
145
 
 
146
 
// FIXME name?
 
127
#define CLOSE_READER(name, gb) (gb)->index = name##_index
 
128
 
 
129
#ifdef BITSTREAM_READER_LE
 
130
 
 
131
# ifdef LONG_BITSTREAM_READER
 
132
#   define UPDATE_CACHE(name, gb) name##_cache = \
 
133
        AV_RL64((gb)->buffer + (name##_index >> 3)) >> (name##_index & 7)
 
134
# else
 
135
#   define UPDATE_CACHE(name, gb) name##_cache = \
 
136
        AV_RL32((gb)->buffer + (name##_index >> 3)) >> (name##_index & 7)
 
137
# endif
 
138
 
 
139
# define SKIP_CACHE(name, gb, num) name##_cache >>= (num)
 
140
 
 
141
#else
 
142
 
 
143
# ifdef LONG_BITSTREAM_READER
 
144
#   define UPDATE_CACHE(name, gb) name##_cache = \
 
145
        AV_RB64((gb)->buffer + (name##_index >> 3)) >> (32 - (name##_index & 7))
 
146
# else
 
147
#   define UPDATE_CACHE(name, gb) name##_cache = \
 
148
        AV_RB32((gb)->buffer + (name##_index >> 3)) << (name##_index & 7)
 
149
# endif
 
150
 
 
151
# define SKIP_CACHE(name, gb, num) name##_cache <<= (num)
 
152
 
 
153
#endif
 
154
 
 
155
#if UNCHECKED_BITSTREAM_READER
147
156
#   define SKIP_COUNTER(name, gb, num) name##_index += (num)
 
157
#else
 
158
#   define SKIP_COUNTER(name, gb, num) \
 
159
    name##_index = FFMIN((gb)->size_in_bits_plus8, name##_index + (num))
 
160
#endif
148
161
 
149
 
#   define SKIP_BITS(name, gb, num) do {        \
 
162
#define SKIP_BITS(name, gb, num) do {           \
150
163
        SKIP_CACHE(name, gb, num);              \
151
164
        SKIP_COUNTER(name, gb, num);            \
152
165
    } while (0)
153
166
 
154
 
#   define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
155
 
#   define LAST_SKIP_CACHE(name, gb, num)
 
167
#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num)
156
168
 
157
 
# ifdef ALT_BITSTREAM_READER_LE
 
169
#ifdef BITSTREAM_READER_LE
158
170
#   define SHOW_UBITS(name, gb, num) zero_extend(name##_cache, num)
159
 
 
160
171
#   define SHOW_SBITS(name, gb, num) sign_extend(name##_cache, num)
161
 
# else
 
172
#else
162
173
#   define SHOW_UBITS(name, gb, num) NEG_USR32(name##_cache, num)
163
 
 
164
174
#   define SHOW_SBITS(name, gb, num) NEG_SSR32(name##_cache, num)
165
 
# endif
166
 
 
167
 
#   define GET_CACHE(name, gb) ((uint32_t)name##_cache)
168
 
 
169
 
static inline int get_bits_count(const GetBitContext *s){
 
175
#endif
 
176
 
 
177
#define GET_CACHE(name, gb) ((uint32_t)name##_cache)
 
178
 
 
179
static inline int get_bits_count(const GetBitContext *s)
 
180
{
170
181
    return s->index;
171
182
}
172
183
 
173
184
static inline void skip_bits_long(GetBitContext *s, int n){
 
185
#if UNCHECKED_BITSTREAM_READER
174
186
    s->index += n;
175
 
}
176
 
 
177
 
#elif defined A32_BITSTREAM_READER
178
 
 
179
 
#   define MIN_CACHE_BITS 32
180
 
 
181
 
#   define OPEN_READER(name, gb)                        \
182
 
    int name##_bit_count        = (gb)->bit_count;      \
183
 
    uint32_t name##_cache0      = (gb)->cache0;         \
184
 
    uint32_t name##_cache1      = (gb)->cache1;         \
185
 
    uint32_t *name##_buffer_ptr = (gb)->buffer_ptr
186
 
 
187
 
#   define CLOSE_READER(name, gb) do {          \
188
 
        (gb)->bit_count  = name##_bit_count;    \
189
 
        (gb)->cache0     = name##_cache0;       \
190
 
        (gb)->cache1     = name##_cache1;       \
191
 
        (gb)->buffer_ptr = name##_buffer_ptr;   \
192
 
    } while (0)
193
 
 
194
 
#   define UPDATE_CACHE(name, gb) do {                                  \
195
 
        if(name##_bit_count > 0){                                       \
196
 
            const uint32_t next = av_be2ne32(*name##_buffer_ptr);       \
197
 
            name##_cache0 |= NEG_USR32(next, name##_bit_count);         \
198
 
            name##_cache1 |= next << name##_bit_count;                  \
199
 
            name##_buffer_ptr++;                                        \
200
 
            name##_bit_count -= 32;                                     \
201
 
        }                                                               \
202
 
    } while (0)
203
 
 
204
 
#if ARCH_X86
205
 
#   define SKIP_CACHE(name, gb, num)                            \
206
 
    __asm__("shldl %2, %1, %0          \n\t"                    \
207
 
            "shll  %2, %1              \n\t"                    \
208
 
            : "+r" (name##_cache0), "+r" (name##_cache1)        \
209
 
            : "Ic" ((uint8_t)(num)))
210
187
#else
211
 
#   define SKIP_CACHE(name, gb, num) do {               \
212
 
        name##_cache0 <<= (num);                        \
213
 
        name##_cache0 |= NEG_USR32(name##_cache1,num);  \
214
 
        name##_cache1 <<= (num);                        \
215
 
    } while (0)
216
 
#endif
217
 
 
218
 
#   define SKIP_COUNTER(name, gb, num) name##_bit_count += (num)
219
 
 
220
 
#   define SKIP_BITS(name, gb, num) do {        \
221
 
        SKIP_CACHE(name, gb, num);              \
222
 
        SKIP_COUNTER(name, gb, num);            \
223
 
    } while (0)
224
 
 
225
 
#   define LAST_SKIP_BITS(name, gb, num)  SKIP_BITS(name, gb, num)
226
 
#   define LAST_SKIP_CACHE(name, gb, num) SKIP_CACHE(name, gb, num)
227
 
 
228
 
#   define SHOW_UBITS(name, gb, num) NEG_USR32(name##_cache0, num)
229
 
 
230
 
#   define SHOW_SBITS(name, gb, num) NEG_SSR32(name##_cache0, num)
231
 
 
232
 
#   define GET_CACHE(name, gb) name##_cache0
233
 
 
234
 
static inline int get_bits_count(const GetBitContext *s) {
235
 
    return ((uint8_t*)s->buffer_ptr - s->buffer)*8 - 32 + s->bit_count;
236
 
}
237
 
 
238
 
static inline void skip_bits_long(GetBitContext *s, int n){
239
 
    OPEN_READER(re, s);
240
 
    re_bit_count += n;
241
 
    re_buffer_ptr += re_bit_count>>5;
242
 
    re_bit_count &= 31;
243
 
    re_cache0 = av_be2ne32(re_buffer_ptr[-1]) << re_bit_count;
244
 
    re_cache1 = 0;
245
 
    UPDATE_CACHE(re, s);
246
 
    CLOSE_READER(re, s);
247
 
}
248
 
 
249
 
#endif
 
188
    s->index += av_clip(n, -s->index, s->size_in_bits_plus8 - s->index);
 
189
#endif
 
190
}
250
191
 
251
192
/**
252
193
 * read mpeg1 dc style vlc (sign bit + mantisse with no MSB).
253
194
 * if MSB not set it is negative
254
195
 * @param n length in bits
255
 
 * @author BERO
256
196
 */
257
 
static inline int get_xbits(GetBitContext *s, int n){
 
197
static inline int get_xbits(GetBitContext *s, int n)
 
198
{
258
199
    register int sign;
259
200
    register int32_t cache;
260
201
    OPEN_READER(re, s);
266
207
    return (NEG_USR32(sign ^ cache, n) ^ sign) - sign;
267
208
}
268
209
 
269
 
static inline int get_sbits(GetBitContext *s, int n){
 
210
static inline int get_sbits(GetBitContext *s, int n)
 
211
{
270
212
    register int tmp;
271
213
    OPEN_READER(re, s);
272
214
    UPDATE_CACHE(re, s);
279
221
/**
280
222
 * Read 1-25 bits.
281
223
 */
282
 
static inline unsigned int get_bits(GetBitContext *s, int n){
 
224
static inline unsigned int get_bits(GetBitContext *s, int n)
 
225
{
283
226
    register int tmp;
284
227
    OPEN_READER(re, s);
285
228
    UPDATE_CACHE(re, s);
290
233
}
291
234
 
292
235
/**
293
 
 * Shows 1-25 bits.
 
236
 * Show 1-25 bits.
294
237
 */
295
 
static inline unsigned int show_bits(GetBitContext *s, int n){
 
238
static inline unsigned int show_bits(GetBitContext *s, int n)
 
239
{
296
240
    register int tmp;
297
241
    OPEN_READER(re, s);
298
242
    UPDATE_CACHE(re, s);
300
244
    return tmp;
301
245
}
302
246
 
303
 
static inline void skip_bits(GetBitContext *s, int n){
304
 
 //Note gcc seems to optimize this to s->index+=n for the ALT_READER :))
 
247
static inline void skip_bits(GetBitContext *s, int n)
 
248
{
305
249
    OPEN_READER(re, s);
306
250
    UPDATE_CACHE(re, s);
307
251
    LAST_SKIP_BITS(re, s, n);
308
252
    CLOSE_READER(re, s);
309
253
}
310
254
 
311
 
static inline unsigned int get_bits1(GetBitContext *s){
312
 
#ifdef ALT_BITSTREAM_READER
 
255
static inline unsigned int get_bits1(GetBitContext *s)
 
256
{
313
257
    unsigned int index = s->index;
314
258
    uint8_t result = s->buffer[index>>3];
315
 
#ifdef ALT_BITSTREAM_READER_LE
 
259
#ifdef BITSTREAM_READER_LE
316
260
    result >>= index & 7;
317
261
    result &= 1;
318
262
#else
319
263
    result <<= index & 7;
320
264
    result >>= 8 - 1;
321
265
#endif
322
 
    index++;
 
266
#if !UNCHECKED_BITSTREAM_READER
 
267
    if (s->index < s->size_in_bits_plus8)
 
268
#endif
 
269
        index++;
323
270
    s->index = index;
324
271
 
325
272
    return result;
326
 
#else
327
 
    return get_bits(s, 1);
328
 
#endif
329
273
}
330
274
 
331
 
static inline unsigned int show_bits1(GetBitContext *s){
 
275
static inline unsigned int show_bits1(GetBitContext *s)
 
276
{
332
277
    return show_bits(s, 1);
333
278
}
334
279
 
335
 
static inline void skip_bits1(GetBitContext *s){
 
280
static inline void skip_bits1(GetBitContext *s)
 
281
{
336
282
    skip_bits(s, 1);
337
283
}
338
284
 
339
285
/**
340
 
 * reads 0-32 bits.
 
286
 * Read 0-32 bits.
341
287
 */
342
 
static inline unsigned int get_bits_long(GetBitContext *s, int n){
343
 
    if (n <= MIN_CACHE_BITS) return get_bits(s, n);
 
288
static inline unsigned int get_bits_long(GetBitContext *s, int n)
 
289
{
 
290
    if (n <= MIN_CACHE_BITS)
 
291
        return get_bits(s, n);
344
292
    else {
345
 
#ifdef ALT_BITSTREAM_READER_LE
 
293
#ifdef BITSTREAM_READER_LE
346
294
        int ret = get_bits(s, 16);
347
295
        return ret | (get_bits(s, n-16) << 16);
348
296
#else
353
301
}
354
302
 
355
303
/**
356
 
 * reads 0-32 bits as a signed integer.
 
304
 * Read 0-32 bits as a signed integer.
357
305
 */
358
 
static inline int get_sbits_long(GetBitContext *s, int n) {
 
306
static inline int get_sbits_long(GetBitContext *s, int n)
 
307
{
359
308
    return sign_extend(get_bits_long(s, n), n);
360
309
}
361
310
 
362
311
/**
363
 
 * shows 0-32 bits.
 
312
 * Show 0-32 bits.
364
313
 */
365
 
static inline unsigned int show_bits_long(GetBitContext *s, int n){
366
 
    if (n <= MIN_CACHE_BITS) return show_bits(s, n);
 
314
static inline unsigned int show_bits_long(GetBitContext *s, int n)
 
315
{
 
316
    if (n <= MIN_CACHE_BITS)
 
317
        return show_bits(s, n);
367
318
    else {
368
319
        GetBitContext gb = *s;
369
320
        return get_bits_long(&gb, n);
380
331
}
381
332
 
382
333
/**
383
 
 * init GetBitContext.
384
 
 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger then the actual read bits
 
334
 * Inititalize GetBitContext.
 
335
 * @param buffer bitstream buffer, must be FF_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits
385
336
 * because some optimized bitstream readers read 32 or 64 bit at once and could read over the end
386
337
 * @param bit_size the size of the buffer in bits
387
 
 *
388
 
 * While GetBitContext stores the buffer size, for performance reasons you are
389
 
 * responsible for checking for the buffer end yourself (take advantage of the padding)!
390
338
 */
391
 
static inline void init_get_bits(GetBitContext *s,
392
 
                   const uint8_t *buffer, int bit_size)
 
339
static inline void init_get_bits(GetBitContext *s, const uint8_t *buffer,
 
340
                                 int bit_size)
393
341
{
394
342
    int buffer_size = (bit_size+7)>>3;
395
343
    if (buffer_size < 0 || bit_size < 0) {
399
347
 
400
348
    s->buffer       = buffer;
401
349
    s->size_in_bits = bit_size;
 
350
#if !UNCHECKED_BITSTREAM_READER
 
351
    s->size_in_bits_plus8 = bit_size + 8;
 
352
#endif
402
353
    s->buffer_end   = buffer + buffer_size;
403
 
#ifdef ALT_BITSTREAM_READER
404
354
    s->index        = 0;
405
 
#elif defined A32_BITSTREAM_READER
406
 
    s->buffer_ptr   = (uint32_t*)((intptr_t)buffer & ~3);
407
 
    s->bit_count    = 32 +     8*((intptr_t)buffer &  3);
408
 
    skip_bits_long(s, 0);
409
 
#endif
410
355
}
411
356
 
412
357
static inline void align_get_bits(GetBitContext *s)
442
387
 
443
388
 
444
389
/**
445
 
 *
446
390
 * If the vlc code is invalid and max_depth=1, then no bits will be removed.
447
391
 * If the vlc code is invalid and max_depth>1, then the number of bits removed
448
392
 * is undefined.
449
393
 */
450
 
#define GET_VLC(code, name, gb, table, bits, max_depth) do {    \
 
394
#define GET_VLC(code, name, gb, table, bits, max_depth)         \
 
395
    do {                                                        \
451
396
        int n, nb_bits;                                         \
452
397
        unsigned int index;                                     \
453
398
                                                                \
478
423
        SKIP_BITS(name, gb, n);                                 \
479
424
    } while (0)
480
425
 
481
 
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) do { \
 
426
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update) \
 
427
    do {                                                                \
482
428
        int n, nb_bits;                                                 \
483
429
        unsigned int index;                                             \
484
430
                                                                        \
504
450
 
505
451
 
506
452
/**
507
 
 * parses a vlc code, faster then get_vlc()
 
453
 * Parse a vlc code.
508
454
 * @param bits is the number of bits which will be read at once, must be
509
455
 *             identical to nb_bits in init_vlc()
510
456
 * @param max_depth is the number of times bits bits must be read to completely
512
458
 *                  = (max_vlc_length + bits - 1) / bits
513
459
 */
514
460
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE (*table)[2],
515
 
                                  int bits, int max_depth)
 
461
                                     int bits, int max_depth)
516
462
{
517
463
    int code;
518
464
 
525
471
    return code;
526
472
}
527
473
 
528
 
static inline int decode012(GetBitContext *gb){
 
474
static inline int decode012(GetBitContext *gb)
 
475
{
529
476
    int n;
530
477
    n = get_bits1(gb);
531
478
    if (n == 0)
534
481
        return get_bits1(gb) + 1;
535
482
}
536
483
 
537
 
static inline int decode210(GetBitContext *gb){
 
484
static inline int decode210(GetBitContext *gb)
 
485
{
538
486
    if (get_bits1(gb))
539
487
        return 0;
540
488
    else
549
497
//#define TRACE
550
498
 
551
499
#ifdef TRACE
552
 
static inline void print_bin(int bits, int n){
 
500
static inline void print_bin(int bits, int n)
 
501
{
553
502
    int i;
554
503
 
555
504
    for (i = n-1; i >= 0; i--) {
560
509
}
561
510
 
562
511
static inline int get_bits_trace(GetBitContext *s, int n, char *file,
563
 
                                 const char *func, int line){
 
512
                                 const char *func, int line)
 
513
{
564
514
    int r = get_bits(s, n);
565
515
 
566
516
    print_bin(r, n);
570
520
}
571
521
static inline int get_vlc_trace(GetBitContext *s, VLC_TYPE (*table)[2],
572
522
                                int bits, int max_depth, char *file,
573
 
                                const char *func, int line){
 
523
                                const char *func, int line)
 
524
{
574
525
    int show  = show_bits(s, 24);
575
526
    int pos   = get_bits_count(s);
576
527
    int r     = get_vlc2(s, table, bits, max_depth);
584
535
    return r;
585
536
}
586
537
static inline int get_xbits_trace(GetBitContext *s, int n, char *file,
587
 
                                  const char *func, int line){
 
538
                                  const char *func, int line)
 
539
{
588
540
    int show = show_bits(s, n);
589
541
    int r    = get_xbits(s, n);
590
542