Mercurial > libavcodec.hg
comparison common.h @ 235:41f0ef2cd942 libavcodec
aligned bitstream writer (1% slower on p3 but perhaps its faster on p4?)
| author | michaelni |
|---|---|
| date | Tue, 12 Feb 2002 22:43:26 +0000 |
| parents | 5fc0c3af3fe4 |
| children | 99a9f903f0e3 |
comparison
equal
deleted
inserted
replaced
| 234:5fc0c3af3fe4 | 235:41f0ef2cd942 |
|---|---|
| 7 #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) | 7 #if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) |
| 8 #define CONFIG_WIN32 | 8 #define CONFIG_WIN32 |
| 9 #endif | 9 #endif |
| 10 | 10 |
| 11 //#define ALT_BITSTREAM_WRITER | 11 //#define ALT_BITSTREAM_WRITER |
| 12 //#define ALIGNED_BITSTREAM_WRITER | |
| 12 //#define ALT_BITSTREAM_READER | 13 //#define ALT_BITSTREAM_READER |
| 13 //#define ALIGNED_BITSTREAM | 14 //#define ALIGNED_BITSTREAM |
| 14 #define FAST_GET_FIRST_VLC | 15 #define FAST_GET_FIRST_VLC |
| 15 | 16 |
| 16 #ifdef HAVE_AV_CONFIG_H | 17 #ifdef HAVE_AV_CONFIG_H |
| 236 } | 237 } |
| 237 #endif | 238 #endif |
| 238 #endif //!ARCH_X86 | 239 #endif //!ARCH_X86 |
| 239 | 240 |
| 240 #ifdef ALT_BITSTREAM_WRITER | 241 #ifdef ALT_BITSTREAM_WRITER |
| 241 static inline void put_bits(PutBitContext *s, int n, int value) | 242 static inline void put_bits(PutBitContext *s, int n, unsigned int value) |
| 242 { | 243 { |
| 244 #ifdef ALIGNED_BITSTREAM_WRITER | |
| 245 #ifdef ARCH_X86 | |
| 246 asm volatile( | |
| 247 "movl %0, %%ecx \n\t" | |
| 248 "xorl %%eax, %%eax \n\t" | |
| 249 "shrdl %%cl, %1, %%eax \n\t" | |
| 250 "shrl %%cl, %1 \n\t" | |
| 251 "movl %0, %%ecx \n\t" | |
| 252 "shrl $3, %%ecx \n\t" | |
| 253 "andl $0xFFFFFFFC, %%ecx \n\t" | |
| 254 "bswapl %1 \n\t" | |
| 255 "orl %1, (%2, %%ecx) \n\t" | |
| 256 "bswapl %%eax \n\t" | |
| 257 "addl %3, %0 \n\t" | |
| 258 "movl %%eax, 4(%2, %%ecx) \n\t" | |
| 259 : "=&r" (s->index), "=&r" (value) | |
| 260 : "r" (s->buf), "r" (n), "0" (s->index), "1" (value<<(-n)) | |
| 261 : "%eax", "%ecx" | |
| 262 ); | |
| 263 #else | |
| 264 int index= s->index; | |
| 265 uint32_t *ptr= ((uint32_t *)s->buf)+(index>>5); | |
| 266 | |
| 267 value<<= 32-n; | |
| 268 | |
| 269 ptr[0] |= be2me_32(value>>(index&31)); | |
| 270 ptr[1] = be2me_32(value<<(32-(index&31))); | |
| 271 //if(n>24) printf("%d %d\n", n, value); | |
| 272 index+= n; | |
| 273 s->index= index; | |
| 274 #endif | |
| 275 #else //ALIGNED_BITSTREAM_WRITER | |
| 243 #ifdef ARCH_X86 | 276 #ifdef ARCH_X86 |
| 244 asm volatile( | 277 asm volatile( |
| 245 "movl $7, %%ecx \n\t" | 278 "movl $7, %%ecx \n\t" |
| 246 "andl %0, %%ecx \n\t" | 279 "andl %0, %%ecx \n\t" |
| 247 "addl %3, %%ecx \n\t" | 280 "addl %3, %%ecx \n\t" |
| 265 ptr[1] = 0; | 298 ptr[1] = 0; |
| 266 //if(n>24) printf("%d %d\n", n, value); | 299 //if(n>24) printf("%d %d\n", n, value); |
| 267 index+= n; | 300 index+= n; |
| 268 s->index= index; | 301 s->index= index; |
| 269 #endif | 302 #endif |
| 303 #endif //!ALIGNED_BITSTREAM_WRITER | |
| 270 } | 304 } |
| 271 #endif | 305 #endif |
| 272 | 306 |
| 273 #ifdef ALT_BITSTREAM_WRITER | 307 #ifdef ALT_BITSTREAM_WRITER |
| 274 static inline void jput_bits(PutBitContext *s, int n, int value) | 308 static inline void jput_bits(PutBitContext *s, int n, int value) |
