[FFmpeg-cvslog] rv40: don't always do the full prev_type search

Christophe Gisquet git at videolan.org
Sun Apr 29 22:52:26 CEST 2012


ffmpeg | branch: master | Christophe Gisquet <christophe.gisquet at gmail.com> | Tue Apr 17 18:44:48 2012 +0000| [34e1b0754638ea6e0356239aad01e74de3a582a5] | committer: Ronald S. Bultje

rv40: don't always do the full prev_type search

120->100 cycles.

Signed-off-by: Ronald S. Bultje <rsbultje at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=34e1b0754638ea6e0356239aad01e74de3a582a5
---

 libavcodec/rv40.c |   25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index b65a200..18dd51e 100644
--- a/libavcodec/rv40.c
+++ b/libavcodec/rv40.c
@@ -228,8 +228,6 @@ static int rv40_decode_mb_info(RV34DecContext *r)
     int q, i;
     int prev_type = 0;
     int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
-    int blocks[RV34_MB_TYPES] = {0};
-    int count = 0;
 
     if(!r->s.mb_skip_run)
         r->s.mb_skip_run = svq3_get_ue_golomb(gb) + 1;
@@ -237,22 +235,27 @@ static int rv40_decode_mb_info(RV34DecContext *r)
     if(--r->s.mb_skip_run)
          return RV34_MB_SKIP;
 
-    if(r->avail_cache[6-1])
-        blocks[r->mb_type[mb_pos - 1]]++;
     if(r->avail_cache[6-4]){
+        int blocks[RV34_MB_TYPES] = {0};
+        int count = 0;
+        if(r->avail_cache[6-1])
+            blocks[r->mb_type[mb_pos - 1]]++;
         blocks[r->mb_type[mb_pos - s->mb_stride]]++;
         if(r->avail_cache[6-2])
             blocks[r->mb_type[mb_pos - s->mb_stride + 1]]++;
         if(r->avail_cache[6-5])
             blocks[r->mb_type[mb_pos - s->mb_stride - 1]]++;
-    }
-
-    for(i = 0; i < RV34_MB_TYPES; i++){
-        if(blocks[i] > count){
-            count = blocks[i];
-            prev_type = i;
+        for(i = 0; i < RV34_MB_TYPES; i++){
+            if(blocks[i] > count){
+                count = blocks[i];
+                prev_type = i;
+                if(count>1)
+                    break;
+            }
         }
-    }
+    } else if (r->avail_cache[6-1])
+        prev_type = r->mb_type[mb_pos - 1];
+
     if(s->pict_type == AV_PICTURE_TYPE_P){
         prev_type = block_num_to_ptype_vlc_num[prev_type];
         q = get_vlc2(gb, ptype_vlc[prev_type].table, PTYPE_VLC_BITS, 1);



More information about the ffmpeg-cvslog mailing list