Mesa (pipe-video): [g3dvl] rename motion vector fields

Christian König deathsimple at kemper.freedesktop.org
Thu Mar 24 20:25:41 UTC 2011


Module: Mesa
Branch: pipe-video
Commit: bac8760f7f3523e9b6d5b2fd7cd46091d4883f5e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bac8760f7f3523e9b6d5b2fd7cd46091d4883f5e

Author: Christian König <deathsimple at vodafone.de>
Date:   Sun Mar 20 21:34:38 2011 +0100

[g3dvl] rename motion vector fields

---

 src/gallium/auxiliary/vl/vl_vertex_buffers.c   |   64 +++++++++++-------------
 src/gallium/include/pipe/p_video_state.h       |   12 +++-
 src/gallium/state_trackers/xorg/xvmc/surface.c |   44 +++++++++--------
 3 files changed, 62 insertions(+), 58 deletions(-)

diff --git a/src/gallium/auxiliary/vl/vl_vertex_buffers.c b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
index c5366e8..928910f 100644
--- a/src/gallium/auxiliary/vl/vl_vertex_buffers.c
+++ b/src/gallium/auxiliary/vl/vl_vertex_buffers.c
@@ -212,58 +212,54 @@ get_motion_vectors(struct pipe_mpeg12_macroblock *mb, struct vertex2s mv[4])
       case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
       {
          if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
-            mv[2].x = mb->pmv[0][1][0];
-            mv[2].y = mb->pmv[0][1][1];
+            mv[2].x = mb->mv[1].top.x;
+            mv[2].y = mb->mv[1].top.y;
 
          } else {
-            mv[2].x = mb->pmv[0][1][0];
-            mv[2].y = mb->pmv[0][1][1] - (mb->pmv[0][1][1] % 4);
+            mv[2].x = mb->mv[1].top.x;
+            mv[2].y = mb->mv[1].top.y - (mb->mv[1].top.y % 4);
 
-            mv[3].x = mb->pmv[1][1][0];
-            mv[3].y = mb->pmv[1][1][1] - (mb->pmv[1][1][1] % 4);
+            mv[3].x = mb->mv[1].bottom.x;
+            mv[3].y = mb->mv[1].bottom.y - (mb->mv[1].bottom.y % 4);
 
-            if(mb->mvfs[0][1]) mv[2].y += 2;
-            if(!mb->mvfs[1][1]) mv[3].y -= 2;
+            if (mb->mv[1].top.field_select) mv[2].y += 2;
+            if (!mb->mv[1].bottom.field_select) mv[3].y -= 2;
          }
 
          /* fall-through */
       }
       case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
-      case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
       {
-         if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD) {
+         if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
+            mv[0].x = mb->mv[0].top.x;
+            mv[0].y = mb->mv[0].top.y;
 
-            if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
-               mv[0].x = mb->pmv[0][1][0];
-               mv[0].y = mb->pmv[0][1][1];
+         } else {
+            mv[0].x = mb->mv[0].top.x;
+            mv[0].y = mb->mv[0].top.y - (mb->mv[0].top.y % 4);
 
-            } else {
-               mv[0].x = mb->pmv[0][1][0];
-               mv[0].y = mb->pmv[0][1][1] - (mb->pmv[0][1][1] % 4);
+            mv[1].x = mb->mv[0].bottom.x;
+            mv[1].y = mb->mv[0].bottom.y - (mb->mv[0].bottom.y % 4);
 
-               mv[1].x = mb->pmv[1][1][0];
-               mv[1].y = mb->pmv[1][1][1] - (mb->pmv[1][1][1] % 4);
+            if (mb->mv[0].top.field_select) mv[0].y += 2;
+            if (!mb->mv[0].bottom.field_select) mv[1].y -= 2;
+         }
+         break;
 
-               if(mb->mvfs[0][1]) mv[0].y += 2;
-               if(!mb->mvfs[1][1]) mv[1].y -= 2;
-            }
+      case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
+         if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
+            mv[0].x = mb->mv[1].top.x;
+            mv[0].y = mb->mv[1].top.y;
 
          } else {
+            mv[0].x = mb->mv[1].top.x;
+            mv[0].y = mb->mv[1].top.y - (mb->mv[1].top.y % 4);
 
-            if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
-               mv[0].x = mb->pmv[0][0][0];
-               mv[0].y = mb->pmv[0][0][1];
-
-            } else {
-               mv[0].x = mb->pmv[0][0][0];
-               mv[0].y = mb->pmv[0][0][1] - (mb->pmv[0][0][1] % 4);
-
-               mv[1].x = mb->pmv[1][0][0];
-               mv[1].y = mb->pmv[1][0][1] - (mb->pmv[1][0][1] % 4);
+            mv[1].x = mb->mv[1].bottom.x;
+            mv[1].y = mb->mv[1].bottom.y - (mb->mv[1].bottom.y % 4);
 
-               if(mb->mvfs[0][0]) mv[0].y += 2;
-               if(!mb->mvfs[1][0]) mv[1].y -= 2;
-            }
+            if (mb->mv[1].top.field_select) mv[0].y += 2;
+            if (!mb->mv[1].bottom.field_select) mv[1].y -= 2;
          }
       }
       default:
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
index 1cb555b..c620472 100644
--- a/src/gallium/include/pipe/p_video_state.h
+++ b/src/gallium/include/pipe/p_video_state.h
@@ -74,12 +74,17 @@ enum pipe_mpeg12_dct_type
    PIPE_MPEG12_DCT_TYPE_FRAME
 };
 
