While the input is not exhausted:
While the input is not exhausted:
Input so many bits of \(x\) as they are needed to:
It is not necessary to wait for the end of the encoding to generate the arithmetic code. When we work with binary representations of the real numbers \(L\) and \(H\), their most significant bits become identical when the interval is reduced. These bits belong to the output arithmetic code, therefore, they can be output as soon as they match.
For example, when the symbol B is encoded, a code-bit 1 can be output because any sequence of symbols that start with B have a code-word that begins with 1.
When the most significant bits of \(L\) and \(H\) are output, the bits of each register are shifted to the left, and new bits need to be inserted. The results is an automatic zoom of the selected sub-interval.
Following with the previous example, the register shifting generates an ampliation of the \([0.50,1.00)\) interval to the \([0.00,1.00)\).
[1] Nelson M. and Gailly J. The Data Compression Book. M&T Books, 1996.
[2] Jorma Rissanen and Glen G. Langdon. Arithmetic coding. IBM Journal of research and development, 23(2):149–162, 1979.
[3] Ian H Witten, Radford M Neal, and John G Cleary. Arithmetic coding for data compression. Communications of the ACM, 30(6):520–540, 1987.