[FFmpeg-cvslog] r24783 - in trunk/libavcodec: vp56.h vp56rac.c x86/vp56_arith.h

darkshikari subversion
Thu Aug 12 03:11:32 CEST 2010


Author: darkshikari
Date: Thu Aug 12 03:11:32 2010
New Revision: 24783

Log:
VP5/6/8: ~7% faster arithmetic decoding
Grab from the bitstream in 16-bit chunks instead of 32-bit chunks.
TODO: grab in 32-bit chunks on 64-bit systems.

Modified:
   trunk/libavcodec/vp56.h
   trunk/libavcodec/vp56rac.c
   trunk/libavcodec/x86/vp56_arith.h

Modified: trunk/libavcodec/vp56.h
==============================================================================
--- trunk/libavcodec/vp56.h	Thu Aug 12 02:35:19 2010	(r24782)
+++ trunk/libavcodec/vp56.h	Thu Aug 12 03:11:32 2010	(r24783)
@@ -194,8 +194,8 @@ static av_always_inline unsigned int vp5
     code_word <<= shift;
     bits       += shift;
     if(bits >= 0 && c->buffer < c->end) {
-        code_word |= *c->buffer++ << bits;
-        bits -= 8;
+        code_word |= bytestream_get_be16(&c->buffer) << bits;
+        bits -= 16;
     }
     c->bits = bits;
     return code_word;
@@ -211,7 +211,7 @@ static av_always_inline int vp56_rac_get
 {
     unsigned int code_word = vp56_rac_renorm(c);
     unsigned int low = 1 + (((c->high - 1) * prob) >> 8);
-    unsigned int low_shift = low << 8;
+    unsigned int low_shift = low << 16;
     int bit = code_word >= low_shift;
 
     c->high = bit ? c->high - low : low;
@@ -226,7 +226,7 @@ static av_always_inline int vp56_rac_get
 {
     unsigned long code_word = vp56_rac_renorm(c);
     unsigned low = 1 + (((c->high - 1) * prob) >> 8);
-    unsigned low_shift = low << 8;
+    unsigned low_shift = low << 16;
 
     if (code_word >= low_shift) {
         c->high     -= low;
@@ -244,7 +244,7 @@ static av_always_inline int vp56_rac_get
     unsigned int code_word = vp56_rac_renorm(c);
     /* equiprobable */
     int low = (c->high + 1) >> 1;
-    unsigned int low_shift = low << 8;
+    unsigned int low_shift = low << 16;
     int bit = code_word >= low_shift;
     if (bit) {
         c->high   -= low;

Modified: trunk/libavcodec/vp56rac.c
==============================================================================
--- trunk/libavcodec/vp56rac.c	Thu Aug 12 02:35:19 2010	(r24782)
+++ trunk/libavcodec/vp56rac.c	Thu Aug 12 03:11:32 2010	(r24783)
@@ -40,8 +40,8 @@ const uint8_t ff_vp56_norm_shift[256]= {
 void ff_vp56_init_range_decoder(VP56RangeCoder *c, const uint8_t *buf, int buf_size)
 {
     c->high = 255;
-    c->bits = -8;
+    c->bits = -16;
     c->buffer = buf;
     c->end = buf + buf_size;
-    c->code_word = bytestream_get_be16(&c->buffer);
+    c->code_word = bytestream_get_be24(&c->buffer);
 }

Modified: trunk/libavcodec/x86/vp56_arith.h
==============================================================================
--- trunk/libavcodec/x86/vp56_arith.h	Thu Aug 12 02:35:19 2010	(r24782)
+++ trunk/libavcodec/x86/vp56_arith.h	Thu Aug 12 03:11:32 2010	(r24783)
@@ -31,7 +31,7 @@ static av_always_inline int vp56_rac_get
     unsigned int code_word = vp56_rac_renorm(c);
     unsigned int high = c->high;
     unsigned int low = 1 + (((high - 1) * prob) >> 8);
-    unsigned int low_shift = low << 8;
+    unsigned int low_shift = low << 16;
     int bit = 0;
 
     __asm__(



More information about the ffmpeg-cvslog mailing list