]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264pred.c
PPC: gas-preprocessor handles m[ft]spr shorthands
[ffmpeg] / libavcodec / h264pred.c
index 0b7394a03a98d614d960889d1807c5a13a79ad4d..5706c97e165d77cb1edf601fdf9b9765a5c17ff1 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file h264pred.c
+ * @file
  * H.264 / AVC / MPEG4 part10 prediction functions.
  * @author Michael Niedermayer <michaelni@gmx.at>
  */
@@ -28,8 +28,9 @@
 #include "avcodec.h"
 #include "mpegvideo.h"
 #include "h264pred.h"
+#include "mathops.h"
 
-static void pred4x4_vertical_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_c(uint8_t *src, const uint8_t *topright, int stride){
     const uint32_t a= ((uint32_t*)(src-stride))[0];
     ((uint32_t*)(src+0*stride))[0]= a;
     ((uint32_t*)(src+1*stride))[0]= a;
@@ -37,14 +38,14 @@ static void pred4x4_vertical_c(uint8_t *src, uint8_t *topright, int stride){
     ((uint32_t*)(src+3*stride))[0]= a;
 }
 
-static void pred4x4_horizontal_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_horizontal_c(uint8_t *src, const uint8_t *topright, int stride){
     ((uint32_t*)(src+0*stride))[0]= src[-1+0*stride]*0x01010101;
     ((uint32_t*)(src+1*stride))[0]= src[-1+1*stride]*0x01010101;
     ((uint32_t*)(src+2*stride))[0]= src[-1+2*stride]*0x01010101;
     ((uint32_t*)(src+3*stride))[0]= src[-1+3*stride]*0x01010101;
 }
 
-static void pred4x4_dc_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_dc_c(uint8_t *src, const uint8_t *topright, int stride){
     const int dc= (  src[-stride] + src[1-stride] + src[2-stride] + src[3-stride]
                    + src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 4) >>3;
 
@@ -54,7 +55,7 @@ static void pred4x4_dc_c(uint8_t *src, uint8_t *topright, int stride){
     ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101;
 }
 
-static void pred4x4_left_dc_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_left_dc_c(uint8_t *src, const uint8_t *topright, int stride){
     const int dc= (  src[-1+0*stride] + src[-1+1*stride] + src[-1+2*stride] + src[-1+3*stride] + 2) >>2;
 
     ((uint32_t*)(src+0*stride))[0]=
@@ -63,7 +64,7 @@ static void pred4x4_left_dc_c(uint8_t *src, uint8_t *topright, int stride){
     ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101;
 }
 
-static void pred4x4_top_dc_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_top_dc_c(uint8_t *src, const uint8_t *topright, int stride){
     const int dc= (  src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;
 
     ((uint32_t*)(src+0*stride))[0]=
@@ -72,7 +73,7 @@ static void pred4x4_top_dc_c(uint8_t *src, uint8_t *topright, int stride){
     ((uint32_t*)(src+3*stride))[0]= dc* 0x01010101;
 }
 
-static void pred4x4_128_dc_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_128_dc_c(uint8_t *src, const uint8_t *topright, int stride){
     ((uint32_t*)(src+0*stride))[0]=
     ((uint32_t*)(src+1*stride))[0]=
     ((uint32_t*)(src+2*stride))[0]=
@@ -104,7 +105,32 @@ static void pred4x4_128_dc_c(uint8_t *src, uint8_t *topright, int stride){
     const int av_unused t2= src[ 2-1*stride];\
     const int av_unused t3= src[ 3-1*stride];\
 
-static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
+    const int lt= src[-1-1*stride];
+    LOAD_TOP_EDGE
+    LOAD_TOP_RIGHT_EDGE
+    uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2,
+                            (t0 + 2*t1 + t2 + 2) >> 2,
+                            (t1 + 2*t2 + t3 + 2) >> 2,
+                            (t2 + 2*t3 + t4 + 2) >> 2);
+
+    AV_WN32A(src+0*stride, v);
+    AV_WN32A(src+1*stride, v);
+    AV_WN32A(src+2*stride, v);
+    AV_WN32A(src+3*stride, v);
+}
+
+static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
+    const int lt= src[-1-1*stride];
+    LOAD_LEFT_EDGE
+
+    AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101);
+    AV_WN32A(src+1*stride, ((l0 + 2*l1 + l2 + 2) >> 2)*0x01010101);
+    AV_WN32A(src+2*stride, ((l1 + 2*l2 + l3 + 2) >> 2)*0x01010101);
+    AV_WN32A(src+3*stride, ((l2 + 2*l3 + l3 + 2) >> 2)*0x01010101);
+}
+
+static void pred4x4_down_right_c(uint8_t *src, const uint8_t *topright, int stride){
     const int lt= src[-1-1*stride];
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
@@ -127,7 +153,7 @@ static void pred4x4_down_right_c(uint8_t *src, uint8_t *topright, int stride){
     src[3+0*stride]=(t1 + 2*t2 + t3 + 2)>>2;
 }
 
-static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_down_left_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
 //    LOAD_LEFT_EDGE
@@ -150,7 +176,7 @@ static void pred4x4_down_left_c(uint8_t *src, uint8_t *topright, int stride){
     src[3+3*stride]=(t6 + 3*t7 + 2)>>2;
 }
 
-static void pred4x4_down_left_svq3_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
     const av_unused int unu0= t0;
@@ -174,7 +200,7 @@ static void pred4x4_down_left_svq3_c(uint8_t *src, uint8_t *topright, int stride
     src[3+3*stride]=(l3 + t3)>>1;
 }
 
-static void pred4x4_down_left_rv40_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_down_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
     LOAD_LEFT_EDGE
@@ -198,29 +224,7 @@ static void pred4x4_down_left_rv40_c(uint8_t *src, uint8_t *topright, int stride
     src[3+3*stride]=(t6 + t7 + 1 + l6 + l7 + 1)>>2;
 }
 
-static void pred4x4_down_left_rv40_notop_c(uint8_t *src, uint8_t *topright, int stride){
-    LOAD_LEFT_EDGE
-    LOAD_DOWN_LEFT_EDGE
-
-    src[0+0*stride]=(l0 + l2 + 2*l1 + 2)>>2;
-    src[1+0*stride]=
-    src[0+1*stride]=(l1 + l3 + 2*l2 + 2)>>2;
-    src[2+0*stride]=
-    src[1+1*stride]=
-    src[0+2*stride]=(l2 + l4 + 2*l3 + 2)>>2;
-    src[3+0*stride]=
-    src[2+1*stride]=
-    src[1+2*stride]=
-    src[0+3*stride]=(l3 + l5 + 2*l4 + 2)>>2;
-    src[3+1*stride]=
-    src[2+2*stride]=
-    src[1+3*stride]=(l4 + l6 + 2*l5 + 2)>>2;
-    src[3+2*stride]=
-    src[2+3*stride]=(l5 + l7 + 2*l6 + 2)>>2;
-    src[3+3*stride]=(l6 + l7 + 1)>>1;
-}
-
-static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
     LOAD_LEFT_EDGE
@@ -243,7 +247,7 @@ static void pred4x4_down_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int
     src[3+3*stride]=(t6 + t7 + 1 + 2*l3 + 1)>>2;
 }
 
-static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_right_c(uint8_t *src, const uint8_t *topright, int stride){
     const int lt= src[-1-1*stride];
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
@@ -266,7 +270,7 @@ static void pred4x4_vertical_right_c(uint8_t *src, uint8_t *topright, int stride
     src[0+3*stride]=(l0 + 2*l1 + l2 + 2)>>2;
 }
 
-static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_left_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
 
@@ -288,7 +292,7 @@ static void pred4x4_vertical_left_c(uint8_t *src, uint8_t *topright, int stride)
     src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
 }
 
-static void pred4x4_vertical_left_rv40(uint8_t *src, uint8_t *topright, int stride,
+static void pred4x4_vertical_left_rv40(uint8_t *src, const uint8_t *topright, int stride,
                                       const int l0, const int l1, const int l2, const int l3, const int l4){
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
@@ -311,20 +315,42 @@ static void pred4x4_vertical_left_rv40(uint8_t *src, uint8_t *topright, int stri
     src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2;
 }
 
-static void pred4x4_vertical_left_rv40_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_left_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_LEFT_EDGE
     LOAD_DOWN_LEFT_EDGE
 
     pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4);
 }
 
-static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_LEFT_EDGE
 
     pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3);
 }
 
-static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_vertical_left_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
+    LOAD_TOP_EDGE
+    LOAD_TOP_RIGHT_EDGE
+
+    src[0+0*stride]=(t0 + t1 + 1)>>1;
+    src[1+0*stride]=
+    src[0+2*stride]=(t1 + t2 + 1)>>1;
+    src[2+0*stride]=
+    src[1+2*stride]=(t2 + t3 + 1)>>1;
+    src[3+0*stride]=
+    src[2+2*stride]=(t3 + t4 + 1)>>1;
+    src[0+1*stride]=(t0 + 2*t1 + t2 + 2)>>2;
+    src[1+1*stride]=
+    src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2;
+    src[2+1*stride]=
+    src[1+3*stride]=(t2 + 2*t3 + t4 + 2)>>2;
+    src[3+1*stride]=
+    src[2+3*stride]=(t3 + 2*t4 + t5 + 2)>>2;
+    src[3+2*stride]=(t4 + 2*t5 + t6 + 2)>>2;
+    src[3+3*stride]=(t5 + 2*t6 + t7 + 2)>>2;
+}
+
+static void pred4x4_horizontal_up_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_LEFT_EDGE
 
     src[0+0*stride]=(l0 + l1 + 1)>>1;
