4 #ifdef HAVE_AV_CONFIG_H
8 #ifndef __WINE_WINDEF16_H
9 /* workaround for typedef conflict in MPlayer (wine typedefs) */
10 typedef unsigned short UINT16;
11 typedef signed short INT16;
14 typedef unsigned char UINT8;
15 typedef unsigned int UINT32;
16 typedef unsigned long long UINT64;
17 typedef signed char INT8;
18 typedef signed int INT32;
19 typedef signed long long INT64;
25 typedef void (*WriteDataFunc)(void *, UINT8 *, int);
27 typedef struct PutBitContext {
30 UINT8 *buf, *buf_ptr, *buf_end;
31 long long data_out_size; /* in bytes */
33 WriteDataFunc write_data;
36 void init_put_bits(PutBitContext *s,
37 UINT8 *buffer, int buffer_size,
39 void (*write_data)(void *, UINT8 *, int));
40 void put_bits(PutBitContext *s, int n, unsigned int value);
41 long long get_bit_count(PutBitContext *s);
42 void align_put_bits(PutBitContext *s);
43 void flush_put_bits(PutBitContext *s);
45 /* jpeg specific put_bits */
46 void jput_bits(PutBitContext *s, int n, unsigned int value);
47 void jflush_put_bits(PutBitContext *s);
51 typedef struct GetBitContext {
54 UINT8 *buf, *buf_ptr, *buf_end;
61 int table_size, table_allocated;
64 void init_get_bits(GetBitContext *s,
65 UINT8 *buffer, int buffer_size);
67 unsigned int get_bits_long(GetBitContext *s, int n);
69 static inline unsigned int get_bits(GetBitContext *s, int n){
71 /* most common case here */
72 unsigned int val = s->bit_buf >> (32 - n);
76 st_bit_counts[st_current_index] += n;
80 return get_bits_long(s,n);
83 void align_get_bits(GetBitContext *s);
84 int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
85 const void *bits, int bits_wrap, int bits_size,
86 const void *codes, int codes_wrap, int codes_size);
87 void free_vlc(VLC *vlc);
88 int get_vlc(GetBitContext *s, VLC *vlc);
90 /* macro to go faster */
92 /* XXX: optimize buffer end test */
93 #define SHOW_BITS(s, val, n)\
95 if (bit_cnt < n && buf_ptr < (s)->buf_end) {\
96 bit_buf |= *buf_ptr++ << (24 - bit_cnt);\
98 if (bit_cnt < n && buf_ptr < (s)->buf_end) {\
99 bit_buf |= *buf_ptr++ << (24 - bit_cnt);\
101 if (bit_cnt < n && buf_ptr < (s)->buf_end) {\
102 bit_buf |= *buf_ptr++ << (24 - bit_cnt);\
107 val = bit_buf >> (32 - n);\
110 /* SHOW_BITS with n1 >= n must be been done before */
111 #define FLUSH_BITS(n)\
117 #define SAVE_BITS(s) \
119 bit_cnt = (s)->bit_cnt;\
120 bit_buf = (s)->bit_buf;\
121 buf_ptr = (s)->buf_ptr;\
124 #define RESTORE_BITS(s) \
126 (s)->buf_ptr = buf_ptr;\
127 (s)->bit_buf = bit_buf;\
128 (s)->bit_cnt = bit_cnt;\
131 /* define it to include statistics code (useful only for optimizing
148 extern int st_current_index;
149 extern unsigned int st_bit_counts[ST_NB];
150 extern unsigned int st_out_bit_counts[ST_NB];
152 void print_stats(void);
155 /* misc math functions */
157 extern inline int log2(unsigned int v)
162 if (v & 0xffff0000) {
185 void *av_mallocz(int size);