changeset 8146:4a92ea42a8bc libavcodec

Weak deblock filter function for future RV40 loop filter
author kostya
date Sat, 15 Nov 2008 14:15:24 +0000
parents f27d01aff4af
children 3b9eefe120e6
files rv40.c
diffstat 1 files changed, 38 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rv40.c	Fri Nov 14 17:36:47 2008 +0000
+++ b/rv40.c	Sat Nov 15 14:15:24 2008 +0000
@@ -247,6 +247,44 @@
     return 0;
 }
 
+#define CLIP_SYMM(a, b) av_clip(a, -(b), b)
+/**
+ * weaker deblocking very similar to the one described in 4.4.2 of JVT-A003r1
+ */
+static inline void rv40_weak_loop_filter(uint8_t *src, const int step,
+                                         const int filter_p1, const int filter_q1,
+                                         const int alpha, const int beta,
+                                         const int lim_p0q0,
+                                         const int lim_q1, const int lim_p1,
+                                         const int diff_p1p0, const int diff_q1q0,
+                                         const int diff_p1p2, const int diff_q1q2)
+{
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    int t, u, diff;
+
+    t = src[0*step] - src[-1*step];
+    if(!t)
+        return;
+    u = (alpha * FFABS(t)) >> 7;
+    if(u > 3 - (filter_p1 && filter_q1))
+        return;
+
+    t <<= 2;
+    if(filter_p1 && filter_q1)
+        t += src[-2*step] - src[1*step];
+    diff = CLIP_SYMM((t + 4) >> 3, lim_p0q0);
+    src[-1*step] = cm[src[-1*step] + diff];
+    src[ 0*step] = cm[src[ 0*step] - diff];
+    if(FFABS(diff_p1p2) <= beta && filter_p1){
+        t = (diff_p1p0 + diff_p1p2 - diff) >> 1;
+        src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim_p1)];
+    }
+    if(FFABS(diff_q1q2) <= beta && filter_q1){
+        t = (diff_q1q0 + diff_q1q2 + diff) >> 1;
+        src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim_q1)];
+    }
+}
+
 /**
  * Initialize decoder.
  */