-
 struct pipe_macroblock
 {
    enum pipe_video_codec codec;
 };
 
+struct pipe_mpeg12_motionvector
+{
+   signed x, y;
+   bool field_select;
+};
+
 struct pipe_mpeg12_macroblock
 {
    struct pipe_macroblock base;
@@ -89,8 +94,9 @@ struct pipe_mpeg12_macroblock
    enum pipe_mpeg12_macroblock_type mb_type;
    enum pipe_mpeg12_motion_type mo_type;
    enum pipe_mpeg12_dct_type dct_type;
-   signed pmv[2][2][2];
-   bool mvfs[2][2];
+   struct {
+      struct pipe_mpeg12_motionvector top, bottom;
+   } mv[2];
    unsigned cbp;
    short *blocks;
 };
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
index ef7ea92..5896cdc 100644
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ b/src/gallium/state_trackers/xorg/xvmc/surface.c
@@ -153,45 +153,47 @@ MacroBlocksToPipe(struct pipe_screen *screen,
                   const XvMCBlockArray *xvmc_blocks,
                   unsigned int first_macroblock,
                   unsigned int num_macroblocks,
-                  struct pipe_mpeg12_macroblock *pipe_macroblocks)
+                  struct pipe_mpeg12_macroblock *mb)
 {
    unsigned int i, j, k, l;
    XvMCMacroBlock *xvmc_mb;
 
    assert(xvmc_macroblocks);
    assert(xvmc_blocks);
-   assert(pipe_macroblocks);
+   assert(mb);
    assert(num_macroblocks);
 
    xvmc_mb = xvmc_macroblocks->macro_blocks + first_macroblock;
 
    for (i = 0; i < num_macroblocks; ++i) {
-      pipe_macroblocks->base.codec = PIPE_VIDEO_CODEC_MPEG12;
-      pipe_macroblocks->mbx = xvmc_mb->x;
-      pipe_macroblocks->mby = xvmc_mb->y;
-      pipe_macroblocks->mb_type = TypeToPipe(xvmc_mb->macroblock_type);
-      if (pipe_macroblocks->mb_type != PIPE_MPEG12_MACROBLOCK_TYPE_INTRA)
-         pipe_macroblocks->mo_type = MotionToPipe(xvmc_mb->motion_type, xvmc_picture_structure);
+      mb->base.codec = PIPE_VIDEO_CODEC_MPEG12;
+      mb->mbx = xvmc_mb->x;
+      mb->mby = xvmc_mb->y;
+      mb->mb_type = TypeToPipe(xvmc_mb->macroblock_type);
+      if (mb->mb_type != PIPE_MPEG12_MACROBLOCK_TYPE_INTRA)
+         mb->mo_type = MotionToPipe(xvmc_mb->motion_type, xvmc_picture_structure);
       /* Get rid of Valgrind 'undefined' warnings */
       else
-         pipe_macroblocks->mo_type = -1;
-      pipe_macroblocks->dct_type = xvmc_mb->dct_type == XVMC_DCT_TYPE_FIELD ?
+         mb->mo_type = -1;
+      mb->dct_type = xvmc_mb->dct_type == XVMC_DCT_TYPE_FIELD ?
          PIPE_MPEG12_DCT_TYPE_FIELD : PIPE_MPEG12_DCT_TYPE_FRAME;
 
-      for (j = 0; j < 2; ++j)
-         for (k = 0; k < 2; ++k)
-            for (l = 0; l < 2; ++l)
-               pipe_macroblocks->pmv[j][k][l] = xvmc_mb->PMV[j][k][l];
+      for (j = 0; j < 2; ++j) {
+         mb->mv[j].top.x = xvmc_mb->PMV[0][j][0];
+         mb->mv[j].top.y = xvmc_mb->PMV[0][j][1];
+         mb->mv[j].bottom.x = xvmc_mb->PMV[1][j][0];
+         mb->mv[j].bottom.y = xvmc_mb->PMV[1][j][1];
+      }
 
-      pipe_macroblocks->mvfs[0][0] = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_FIRST_FORWARD;
-      pipe_macroblocks->mvfs[0][1] = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_FIRST_BACKWARD;
-      pipe_macroblocks->mvfs[1][0] = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_SECOND_FORWARD;
-      pipe_macroblocks->mvfs[1][1] = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_SECOND_BACKWARD;
+      mb->mv[0].top.field_select = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_FIRST_FORWARD;
+      mb->mv[1].top.field_select = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_FIRST_BACKWARD;
+      mb->mv[0].bottom.field_select = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_SECOND_FORWARD;
+      mb->mv[1].bottom.field_select = xvmc_mb->motion_vertical_field_select & XVMC_SELECT_SECOND_BACKWARD;
 
-      pipe_macroblocks->cbp = xvmc_mb->coded_block_pattern;
-      pipe_macroblocks->blocks = xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES;
+      mb->cbp = xvmc_mb->coded_block_pattern;
+      mb->blocks = xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES;
 
-      ++pipe_macroblocks;
+      ++mb;
       ++xvmc_mb;
    }
 }




More information about the mesa-commit mailing list