private void SubMacroBlockPrediction() { if (_sliceState.SliceType == SliceType.B) { for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { uint subMbType = GetSubMbTypeB(); _subMbTypes[mbPartIdx] = SubMacroblockType.GetSubMbTypeB(subMbType); } } else // P or Sp { for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { uint subMbType = GetSubMbTypeP(); _subMbTypes[mbPartIdx] = SubMacroblockType.GetSubMbTypeP(subMbType); } } uint referencePictureCount0 = _sliceState.ActiveReferencePictureCount0; //defaults to _pictureState.DefaultReferencePictureCount0; if (HasReferencePictureIndex(referencePictureCount0)) { var referencePictureIndex = new ReferencePictureIndex(_mbStateA.RefIdxL0, _mbStateB.RefIdxL0); for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (_subMbTypes[mbPartIdx].List0Predicted) { uint idx = MacroblockPartitioning.M8X8[mbPartIdx].Idx; if (GetReferencePicture(referencePictureCount0, referencePictureIndex.GetCtxIdxInc(idx))) // ref_idx_l0[ mbPartIdx ] { referencePictureIndex.SetNonZeroRefIdx(idx); } } } _currMbState.RefIdxL0 = referencePictureIndex.Bits; } uint referencePictureCount1 = _sliceState.ActiveReferencePictureCount1; //defaults to _pictureState.DefaultReferencePictureCount1; if (HasReferencePictureIndex(referencePictureCount1)) { var referencePictureIndex = new ReferencePictureIndex(_mbStateA.RefIdxL1, _mbStateB.RefIdxL1); for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (_subMbTypes[mbPartIdx].List1Predicted) { uint idx = MacroblockPartitioning.M8X8[mbPartIdx].Idx; if (GetReferencePicture(referencePictureCount1, referencePictureIndex.GetCtxIdxInc(idx))) // ref_idx_l0[ mbPartIdx ] { referencePictureIndex.SetNonZeroRefIdx(idx); } } } _currMbState.RefIdxL1 = referencePictureIndex.Bits; } for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { ISubMacroblockType subMbType = _subMbTypes[mbPartIdx]; if (subMbType.List0Predicted) { MacroblockPartitioning macroblockPartitioning = subMbType.MacroblockPartitioning; uint subMbPartOffset = (mbPartIdx * subMbType.NumSubMbPart); for (uint subMbPartIdx = 0; subMbPartIdx < subMbType.NumSubMbPart; subMbPartIdx++) { GetMotionVector(_motionFieldL0, macroblockPartitioning[subMbPartOffset + subMbPartIdx]); // mvd_l0[ i ][ j ][ compIdx ] } } } for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { ISubMacroblockType subMbType = _subMbTypes[mbPartIdx]; if (subMbType.List1Predicted) { MacroblockPartitioning macroblockPartitioning = subMbType.MacroblockPartitioning; uint subMbPartOffset = (mbPartIdx * subMbType.NumSubMbPart); for (uint subMbPartIdx = 0; subMbPartIdx < subMbType.NumSubMbPart; subMbPartIdx++) { GetMotionVector(_motionFieldL1, macroblockPartitioning[subMbPartOffset + subMbPartIdx]); // mvd_l1[ i ][ j ][ compIdx ] } } } }
private void SubMacroBlockPrediction(IMacroblockType macroBlockType) { if (_sliceState.SliceType == SliceType.B) { for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { uint subMbType = _reader.GetExpGolombCoded(12); // sub_mb_type[mbPartIdx] _subMbTypes[mbPartIdx] = SubMacroblockType.GetSubMbTypeB(subMbType); } } else // P or Sp { for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { uint subMbType = _reader.GetExpGolombCoded(3); // sub_mb_type[mbPartIdx] _subMbTypes[mbPartIdx] = SubMacroblockType.GetSubMbTypeP(subMbType); } } uint referencePictureCount0 = _sliceState.ActiveReferencePictureCount0; //defaults to _pictureState.DefaultReferencePictureCount0; if (HasReferencePictureIndex(referencePictureCount0) && !macroBlockType.IsP8X8Ref0) { for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (_subMbTypes[mbPartIdx].List0Predicted) { GetReferencePicture(referencePictureCount0); } } } uint referencePictureCount1 = _sliceState.ActiveReferencePictureCount1; //defaults to _pictureState.DefaultReferencePictureCount1; if (HasReferencePictureIndex(referencePictureCount1)) { for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { if (_subMbTypes[mbPartIdx].List1Predicted) { GetReferencePicture(referencePictureCount1); } } } for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { ISubMacroblockType subMbType = _subMbTypes[mbPartIdx]; if (subMbType.List0Predicted) { for (uint subMbPartIdx = 0; subMbPartIdx < subMbType.NumSubMbPart; subMbPartIdx++) { GetMotionVector(); // mvd_l0[ i ][ j ][ compIdx ] } } } for (uint mbPartIdx = 0; mbPartIdx < 4; mbPartIdx++) { ISubMacroblockType subMbType = _subMbTypes[mbPartIdx]; if (subMbType.List1Predicted) { for (uint subMbPartIdx = 0; subMbPartIdx < subMbType.NumSubMbPart; subMbPartIdx++) { GetMotionVector(); // mvd_l1[ i ][ j ][ compIdx ] } } } }