The power of CABAC
Today we’ll take a post directly from the stream analyzer.
position : 24×25 (384×400)
mb_addr : 1024
size (in bits) : 1
mb_type : 1
pmode : 0
mb_type : Intra(I_16x16_0_0_0)
slice_number : 0
transform_8x8 : 0
field\frame : frame
cbp bits
: 0000 00 00
: 0000 00 00
: 0000
: 0000
quant_param : 0
pmode : Intra_16x16
ipred : 16x16_Vertical
position : 23×27 (368×432)
mb_addr : 1103
size (in bits) : 15
mb_type : 6
pmode : 0
mb_type : Intra(I_16x16_0_0_0)
slice_number : 0
transform_8x8 : 0
field\frame : frame
cbp bits
: 0000 00 00
: 0000 00 00
: 0000
: 0000
quant_param : 0
pmode : Intra_16x16
ipred : 16x16_Vertical
Same macroblock type. Same (zero) coded block pattern. Same prediction mode. Except that one is 1 bit, and the other is 15. Both are CABAC; the only different is the state of the context table.
June 6th, 2008 at 2:34 pm
Well, that’s unfair as it depends on how the previous macroblocks did. On normal cases the global gain is about 5%, isn’t it? And extreme cases like QP51 are likely to be tiny anyway, not much point in optimizing the easy case.
Something that would make for a more interesting analysis would be number of CABAC bins vs number of CAVLC bits, and average size taken per each CABAC decision (or equivalenty the average probability of the MPS and the number of MPS hits).
June 6th, 2008 at 4:02 pm
I think you slightly missed the point of the post; both of them are CABAC, the point is how varying states of the context table can dramatically change the bit cost of a block, often to absurd levels. I’ll clarify a bit more in the post.
The global gain of CABAC is about 12-15%, though it depends heavily on the QP and the type of footage (anime, for example, has gains upwards of 20-30% at higher QPs).
June 7th, 2008 at 8:40 am
Yeah, I indeed misunderstood, the post made it sound like the first one was CAVLC.
One thing that I’ve always wondered is whether x264 performs local minimum search in the RDO process. If it weights decisions based on current CABAC cost, it might make suboptimal decisions where choosing a “worse” match would have benefited future blocks due to the adaptable nature of CABAC. I understand that this is rather expensive, but I don’t know what’s the standard on modern codecs (it’d be similar in nature to iterative motion search, which I think nobody does).
June 7th, 2008 at 9:06 am
That’s called multi-MB trellis an it is indeed very very expensive.
I have seen exactly what you mean though; I have one clip where by the end of the frame there were no more p16x16 blocks and only p8x8 (hundreds of them), because CABAC had adapted such that it was cheaper to code p8x8 than p16x16 even if all the partition motion vectors were the same!
June 8th, 2008 at 12:54 pm
multi-MB trellis for MVs is very very slow. multi-MB trellis for CABAC states is O(macroblocks*128^310) slow.
iterative ME is O(macroblocks) with a constant not too many orders of magnitude higher than normal ME. iterative RDO for CABAC state is O(macroblocks^2), i.e. you entropy code half the frame for each candidate of each block.
June 27th, 2008 at 3:37 pm
It’s been awhile since your last post – Dark Shikari!
I’m looking forward to more