diff vp8dsp.c @ 11974:356b20a6566d libavcodec

VP8 bilinear filter
author conrad
date Sun, 27 Jun 2010 01:46:29 +0000
parents 496d1300204d
children c3afb5be0d9b
line wrap: on
line diff
--- a/vp8dsp.c	Sun Jun 27 01:46:23 2010 +0000
+++ b/vp8dsp.c	Sun Jun 27 01:46:29 2010 +0000
@@ -348,6 +348,61 @@
 VP8_EPEL_HV(8,  FILTER_6TAP, FILTER_6TAP, h6v6)
 VP8_EPEL_HV(4,  FILTER_6TAP, FILTER_6TAP, h6v6)
 
+#define VP8_BILINEAR(SIZE) \
+static void put_vp8_bilinear ## SIZE ## _h_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \
+{ \
+    int a = 8-mx, b = mx; \
+    int x, y; \
+\
+    for (y = 0; y < h; y++) { \
+        for (x = 0; x < SIZE; x++) \
+            dst[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \
+        dst += stride; \
+        src += stride; \
+    } \
+} \
+static void put_vp8_bilinear ## SIZE ## _v_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \
+{ \
+    int c = 8-my, d = my; \
+    int x, y; \
+\
+    for (y = 0; y < h; y++) { \
+        for (x = 0; x < SIZE; x++) \
+            dst[x] = (c*src[x] + d*src[x+stride] + 4) >> 3; \
+        dst += stride; \
+        src += stride; \
+    } \
+} \
+\
+static void put_vp8_bilinear ## SIZE ## _hv_c(uint8_t *dst, int stride, uint8_t *src, int s2, int h, int mx, int my) \
+{ \
+    int a = 8-mx, b = mx; \
+    int c = 8-my, d = my; \
+    int x, y; \
+    uint8_t tmp_array[(2*SIZE+1)*SIZE]; \
+    uint8_t *tmp = tmp_array; \
+\
+    for (y = 0; y < h+1; y++) { \
+        for (x = 0; x < SIZE; x++) \
+            tmp[x] = (a*src[x] + b*src[x+1] + 4) >> 3; \
+        tmp += SIZE; \
+        src += stride; \
+    } \
+\
+    tmp = tmp_array; \
+\
+    for (y = 0; y < h; y++) { \
+        for (x = 0; x < SIZE; x++) \
+            dst[x] = (c*tmp[x] + d*tmp[x+SIZE] + 4) >> 3; \
+        dst += stride; \
+        tmp += SIZE; \
+    } \
+}
+
+VP8_BILINEAR(16)
+VP8_BILINEAR(8)
+VP8_BILINEAR(4)
+
 #define VP8_MC_FUNC(IDX, SIZE) \
     dsp->put_vp8_epel_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
     dsp->put_vp8_epel_pixels_tab[IDX][0][1] = put_vp8_epel ## SIZE ## _h4_c; \
@@ -359,6 +414,17 @@
     dsp->put_vp8_epel_pixels_tab[IDX][2][1] = put_vp8_epel ## SIZE ## _h4v6_c; \
     dsp->put_vp8_epel_pixels_tab[IDX][2][2] = put_vp8_epel ## SIZE ## _h6v6_c
 
+#define VP8_BILINEAR_MC_FUNC(IDX, SIZE) \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][0][0] = put_vp8_pixels ## SIZE ## _c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][0][1] = put_vp8_bilinear ## SIZE ## _h_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][0][2] = put_vp8_bilinear ## SIZE ## _h_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][1][0] = put_vp8_bilinear ## SIZE ## _v_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][1][1] = put_vp8_bilinear ## SIZE ## _hv_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][1][2] = put_vp8_bilinear ## SIZE ## _hv_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][2][0] = put_vp8_bilinear ## SIZE ## _v_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][2][1] = put_vp8_bilinear ## SIZE ## _hv_c; \
+    dsp->put_vp8_bilinear_pixels_tab[IDX][2][2] = put_vp8_bilinear ## SIZE ## _hv_c
+
 av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
 {
     dsp->vp8_luma_dc_wht = vp8_luma_dc_wht_c;
@@ -381,4 +447,8 @@
     VP8_MC_FUNC(0, 16);
     VP8_MC_FUNC(1, 8);
     VP8_MC_FUNC(2, 4);
+
+    VP8_BILINEAR_MC_FUNC(0, 16);
+    VP8_BILINEAR_MC_FUNC(1, 8);
+    VP8_BILINEAR_MC_FUNC(2, 4);
 }