[FFmpeg-soc] [soc]: r581 - in rv40: h264pred.c h264pred.h rv40.c

kostya subversion at mplayerhq.hu
Wed Aug 1 13:28:58 CEST 2007


Author: kostya
Date: Wed Aug  1 13:28:58 2007
New Revision: 581

Log:
Initialize predictors using codec_id

Modified:
   rv40/h264pred.c
   rv40/h264pred.h
   rv40/rv40.c

Modified: rv40/h264pred.c
==============================================================================
--- rv40/h264pred.c	(original)
+++ rv40/h264pred.c	Wed Aug  1 13:28:58 2007
@@ -513,6 +513,10 @@ static void pred16x16_plane_c(uint8_t *s
     pred16x16_plane_compat_c(src, stride, 0);
 }
 
+static void pred16x16_plane_svq3_c(uint8_t *src, int stride){
+    pred16x16_plane_compat_c(src, stride, 1);
+}
+
 static void pred8x8_vertical_c(uint8_t *src, int stride){
     int i;
     const uint32_t a= ((uint32_t*)(src-stride))[0];
@@ -564,6 +568,21 @@ static void pred8x8_left_dc_c(uint8_t *s
     }
 }
 
+static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){
+    int i;
+    int dc0;
+
+    dc0=0;
+    for(i=0;i<8; i++)
+        dc0+= src[-1 + i*stride];
+    dc0= 0x01010101*((dc0 + 4)>>3);
+
+    for(i=0; i<8; i++){
+        ((uint32_t*)(src+i*stride))[0]=
+        ((uint32_t*)(src+i*stride))[1]= dc0;
+    }
+}
+
 static void pred8x8_top_dc_c(uint8_t *src, int stride){
     int i;
     int dc0, dc1;
@@ -586,6 +605,21 @@ static void pred8x8_top_dc_c(uint8_t *sr
     }
 }
 
