private void GetMotionVector(MotionField motionField, MacroblockPartition mbPart)
        {
#if DEBUG
            int dmvx = 0, dmvy = 0;
#endif
            if (_arithmeticDecoder.DecodeDecision(40 + motionField.GetCtxIdxInc(_currMbAddr, mbPart, 0)) == 1)
            {
                uint dx = GetAbsMotionVectorComponent(40);                 // dx coordinate?
                motionField.UpdateComponent(_currMbAddr, mbPart, 0, dx);
#if DEBUG
                dmvx = (_arithmeticDecoder.DecodeBypass() == 1) ? -(int)dx : (int)dx; // sign?
#else
                _arithmeticDecoder.DecodeBypass();                                    // sign
#endif
            }
            if (_arithmeticDecoder.DecodeDecision(47 + motionField.GetCtxIdxInc(_currMbAddr, mbPart, 1)) == 1)
            {
                uint dy = GetAbsMotionVectorComponent(47);                 // dy coordinate?
                motionField.UpdateComponent(_currMbAddr, mbPart, 1, dy);
#if DEBUG
                dmvy = (_arithmeticDecoder.DecodeBypass() == 1) ? -(int)dy : (int)dy; // sign?
#else
                _arithmeticDecoder.DecodeBypass();                                    // sign
#endif
            }
#if DEBUG
            H264Debug.WriteLine("   dmv={0},{1}", dmvx, dmvy);
#endif
        }
        public CabacSliceData(INalUnitReader reader, IState readerState)
        {
            _reader        = reader;
            _readerState   = readerState;
            _sliceState    = reader.State.SliceState;
            _pictureState  = _sliceState.PictureState;
            _sequenceState = _pictureState.SequenceState;
            _unavailableMacroblockState = _sliceState.IntraCoded
                                                        ? MacroblockState.UnavailableIntraCoded
                                                        : MacroblockState.UnavailableInterCoded;
            _macroblockStates  = new MacroblockState[PicSizeInMbs];
            _motionFieldL0     = IsList0Predicted ? new MotionField(_sliceState) : null;
            _motionFieldL1     = IsList1Predicted ? new MotionField(_sliceState) : null;
            _subMbTypes        = new ISubMacroblockType[4];
            _arithmeticDecoder = new ArithmeticDecoder(reader);

            for (int i = 0; i < _macroblockStates.Length; i++)
            {
                _macroblockStates[i] = _unavailableMacroblockState;
            }

            MbToSliceGroupMap = _mbToSliceGroup.CreateMacroBlockToSliceGroupMap(_sliceState);
        }