📄 md_common.c
字号:
if (bipred_me && (img->MbaffFrameFlag || (params->UseRDOQuant && params->RDOQ_QP_Num > 1)))
{
memcpy(rdopt->all_mv [LIST_0][l0_ref][P16x8][pos][0], all_mv [LIST_0][l0_ref][P16x8][pos][0], 2 * BLOCK_MULTIPLE * 2 * sizeof(short));
memcpy(rdopt->all_mv [LIST_1][l1_ref][P16x8][pos][0], all_mv [LIST_1][l1_ref][P16x8][pos][0], 2 * BLOCK_MULTIPLE * 2 * sizeof(short));
}
}
}
/*!
*************************************************************************************
* \brief
* Sets motion vectors for a 8x16 partition in a B Slice
*************************************************************************************
*/
static void SetMVBSlice8x16(PicMotionParams *motion, Macroblock* currMB, int pos)
{
int l0_ref, l1_ref;
int pdir = currMB->b8pdir[pos >> 1];
if (pdir == LIST_0)
{
l0_ref = motion->ref_idx[LIST_0][img->block_y][img->block_x + pos];
CopyMVBlock8 (motion->mv[LIST_0], img->all_mv [LIST_0][l0_ref][P8x16], 0, 4, pos);
ResetMVBlock8(motion->mv[LIST_1], 0, 4, pos);
ResetRefBlock8(motion->ref_idx[LIST_1], 0, 4, pos);
}
else if (pdir == LIST_1)
{
ResetMVBlock8(motion->mv[LIST_0], 0, 4, pos);
ResetRefBlock8(motion->ref_idx[LIST_0], 0, 4, pos);
l1_ref = motion->ref_idx[LIST_1][img->block_y][img->block_x + pos];
CopyMVBlock8 (motion->mv[LIST_1], img->all_mv [LIST_1][l1_ref][P8x16], 0, 4, pos);
}
else
{
int bipred_me = currMB->bipred_me[pos >> 1];
short ******all_mv = bipred_me ? img->bipred_mv[bipred_me - 1]: img->all_mv;
l0_ref = motion->ref_idx[LIST_0][img->block_y][img->block_x + pos];
CopyMVBlock8(motion->mv [LIST_0], all_mv [LIST_0][l0_ref][P8x16], 0, 4, pos);
l1_ref = motion->ref_idx[LIST_1][img->block_y][img->block_x + pos];
CopyMVBlock8(motion->mv [LIST_1], all_mv [LIST_1][l1_ref][P8x16], 0, 4, pos);
if (bipred_me && (img->MbaffFrameFlag || (params->UseRDOQuant && params->RDOQ_QP_Num > 1)))
{
int j;
for (j = 0; j < BLOCK_MULTIPLE; j++)
{
memcpy(rdopt->all_mv [LIST_0][l0_ref][P8x16][j][pos], all_mv [LIST_0][l0_ref][P8x16][j][pos], 2 * 2 * sizeof(short));
}
for (j = 0; j < BLOCK_MULTIPLE; j++)
{
memcpy(rdopt->all_mv [LIST_1][l1_ref][P8x16][j][pos], all_mv [LIST_1][l1_ref][P8x16][j][pos], 2 * 2 * sizeof(short));
}
}
}
}
/*!
*************************************************************************************
* \brief
* Sets motion vectors for a 8x8 partition in a B Slice
*************************************************************************************
*/
static void SetMVBSlice8x8(PicMotionParams *motion, Macroblock* currMB, int pos_y, int pos_x)
{
int l0_ref, l1_ref;
int pos = pos_y + (pos_x >> 1);
int pdir = currMB->b8pdir[pos];
int mode = currMB->b8mode[pos];
int block_y = img->block_y + pos_y;
int block_x = img->block_x + pos_x;
if (pdir == LIST_0)
{
l0_ref = motion->ref_idx[LIST_0][block_y][block_x];
CopyMVBlock8 (motion->mv[LIST_0], img->all_mv [LIST_0][l0_ref][mode], pos_y, pos_y + 2, pos_x);
ResetMVBlock8(motion->mv[LIST_1], pos_y, pos_y + 2, pos_x);
ResetRefBlock8(motion->ref_idx[LIST_1], pos_y, pos_y + 2, pos_x);
}
else if (pdir == LIST_1)
{
ResetMVBlock8(motion->mv[LIST_0], pos_y, pos_y + 2, pos_x);
ResetRefBlock8(motion->ref_idx[LIST_0], pos_y, pos_y + 2, pos_x);
l1_ref = motion->ref_idx[LIST_1][block_y][block_x];
CopyMVBlock8 (motion->mv[LIST_1], img->all_mv [LIST_1][l1_ref][mode], pos_y, pos_y + 2, pos_x);
}
else if (pdir == BI_PRED)
{
int bipred_me = currMB->bipred_me[pos];
short ******all_mv = bipred_me ? img->bipred_mv[bipred_me - 1]: img->all_mv;
l0_ref = motion->ref_idx[LIST_0][block_y][block_x];
CopyMVBlock8(motion->mv [LIST_0], all_mv [LIST_0][l0_ref][mode], pos_y, pos_y + 2, pos_x);
l1_ref = motion->ref_idx[LIST_1][block_y][block_x];
CopyMVBlock8(motion->mv [LIST_1], all_mv [LIST_1][l1_ref][mode], pos_y, pos_y + 2, pos_x);
if (bipred_me && (img->MbaffFrameFlag || (params->UseRDOQuant && params->RDOQ_QP_Num > 1)))
{
memcpy(rdopt->all_mv [LIST_0][l0_ref][mode][pos_y ][pos_x], all_mv [LIST_0][l0_ref][mode][pos_y ][pos_x], 2 * 2 * sizeof(short));
memcpy(rdopt->all_mv [LIST_0][l0_ref][mode][pos_y + 1][pos_x], all_mv [LIST_0][l0_ref][mode][pos_y + 1][pos_x], 2 * 2 * sizeof(short));
memcpy(rdopt->all_mv [LIST_1][l1_ref][mode][pos_y ][pos_x], all_mv [LIST_1][l1_ref][mode][pos_y ][pos_x], 2 * 2 * sizeof(short));
memcpy(rdopt->all_mv [LIST_1][l1_ref][mode][pos_y + 1][pos_x], all_mv [LIST_1][l1_ref][mode][pos_y + 1][pos_x], 2 * 2 * sizeof(short));
}
}
else // Invalid direct modes (out of range mvs). Adding this here for precaution purposes.
{
ResetMVBlock8(motion->mv[LIST_0], pos_y, pos_y + 2, pos_x);
ResetRefBlock8(motion->ref_idx[LIST_0], pos_y, pos_y + 2, pos_x);
ResetMVBlock8(motion->mv[LIST_1], pos_y, pos_y + 2, pos_x);
ResetRefBlock8(motion->ref_idx[LIST_1], pos_y, pos_y + 2, pos_x);
}
}
/*!
*************************************************************************************
* \brief
* Sets motion vectors for a macroblock in a P Slice
*************************************************************************************
*/
static void SetMotionVectorsMBBSlice (ImageParameters *img, PicMotionParams *motion, Macroblock* currMB)
{
int l0_ref, l1_ref;
// copy all the motion vectors into rdopt structure
// Can simplify this by copying the MV's of the best mode (TBD)
// Should maybe add code to check for Intra only profiles
if (img->MbaffFrameFlag || (params->UseRDOQuant && params->RDOQ_QP_Num > 1))
{
memcpy(&rdopt->all_mv[LIST_0][0][0][0][0][0], &img->all_mv[LIST_0][0][0][0][0][0], 2 * img->max_num_references * 9 * MB_BLOCK_PARTITIONS * 2 * sizeof(short));
}
if (currMB->mb_type == P16x16) // 16x16
{
int pdir = currMB->b8pdir[0];
if (pdir == LIST_0)
{
l0_ref = motion->ref_idx[LIST_0][img->block_y][img->block_x];
CopyMVBlock16 (motion->mv[LIST_0], img->all_mv [LIST_0][l0_ref][P16x16], 0, 4);
ResetMVBlock16(motion->mv[LIST_1], 0, 4);
}
else if (pdir == LIST_1)
{
l1_ref = motion->ref_idx[LIST_1][img->block_y][img->block_x];
ResetMVBlock16(motion->mv[LIST_0], 0, 4);
CopyMVBlock16 (motion->mv[LIST_1], img->all_mv [LIST_1][l1_ref][P16x16], 0, 4);
}
else
{
int bipred_me = currMB->bipred_me[0];
short ******all_mv = bipred_me ? img->bipred_mv[bipred_me - 1]: img->all_mv;
l0_ref = motion->ref_idx[LIST_0][img->block_y][img->block_x];
CopyMVBlock16 (motion->mv[LIST_0], all_mv [LIST_0][l0_ref][P16x16], 0, 4);
l1_ref = motion->ref_idx[LIST_1][img->block_y][img->block_x];
CopyMVBlock16 (motion->mv[LIST_1], all_mv [LIST_1][l1_ref][P16x16], 0, 4);
// Is this necessary here? Can this be moved somewhere else?
if (bipred_me && (img->MbaffFrameFlag || (params->UseRDOQuant && params->RDOQ_QP_Num > 1)))
{
memcpy(rdopt->all_mv [LIST_0][l0_ref][P16x16][0][0], all_mv [LIST_0][l0_ref][P16x16][0][0], MB_BLOCK_PARTITIONS * 2 * sizeof(short));
memcpy(rdopt->all_mv [LIST_1][l1_ref][P16x16][0][0], all_mv [LIST_1][l1_ref][P16x16][0][0], MB_BLOCK_PARTITIONS * 2 * sizeof(short));
}
}
}
else if (currMB->mb_type == P16x8) // 16x8
{
SetMVBSlice16x8(motion, currMB, 0);
SetMVBSlice16x8(motion, currMB, 2);
}
else if (currMB->mb_type == P8x16) // 16x8
{
SetMVBSlice8x16(motion, currMB, 0);
SetMVBSlice8x16(motion, currMB, 2);
}
else if (currMB->mb_type == P8x8 || currMB->mb_type == BSKIP_DIRECT) // 8x8 & Direct/SKIP
{
SetMVBSlice8x8(motion, currMB, 0, 0);
SetMVBSlice8x8(motion, currMB, 0, 2);
SetMVBSlice8x8(motion, currMB, 2, 0);
SetMVBSlice8x8(motion, currMB, 2, 2);
}
else // Intra modes
{
ResetMVBlock16(motion->mv[LIST_0], 0, 4);
ResetRefBlock16(motion->ref_idx[LIST_0], 0, 4);
ResetMVBlock16(motion->mv[LIST_1], 0, 4);
ResetRefBlock16(motion->ref_idx[LIST_1], 0, 4);
}
}
/*!
*************************************************************************************
* \brief
* Sets motion vectors for a macroblock
*************************************************************************************
*/
void SetMotionVectorsMB (ImageParameters *img, PicMotionParams *motion, Macroblock *currMB)
{
if (img->type == B_SLICE)
{
SetMotionVectorsMBBSlice (img, motion, currMB);
}
else if (img->type == P_SLICE || img->type == SP_SLICE)
{
SetMotionVectorsMBPSlice (img, motion, currMB);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -