mirror of https://git.ffmpeg.org/ffmpeg.git
(commited by michael / arpi was crazy enough to give me his password)
fixed a bug in get_vlc() when using the ALT_BITSTREAM_READER (rv10 & mpeg12 decoders where not working) some optimizations replaced a if() with a >> changed get_bits1() a bit so it hopefully is faster on p4 Originally committed as revision 259 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
eede215681
commit
05f361f0c7
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
//#define ALT_BITSTREAM_READER
|
//#define ALT_BITSTREAM_READER
|
||||||
//#define ALIGNED_BITSTREAM
|
//#define ALIGNED_BITSTREAM
|
||||||
|
#define FAST_GET_FIRST_VLC
|
||||||
|
|
||||||
#ifdef HAVE_AV_CONFIG_H
|
#ifdef HAVE_AV_CONFIG_H
|
||||||
/* only include the following when compiling package */
|
/* only include the following when compiling package */
|
||||||
|
@ -244,8 +245,8 @@ static inline unsigned int get_bits(GetBitContext *s, int n){
|
||||||
: "0" (result1), "r" (result2), "c" (index));
|
: "0" (result1), "r" (result2), "c" (index));
|
||||||
#else
|
#else
|
||||||
result1<<= (index&0x1F);
|
result1<<= (index&0x1F);
|
||||||
result2>>= 32-(index&0x1F);
|
result2= (result2>>1) >> (31-(index&0x1F));
|
||||||
if((index&0x1F)!=0) result1|= result2;
|
result1|= result2;
|
||||||
#endif
|
#endif
|
||||||
result1>>= 32 - n;
|
result1>>= 32 - n;
|
||||||
index+= n;
|
index+= n;
|
||||||
|
@ -282,8 +283,8 @@ static inline unsigned int get_bits1(GetBitContext *s){
|
||||||
#ifdef ALT_BITSTREAM_READER
|
#ifdef ALT_BITSTREAM_READER
|
||||||
int index= s->index;
|
int index= s->index;
|
||||||
uint8_t result= s->buffer[ index>>3 ];
|
uint8_t result= s->buffer[ index>>3 ];
|
||||||
result>>= 7-(index&0x07);
|
result<<= (index&0x07);
|
||||||
result&=1;
|
result>>= 8 - 1;
|
||||||
index++;
|
index++;
|
||||||
s->index= index;
|
s->index= index;
|
||||||
|
|
||||||
|
@ -319,8 +320,8 @@ static inline unsigned int show_bits(GetBitContext *s, int n)
|
||||||
: "0" (result1), "r" (result2), "c" (index));
|
: "0" (result1), "r" (result2), "c" (index));
|
||||||
#else
|
#else
|
||||||
result1<<= (index&0x1F);
|
result1<<= (index&0x1F);
|
||||||
result2>>= 32-(index&0x1F);
|
result2= (result2>>1) >> (31-(index&0x1F));
|
||||||
if((index&0x1F)!=0) result1|= result2;
|
result1|= result2;
|
||||||
#endif
|
#endif
|
||||||
result1>>= 32 - n;
|
result1>>= 32 - n;
|
||||||
|
|
||||||
|
@ -394,10 +395,33 @@ int init_vlc(VLC *vlc, int nb_bits, int nb_codes,
|
||||||
void free_vlc(VLC *vlc);
|
void free_vlc(VLC *vlc);
|
||||||
|
|
||||||
#ifdef ALT_BITSTREAM_READER
|
#ifdef ALT_BITSTREAM_READER
|
||||||
#define SHOW_BITS(s, val, n) val= show_bits(s, n);
|
#ifdef ALIGNED_BITSTREAM
|
||||||
#define FLUSH_BITS(n) skip_bits(s, n);
|
#ifdef ARCH_X86
|
||||||
#define SAVE_BITS(s) ;
|
#define SHOW_BITS(s, val, n) \
|
||||||
#define RESTORE_BITS(s) ;
|
val= be2me_32( ((uint32_t *)(s)->buffer)[bit_cnt>>5] );\
|
||||||
|
{uint32_t result2= be2me_32( ((uint32_t *)(s)->buffer)[(bit_cnt>>5) + 1] );\
|
||||||
|
asm ("shldl %%cl, %2, %0\n\t"\
|
||||||
|
: "=r" (val)\
|
||||||
|
: "0" (val), "r" (result2), "c" (bit_cnt));\
|
||||||
|
((uint32_t)val)>>= 32 - n;}
|
||||||
|
#else //ARCH_X86
|
||||||
|
#define SHOW_BITS(s, val, n) \
|
||||||
|
val= be2me_32( ((uint32_t *)(s)->buffer)[bit_cnt>>5] );\
|
||||||
|
{uint32_t result2= be2me_32( ((uint32_t *)(s)->buffer)[(bit_cnt>>5) + 1] );\
|
||||||
|
val<<= (bit_cnt&0x1F);\
|
||||||
|
result2= (result2>>1) >> (31-(bit_cnt&0x1F));\
|
||||||
|
val|= result2;\
|
||||||
|
((uint32_t)val)>>= 32 - n;}
|
||||||
|
#endif //!ARCH_X86
|
||||||
|
#else //ALIGNED_BITSTREAM
|
||||||
|
#define SHOW_BITS(s, val, n) \
|
||||||
|
val= be2me_32( unaligned32( ((uint8_t *)(s)->buffer)+(bit_cnt>>3) ) );\
|
||||||
|
val<<= (bit_cnt&0x07);\
|
||||||
|
((uint32_t)val)>>= 32 - n;
|
||||||
|
#endif // !ALIGNED_BITSTREAM
|
||||||
|
#define FLUSH_BITS(n) bit_cnt+=n;
|
||||||
|
#define SAVE_BITS(s) bit_cnt= (s)->index;
|
||||||
|
#define RESTORE_BITS(s) (s)->index= bit_cnt;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* macro to go faster */
|
/* macro to go faster */
|
||||||
|
@ -447,8 +471,8 @@ static inline int get_vlc(GetBitContext *s, VLC *vlc)
|
||||||
int code, n, nb_bits, index;
|
int code, n, nb_bits, index;
|
||||||
INT16 *table_codes;
|
INT16 *table_codes;
|
||||||
INT8 *table_bits;
|
INT8 *table_bits;
|
||||||
#ifndef ALT_BITSTREAM_READER
|
|
||||||
int bit_cnt;
|
int bit_cnt;
|
||||||
|
#ifndef ALT_BITSTREAM_READER
|
||||||
UINT32 bit_buf;
|
UINT32 bit_buf;
|
||||||
UINT8 *buf_ptr;
|
UINT8 *buf_ptr;
|
||||||
#endif
|
#endif
|
||||||
|
@ -457,7 +481,8 @@ static inline int get_vlc(GetBitContext *s, VLC *vlc)
|
||||||
nb_bits = vlc->bits;
|
nb_bits = vlc->bits;
|
||||||
table_codes = vlc->table_codes;
|
table_codes = vlc->table_codes;
|
||||||
table_bits = vlc->table_bits;
|
table_bits = vlc->table_bits;
|
||||||
|
|
||||||
|
#ifdef FAST_GET_FIRST_VLC
|
||||||
SHOW_BITS(s, index, nb_bits);
|
SHOW_BITS(s, index, nb_bits);
|
||||||
code = table_codes[index];
|
code = table_codes[index];
|
||||||
n = table_bits[index];
|
n = table_bits[index];
|
||||||
|
@ -474,6 +499,7 @@ static inline int get_vlc(GetBitContext *s, VLC *vlc)
|
||||||
table_codes = vlc->table_codes + code;
|
table_codes = vlc->table_codes + code;
|
||||||
table_bits = vlc->table_bits + code;
|
table_bits = vlc->table_bits + code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
for(;;) {
|
for(;;) {
|
||||||
SHOW_BITS(s, index, nb_bits);
|
SHOW_BITS(s, index, nb_bits);
|
||||||
code = table_codes[index];
|
code = table_codes[index];
|
||||||
|
|
Loading…
Reference in New Issue