mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-11 06:28:09 +02:00
[g3dvl] make mv weights a public interface
This commit is contained in:
parent
44477ac489
commit
7a5390b06f
3 changed files with 61 additions and 99 deletions
|
|
@ -211,46 +211,30 @@ vl_vb_map(struct vl_vertex_buffer *buffer, struct pipe_context *pipe)
|
|||
static void
|
||||
get_motion_vectors(struct pipe_mpeg12_macroblock *mb, struct vertex2s mv[4])
|
||||
{
|
||||
if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BI ||
|
||||
mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_FWD) {
|
||||
if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
|
||||
mv[0].x = mv[1].x = mb->mv[0].top.x;
|
||||
mv[0].y = mv[1].y = mb->mv[0].top.y;
|
||||
mv[2].x = mv[3].x = mb->mv[1].top.x;
|
||||
mv[2].y = mv[3].y = mb->mv[1].top.y;
|
||||
|
||||
if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
|
||||
mv[0].x = mv[1].x = mb->mv[0].top.x;
|
||||
mv[0].y = mv[1].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);
|
||||
|
||||
mv[1].x = mb->mv[0].bottom.x;
|
||||
mv[1].y = mb->mv[0].bottom.y - (mb->mv[0].bottom.y % 4);
|
||||
|
||||
if (mb->mv[0].top.field_select) mv[0].y += 2;
|
||||
if (!mb->mv[0].bottom.field_select) mv[1].y -= 2;
|
||||
}
|
||||
} else {
|
||||
mv[0].x = mv[0].y = mv[1].x = mv[1].y = 0x8000;
|
||||
}
|
||||
mv[0].x = mb->mv[0].top.x;
|
||||
mv[0].y = mb->mv[0].top.y - (mb->mv[0].top.y % 4);
|
||||
|
||||
if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BI ||
|
||||
mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD) {
|
||||
mv[1].x = mb->mv[0].bottom.x;
|
||||
mv[1].y = mb->mv[0].bottom.y - (mb->mv[0].bottom.y % 4);
|
||||
|
||||
if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
|
||||
mv[2].x = mv[3].x = mb->mv[1].top.x;
|
||||
mv[2].y = mv[3].y = mb->mv[1].top.y;
|
||||
if (mb->mv[0].top.field_select) mv[0].y += 2;
|
||||
if (!mb->mv[0].bottom.field_select) mv[1].y -= 2;
|
||||
|
||||
} else {
|
||||
mv[2].x = mb->mv[1].top.x;
|
||||
mv[2].y = mb->mv[1].top.y - (mb->mv[1].top.y % 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->mv[1].bottom.x;
|
||||
mv[3].y = mb->mv[1].bottom.y - (mb->mv[1].bottom.y % 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->mv[1].top.field_select) mv[2].y += 2;
|
||||
if (!mb->mv[1].bottom.field_select) mv[3].y -= 2;
|
||||
}
|
||||
} else {
|
||||
mv[2].x = mv[2].y = mv[3].x = mv[3].y = 0x8000;
|
||||
if (mb->mv[1].top.field_select) mv[2].y += 2;
|
||||
if (!mb->mv[1].bottom.field_select) mv[3].y -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -279,29 +263,10 @@ vl_vb_add_block(struct vl_vertex_buffer *buffer, struct pipe_mpeg12_macroblock *
|
|||
stream->eb[i][j][k] = !(mb->cbp & (*empty_block_mask)[i][j][k]);
|
||||
|
||||
stream->dct_type_field = mb->dct_type == PIPE_MPEG12_DCT_TYPE_FIELD;
|
||||
//stream->mo_type_frame = mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME;
|
||||
stream->mb_type_intra = mb->mb_type != PIPE_MPEG12_MACROBLOCK_TYPE_INTRA;
|
||||
switch (mb->mb_type) {
|
||||
case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
|
||||
stream->mv_wheights[0] = 255;
|
||||
stream->mv_wheights[1] = 0;
|
||||
break;
|
||||
|
||||
case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
|
||||
stream->mv_wheights[0] = 127;
|
||||
stream->mv_wheights[1] = 127;
|
||||
break;
|
||||
|
||||
case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
|
||||
stream->mv_wheights[0] = 0;
|
||||
stream->mv_wheights[1] = 255;
|
||||
break;
|
||||
|
||||
default:
|
||||
stream->mv_wheights[0] = 0;
|
||||
stream->mv_wheights[1] = 0;
|
||||
}
|
||||
stream->mb_type_intra = !mb->dct_intra;
|
||||
|
||||
stream->mv_wheights[0] = mb->mv[0].wheight;
|
||||
stream->mv_wheights[1] = mb->mv[1].wheight;
|
||||
get_motion_vectors(mb, stream->mv);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,16 +50,6 @@ enum pipe_mpeg12_picture_type
|
|||
PIPE_MPEG12_PICTURE_TYPE_FRAME
|
||||
};
|
||||
|
||||
enum pipe_mpeg12_macroblock_type
|
||||
{
|
||||
PIPE_MPEG12_MACROBLOCK_TYPE_INTRA,
|
||||
PIPE_MPEG12_MACROBLOCK_TYPE_FWD,
|
||||
PIPE_MPEG12_MACROBLOCK_TYPE_BKWD,
|
||||
PIPE_MPEG12_MACROBLOCK_TYPE_BI,
|
||||
|
||||
PIPE_MPEG12_MACROBLOCK_NUM_TYPES
|
||||
};
|
||||
|
||||
enum pipe_mpeg12_motion_type
|
||||
{
|
||||
PIPE_MPEG12_MOTION_TYPE_FIELD,
|
||||
|
|
@ -91,10 +81,11 @@ struct pipe_mpeg12_macroblock
|
|||
|
||||
unsigned mbx;
|
||||
unsigned mby;
|
||||
enum pipe_mpeg12_macroblock_type mb_type;
|
||||
enum pipe_mpeg12_motion_type mo_type;
|
||||
bool dct_intra;
|
||||
enum pipe_mpeg12_dct_type dct_type;
|
||||
struct {
|
||||
unsigned wheight:8;
|
||||
struct pipe_mpeg12_motionvector top, bottom;
|
||||
} mv[2];
|
||||
unsigned cbp;
|
||||
|
|
|
|||
|
|
@ -37,24 +37,6 @@
|
|||
#include <util/u_math.h>
|
||||
#include "xvmc_private.h"
|
||||
|
||||
static enum pipe_mpeg12_macroblock_type TypeToPipe(int xvmc_mb_type)
|
||||
{
|
||||
if (xvmc_mb_type & XVMC_MB_TYPE_INTRA)
|
||||
return PIPE_MPEG12_MACROBLOCK_TYPE_INTRA;
|
||||
if ((xvmc_mb_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) == XVMC_MB_TYPE_MOTION_FORWARD)
|
||||
return PIPE_MPEG12_MACROBLOCK_TYPE_FWD;
|
||||
if ((xvmc_mb_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) == XVMC_MB_TYPE_MOTION_BACKWARD)
|
||||
return PIPE_MPEG12_MACROBLOCK_TYPE_BKWD;
|
||||
if ((xvmc_mb_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) == (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD))
|
||||
return PIPE_MPEG12_MACROBLOCK_TYPE_BI;
|
||||
|
||||
assert(0);
|
||||
|
||||
XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized mb type 0x%08X.\n", xvmc_mb_type);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static enum pipe_mpeg12_picture_type PictureToPipe(int xvmc_pic)
|
||||
{
|
||||
switch (xvmc_pic) {
|
||||
|
|
@ -73,21 +55,21 @@ static enum pipe_mpeg12_picture_type PictureToPipe(int xvmc_pic)
|
|||
return -1;
|
||||
}
|
||||
|
||||
static enum pipe_mpeg12_motion_type MotionToPipe(int xvmc_motion_type, unsigned int xvmc_picture_structure)
|
||||
static enum pipe_mpeg12_motion_type MotionToPipe(int xvmc_motion_type, unsigned xvmc_picture_structure)
|
||||
{
|
||||
switch (xvmc_motion_type) {
|
||||
case XVMC_PREDICTION_FRAME:
|
||||
if (xvmc_picture_structure == XVMC_FRAME_PICTURE)
|
||||
return PIPE_MPEG12_MOTION_TYPE_FRAME;
|
||||
else
|
||||
return PIPE_MPEG12_MOTION_TYPE_16x8;
|
||||
break;
|
||||
case XVMC_PREDICTION_FIELD:
|
||||
return PIPE_MPEG12_MOTION_TYPE_FIELD;
|
||||
case XVMC_PREDICTION_DUAL_PRIME:
|
||||
return PIPE_MPEG12_MOTION_TYPE_DUALPRIME;
|
||||
default:
|
||||
assert(0);
|
||||
case XVMC_PREDICTION_FRAME:
|
||||
if (xvmc_picture_structure == XVMC_FRAME_PICTURE)
|
||||
return PIPE_MPEG12_MOTION_TYPE_FRAME;
|
||||
else
|
||||
return PIPE_MPEG12_MOTION_TYPE_16x8;
|
||||
break;
|
||||
|
||||
case XVMC_PREDICTION_FIELD:
|
||||
return PIPE_MPEG12_MOTION_TYPE_FIELD;
|
||||
|
||||
case XVMC_PREDICTION_DUAL_PRIME:
|
||||
return PIPE_MPEG12_MOTION_TYPE_DUALPRIME;
|
||||
}
|
||||
|
||||
XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized motion type 0x%08X (with picture structure 0x%08X).\n", xvmc_motion_type, xvmc_picture_structure);
|
||||
|
|
@ -118,15 +100,39 @@ MacroBlocksToPipe(struct pipe_screen *screen,
|
|||
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)
|
||||
|
||||
if (!xvmc_mb->macroblock_type & XVMC_MB_TYPE_INTRA)
|
||||
mb->mo_type = MotionToPipe(xvmc_mb->motion_type, xvmc_picture_structure);
|
||||
/* Get rid of Valgrind 'undefined' warnings */
|
||||
else
|
||||
mb->mo_type = -1;
|
||||
|
||||
mb->dct_intra = xvmc_mb->macroblock_type & XVMC_MB_TYPE_INTRA;
|
||||
mb->dct_type = xvmc_mb->dct_type == XVMC_DCT_TYPE_FIELD ?
|
||||
PIPE_MPEG12_DCT_TYPE_FIELD : PIPE_MPEG12_DCT_TYPE_FRAME;
|
||||
|
||||
switch (xvmc_mb->macroblock_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) {
|
||||
case XVMC_MB_TYPE_MOTION_FORWARD:
|
||||
mb->mv[0].wheight = 255;
|
||||
mb->mv[1].wheight = 0;
|
||||
break;
|
||||
|
||||
case (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD):
|
||||
mb->mv[0].wheight = 127;
|
||||
mb->mv[1].wheight = 127;
|
||||
break;
|
||||
|
||||
case XVMC_MB_TYPE_MOTION_BACKWARD:
|
||||
mb->mv[0].wheight = 0;
|
||||
mb->mv[1].wheight = 255;
|
||||
break;
|
||||
|
||||
default:
|
||||
mb->mv[0].wheight = 0;
|
||||
mb->mv[1].wheight = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
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];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue