summaryrefslogtreecommitdiff
path: root/libavcodec/rv40.c
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2012-04-17 18:44:48 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2012-04-28 11:06:05 -0700
commit34e1b0754638ea6e0356239aad01e74de3a582a5 (patch)
tree14ec077c090b52a156f9d4fe6ced9b8f4bd6ed84 /libavcodec/rv40.c
parente75d1d4f7321b097f4b09799bf28a22ad259fea6 (diff)
rv40: don't always do the full prev_type search
120->100 cycles. Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
Diffstat (limited to 'libavcodec/rv40.c')
-rw-r--r--libavcodec/rv40.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/libavcodec/rv40.c b/libavcodec/rv40.c
index b65a2005f0..18dd51e871 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);