📄 umc_h264_segment_decoder_templates.h
字号:
if (sum_partnum == 0)
noSubMbPartSizeLessThan8x8Flag = true;
}
else
noSubMbPartSizeLessThan8x8Flag = true;
}
if (mbtype != MBTYPE_DIRECT)
{
// Motion Vector Computation
if (mbtype == MBTYPE_INTER_8x8)
{
// First, if B slice and MB is 8x8, set the MV for any DIRECT
// 8x8 partitions. The MV for the 8x8 DIRECT partition need to
// be properly set before the MV for subsequent 8x8 partitions
// can be computed, due to prediction. The DIRECT MV are computed
// by a separate function and do not depend upon block neighbors for
// predictors, so it is done here first.
if (sd->m_cur_mb.GlobalMacroblockInfo->sbtype[0] == SBTYPE_DIRECT ||
sd->m_cur_mb.GlobalMacroblockInfo->sbtype[1] == SBTYPE_DIRECT ||
sd->m_cur_mb.GlobalMacroblockInfo->sbtype[2] == SBTYPE_DIRECT ||
sd->m_cur_mb.GlobalMacroblockInfo->sbtype[3] == SBTYPE_DIRECT)
{
sd->DecodeDirectMotionVectors(false);
}
}
// MV and Ref Index
sd->DecodeMotionVectors_CAVLC(true);
//sd->ReconstructMotionVectors();
}
else
{
sd->DecodeDirectMotionVectors(true);
}
sd->m_cur_mb.LocalMacroblockInfo->cbp = (Ipp8u) sd->DecodeCBP_CAVLC(color_format);
if (0 == sd->m_cur_mb.LocalMacroblockInfo->cbp)
{
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_luma = 0;
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_chroma[0] = 0;
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_chroma[1] = 0;
sd->m_prev_dquant = 0;
}
else
{
if (is_high_profile && noSubMbPartSizeLessThan8x8Flag && sd->m_cur_mb.LocalMacroblockInfo->cbp&15)
{
Ipp8u transform_size_8x8_mode_flag = 0;
if (sd->m_pPicParamSet->transform_8x8_mode_flag)
{
transform_size_8x8_mode_flag = (Ipp8u) sd->m_pBitStream->Get1Bit();
pSetMB8x8TSFlag(sd->m_cur_mb.GlobalMacroblockInfo, transform_size_8x8_mode_flag);
}
}
// check for usual case of zero QP delta
if (!sd->m_pBitStream->NextBit())
{
sd->DecodeMBQPDelta_CAVLC();
sd->m_QuantPrev = sd->m_cur_mb.LocalMacroblockInfo->QP;
}
// Now, decode the coefficients
if (is_high_profile && pGetMB8x8TSFlag(sd->m_cur_mb.GlobalMacroblockInfo))
this->DecodeCoefficients8x8_CAVLC(sd);
else
this->DecodeCoefficients4x4_CAVLC(sd);
}
} // void DecodeMacroblock_B_CAVLC(H264SegmentDecoderMultiThreaded *sd)
void DecodeMacroblock_PCM(H264SegmentDecoderMultiThreaded *sd)
{
// Reset buffer pointers to start
// This works only as long as "batch size" for VLD and reconstruct
// is the same. When/if want to make them different, need to change this.
for (;;) // not really a loop, while used to enable use of break
{
// First decode the "macroblock header", e.g., macroblock type,
// intra-coding types, motion vectors and CBP.
{
this->DecodeCoefficients_PCM(sd);
// For PCM type MB, num coeffs are set by above call, cbp is
// set to all blocks coded (for deblock filter), MV are set to zero,
// QP is unchanged.
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_luma = D_CBP_LUMA_DC | D_CBP_LUMA_AC;
if (color_format)
{
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_chroma[0] =
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_chroma[1] = D_CBP_CHROMA_DC | ColorSpecific<color_format, Coeffs, PlaneY, PlaneUV, is_field>::GetChromaAC();
}
sd->m_prev_dquant = 0;
}
break; // no more to read from bitstream
} // while 1
} // void DecodeMacroblock_PCM(H264SegmentDecoderMultiThreaded *sd)
};
template <typename Coeffs, typename PlaneY, typename PlaneUV, Ipp32s color_format, Ipp32s is_field, bool is_high_profile>
class MBNullDecoder //:
/*public ResidualDecoderCABAC<Coeffs, color_format, is_field>,
public ResidualDecoderCAVLC<Coeffs, color_format, is_field>,
public ResidualDecoderPCM<Coeffs, PlaneY, PlaneUV, color_format, is_field>*/
{
public:
virtual
~MBNullDecoder(void)
{
} // MBNullDecoder(void)
void DecodeMacroblock_ISlice_CABAC(H264SegmentDecoderMultiThreaded *)
{
} // void DecodeMacroblock_ISlice_CABAC(
void DecodeMacroblock_PSlice_CABAC(H264SegmentDecoderMultiThreaded *)
{
} // void DecodeMacroblock_PSlice_CABAC(
void DecodeMacroblock_BSlice_CABAC(H264SegmentDecoderMultiThreaded * )
{
} // void DecodeMacroblock_BSlice_CABAC(
void DecodeMacroblock_ISlice_CAVLC(H264SegmentDecoderMultiThreaded *)
{
} // void DecodeMacroblock_ISlice_CAVLC(
void DecodeMacroblock_PSlice_CAVLC(H264SegmentDecoderMultiThreaded *)
{
} // void DecodeMacroblock_PSlice_CAVLC(
void DecodeMacroblock_BSlice_CAVLC(H264SegmentDecoderMultiThreaded *)
{
} // void DecodeMacroblock_BSlice_CAVLC(
};
template <typename Coeffs, typename PlaneY, typename PlaneUV, Ipp32s color_format, Ipp32s is_field, bool is_high_profile>
class MBReconstructor
{
public:
typedef PlaneY * PlanePtrY;
typedef PlaneUV * PlanePtrUV;
typedef Coeffs * CoeffsPtr;
virtual ~MBReconstructor() {}
void ReconstructMacroblock_ISlice(H264SegmentDecoderMultiThreaded * sd)
{
// per-macroblock variables
Ipp32s fdf = pGetMBFieldDecodingFlag(sd->m_cur_mb.GlobalMacroblockInfo);
// reconstruct Data
IntraType *pMBIntraTypes = sd->m_pMBIntraTypes + sd->m_CurMBAddr*NUM_INTRA_TYPE_ELEMENTS;
Ipp8u mbtype = sd->m_cur_mb.GlobalMacroblockInfo->mbtype;
Ipp32s mbXOffset = sd->m_CurMB_X * 16;
Ipp32s mbYOffset = sd->m_CurMB_Y * 16;
VM_ASSERT(mbXOffset < sd->m_pCurrentFrame->lumaSize().width);
VM_ASSERT(mbYOffset < sd->m_pCurrentFrame->lumaSize().height);
mbtype = sd->m_cur_mb.GlobalMacroblockInfo->mbtype;
// reconstruct starts here
// Perform motion compensation to reconstruct the YUV data
//
Ipp32u offsetY = mbXOffset + (mbYOffset * sd->m_uPitchLuma);
Ipp32u offsetC = (mbXOffset >> (Ipp32s)(color_format<3)) + ((mbYOffset >> (Ipp32s)(color_format <= 1)) * sd->m_uPitchChroma);
Ipp32s bitdepth_luma_qp_scale = 6*(sd->bit_depth_luma - 8);
Ipp32s bitdepth_chroma_qp_scale = 6*(sd->bit_depth_chroma - 8
+ sd->m_pSeqParamSet->residual_colour_transform_flag);
Ipp32s lumaQP = sd->m_cur_mb.LocalMacroblockInfo->QP + bitdepth_luma_qp_scale;
Ipp32s QPChromaU, QPChromaV;
Ipp32s QPChromaIndexU, QPChromaIndexV;
QPChromaIndexU = sd->m_cur_mb.LocalMacroblockInfo->QP + sd->m_pPicParamSet->chroma_qp_index_offset[0];
QPChromaIndexU = IPP_MIN(QPChromaIndexU, (Ipp32s)QP_MAX);
QPChromaIndexU = IPP_MAX(-bitdepth_chroma_qp_scale, QPChromaIndexU);
QPChromaU = QPChromaIndexU < 0 ? QPChromaIndexU : QPtoChromaQP[QPChromaIndexU];
QPChromaU += bitdepth_chroma_qp_scale;
if (is_high_profile)
{
QPChromaIndexV = sd->m_cur_mb.LocalMacroblockInfo->QP + sd->m_pPicParamSet->chroma_qp_index_offset[1];
QPChromaIndexV = IPP_MIN(QPChromaIndexV, (Ipp32s)QP_MAX);
QPChromaIndexV = IPP_MAX(-bitdepth_chroma_qp_scale, QPChromaIndexV);
QPChromaV = QPChromaIndexV < 0 ? QPChromaIndexV : QPtoChromaQP[QPChromaIndexV];
QPChromaV += bitdepth_chroma_qp_scale;
}
Ipp16s *ScalingMatrix4x4Y;
Ipp16s *ScalingMatrix4x4U;
Ipp16s *ScalingMatrix4x4V;
Ipp16s *ScalingMatrix8x8;
Ipp16s ScalingDCU,ScalingDCV;
{
if (is_high_profile)
{
ScalingMatrix4x4Y = sd->m_pPicParamSet->m_LevelScale4x4[0].LevelScaleCoeffs[lumaQP];
ScalingMatrix4x4U = sd->m_pPicParamSet->m_LevelScale4x4[1].LevelScaleCoeffs[QPChromaU];
ScalingMatrix4x4V = sd->m_pPicParamSet->m_LevelScale4x4[2].LevelScaleCoeffs[QPChromaV];
ScalingMatrix8x8 = sd->m_pPicParamSet->m_LevelScale8x8[0].LevelScaleCoeffs[lumaQP];
ScalingDCU = sd->m_pPicParamSet->m_LevelScale4x4[1].LevelScaleCoeffs[QPChromaU+3][0];
ScalingDCV = sd->m_pPicParamSet->m_LevelScale4x4[2].LevelScaleCoeffs[QPChromaV+3][0];
}
Ipp32u rec_pitch_luma = sd->m_uPitchLuma; // !!! adjust rec_pitch to MBAFF
Ipp32u rec_pitch_chroma = sd->m_uPitchChroma; // !!! adjust rec_pitch to MBAFF
if (sd->m_isMBAFF)
{
Ipp32s currmb_fdf = fdf;
Ipp32s currmb_bf = (sd->m_CurMBAddr & 1);
if (currmb_fdf) //current mb coded as field MB
{
if (currmb_bf)
{
offsetY -= 15 * rec_pitch_luma;
offsetC -= (color_format == 1 ? 7 : 15) * rec_pitch_chroma;
}
rec_pitch_luma *= 2;
rec_pitch_chroma *= 2;
}
}
if (mbtype != MBTYPE_PCM)
{
Ipp32s special_MBAFF_case = 0; // !!!
Ipp8u edge_type = 0;
Ipp8u edge_type_2t = 0;
Ipp8u edge_type_2b = 0;
if (sd->m_isMBAFF)
{
special_MBAFF_case = 0; // adjust to MBAFF
sd->ReconstructEdgeType(edge_type_2t, edge_type_2b, special_MBAFF_case);
edge_type = edge_type_2t | edge_type_2b;
}
else
{
edge_type = (Ipp8u)sd->m_mbinfo.mbs[sd->m_CurMBAddr].IntraTypes.edge_type;
}
// reconstruct luma block(s)
if (mbtype == MBTYPE_INTRA_16x16)
{
if (is_high_profile)
{
ReconstructLumaIntra_16x16MB(
(CoeffsPtr*)(&sd->m_pCoeffBlocksRead),
(PlanePtrY)sd->m_pYPlane + offsetY,
rec_pitch_luma,
(IppIntra16x16PredMode_H264) pMBIntraTypes[0],
sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_luma,
lumaQP,
edge_type,
ScalingMatrix4x4Y,
sd->m_pSeqParamSet->qpprime_y_zero_transform_bypass_flag,
sd->bit_depth_luma);
}
else
{
ReconstructLumaIntra16x16MB(
(CoeffsPtr*)&sd->m_pCoeffBlocksRead,
(PlanePtrY)sd->m_pYPlane + offsetY,
rec_pitch_luma,
(IppIntra16x16PredMode_H264) pMBIntraTypes[0],
(Ipp32u) sd->m_cur_mb.LocalMacroblockInfo->cbp4x4_luma,
lumaQP,
edge_type,
sd->bit_depth_luma);
}
}
else // if (intra16x16)
{
if (is_high_profile)
{
switch (special_MBAFF_case)
{
default:
if (pGetMB8x8TSFlag(sd->m_cur_mb.GlobalMacroblockInfo))
{
ReconstructLumaIntraHalf8x8MB(
(CoeffsPtr*)&sd->m_pCoeffBlocksRead,
(PlanePtrY)sd->m_pYPlane + offsetY,
rec_pitch_luma,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -