[g3dvl] rename motion vector fields

This commit is contained in:
Christian König 2011-03-20 21:34:38 +01:00
parent dd6cd206a6
commit bac8760f7f
3 changed files with 64 additions and 60 deletions

View file

@ -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->pmv[0][1][0];
mv[0].y = mb->pmv[0][1][1];
} 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->pmv[1][1][0];
mv[1].y = mb->pmv[1][1][1] - (mb->pmv[1][1][1] % 4);
if(mb->mvfs[0][1]) mv[0].y += 2;
if(!mb->mvfs[1][1]) mv[1].y -= 2;
}
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;
} else {
mv[0].x = mb->mv[0].top.x;
mv[0].y = mb->mv[0].top.y - (mb->mv[0].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];
mv[1].x = mb->mv[0].bottom.x;
mv[1].y = mb->mv[0].bottom.y - (mb->mv[0].bottom.y % 4);
} else {
mv[0].x = mb->pmv[0][0][0];
mv[0].y = mb->pmv[0][0][1] - (mb->pmv[0][0][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;
mv[1].x = mb->pmv[1][0][0];
mv[1].y = mb->pmv[1][0][1] - (mb->pmv[1][0][1] % 4);
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;
if(mb->mvfs[0][0]) mv[0].y += 2;
if(!mb->mvfs[1][0]) mv[1].y -= 2;
}
} else {
mv[0].x = mb->mv[1].top.x;
mv[0].y = mb->mv[1].top.y - (mb->mv[1].top.y % 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->mv[1].top.field_select) mv[0].y += 2;
if (!mb->mv[1].bottom.field_select) mv[1].y -= 2;
}
}
default:

View file

@ -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;
};

View file

@ -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;
}
}