示例#1
0
        public void Encode(ArithmeticCoder coder, long budget)
        {
            _coder  = coder;
            _budget = budget;

            Init();

            var thresholdBits = (int)Math.Floor(Math.Log(_threshold) / Math.Log(2) + 0.00001);

            _coder.EncodeSymbol(_thresholdModel, thresholdBits);

            _threshold = 1 << thresholdBits;

            for (; thresholdBits >= 0; thresholdBits--)
            {
                if (!SortingPass1())
                {
                    break;
                }
                if (!SortingPass2())
                {
                    break;
                }
                if (!RefinementPass())
                {
                    break;
                }

                _threshold >>= 1;

                GC.Collect();
            }

            EndEncoding();
        }
示例#2
0
 private void Output(bool bit, ArithmeticModel model)
 {
     _coder.EncodeSymbol(model, bit ? 1 : 0);
 }