📄 umc_mpeg2_dec_mc.cpp
字号:
FUNC_MC_FULLPEL(BKW, AVE, AV);
}
#define FIELD_BUFF_IND(field_sel) \
((frame_buffer.field_buffer_index && PictureHeader.picture_structure + field_sel == BOTTOM_FIELD) \
? frame_buffer.curr_index : frame_buffer.prev_index)
#define FUNC_MC_FIELD_420(DIR, METH, FLG) \
Ipp8u *cur_Y = video->blkCurrYUV[0]; \
Ipp8u *cur_U = video->blkCurrYUV[1]; \
Ipp8u *cur_V = video->blkCurrYUV[2]; \
Ipp32s pitch_l = frame_buffer.Y_comp_pitch; \
Ipp32s pitch_c = frame_buffer.U_comp_pitch; \
\
if(video->prediction_type == IPPVC_MC_FIELD) \
{ \
Ipp8u *ref_Y; \
Ipp8u *ref_U; \
Ipp8u *ref_V; \
Ipp32s offs_l, offs_c; \
Ipp32s flag_l, flag_c; \
Ipp16s vec_x, vec_y; \
Ipp32s field_sel; \
\
GET_1BIT(video->bs, field_sel); \
DECODE_MV(video->bs, index##DIR, index##DIR, vec_x, vec_y); \
video->PMV[index##DIR + 4] = video->PMV[index##DIR + 0]; \
video->PMV[index##DIR + 5] = video->PMV[index##DIR + 1]; \
\
Ipp32s ind0 = FIELD_BUFF_IND(field_sel); \
if (PictureHeader.picture_coding_type == B_PICTURE) \
ind0 = frame_buffer.buff##DIR; \
\
ref_Y = frame_buffer.frame_p_c_n[ind0].Y_comp_data; \
ref_U = frame_buffer.frame_p_c_n[ind0].U_comp_data; \
ref_V = frame_buffer.frame_p_c_n[ind0].V_comp_data; \
\
CALC_OFFSETS_FIELDX_420(offs_l, offs_c, flag_l, flag_c, vec_x, vec_y, field_sel, HP_FLAG_##FLG) \
pitch_l *= 2; \
pitch_c *= 2; \
CHECK_OFFSET_L(offs_l+(vec_x&1), pitch_l, 16+(vec_y&1)) \
FUNC_##METH##_HP(16, 16, ref_Y + offs_l, pitch_l, cur_Y, pitch_l, flag_l, 0); \
FUNC_##METH##_HP(8, 8, ref_U + offs_c, pitch_c, cur_U, pitch_c, flag_c, 0); \
FUNC_##METH##_HP(8, 8, ref_V + offs_c, pitch_c, cur_V, pitch_c, flag_c, 0); \
} \
else /* 16x8 */ \
{ \
Ipp16s vec_x0, vec_y0, vec_x1, vec_y1; \
Ipp32s field_sel0, field_sel1; \
\
GET_1BIT(video->bs, field_sel0); \
DECODE_MV(video->bs, index##DIR, index##DIR, vec_x0, vec_y0); \
\
GET_1BIT(video->bs, field_sel1); \
DECODE_MV(video->bs, index##DIR + 4, index##DIR, vec_x1, vec_y1); \
\
Ipp32s ind0 = FIELD_BUFF_IND(field_sel0); \
Ipp32s ind1 = FIELD_BUFF_IND(field_sel1); \
if (PictureHeader.picture_coding_type == B_PICTURE) \
ind0 = ind1 = frame_buffer.buff##DIR; \
\
Ipp8u *ref_Y0 = frame_buffer.frame_p_c_n[ind0].Y_comp_data; \
Ipp8u *ref_U0 = frame_buffer.frame_p_c_n[ind0].U_comp_data; \
Ipp8u *ref_V0 = frame_buffer.frame_p_c_n[ind0].V_comp_data; \
Ipp8u *ref_Y1 = frame_buffer.frame_p_c_n[ind1].Y_comp_data; \
Ipp8u *ref_U1 = frame_buffer.frame_p_c_n[ind1].U_comp_data; \
Ipp8u *ref_V1 = frame_buffer.frame_p_c_n[ind1].V_comp_data; \
Ipp32s offs_l0, offs_c0, flag_l0, flag_c0; \
Ipp32s offs_l1, offs_c1, flag_l1, flag_c1; \
\
CALC_OFFSETS_FIELDX_420(offs_l0, offs_c0, flag_l0, flag_c0, vec_x0, vec_y0, field_sel0, HP_FLAG_##FLG) \
CALC_OFFSETS_FIELDX_420(offs_l1, offs_c1, flag_l1, flag_c1, vec_x1, vec_y1, field_sel1, HP_FLAG_##FLG) \
pitch_l *= 2; \
pitch_c *= 2; \
offs_l1 += 8*pitch_l; \
offs_c1 += 4*pitch_c; \
CHECK_OFFSET_L(offs_l0+(vec_x0&1), pitch_l, 8+(vec_y0&1)) \
CHECK_OFFSET_L(offs_l1+(vec_x1&1), pitch_l, 8+(vec_y1&1)) \
FUNC_##METH##_HP(16, 8, ref_Y0 + offs_l0, pitch_l, cur_Y, pitch_l, flag_l0, 0); \
FUNC_##METH##_HP(16, 8, ref_Y1 + offs_l1, pitch_l, cur_Y + 8*pitch_l, pitch_l, flag_l1, 0); \
FUNC_##METH##_HP( 8, 4, ref_U0 + offs_c0, pitch_c, cur_U, pitch_c, flag_c0, 0); \
FUNC_##METH##_HP( 8, 4, ref_U1 + offs_c1, pitch_c, cur_U + 4*pitch_c, pitch_c, flag_c1, 0); \
FUNC_##METH##_HP( 8, 4, ref_V0 + offs_c0, pitch_c, cur_V, pitch_c, flag_c0, 0); \
FUNC_##METH##_HP( 8, 4, ref_V1 + offs_c1, pitch_c, cur_V + 4*pitch_c, pitch_c, flag_c1, 0); \
} \
return UMC_OK
Status MPEG2VideoDecoderBase::mc_field_forward_420(IppVideoContext *video)
{
FUNC_MC_FIELD_420(FRW, COPY, CP);
}
Status MPEG2VideoDecoderBase::mc_field_backward_420(IppVideoContext *video)
{
FUNC_MC_FIELD_420(BKW, COPY, CP);
}
Status MPEG2VideoDecoderBase::mc_field_backward_add_420(IppVideoContext *video)
{
FUNC_MC_FIELD_420(BKW, AVE, AV);
}
#define FUNC_MC_FIELD_422(DIR, METH, FLG) \
Ipp8u *cur_Y = video->blkCurrYUV[0]; \
Ipp8u *cur_U = video->blkCurrYUV[1]; \
Ipp8u *cur_V = video->blkCurrYUV[2]; \
Ipp32s pitch_l = frame_buffer.Y_comp_pitch; \
Ipp32s pitch_c = frame_buffer.U_comp_pitch; \
\
if(video->prediction_type == IPPVC_MC_FIELD) \
{ \
Ipp8u *ref_Y; \
Ipp8u *ref_U; \
Ipp8u *ref_V; \
Ipp32s offs_l, offs_c; \
Ipp32s flag_l, flag_c; \
Ipp16s vec_x, vec_y; \
Ipp32s field_sel; \
\
GET_1BIT(video->bs, field_sel); \
DECODE_MV(video->bs, index##DIR, index##DIR, vec_x, vec_y); \
video->PMV[index##DIR + 4] = video->PMV[index##DIR + 0]; \
video->PMV[index##DIR + 5] = video->PMV[index##DIR + 1]; \
\
Ipp32s ind0 = FIELD_BUFF_IND(field_sel); \
if (PictureHeader.picture_coding_type == B_PICTURE) \
ind0 = frame_buffer.buff##DIR; \
\
ref_Y = frame_buffer.frame_p_c_n[ind0].Y_comp_data; \
ref_U = frame_buffer.frame_p_c_n[ind0].U_comp_data; \
ref_V = frame_buffer.frame_p_c_n[ind0].V_comp_data; \
\
CALC_OFFSETS_FIELDX_422(offs_l, offs_c, flag_l, flag_c, vec_x, vec_y, field_sel, HP_FLAG_##FLG) \
pitch_l *= 2; \
pitch_c *= 2; \
CHECK_OFFSET_L(offs_l+(vec_x&1), pitch_l, 16+(vec_y&1)) \
FUNC_##METH##_HP(16, 16, ref_Y + offs_l, pitch_l, cur_Y, pitch_l, flag_l, 0); \
FUNC_##METH##_HP(8, 16, ref_U + offs_c, pitch_c, cur_U, pitch_c, flag_c, 0); \
FUNC_##METH##_HP(8, 16, ref_V + offs_c, pitch_c, cur_V, pitch_c, flag_c, 0); \
} \
else /* 16x8 */ \
{ \
Ipp16s vec_x0, vec_y0, vec_x1, vec_y1; \
Ipp32s field_sel0, field_sel1; \
\
GET_1BIT(video->bs, field_sel0); \
DECODE_MV(video->bs, index##DIR, index##DIR, vec_x0, vec_y0); \
\
GET_1BIT(video->bs, field_sel1); \
DECODE_MV(video->bs, index##DIR + 4, index##DIR, vec_x1, vec_y1); \
\
Ipp32s ind0 = FIELD_BUFF_IND(field_sel0); \
Ipp32s ind1 = FIELD_BUFF_IND(field_sel1); \
if (PictureHeader.picture_coding_type == B_PICTURE) \
ind0 = ind1 = frame_buffer.buff##DIR; \
\
Ipp8u *ref_Y0 = frame_buffer.frame_p_c_n[ind0].Y_comp_data; \
Ipp8u *ref_U0 = frame_buffer.frame_p_c_n[ind0].U_comp_data; \
Ipp8u *ref_V0 = frame_buffer.frame_p_c_n[ind0].V_comp_data; \
Ipp8u *ref_Y1 = frame_buffer.frame_p_c_n[ind1].Y_comp_data; \
Ipp8u *ref_U1 = frame_buffer.frame_p_c_n[ind1].U_comp_data; \
Ipp8u *ref_V1 = frame_buffer.frame_p_c_n[ind1].V_comp_data; \
Ipp32s offs_l0, offs_c0, flag_l0, flag_c0; \
Ipp32s offs_l1, offs_c1, flag_l1, flag_c1; \
\
CALC_OFFSETS_FIELDX_422(offs_l0, offs_c0, flag_l0, flag_c0, vec_x0, vec_y0, field_sel0, HP_FLAG_##FLG) \
CALC_OFFSETS_FIELDX_422(offs_l1, offs_c1, flag_l1, flag_c1, vec_x1, vec_y1, field_sel1, HP_FLAG_##FLG) \
pitch_l *= 2; \
pitch_c *= 2; \
offs_l1 += 8*pitch_l; \
offs_c1 += 8*pitch_c; \
CHECK_OFFSET_L(offs_l0+(vec_x0&1), pitch_l, 8+(vec_y0&1)) \
CHECK_OFFSET_L(offs_l1+(vec_x1&1), pitch_l, 8+(vec_y1&1)) \
FUNC_##METH##_HP(16, 8, ref_Y0 + offs_l0, pitch_l, cur_Y, pitch_l, flag_l0, 0); \
FUNC_##METH##_HP(16, 8, ref_Y1 + offs_l1, pitch_l, cur_Y + 8*pitch_l, pitch_l, flag_l1, 0); \
FUNC_##METH##_HP( 8, 8, ref_U0 + offs_c0, pitch_c, cur_U, pitch_c, flag_c0, 0); \
FUNC_##METH##_HP( 8, 8, ref_U1 + offs_c1, pitch_c, cur_U + 8*pitch_c, pitch_c, flag_c1, 0); \
FUNC_##METH##_HP( 8, 8, ref_V0 + offs_c0, pitch_c, cur_V, pitch_c, flag_c0, 0); \
FUNC_##METH##_HP( 8, 8, ref_V1 + offs_c1, pitch_c, cur_V + 8*pitch_c, pitch_c, flag_c1, 0); \
} \
return UMC_OK
Status MPEG2VideoDecoderBase::mc_field_forward_422(IppVideoContext *video)
{
FUNC_MC_FIELD_422(FRW, COPY, CP);
}
Status MPEG2VideoDecoderBase::mc_field_backward_422(IppVideoContext *video)
{
FUNC_MC_FIELD_422(BKW, COPY, CP);
}
Status MPEG2VideoDecoderBase::mc_field_backward_add_422(IppVideoContext *video)
{
FUNC_MC_FIELD_422(BKW, AVE, AV);
}
Status MPEG2VideoDecoderBase::mc_mp2_420_skip(IppVideoContext *video)
{
Ipp32s ref_index = (video->macroblock_motion_backward) ? frame_buffer.next_index : frame_buffer.prev_index;
Ipp8u *ref_Y_data = frame_buffer.frame_p_c_n[ref_index].Y_comp_data;
Ipp8u *ref_U_data = frame_buffer.frame_p_c_n[ref_index].U_comp_data;
Ipp8u *ref_V_data = frame_buffer.frame_p_c_n[ref_index].V_comp_data;
Ipp8u *cur_Y_data = frame_buffer.frame_p_c_n[frame_buffer.curr_index].Y_comp_data;
Ipp8u *cur_U_data = frame_buffer.frame_p_c_n[frame_buffer.curr_index].U_comp_data;
Ipp8u *cur_V_data = frame_buffer.frame_p_c_n[frame_buffer.curr_index].V_comp_data;
Ipp32u pitch_l = frame_buffer.Y_comp_pitch;
Ipp32u pitch_c = frame_buffer.U_comp_pitch;
Ipp32u flag1, flag2;
Ipp32s offs_uv1, offs_y1;
Ipp16s *vector = video->vector;
IppiSize roi = {16*(video->mb_address_increment - 1), 16};
Ipp32s i;
cur_Y_data += video->offset_l;
cur_U_data += video->offset_c;
cur_V_data += video->offset_c;
if (video->macroblock_motion_backward) vector += 2;
if (PictureHeader.picture_coding_type == P_FRAME) {
ref_Y_data += video->offset_l;
ref_U_data += video->offset_c;
ref_V_data += video->offset_c;
if(PictureHeader.picture_structure != FRAME_PICTURE) {
if(PictureHeader.picture_structure == BOTTOM_FIELD) {
cur_Y_data += pitch_l;
cur_U_data += pitch_c;
cur_V_data += pitch_c;
}
pitch_l <<= 1;
pitch_c <<= 1;
}
ippiCopy_8u_C1R( ref_Y_data, pitch_l, cur_Y_data, pitch_l, roi );
roi.height >>= 1;
roi.width >>= 1;
ippiCopy_8u_C1R(ref_U_data, pitch_c, cur_U_data, pitch_c, roi);
ippiCopy_8u_C1R(ref_V_data, pitch_c, cur_V_data, pitch_c, roi);
return UMC_OK;
}
if(PictureHeader.picture_structure == FRAME_PICTURE) {
CALC_OFFSETS_FRAME_420(offs_y1, offs_uv1, flag1, flag2, vector[0], vector[1], HP_FLAG_CP)
} else {
CALC_OFFSETS_FIELD_420(offs_y1, offs_uv1, flag1, flag2, vector[0], vector[1], 0, HP_FLAG_CP)
pitch_l <<= 1;
pitch_c <<= 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -