[03/15] vc1dec: Implement intensity compensation for vc1_interp_mc()

Message ID 1369729571-75967-3-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö May 28, 2013, 8:25 a.m.
From: Michael Niedermayer <michaelni@gmx.at>

---
 libavcodec/vc1dec.c |   26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

Comments

Kostya Shishkov May 28, 2013, 9:03 a.m. | #1
On Tue, May 28, 2013 at 11:25:59AM +0300, Martin Storsjö wrote:
> From: Michael Niedermayer <michaelni@gmx.at>
> 
> ---
>  libavcodec/vc1dec.c |   26 +++++++++++++++++++++++++-
>  1 file changed, 25 insertions(+), 1 deletion(-)

probably OK
Luca Barbato May 28, 2013, 10:14 a.m. | #2
On 5/28/13 10:25 AM, Martin Storsjö wrote:
> +    if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || v->mv_mode == MV_PMODE_INTENSITY_COMP

Split the line please.

lu

Patch

diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 73e1f3b..bd56d29 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1898,7 +1898,7 @@  static void vc1_interp_mc(VC1Context *v)
         srcV = s->edge_emu_buffer + 18 * s->linesize;
     }
 
-    if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22
+    if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || v->mv_mode == MV_PMODE_INTENSITY_COMP
         || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3
         || (unsigned)(src_y - 1) > v_edge_pos    - (my & 3) - 16 - 3) {
         uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize;
@@ -1937,6 +1937,30 @@  static void vc1_interp_mc(VC1Context *v)
                 src2 += s->uvlinesize;
             }
         }
+
+        if (v->mv_mode == MV_PMODE_INTENSITY_COMP) {
+            const uint8_t *luty = v->next_luty [v->ref_field_type[1]];
+            const uint8_t *lutuv= v->next_lutuv[v->ref_field_type[1]];
+            int i, j;
+            uint8_t *src, *src2;
+
+            src = srcY;
+            for (j = 0; j < 17 + s->mspel * 2; j++) {
+                for (i = 0; i < 17 + s->mspel * 2; i++)
+                    src[i] = luty[src[i]];
+                src += s->linesize;
+            }
+            src  = srcU;
+            src2 = srcV;
+            for (j = 0; j < 9; j++) {
+                for (i = 0; i < 9; i++) {
+                    src[i]  = lutuv[src[i]];
+                    src2[i] = lutuv[src2[i]];
+                }
+                src  += s->uvlinesize;
+                src2 += s->uvlinesize;
+            }
+        }
         srcY += s->mspel * (1 + s->linesize);
     }