diff options
author | Jason Garrett-Glaser | 2010-06-30 23:59:27 +0000 |
---|---|---|
committer | Jason Garrett-Glaser | 2010-06-30 23:59:27 +0000 |
commit | 4148855ee4f3506cc1f7341f688e5fa260a017d4 (patch) | |
tree | 287a9818256f89a07e3bd5633b5ba632c57cda0a /libavcodec | |
parent | 2e79db01414b43e4dee26ad7834ba2f74fc6320a (diff) |
Eliminate another redundant instruction in vp56/8 arithcoder
Necessary because of this GCC bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44474
To do this, convert some, but not all (!) of the variables in VP56RangeCoder
into local variables.
If we convert c->high into a local variable, gcc gets the stupids and refuses
to use a conditional move for the unpredictable main branch.
TODO: dispense with this bullshit and write an asm version.
Originally committed as revision 23924 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/vp56.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/libavcodec/vp56.h b/libavcodec/vp56.h index 6a2e29f898..74a14ef42e 100644 --- a/libavcodec/vp56.h +++ b/libavcodec/vp56.h @@ -194,23 +194,32 @@ static inline void vp56_init_range_decoder(VP56RangeCoder *c, static inline int vp56_rac_get_prob(VP56RangeCoder *c, uint8_t prob) { + /* Don't put c->high in a local variable; if we do that, gcc gets + * the stupids and turns the code below into a branch again. */ + int bits = c->bits; + unsigned long code_word = c->code_word; unsigned int low = 1 + (((c->high - 1) * prob) >> 8); unsigned int low_shift = low << 8; - int bit = c->code_word >= low_shift; + int bit = code_word >= low_shift; int shift; + /* Incantation to convince GCC to turn these into conditional moves + * instead of branches -- faster, as this branch is basically + * unpredictable. */ c->high = bit ? c->high - low : low; - c->code_word = bit ? c->code_word - low_shift : c->code_word; + code_word = bit ? code_word - low_shift : code_word; /* normalize */ shift = ff_h264_norm_shift[c->high] - 1; - c->high <<= shift; - c->code_word <<= shift; - c->bits += shift; - if(c->bits >= 0 && c->buffer < c->end) { - c->code_word |= *c->buffer++ << c->bits; - c->bits -= 8; + c->high <<= shift; + code_word <<= shift; + bits += shift; + if(bits >= 0 && c->buffer < c->end) { + code_word |= *c->buffer++ << bits; + bits -= 8; } + c->bits = bits; + c->code_word = code_word; return bit; } |