On 18.01.2012 15:55, Sebastian wrote:
> Hi!
>
> Recent posts sparked my interest in efficient implementations of
> arithmetic coding again. The "CABA coder" (CABAC = context adaptive
> binary arithmetic coding) used in the H.264 video compression standard
> seems to be very interesting. It's also table-based and reduces the
> approximation errors during interval subdivision by using two high
> order bits of the current interval size in addition to the current
> "context" as part of the lookup table index for approximating
> "A*Pr(LPS)".
Indeed, it puts most of the logic in tables where MQ/QM still have
additions. I wouldn't call it "complex", actually, as it is rather a
state machine that has its cleverness encoded in the state transitions.
> What is actually the patent situation for these kinds of things
> (including MQ-, QM- coders etc)?
CABAC is, as far as I know, still patented and thus out of reach for
free implementations. MQ and QM coder patents run out a couple of years
ago already, there are several actually: On bit-stuffing (MQ coder) and
on the MPS/LPS inversion handling. I always forgot which one was which,
but one of the patents was due to IBM (I believe the interchange) and
the other was from Mitsubishi. None of these should apply anymore to my
very knowledge, its too long ago. Just use them now. [This is not a
legal advice, of course. Patents are a minefield anyhow.]
> Also, I'm not sure on how to estimate the overhead due to bit
> stuffing / byte stuffing. Let's take the arithmetic coder from JBIG2
> for example. It outputs octets from the code register every now and
> then. My understanding is that overflow is restricted to not propagate
> beyond the last extracted octet by inserting a zero bit in case a 0xFF
> byte could otherwise overflow. If my intuition is correct this
> procedure reduces the coding space by 0.5/256 = 0.2% which should
> increase the expected length of the coded stream by about 0.035%. Is
> this correct?
I believe there is some discussion of that in either the Pink Book or
the JPEG 2000 Marcellin book, I can check this out tomorrow. If we
assume that the output of the coder is approximately uniformely iid
(which is sensible of course) then 1/256 of the possible outcomes is
increased by 1 bit, thus I get (8/8 * 255/256 + 9/8 * 1/256)
approximately 0.05% overhead (what I get from this - probably wrong, too
late now). Of course, this is not entirely correct because one purpose
of the stuffed bit is to absorb any carry over, i.e. there are cases
where a carry-over can flow into this bit, and I'm getting too tired to
make a good model for that. Thus, coding space is even used a bit better
than that.
[J2K is here designed smart enough that all the possible overflow cases
do not generate conflicting marker codes, namely 0xff80 through 0xff8f
are reserved. Nice trick.]
Byte-stuffing creates a larger overhead, I get approximately 0.4% by a
similar simple computation. The QM coder does neither use this zero-byte
for carry-over resolution, thus the coding space is truly wasted
entirely and not even used for a faster implementation. Instead, it uses
the old carry-over delayed output approach which may cause very long
propagation delays (i.e. times where the input just accumulates carries
and delays the output until finally a very long stream of zeros and
0xffs - sorry 0xff 0x00 pairs) is generated.
There are a couple of completely different designs of arithmetic coders,
one of them being the ELS coder which operates on logarithmic space
(hence the name (*) e??? Logarithmic Scale) and thus avoids
multiplications in a different way. It wastes more coding space, but it
has a more precise computation of the coding interval size because it
avoids the "addition = multiplication" trick in the Q-coder family.
(*) well, not entirely true. Els Withers is also the nick name of the
inventor which I happen to know. (-; There are a couple of more stories
behind it - the ELS coder was one of the reasons why IBM finally agreed
to provide the MQ coder royality free for standards after Els made his
offer. Old stories...
So long,
Thomas