Revision 05f361f0 libavcodec/common.h

View differences:

libavcodec/common.h
10 10

  
11 11
//#define ALT_BITSTREAM_READER
12 12
//#define ALIGNED_BITSTREAM
13
#define FAST_GET_FIRST_VLC
13 14

  
14 15
#ifdef HAVE_AV_CONFIG_H
15 16
/* only include the following when compiling package */
......
244 245
	 : "0" (result1), "r" (result2), "c" (index));
245 246
#else
246 247
    result1<<= (index&0x1F);
247
    result2>>= 32-(index&0x1F);
248
    if((index&0x1F)!=0) result1|= result2;
248
    result2= (result2>>1) >> (31-(index&0x1F));
249
    result1|= result2;
249 250
#endif
250 251
    result1>>= 32 - n;
251 252
    index+= n;
......
282 283
#ifdef ALT_BITSTREAM_READER
283 284
    int index= s->index;
284 285
    uint8_t result= s->buffer[ index>>3 ];
285
    result>>= 7-(index&0x07);
286
    result&=1;
286
    result<<= (index&0x07);
287
    result>>= 8 - 1;
287 288
    index++;
288 289
    s->index= index;
289 290
    
......
319 320
	 : "0" (result1), "r" (result2), "c" (index));
320 321
#else
321 322
    result1<<= (index&0x1F);
322
    result2>>= 32-(index&0x1F);
323
    if((index&0x1F)!=0) result1|= result2;
323
    result2= (result2>>1) >> (31-(index&0x1F));
324
    result1|= result2;
324 325
#endif
325 326
    result1>>= 32 - n;
326 327
    
......
394 395
void free_vlc(VLC *vlc);
395 396

  
396 397
#ifdef ALT_BITSTREAM_READER
397
#define SHOW_BITS(s, val, n) val= show_bits(s, n);
398
#define FLUSH_BITS(n) skip_bits(s, n); 
399
#define SAVE_BITS(s) ;
400
#define RESTORE_BITS(s) ;
398
#ifdef ALIGNED_BITSTREAM
399
#ifdef ARCH_X86
400
#define SHOW_BITS(s, val, n) \
401
    val= be2me_32( ((uint32_t *)(s)->buffer)[bit_cnt>>5] );\
402
    {uint32_t result2= be2me_32( ((uint32_t *)(s)->buffer)[(bit_cnt>>5) + 1] );\
403
    asm ("shldl %%cl, %2, %0\n\t"\
404
         : "=r" (val)\
405
         : "0" (val), "r" (result2), "c" (bit_cnt));\
406
    ((uint32_t)val)>>= 32 - n;}
407
#else //ARCH_X86
408
#define SHOW_BITS(s, val, n) \
409
    val= be2me_32( ((uint32_t *)(s)->buffer)[bit_cnt>>5] );\
410
    {uint32_t result2= be2me_32( ((uint32_t *)(s)->buffer)[(bit_cnt>>5) + 1] );\
411
    val<<= (bit_cnt&0x1F);\
412
    result2= (result2>>1) >> (31-(bit_cnt&0x1F));\
413
    val|= result2;\
414
    ((uint32_t)val)>>= 32 - n;}
415
#endif //!ARCH_X86
416
#else //ALIGNED_BITSTREAM
417
#define SHOW_BITS(s, val, n) \
418
    val= be2me_32( unaligned32( ((uint8_t *)(s)->buffer)+(bit_cnt>>3) ) );\
419
    val<<= (bit_cnt&0x07);\
420
    ((uint32_t)val)>>= 32 - n;
421
#endif // !ALIGNED_BITSTREAM
422
#define FLUSH_BITS(n) bit_cnt+=n; 
423
#define SAVE_BITS(s) bit_cnt= (s)->index;
424
#define RESTORE_BITS(s) (s)->index= bit_cnt;
401 425
#else
402 426

  
403 427
/* macro to go faster */
......
447 471
    int code, n, nb_bits, index;
448 472
    INT16 *table_codes;
449 473
    INT8 *table_bits;
450
#ifndef ALT_BITSTREAM_READER
451 474
    int bit_cnt;
475
#ifndef ALT_BITSTREAM_READER
452 476
    UINT32 bit_buf;
453 477
    UINT8 *buf_ptr;
454 478
#endif
......
457 481
    nb_bits = vlc->bits;
458 482
    table_codes = vlc->table_codes;
459 483
    table_bits = vlc->table_bits;
460
    
484

  
485
#ifdef FAST_GET_FIRST_VLC
461 486
    SHOW_BITS(s, index, nb_bits);
462 487
    code = table_codes[index];
463 488
    n = table_bits[index];
......
474 499
        table_codes = vlc->table_codes + code;
475 500
        table_bits = vlc->table_bits + code;
476 501
    }
502
#endif
477 503
    for(;;) {
478 504
        SHOW_BITS(s, index, nb_bits);
479 505
        code = table_codes[index];

Also available in: Unified diff