comparison common.c @ 1064:b32afefe7d33 libavcodec

* UINTX -> uintx_t INTX -> intx_t
author kabi
date Tue, 11 Feb 2003 16:35:48 +0000
parents bb5de8a59da8
children b923be2fc4b5
comparison
equal deleted inserted replaced
1063:fdeac9642346 1064:b32afefe7d33
18 * 18 *
19 * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at> 19 * alternative bitstream reader & writer by Michael Niedermayer <michaelni@gmx.at>
20 */ 20 */
21 #include "avcodec.h" 21 #include "avcodec.h"
22 22
23 const UINT8 ff_sqrt_tab[128]={ 23 const uint8_t ff_sqrt_tab[128]={
24 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 24 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5,
25 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 25 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
26 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 26 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
27 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11 27 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11
28 }; 28 };
37 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 37 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
38 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 38 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7
39 }; 39 };
40 40
41 void init_put_bits(PutBitContext *s, 41 void init_put_bits(PutBitContext *s,
42 UINT8 *buffer, int buffer_size, 42 uint8_t *buffer, int buffer_size,
43 void *opaque, 43 void *opaque,
44 void (*write_data)(void *, UINT8 *, int)) 44 void (*write_data)(void *, uint8_t *, int))
45 { 45 {
46 s->buf = buffer; 46 s->buf = buffer;
47 s->buf_end = s->buf + buffer_size; 47 s->buf_end = s->buf + buffer_size;
48 s->data_out_size = 0; 48 s->data_out_size = 0;
49 if(write_data!=NULL) 49 if(write_data!=NULL)
60 s->bit_buf=0; 60 s->bit_buf=0;
61 #endif 61 #endif
62 } 62 }
63 63
64 /* return the number of bits output */ 64 /* return the number of bits output */
65 INT64 get_bit_count(PutBitContext *s) 65 int64_t get_bit_count(PutBitContext *s)
66 { 66 {
67 #ifdef ALT_BITSTREAM_WRITER 67 #ifdef ALT_BITSTREAM_WRITER
68 return s->data_out_size * 8 + s->index; 68 return s->data_out_size * 8 + s->index;
69 #else 69 #else
70 return (s->buf_ptr - s->buf + s->data_out_size) * 8 + 32 - (INT64)s->bit_left; 70 return (s->buf_ptr - s->buf + s->data_out_size) * 8 + 32 - (int64_t)s->bit_left;
71 #endif 71 #endif
72 } 72 }
73 73
74 void align_put_bits(PutBitContext *s) 74 void align_put_bits(PutBitContext *s)
75 { 75 {
108 } 108 }
109 109
110 /* bit input functions */ 110 /* bit input functions */
111 111
112 void init_get_bits(GetBitContext *s, 112 void init_get_bits(GetBitContext *s,
113 UINT8 *buffer, int bit_size) 113 uint8_t *buffer, int bit_size)
114 { 114 {
115 const int buffer_size= (bit_size+7)>>3; 115 const int buffer_size= (bit_size+7)>>3;
116 116
117 s->buffer= buffer; 117 s->buffer= buffer;
118 s->size_in_bits= bit_size; 118 s->size_in_bits= bit_size;
158 158
159 //#define DEBUG_VLC 159 //#define DEBUG_VLC
160 160
161 #define GET_DATA(v, table, i, wrap, size) \ 161 #define GET_DATA(v, table, i, wrap, size) \
162 {\ 162 {\
163 const UINT8 *ptr = (const UINT8 *)table + i * wrap;\ 163 const uint8_t *ptr = (const uint8_t *)table + i * wrap;\
164 switch(size) {\ 164 switch(size) {\
165 case 1:\ 165 case 1:\
166 v = *(const UINT8 *)ptr;\ 166 v = *(const uint8_t *)ptr;\
167 break;\ 167 break;\
168 case 2:\ 168 case 2:\
169 v = *(const UINT16 *)ptr;\ 169 v = *(const uint16_t *)ptr;\
170 break;\ 170 break;\
171 default:\ 171 default:\
172 v = *(const UINT32 *)ptr;\ 172 v = *(const uint32_t *)ptr;\
173 break;\ 173 break;\
174 }\ 174 }\
175 } 175 }
176 176
177 177
192 192
193 static int build_table(VLC *vlc, int table_nb_bits, 193 static int build_table(VLC *vlc, int table_nb_bits,
194 int nb_codes, 194 int nb_codes,
195 const void *bits, int bits_wrap, int bits_size, 195 const void *bits, int bits_wrap, int bits_size,
196 const void *codes, int codes_wrap, int codes_size, 196 const void *codes, int codes_wrap, int codes_size,
197 UINT32 code_prefix, int n_prefix) 197 uint32_t code_prefix, int n_prefix)
198 { 198 {
199 int i, j, k, n, table_size, table_index, nb, n1, index; 199 int i, j, k, n, table_size, table_index, nb, n1, index;
200 UINT32 code; 200 uint32_t code;
201 VLC_TYPE (*table)[2]; 201 VLC_TYPE (*table)[2];
202 202
203 table_size = 1 << table_nb_bits; 203 table_size = 1 << table_nb_bits;
204 table_index = alloc_table(vlc, table_size); 204 table_index = alloc_table(vlc, table_size);
205 #ifdef DEBUG_VLC 205 #ifdef DEBUG_VLC