private IMacroblockType GetMacroBlockType() { //Table 7-10,7-11,.. switch (_sliceState.SliceType) { case SliceType.I: uint mbTypeI = _reader.GetExpGolombCoded(25); return(MacroblockType.GetMbTypeI(mbTypeI)); case SliceType.Si: uint mbTypeSi = _reader.GetExpGolombCoded(26); return(MacroblockType.GetMbTypeSi(mbTypeSi)); case SliceType.P: case SliceType.Sp: uint mbTypeP = _reader.GetExpGolombCoded(30); return(MacroblockType.GetMbTypeP(mbTypeP)); case SliceType.B: uint mbTypeB = _reader.GetExpGolombCoded(48); return(MacroblockType.GetMbTypeB(mbTypeB)); } throw new InvalidOperationException("Current type not set"); }
private IMacroblockType GetMbTypeP() { // Note: The 'MbTypeNotZero' flag is not used in P-slices! // Table 9-37 – Binarization for macroblock types in P, SP, and B slices const uint ctxOffsetPrefix = 14; if (_arithmeticDecoder.DecodeDecision(ctxOffsetPrefix) == 0) { // 9.3.3.1.2 Assignment process of ctxIdxInc using prior decoded bin values uint b1 = _arithmeticDecoder.DecodeDecision(ctxOffsetPrefix + 1); uint b2 = _arithmeticDecoder.DecodeDecision(ctxOffsetPrefix + (b1 + 2)); return(MacroblockType.GetMbTypeP((b1 << 1) ^ (3 * b2))); } const uint ctxOffsetSuffix = 17; if (_arithmeticDecoder.DecodeDecision(ctxOffsetSuffix) == 0) { return(MacroblockType.GetMbTypeI(0)); } return(GetMbTypeIntra(ctxOffsetSuffix, MbTypeIntraCtxIdxIncInterSlice)); }