+static void pred8x8_top_dc_rv40_c(uint8_t *src, int stride){
+    int i;
+    int dc0;
+
+    dc0=0;
+    for(i=0;i<8; i++)
+        dc0+= src[i-stride];
+    dc0= 0x01010101*((dc0 + 4)>>3);
+
+    for(i=0; i<8; i++){
+        ((uint32_t*)(src+i*stride))[0]=
+        ((uint32_t*)(src+i*stride))[1]= dc0;
+    }
+}
+
 
 static void pred8x8_dc_c(uint8_t *src, int stride){
     int i;
@@ -890,9 +924,10 @@ static void pred8x8l_horizontal_up_c(uin
 /**
  * Sets the intra prediction function pointers.
  */
-void ff_h264_pred_init(H264PredContext *h){
+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;
     h->pred4x4[DC_PRED             ]= pred4x4_dc_c;
@@ -905,12 +940,22 @@ void ff_h264_pred_init(H264PredContext *
     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;
-    h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40]= pred4x4_down_left_rv40_c;
+    }else{
+    h->pred4x4[VERT_PRED           ]= pred4x4_vertical_c;
+    h->pred4x4[HOR_PRED            ]= pred4x4_horizontal_c;
+    h->pred4x4[DC_PRED             ]= pred4x4_dc_c;
+    h->pred4x4[DIAG_DOWN_LEFT_PRED ]= pred4x4_down_left_rv40_c;
+    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_rv40_c;
+    h->pred4x4[HOR_UP_PRED         ]= pred4x4_horizontal_up_rv40_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;
     h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= pred4x4_down_left_rv40_nodown_c;
-    h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NOTOP]= pred4x4_down_left_rv40_notop_c;
-    h->pred4x4[VERT_LEFT_PRED_RV40 ]= pred4x4_vertical_left_rv40_c;
-    h->pred4x4[HOR_UP_PRED_RV40    ]= pred4x4_horizontal_up_rv40_c;
     h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= pred4x4_horizontal_up_rv40_nodown_c;
+    }
 
     h->pred8x8l[VERT_PRED           ]= pred8x8l_vertical_c;
     h->pred8x8l[HOR_PRED            ]= pred8x8l_horizontal_c;
@@ -929,14 +974,29 @@ void ff_h264_pred_init(H264PredContext *
     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){
     h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_c;
     h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_c;
+    }else{
+    h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_rv40_c;
+    h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_rv40_c;
+    }
     h->pred8x8[DC_128_PRED8x8 ]= pred8x8_128_dc_c;
 
     h->pred16x16[DC_PRED8x8     ]= pred16x16_dc_c;
     h->pred16x16[VERT_PRED8x8   ]= pred16x16_vertical_c;
     h->pred16x16[HOR_PRED8x8    ]= pred16x16_horizontal_c;
     h->pred16x16[PLANE_PRED8x8  ]= pred16x16_plane_c;
+    switch(codec_id){
+    case CODEC_ID_SVQ3:
+       h->pred16x16[PLANE_PRED8x8  ]= pred16x16_plane_svq3_c;
+       break;
+    case CODEC_ID_RV40: //FIXME find right predictor
+       h->pred16x16[PLANE_PRED8x8  ]= pred16x16_plane_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;

Modified: rv40/h264pred.h
==============================================================================
--- rv40/h264pred.h	(original)
+++ rv40/h264pred.h	Wed Aug  1 13:28:58 2007
@@ -48,12 +48,8 @@
 #define TOP_DC_PRED           10
 #define DC_128_PRED           11
 
-#define DIAG_DOWN_LEFT_PRED_RV40          12
-#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN   13
-#define DIAG_DOWN_LEFT_PRED_RV40_NOTOP    14
-#define VERT_LEFT_PRED_RV40               15
-#define HOR_UP_PRED_RV40                  16
-#define HOR_UP_PRED_RV40_NODOWN           17
+#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN   12
+#define HOR_UP_PRED_RV40_NODOWN           13
 
 #define DC_PRED8x8            0
 #define HOR_PRED8x8           1
@@ -69,12 +65,12 @@
  * Context for storing H.264 prediction functions
  */
 typedef struct H264PredContext{
-    void (*pred4x4  [9+3+6])(uint8_t *src, uint8_t *topright, int stride);//FIXME move to dsp?
+    void (*pred4x4  [9+3+2])(uint8_t *src, uint8_t *topright, int stride);//FIXME move to dsp?
     void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride);
     void (*pred8x8  [4+3])(uint8_t *src, int stride);
     void (*pred16x16[4+3])(uint8_t *src, int stride);
 }H264PredContext;
 
-void ff_h264_pred_init(H264PredContext *h);
+void ff_h264_pred_init(H264PredContext *h, int codec_id);
 
 #endif /* H264PRED_H */

Modified: rv40/rv40.c
==============================================================================
--- rv40/rv40.c	(original)
+++ rv40/rv40.c	Wed Aug  1 13:28:58 2007
@@ -651,8 +651,8 @@ static int rv40_decode_mb_info(RV40DecCo
 
 /** Mapping of RV40 intra prediction types to standard H.264 types */
 static const int ittrans[9] = {
- DC_PRED, VERT_PRED, HOR_PRED, DIAG_DOWN_RIGHT_PRED, DIAG_DOWN_LEFT_PRED_RV40,
- VERT_RIGHT_PRED, VERT_LEFT_PRED_RV40, HOR_UP_PRED_RV40, HOR_DOWN_PRED,
+ DC_PRED, VERT_PRED, HOR_PRED, DIAG_DOWN_RIGHT_PRED, DIAG_DOWN_LEFT_PRED,
+ VERT_RIGHT_PRED, VERT_LEFT_PRED, HOR_UP_PRED, HOR_DOWN_PRED,
 };
 
 /** Mapping of RV40 intra 16x16 prediction types to standard H.264 types */
@@ -673,15 +673,14 @@ static void rv40_pred_4x4_block(RV40DecC
     else if(no_up){
         if(itype == VERT_PRED) itype = HOR_PRED;
         if(itype == DC_PRED)   itype = LEFT_DC_PRED;
-        if(itype == DIAG_DOWN_LEFT_PRED_RV40) itype = DIAG_DOWN_LEFT_PRED_RV40_NOTOP;
     }else if(no_left){
         if(itype == HOR_PRED)  itype = VERT_PRED;
         if(itype == DC_PRED)   itype = TOP_DC_PRED;
-        if(itype == DIAG_DOWN_LEFT_PRED_RV40) itype = DIAG_DOWN_LEFT_PRED;
+        if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN;
     }
     if(no_down){
-        if(itype == DIAG_DOWN_LEFT_PRED_RV40) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN;
-        if(itype == HOR_UP_PRED_RV40) itype = HOR_UP_PRED_RV40_NODOWN;
+        if(itype == DIAG_DOWN_LEFT_PRED) itype = DIAG_DOWN_LEFT_PRED_RV40_NODOWN;
+        if(itype == HOR_UP_PRED) itype = HOR_UP_PRED_RV40_NODOWN;
     }
     if(no_right){
         topleft = dst[-stride + 3] * 0x01010101;
@@ -948,7 +947,7 @@ static int rv40_decode_init(AVCodecConte
     if (MPV_common_init(s) < 0)
         return -1;
 
-    ff_h264_pred_init(&r->h);
+    ff_h264_pred_init(&r->h, s->codec_id);
 
     r->intra_types_stride = (s->mb_width + 1) * 4;
     r->intra_types_hist = av_malloc(r->intra_types_stride * 4 * 2 * sizeof(int));



More information about the FFmpeg-soc mailing list