Пример #1
0
        // Decode a bit with modelling
        public uint decodeBit(ArithmeticBitModel m)
        {
            Debug.Assert(m != null);

            uint x   = m.bit_0_prob * (length >> BM.LengthShift); // product l x p0
            uint sym = (value >= x)?1u:0u;                        // decision

            // update & shift interval
            if (sym == 0)
            {
                length = x;
                ++m.bit_0_count;
            }
            else
            {
                value  -= x;              // shifted interval base = 0
                length -= x;
            }

            if (length < AC.MinLength)
            {
                renorm_dec_interval();                                 // renormalization
            }
            if (--m.bits_until_update == 0)
            {
                m.update();         // periodic model update
            }
            return(sym);            // return data bit value
        }
Пример #2
0
        // Encode a bit with modelling
        public void encodeBit(ArithmeticBitModel m, uint bit)
        {
            Debug.Assert(m != null && (bit <= 1));

            uint x = m.bit_0_prob * (length >> BM.LengthShift);       // product l x p0

            // update interval
            if (bit == 0)
            {
                length = x;
                ++m.bit_0_count;
            }
            else
            {
                uint init_interval_base = interval_base;
                interval_base += x;
                length        -= x;
                if (init_interval_base > interval_base)
                {
                    propagate_carry();                                                  // overflow = carry
                }
            }

            if (length < AC.MinLength)
            {
                renorm_enc_interval();                                 // renormalization
            }
            if (--m.bits_until_update == 0)
            {
                m.update();                                      // periodic model update
            }
        }
Пример #3
0
		// Encode a bit with modelling
		public void encodeBit(ArithmeticBitModel m, uint bit)
		{
			Debug.Assert(m!=null&&(bit<=1));

			uint x=m.bit_0_prob*(length>>BM.LengthShift); // product l x p0
			// update interval
			if(bit==0)
			{
				length=x;
				++m.bit_0_count;
			}
			else
			{
				uint init_interval_base=interval_base;
				interval_base+=x;
				length-=x;
				if(init_interval_base>interval_base) propagate_carry(); // overflow = carry
			}

			if(length<AC.MinLength) renorm_enc_interval(); // renormalization
			if(--m.bits_until_update==0) m.update(); // periodic model update
		}
Пример #4
0
		// Decode a bit with modelling
		public uint decodeBit(ArithmeticBitModel m)
		{
			Debug.Assert(m!=null);

			uint x=m.bit_0_prob*(length>>BM.LengthShift); // product l x p0
			uint sym=(value>=x)?1u:0u; // decision

			// update & shift interval
			if(sym==0)
			{
				length=x;
				++m.bit_0_count;
			}
			else
			{
				value-=x; // shifted interval base = 0
				length-=x;
			}

			if(length<AC.MinLength) renorm_dec_interval(); // renormalization
			if(--m.bits_until_update==0) m.update(); // periodic model update

			return sym; // return data bit value
		}