@@ -345,7 +371,7 @@ static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride)
     src[3+3*stride]=l3;
 }
 
-static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_horizontal_up_rv40_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_LEFT_EDGE
     LOAD_DOWN_LEFT_EDGE
     LOAD_TOP_EDGE
@@ -369,7 +395,7 @@ static void pred4x4_horizontal_up_rv40_c(uint8_t *src, uint8_t *topright, int st
     src[3+3*stride]=(l4 + 2*l5 + l6 + 2)>>2;
 }
 
-static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, const uint8_t *topright, int stride){
     LOAD_LEFT_EDGE
     LOAD_TOP_EDGE
     LOAD_TOP_RIGHT_EDGE
@@ -392,7 +418,7 @@ static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src, uint8_t *topright,
     src[3+3*stride]=l3;
 }
 
-static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int stride){
+static void pred4x4_horizontal_down_c(uint8_t *src, const uint8_t *topright, int stride){
     const int lt= src[-1-1*stride];
     LOAD_TOP_EDGE
     LOAD_LEFT_EDGE
@@ -415,6 +441,21 @@ static void pred4x4_horizontal_down_c(uint8_t *src, uint8_t *topright, int strid
     src[1+3*stride]=(l1 + 2*l2 + l3 + 2)>>2;
 }
 
+static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright, int stride){
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+    uint8_t *top = src-stride;
+    int y;
+
+    for (y = 0; y < 4; y++) {
+        uint8_t *cm_in = cm + src[-1];
+        src[0] = cm_in[top[0]];
+        src[1] = cm_in[top[1]];
+        src[2] = cm_in[top[2]];
+        src[3] = cm_in[top[3]];
+        src += stride;
+    }
+}
+
 static void pred16x16_vertical_c(uint8_t *src, int stride){
     int i;
     const uint32_t a= ((uint32_t*)(src-stride))[0];
@@ -561,6 +602,33 @@ static void pred16x16_plane_rv40_c(uint8_t *src, int stride){
     pred16x16_plane_compat_c(src, stride, 0, 1);
 }
 
+static void pred16x16_tm_vp8_c(uint8_t *src, int stride){
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+    uint8_t *top = src-stride;
+    int y;
+
+    for (y = 0; y < 16; y++) {
+        uint8_t *cm_in = cm + src[-1];
+        src[0]  = cm_in[top[0]];
+        src[1]  = cm_in[top[1]];
+        src[2]  = cm_in[top[2]];
+        src[3]  = cm_in[top[3]];
+        src[4]  = cm_in[top[4]];
+        src[5]  = cm_in[top[5]];
+        src[6]  = cm_in[top[6]];
+        src[7]  = cm_in[top[7]];
+        src[8]  = cm_in[top[8]];
+        src[9]  = cm_in[top[9]];
+        src[10] = cm_in[top[10]];
+        src[11] = cm_in[top[11]];
+        src[12] = cm_in[top[12]];
+        src[13] = cm_in[top[13]];
+        src[14] = cm_in[top[14]];
+        src[15] = cm_in[top[15]];
+        src += stride;
+    }
+}
+
 static void pred8x8_vertical_c(uint8_t *src, int stride){
     int i;
     const uint32_t a= ((uint32_t*)(src-stride))[0];
@@ -767,6 +835,25 @@ static void pred8x8_plane_c(uint8_t *src, int stride){
   }
 }
 
+static void pred8x8_tm_vp8_c(uint8_t *src, int stride){
+    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+    uint8_t *top = src-stride;
+    int y;
+
+    for (y = 0; y < 8; y++) {
+        uint8_t *cm_in = cm + src[-1];
+        src[0] = cm_in[top[0]];
+        src[1] = cm_in[top[1]];
+        src[2] = cm_in[top[2]];
+        src[3] = cm_in[top[3]];
+        src[4] = cm_in[top[4]];
+        src[5] = cm_in[top[5]];
+        src[6] = cm_in[top[6]];
+        src[7] = cm_in[top[7]];
+        src += stride;
+    }
+}
+
 #define SRC(x,y) src[(x)+(y)*stride]
 #define PL(y) \
     const int l##y = (SRC(-1,y-1) + 2*SRC(-1,y) + SRC(-1,y+1) + 2) >> 2;
@@ -1009,15 +1096,107 @@ static void pred8x8l_horizontal_up_c(uint8_t *src, int has_topleft, int has_topr
 #undef PL
 #undef SRC
 
+static void pred4x4_vertical_add_c(uint8_t *pix, const DCTELEM *block, int stride){
+    int i;
+    pix -= stride;
+    for(i=0; i<4; i++){
+        uint8_t v = pix[0];
+        pix[1*stride]= v += block[0];
+        pix[2*stride]= v += block[4];
+        pix[3*stride]= v += block[8];
+        pix[4*stride]= v +  block[12];
+        pix++;
+        block++;
+    }
+}
+
+static void pred4x4_horizontal_add_c(uint8_t *pix, const DCTELEM *block, int stride){
+    int i;
+    for(i=0; i<4; i++){
+        uint8_t v = pix[-1];
+        pix[0]= v += block[0];
+        pix[1]= v += block[1];
+        pix[2]= v += block[2];
+        pix[3]= v +  block[3];
+        pix+= stride;
+        block+= 4;
+    }
+}
+
+static void pred8x8l_vertical_add_c(uint8_t *pix, const DCTELEM *block, int stride){
+    int i;
+    pix -= stride;
+    for(i=0; i<8; i++){
+        uint8_t v = pix[0];
+        pix[1*stride]= v += block[0];
+        pix[2*stride]= v += block[8];
+        pix[3*stride]= v += block[16];
+        pix[4*stride]= v += block[24];
+        pix[5*stride]= v += block[32];
+        pix[6*stride]= v += block[40];
+        pix[7*stride]= v += block[48];
+        pix[8*stride]= v +  block[56];
+        pix++;
+        block++;
+    }
+}
+
+static void pred8x8l_horizontal_add_c(uint8_t *pix, const DCTELEM *block, int stride){
+    int i;
+    for(i=0; i<8; i++){
+        uint8_t v = pix[-1];
+        pix[0]= v += block[0];
+        pix[1]= v += block[1];
+        pix[2]= v += block[2];
+        pix[3]= v += block[3];
+        pix[4]= v += block[4];
+        pix[5]= v += block[5];
+        pix[6]= v += block[6];
+        pix[7]= v +  block[7];
+        pix+= stride;
+        block+= 8;
+    }
+}
+
+static void pred16x16_vertical_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
+    int i;
+    for(i=0; i<16; i++)
+        pred4x4_vertical_add_c(pix + block_offset[i], block + i*16, stride);
+}
+
+static void pred16x16_horizontal_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
+    int i;
+    for(i=0; i<16; i++)
+        pred4x4_horizontal_add_c(pix + block_offset[i], block + i*16, stride);
+}
+
+static void pred8x8_vertical_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
+    int i;
+    for(i=0; i<4; i++)
+        pred4x4_vertical_add_c(pix + block_offset[i], block + i*16, stride);
+}
+
+static void pred8x8_horizontal_add_c(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){
+    int i;
+    for(i=0; i<4; i++)
+        pred4x4_horizontal_add_c(pix + block_offset[i], block + i*16, stride);
+}
+
+
 /**
- * Sets the intra prediction function pointers.
+ * Set the intra prediction function pointers.
  */
 void ff_h264_pred_init(H264PredContext *h, int codec_id){
 //    MpegEncContext * const s = &h->s;
 
     if(codec_id != CODEC_ID_RV40){
-        h->pred4x4[VERT_PRED           ]= pred4x4_vertical_c;
-        h->pred4x4[HOR_PRED            ]= pred4x4_horizontal_c;
+        if(codec_id == CODEC_ID_VP8) {
+            h->pred4x4[VERT_PRED       ]= pred4x4_vertical_vp8_c;
+            h->pred4x4[HOR_PRED        ]= pred4x4_horizontal_vp8_c;
+        } else {
+            h->pred4x4[VERT_PRED       ]= pred4x4_vertical_c;
+            h->pred4x4[HOR_PRED        ]= pred4x4_horizontal_c;
+        }
         h->pred4x4[DC_PRED             ]= pred4x4_dc_c;
         if(codec_id == CODEC_ID_SVQ3)
             h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_svq3_c;
@@ -1026,11 +1205,16 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
         h->pred4x4[DIAG_DOWN_RIGHT_PRED]= pred4x4_down_right_c;
         h->pred4x4[VERT_RIGHT_PRED     ]= pred4x4_vertical_right_c;
         h->pred4x4[HOR_DOWN_PRED       ]= pred4x4_horizontal_down_c;
-        h->pred4x4[VERT_LEFT_PRED      ]= pred4x4_vertical_left_c;
+        if (codec_id == CODEC_ID_VP8) {
+            h->pred4x4[VERT_LEFT_PRED  ]= pred4x4_vertical_left_vp8_c;
+        } else
+            h->pred4x4[VERT_LEFT_PRED  ]= pred4x4_vertical_left_c;
         h->pred4x4[HOR_UP_PRED         ]= pred4x4_horizontal_up_c;
         h->pred4x4[LEFT_DC_PRED        ]= pred4x4_left_dc_c;
         h->pred4x4[TOP_DC_PRED         ]= pred4x4_top_dc_c;
         h->pred4x4[DC_128_PRED         ]= pred4x4_128_dc_c;
+        if(codec_id == CODEC_ID_VP8)
+            h->pred4x4[TM_VP8_PRED     ]= pred4x4_tm_vp8_c;
     }else{
         h->pred4x4[VERT_PRED           ]= pred4x4_vertical_c;
         h->pred4x4[HOR_PRED            ]= pred4x4_horizontal_c;
@@ -1064,8 +1248,11 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
 
     h->pred8x8[VERT_PRED8x8   ]= pred8x8_vertical_c;
     h->pred8x8[HOR_PRED8x8    ]= pred8x8_horizontal_c;
-    h->pred8x8[PLANE_PRED8x8  ]= pred8x8_plane_c;
-    if(codec_id != CODEC_ID_RV40){
+    if (codec_id != CODEC_ID_VP8) {
+        h->pred8x8[PLANE_PRED8x8]= pred8x8_plane_c;
+    } else
+        h->pred8x8[PLANE_PRED8x8]= pred8x8_tm_vp8_c;
+    if(codec_id != CODEC_ID_RV40 && codec_id != CODEC_ID_VP8){
         h->pred8x8[DC_PRED8x8     ]= pred8x8_dc_c;
         h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_c;
         h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_c;
@@ -1091,10 +1278,26 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
     case CODEC_ID_RV40:
        h->pred16x16[PLANE_PRED8x8  ]= pred16x16_plane_rv40_c;
        break;
+    case CODEC_ID_VP8:
+       h->pred16x16[PLANE_PRED8x8  ]= pred16x16_tm_vp8_c;
+       break;
     default:
        h->pred16x16[PLANE_PRED8x8  ]= pred16x16_plane_c;
     }
     h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c;
     h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c;
     h->pred16x16[DC_128_PRED8x8 ]= pred16x16_128_dc_c;
+
+    //special lossless h/v prediction for h264
+    h->pred4x4_add  [VERT_PRED   ]= pred4x4_vertical_add_c;
+    h->pred4x4_add  [ HOR_PRED   ]= pred4x4_horizontal_add_c;
+    h->pred8x8l_add [VERT_PRED   ]= pred8x8l_vertical_add_c;
+    h->pred8x8l_add [ HOR_PRED   ]= pred8x8l_horizontal_add_c;
+    h->pred8x8_add  [VERT_PRED8x8]= pred8x8_vertical_add_c;
+    h->pred8x8_add  [ HOR_PRED8x8]= pred8x8_horizontal_add_c;
+    h->pred16x16_add[VERT_PRED8x8]= pred16x16_vertical_add_c;
+    h->pred16x16_add[ HOR_PRED8x8]= pred16x16_horizontal_add_c;
+
+    if (ARCH_ARM) ff_h264_pred_init_arm(h, codec_id);
+    if (HAVE_MMX) ff_h264_pred_init_x86(h, codec_id);
 }