4 #define FFMPEG_VERSION_INT 0x000406
5 #define FFMPEG_VERSION "0.4.6"
7 #if defined(WIN32) && !defined(__MINGW32__)
11 //#define ALT_BITSTREAM_READER
13 #ifdef HAVE_AV_CONFIG_H
14 /* only include the following when compiling package */
15 #include "../config.h"
32 typedef unsigned short UINT16;
33 typedef signed short INT16;
34 typedef unsigned char UINT8;
35 typedef unsigned int UINT32;
36 typedef unsigned __int64 UINT64;
37 typedef signed char INT8;
38 typedef signed int INT32;
39 typedef signed __int64 INT64;
41 typedef UINT8 uint8_t;
43 typedef UINT16 uint16_t;
44 typedef INT16 int16_t;
45 typedef UINT32 uint32_t;
46 typedef INT32 int32_t;
49 #define INT64_C(c) (c ## i64)
50 #define UINT64_C(c) (c ## i64)
52 #define inline __inline
55 Disable warning messages:
56 warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
57 warning C4305: 'argument' : truncation from 'const double' to 'float'
59 #pragma warning( disable : 4244 )
60 #pragma warning( disable : 4305 )
63 #define INT64_C(c) (c ## LL)
64 #define UINT64_C(c) (c ## ULL)
65 #endif /* __MINGW32__ */
67 #define M_PI 3.14159265358979323846
68 #define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
74 // code from bits/byteswap.h (C) 1997, 1998 Free Software Foundation, Inc.
76 ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \
77 (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
78 #define be2me_32(x) bswap_32(x)
80 #define snprintf _snprintf
83 /* no config.h with VC */
84 #define CONFIG_ENCODERS 1
85 #define CONFIG_DECODERS 1
95 #ifndef __WINE_WINDEF16_H
96 /* workaround for typedef conflict in MPlayer (wine typedefs) */
97 typedef unsigned short UINT16;
98 typedef signed short INT16;
101 typedef unsigned char UINT8;
102 typedef unsigned int UINT32;
103 typedef unsigned long long UINT64;
104 typedef signed char INT8;
105 typedef signed int INT32;
106 typedef signed long long INT64;
108 #ifdef HAVE_AV_CONFIG_H
111 #include <sys/param.h>
115 #define INT64_C(c) (c ## LL)
116 #define UINT64_C(c) (c ## ULL)
119 #include "../bswap.h"
121 #ifdef USE_FASTMEMCPY
122 #include "fastmemcpy.h"
125 #endif /* HAVE_AV_CONFIG_H */
127 #endif /* !CONFIG_WIN32 */
131 #ifdef HAVE_AV_CONFIG_H
139 #if defined(CONFIG_WIN32) && !defined(__MINGW32__)
141 inline void dprintf(const char* fmt,...) {}
146 #define dprintf(fmt,args...) printf(fmt, ## args)
148 #define dprintf(fmt,args...)
151 #endif /* !CONFIG_WIN32 */
153 #endif /* HAVE_AV_CONFIG_H */
157 struct PutBitContext;
159 typedef void (*WriteDataFunc)(void *, UINT8 *, int);
161 typedef struct PutBitContext {
164 UINT8 *buf, *buf_ptr, *buf_end;
165 INT64 data_out_size; /* in bytes */
167 WriteDataFunc write_data;
170 void init_put_bits(PutBitContext *s,
171 UINT8 *buffer, int buffer_size,
173 void (*write_data)(void *, UINT8 *, int));
174 void put_bits(PutBitContext *s, int n, unsigned int value);
175 INT64 get_bit_count(PutBitContext *s); /* XXX: change function name */
176 void align_put_bits(PutBitContext *s);
177 void flush_put_bits(PutBitContext *s);
179 /* jpeg specific put_bits */
180 void jput_bits(PutBitContext *s, int n, unsigned int value);
181 void jflush_put_bits(PutBitContext *s);
185 typedef struct GetBitContext {
186 #ifdef ALT_BITSTREAM_READER
192 UINT8 *buf, *buf_ptr, *buf_end;
200 int table_size, table_allocated;
203 void init_get_bits(GetBitContext *s,
204 UINT8 *buffer, int buffer_size);
206 #ifndef ALT_BITSTREAM_READER
207 unsigned int get_bits_long(GetBitContext *s, int n);
208 unsigned int show_bits_long(GetBitContext *s, int n);
211 static inline unsigned int get_bits(GetBitContext *s, int n){
212 #ifdef ALT_BITSTREAM_READER
214 uint32_t result= be2me_32( *(uint32_t *)(((uint8_t *)s->buffer)+(index>>3)) );
216 result<<= (index&0x07);
224 /* most common case here */
225 unsigned int val = s->bit_buf >> (32 - n);
229 st_bit_counts[st_current_index] += n;
233 return get_bits_long(s,n);
237 static inline unsigned int get_bits1(GetBitContext *s){
238 #ifdef ALT_BITSTREAM_READER
240 uint32_t result= be2me_32( *(uint32_t *)(((uint8_t *)s->buffer)+(index>>3)) );
242 result<<= (index&0x07);
250 /* most common case here */
251 unsigned int val = s->bit_buf >> 31;
255 st_bit_counts[st_current_index]++;
259 return get_bits_long(s,1);
263 /* This function is identical to get_bits(), the only */
264 /* diference is that it doesn't touch the buffer */
265 /* it is usefull to see the buffer. */
266 static inline unsigned int show_bits(GetBitContext *s, int n)
268 #ifdef ALT_BITSTREAM_READER
270 uint32_t result= be2me_32( *(uint32_t *)(((uint8_t *)s->buffer)+(index>>3)) );
272 result<<= (index&0x07);
278 /* most common case here */
279 unsigned int val = s->bit_buf >> (32 - n);
282 return show_bits_long(s,n);
286 static inline void skip_bits(GetBitContext *s, int n){
287 #ifdef ALT_BITSTREAM_READER
291 /* most common case here */
295 st_bit_counts[st_current_index] += n;
303 static inline void skip_bits1(GetBitContext *s){
304 #ifdef ALT_BITSTREAM_READER
308 /* most common case here */
312 st_bit_counts[st_current_index]++;
320 static inline int get_bits_count(GetBitContext *s)
322 #ifdef ALT_BITSTREAM_READER
325 return (s->buf_ptr - s->buf) * 8 - s->bit_cnt;
329 void align_get_bits(GetBitContext *s);
330 int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
331 const void *bits, int bits_wrap, int bits_size,
332 const void *codes, int codes_wrap, int codes_size);
333 void free_vlc(VLC *vlc);
334 int get_vlc(GetBitContext *s, VLC *vlc);
336 #ifdef ALT_BITSTREAM_READER
337 #define SHOW_BITS(s, val, n) val= show_bits(s, n);
338 #define FLUSH_BITS(n) skip_bits(s, n);
339 #define SAVE_BITS(s) ;
340 #define RESTORE_BITS(s) ;
343 /* macro to go faster */
344 /* n must be <= 24 */
345 /* XXX: optimize buffer end test */
346 #define SHOW_BITS(s, val, n)\
348 if (bit_cnt < n && buf_ptr < (s)->buf_end) {\
349 bit_buf |= *buf_ptr++ << (24 - bit_cnt);\
351 if (bit_cnt < n && buf_ptr < (s)->buf_end) {\
352 bit_buf |= *buf_ptr++ << (24 - bit_cnt);\
354 if (bit_cnt < n && buf_ptr < (s)->buf_end) {\
355 bit_buf |= *buf_ptr++ << (24 - bit_cnt);\
360 val = bit_buf >> (32 - n);\
363 /* SHOW_BITS with n1 >= n must be been done before */
364 #define FLUSH_BITS(n)\
370 #define SAVE_BITS(s) \
372 bit_cnt = (s)->bit_cnt;\
373 bit_buf = (s)->bit_buf;\
374 buf_ptr = (s)->buf_ptr;\
377 #define RESTORE_BITS(s) \
379 (s)->buf_ptr = buf_ptr;\
380 (s)->bit_buf = bit_buf;\
381 (s)->bit_cnt = bit_cnt;\
383 #endif // !ALT_BITSTREAM_READER
384 /* define it to include statistics code (useful only for optimizing
401 extern int st_current_index;
402 extern unsigned int st_bit_counts[ST_NB];
403 extern unsigned int st_out_bit_counts[ST_NB];
405 void print_stats(void);
408 /* misc math functions */
410 static inline int av_log2(unsigned int v)
415 if (v & 0xffff0000) {
438 void *av_mallocz(int size);