changeset 8116:2d01559f824c libavcodec

Calculating an additional MV-based deblocking pattern is the same for both RV3 and RV4, so move it into common code.
author kostya
date Fri, 07 Nov 2008 07:18:22 +0000
parents e61cc20bad68
children a0f9045e0a82
files rv34.c rv34.h
diffstat 2 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rv34.c	Thu Nov 06 01:33:28 2008 +0000
+++ b/rv34.c	Fri Nov 07 07:18:22 2008 +0000
@@ -1067,6 +1067,38 @@
         s->dsp.add_pixels_clamped(s->block[5], s->dest[2], s->uvlinesize);
 }
 
+static int is_mv_diff_gt_3(int16_t (*motion_val)[2], int step)
+{
+    int d;
+    d = motion_val[0][0] - motion_val[-step][0];
+    if(d < -3 || d > 3)
+        return 1;
+    d = motion_val[0][1] - motion_val[-step][1];
+    if(d < -3 || d > 3)
+        return 1;
+    return 0;
+}
+
+static int rv34_set_deblock_coef(RV34DecContext *r)
+{
+    MpegEncContext *s = &r->s;
+    int mvmask = 0, i, j;
+    int midx = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride;
+    int16_t (*motion_val)[2] = s->current_picture_ptr->motion_val[0][midx];
+    if(s->pict_type == FF_I_TYPE)
+        return 0;
+    for(j = 0; j < 16; j += 8){
+        for(i = 0; i < 2; i++){
+            if(is_mv_diff_gt_3(motion_val + i, 1))
+                mvmask |= 0x11 << (j + i*2);
+            if(is_mv_diff_gt_3(motion_val + i, s->b8_stride))
+                mvmask |= 0x03 << (j + i*2);
+        }
+        motion_val += s->b8_stride;
+    }
+    return mvmask;
+}
+
 static int rv34_decode_macroblock(RV34DecContext *r, int8_t *intra_types)
 {
     MpegEncContext *s = &r->s;
@@ -1097,8 +1129,10 @@
     cbp = cbp2 = rv34_decode_mb_header(r, intra_types);
     r->cbp_luma  [s->mb_x + s->mb_y * s->mb_stride] = cbp;
     r->cbp_chroma[s->mb_x + s->mb_y * s->mb_stride] = cbp >> 16;
-    if(r->set_deblock_coef)
-        r->deblock_coefs[s->mb_x + s->mb_y * s->mb_stride] = r->set_deblock_coef(r);
+    if(s->pict_type == FF_I_TYPE)
+        r->deblock_coefs[mb_pos] = 0;
+    else
+        r->deblock_coefs[mb_pos] = rv34_set_deblock_coef(r);
     s->current_picture.qscale_table[s->mb_x + s->mb_y * s->mb_stride] = s->qscale;
 
     if(cbp == -1)
--- a/rv34.h	Thu Nov 06 01:33:28 2008 +0000
+++ b/rv34.h	Fri Nov 07 07:18:22 2008 +0000
@@ -115,7 +115,6 @@
     int (*parse_slice_header)(struct RV34DecContext *r, GetBitContext *gb, SliceInfo *si);
     int (*decode_mb_info)(struct RV34DecContext *r);
     int (*decode_intra_types)(struct RV34DecContext *r, GetBitContext *gb, int8_t *dst);
-    int (*set_deblock_coef)(struct RV34DecContext *r);
     void (*loop_filter)(struct RV34DecContext *r);
 }RV34DecContext;