Commit 5659b509 authored by Michael Niedermayer's avatar Michael Niedermayer

refill cabac variables in 16bit steps, 3% faster get_cabac()

Originally committed as revision 6578 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent d026b45e
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
//#undef NDEBUG //#undef NDEBUG
#include <assert.h> #include <assert.h>
#define CABAC_BITS 8 #define CABAC_BITS 16
#define CABAC_MASK ((1<<CABAC_BITS)-1) #define CABAC_MASK ((1<<CABAC_BITS)-1)
typedef struct CABACContext{ typedef struct CABACContext{
...@@ -302,7 +302,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ ...@@ -302,7 +302,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
#if 0 #if 0
//P3:683 //P3:683
asm( asm(
"lea -0x20000(%0), %2 \n\t" "lea -0x2000000(%0), %2 \n\t"
"shr $31, %2 \n\t" //FIXME 31->63 for x86-64 "shr $31, %2 \n\t" //FIXME 31->63 for x86-64
"shl %%cl, %0 \n\t" "shl %%cl, %0 \n\t"
"shl %%cl, %1 \n\t" "shl %%cl, %1 \n\t"
...@@ -311,7 +311,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ ...@@ -311,7 +311,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
#elif 0 #elif 0
//P3:680 //P3:680
asm( asm(
"cmp $0x20000, %0 \n\t" "cmp $0x2000000, %0 \n\t"
"setb %%cl \n\t" //FIXME 31->63 for x86-64 "setb %%cl \n\t" //FIXME 31->63 for x86-64
"shl %%cl, %0 \n\t" "shl %%cl, %0 \n\t"
"shl %%cl, %1 \n\t" "shl %%cl, %1 \n\t"
...@@ -321,7 +321,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ ...@@ -321,7 +321,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
int temp2; int temp2;
//P3:665 //P3:665
asm( asm(
"lea -0x20000(%0), %%eax \n\t" "lea -0x2000000(%0), %%eax \n\t"
"cdq \n\t" "cdq \n\t"
"mov %0, %%eax \n\t" "mov %0, %%eax \n\t"
"and %%edx, %0 \n\t" "and %%edx, %0 \n\t"
...@@ -334,7 +334,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ ...@@ -334,7 +334,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
int temp2; int temp2;
//P3:673 //P3:673
asm( asm(
"cmp $0x20000, %0 \n\t" "cmp $0x2000000, %0 \n\t"
"sbb %%edx, %%edx \n\t" "sbb %%edx, %%edx \n\t"
"mov %0, %%eax \n\t" "mov %0, %%eax \n\t"
"and %%edx, %0 \n\t" "and %%edx, %0 \n\t"
...@@ -347,7 +347,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){ ...@@ -347,7 +347,7 @@ static inline void renorm_cabac_decoder_once(CABACContext *c){
int temp2; int temp2;
//P3:677 //P3:677
asm( asm(
"cmp $0x20000, %0 \n\t" "cmp $0x2000000, %0 \n\t"
"lea (%0, %0), %%eax \n\t" "lea (%0, %0), %%eax \n\t"
"lea (%1, %1), %%edx \n\t" "lea (%1, %1), %%edx \n\t"
"cmovb %%eax, %0 \n\t" "cmovb %%eax, %0 \n\t"
......
...@@ -7420,7 +7420,7 @@ static int decode_slice(H264Context *h){ ...@@ -7420,7 +7420,7 @@ static int decode_slice(H264Context *h){
} }
eos = get_cabac_terminate( &h->cabac ); eos = get_cabac_terminate( &h->cabac );
if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 1) { if( ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%d)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream); av_log(h->s.avctx, AV_LOG_ERROR, "error while decoding MB %d %d, bytestream (%d)\n", s->mb_x, s->mb_y, h->cabac.bytestream_end - h->cabac.bytestream);
ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask); ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, (AC_ERROR|DC_ERROR|MV_ERROR)&part_mask);
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment