[Ffmpeg-cvslog] r5694 - in trunk/libavcodec: cavs.c cavsdata.h

michael subversion
Sun Jul 9 17:20:19 CEST 2006


Author: michael
Date: Sun Jul  9 17:20:18 2006
New Revision: 5694

Modified:
   trunk/libavcodec/cavs.c
   trunk/libavcodec/cavsdata.h

Log:
simplify


Modified: trunk/libavcodec/cavs.c
==============================================================================
--- trunk/libavcodec/cavs.c	(original)
+++ trunk/libavcodec/cavs.c	Sun Jul  9 17:20:18 2006
@@ -104,26 +104,18 @@
  *
  ****************************************************************************/
 
-static inline int get_bs_p(vector_t *mvP, vector_t *mvQ) {
+static inline int get_bs(vector_t *mvP, vector_t *mvQ, int b) {
     if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA))
         return 2;
-    if(mvP->ref != mvQ->ref)
-        return 1;
     if( (abs(mvP->x - mvQ->x) >= 4) ||  (abs(mvP->y - mvQ->y) >= 4) )
         return 1;
-    return 0;
-}
-
-static inline int get_bs_b(vector_t *mvP, vector_t *mvQ) {
-    if((mvP->ref == REF_INTRA) || (mvQ->ref == REF_INTRA)) {
-        return 2;
-    } else {
-        vector_t *mvPbw = mvP + MV_BWD_OFFS;
-        vector_t *mvQbw = mvQ + MV_BWD_OFFS;
-        if( (abs(  mvP->x -   mvQ->x) >= 4) ||
-            (abs(  mvP->y -   mvQ->y) >= 4) ||
-            (abs(mvPbw->x - mvQbw->x) >= 4) ||
-            (abs(mvPbw->y - mvQbw->y) >= 4) )
+    if(b){
+        mvP += MV_BWD_OFFS;
+        mvQ += MV_BWD_OFFS;
+        if( (abs(mvP->x - mvQ->x) >= 4) ||  (abs(mvP->y - mvQ->y) >= 4) )
+            return 1;
+    }else{
+        if(mvP->ref != mvQ->ref)
             return 1;
     }
     return 0;
@@ -165,52 +157,23 @@
         h->left_border_v[i+1] = *(h->cv + 7 + i*h->c_stride);
     }
     if(!h->loop_filter_disable) {
-        /* clear bs */
-        *((uint64_t *)bs) = 0;
         /* determine bs */
-        switch(mb_type) {
-        case I_8X8:
+        if(mb_type == I_8X8)
             *((uint64_t *)bs) = 0x0202020202020202ULL;
-            break;
-        case P_8X8:
-        case P_8X16:
-            bs[2] = get_bs_p(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
-            bs[3] = get_bs_p(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3]);
-        case P_16X8:
-            bs[6] = get_bs_p(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
-            bs[7] = get_bs_p(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3]);
-        case P_16X16:
-        case P_SKIP:
-            bs[0] = get_bs_p(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
-            bs[1] = get_bs_p(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
-            bs[4] = get_bs_p(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
-            bs[5] = get_bs_p(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
-            break;
-        case B_SKIP:
-        case B_DIRECT:
-        case B_8X8:
-            bs[2] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
-            bs[3] = get_bs_b(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3]);
-            bs[6] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
-            bs[7] = get_bs_b(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3]);
-        case B_FWD_16X16:
-        case B_BWD_16X16:
-        case B_SYM_16X16:
-            bs[0] = get_bs_b(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
-            bs[1] = get_bs_b(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
-            bs[4] = get_bs_b(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
-            bs[5] = get_bs_b(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
-            break;
-        default:
-            if(mb_type & 1) { //16X8
-                bs[6] = bs[7] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2]);
-            } else {          //8X16
-                bs[2] = bs[3] = get_bs_b(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1]);
+        else{
+            *((uint64_t *)bs) = 0;
+            if(partition_flags[mb_type] & SPLITV){
+                bs[2] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X1], mb_type > P_8X8);
+                bs[3] = get_bs(&h->mv[MV_FWD_X2], &h->mv[MV_FWD_X3], mb_type > P_8X8);
             }
-            bs[0] = get_bs_b(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0]);
-            bs[1] = get_bs_b(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2]);
-            bs[4] = get_bs_b(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0]);
-            bs[5] = get_bs_b(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1]);
+            if(partition_flags[mb_type] & SPLITH){
+                bs[6] = get_bs(&h->mv[MV_FWD_X0], &h->mv[MV_FWD_X2], mb_type > P_8X8);
+                bs[7] = get_bs(&h->mv[MV_FWD_X1], &h->mv[MV_FWD_X3], mb_type > P_8X8);
+            }
+            bs[0] = get_bs(&h->mv[MV_FWD_A1], &h->mv[MV_FWD_X0], mb_type > P_8X8);
+            bs[1] = get_bs(&h->mv[MV_FWD_A3], &h->mv[MV_FWD_X2], mb_type > P_8X8);
+            bs[4] = get_bs(&h->mv[MV_FWD_B2], &h->mv[MV_FWD_X0], mb_type > P_8X8);
+            bs[5] = get_bs(&h->mv[MV_FWD_B3], &h->mv[MV_FWD_X1], mb_type > P_8X8);
         }
         if( *((uint64_t *)bs) ) {
             if(h->flags & A_AVAIL) {
@@ -486,19 +449,13 @@
 }
 
 static void inter_pred(AVSContext *h, enum mb_t mb_type) {
-    switch(mb_type) {
-    case P_SKIP:
-    case P_16X16:
-    case B_FWD_16X16:
-    case B_BWD_16X16:
-    case B_SYM_16X16:
+    if(partition_flags[mb_type] == 0){ // 16x16
         mc_part_std(h, 1, 8, 0, h->cy, h->cu, h->cv, 0, 0,
                 h->s.dsp.put_cavs_qpel_pixels_tab[0],
                 h->s.dsp.put_h264_chroma_pixels_tab[0],
                 h->s.dsp.avg_cavs_qpel_pixels_tab[0],
                 h->s.dsp.avg_h264_chroma_pixels_tab[0],&h->mv[MV_FWD_X0]);
-        break;
-    default:
+    }else{
         mc_part_std(h, 1, 4, 0, h->cy, h->cu, h->cv, 0, 0,
                 h->s.dsp.put_cavs_qpel_pixels_tab[1],
                 h->s.dsp.put_h264_chroma_pixels_tab[1],
@@ -519,7 +476,6 @@
                 h->s.dsp.put_h264_chroma_pixels_tab[1],
                 h->s.dsp.avg_cavs_qpel_pixels_tab[1],
                 h->s.dsp.avg_h264_chroma_pixels_tab[1],&h->mv[MV_FWD_X3]);
-        break;
     }
     /* set intra prediction modes to default values */
     h->pred_mode_Y[3] =  h->pred_mode_Y[6] = INTRA_L_LP;
@@ -1102,7 +1058,7 @@
         break;
     default:
         assert((mb_type > B_SYM_16X16) && (mb_type < B_8X8));
-        flags = b_partition_flags[(mb_type-1)>>1];
+        flags = partition_flags[mb_type];
         if(mb_type & 1) { /* 16x8 macroblock types */
             if(flags & FWD0)
                 mv_pred(h, MV_FWD_X0, MV_FWD_C2, MV_PRED_TOP,  BLK_16X8, 1);

Modified: trunk/libavcodec/cavsdata.h
==============================================================================
--- trunk/libavcodec/cavsdata.h	(original)
+++ trunk/libavcodec/cavsdata.h	Sun Jul  9 17:20:18 2006
@@ -41,6 +41,8 @@
 #define BWD1                          0x08
 #define SYM0                          0x10
 #define SYM1                          0x20
+#define SPLITH                        0x40
+#define SPLITV                        0x80
 
 #define MV_BWD_OFFS                     12
 #define MV_STRIDE                        4
@@ -127,17 +129,37 @@
   MV_BWD_X3
 };
 
-static const uint8_t b_partition_flags[14] = {
-  0,0,0,0,0,
-  FWD0|FWD1,
-  BWD0|BWD1,
-  FWD0|BWD1,
-  BWD0|FWD1,
-  FWD0|SYM1,
-  BWD0|SYM1,
-  SYM0|FWD1,
-  SYM0|BWD1,
-  SYM0|SYM1
+static const uint8_t partition_flags[30] = {
+  0,                      //I_8X8
+  0,                      //P_SKIP
+  0,                      //P_16X16
+            SPLITH,       //P_16X8
+                   SPLITV,//P_8X16
+            SPLITH|SPLITV,//P_8X8
+            SPLITH|SPLITV,//B_SKIP
+            SPLITH|SPLITV,//B_DIRECT
+  0,                      //B_FWD_16X16
+  0,                      //B_BWD_16X16
+  0,                      //B_SYM_16X16
+  FWD0|FWD1|SPLITH,
+  FWD0|FWD1       |SPLITV,
+  BWD0|BWD1|SPLITH,
+  BWD0|BWD1       |SPLITV,
+  FWD0|BWD1|SPLITH,
+  FWD0|BWD1       |SPLITV,
+  BWD0|FWD1|SPLITH,
+  BWD0|FWD1       |SPLITV,
+  FWD0|SYM1|SPLITH,
+  FWD0|SYM1       |SPLITV,
+  BWD0|SYM1|SPLITH,
+  BWD0|SYM1       |SPLITV,
+  SYM0|FWD1|SPLITH,
+  SYM0|FWD1       |SPLITV,
+  SYM0|BWD1|SPLITH,
+  SYM0|BWD1       |SPLITV,
+  SYM0|SYM1|SPLITH,
+  SYM0|SYM1       |SPLITV,
+            SPLITH|SPLITV,//B_8X8 = 29
 };
 
 static const uint8_t scan3x3[4] = {4,5,7,8};




More information about the ffmpeg-cvslog mailing list