[FFmpeg-cvslog] r23920 - trunk/libavcodec/vp56.h
darkshikari
subversion
Thu Jul 1 01:15:25 CEST 2010
Author: darkshikari
Date: Thu Jul 1 01:15:25 2010
New Revision: 23920
Log:
Optimize vp56 arithmetic decoder
Negate "bits" to eliminate a negate in cache refilling.
Modified:
trunk/libavcodec/vp56.h
Modified: trunk/libavcodec/vp56.h
==============================================================================
--- trunk/libavcodec/vp56.h Thu Jul 1 01:01:44 2010 (r23919)
+++ trunk/libavcodec/vp56.h Thu Jul 1 01:15:25 2010 (r23920)
@@ -48,7 +48,8 @@ typedef int (*VP56ParseHeader)(VP56Cont
typedef struct {
int high;
- int bits;
+ int bits; /* Stored negated (i.e. negative "bits" is a positive number of bits left)
+ * in order to eliminate a negate in cache refilling */
const uint8_t *buffer;
const uint8_t *end;
unsigned long code_word;
@@ -185,7 +186,7 @@ static inline void vp56_init_range_decod
const uint8_t *buf, int buf_size)
{
c->high = 255;
- c->bits = 8;
+ c->bits = -8;
c->buffer = buf;
c->end = buf + buf_size;
c->code_word = bytestream_get_be16(&c->buffer);
@@ -209,10 +210,10 @@ static inline int vp56_rac_get_prob(VP56
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->bits += shift;
+ if(c->bits >= 0 && c->buffer < c->end) {
+ c->code_word |= *c->buffer++ << c->bits;
+ c->bits -= 8;
}
return bit;
}
@@ -232,8 +233,8 @@ static inline int vp56_rac_get(VP56Range
/* normalize */
c->code_word <<= 1;
- if (--c->bits == 0 && c->buffer < c->end) {
- c->bits = 8;
+ if (++c->bits == 0 && c->buffer < c->end) {
+ c->bits = -8;
c->code_word |= *c->buffer++;
}
return bit;
More information about the ffmpeg-cvslog
mailing list