page_title: Context-adaptive binary arithmetic coding
section_title: Algorithm
hierarchical_section_title: Context-adaptive binary arithmetic coding / Algorithm
caption_attribution_description: English: H.264 CABAC Encoder Workflow Diagram
context_page_description: Context-adaptive binary arithmetic coding is a form of entropy encoding used in the H.264/MPEG-4 AVC and High Efficiency Video Coding standards. It is a lossless compression technique, although the video coding standards in which it is used are typically for lossy compression applications. CABAC is notable for providing much better compression than most other entropy encoding algorithms used in video encoding, and it is one of the key elements that provides the H.264/AVC encoding scheme with better compression capability than its predecessors.
  In H.264/MPEG-4 AVC, CABAC is only supported in the Main and higher profiles of the standard, as it requires a larger amount of processing to decode than the simpler scheme known as context-adaptive variable-length coding that is used in the standard's Baseline profile. CABAC is also difficult to parallelize and vectorize, so other forms of parallelism may be coupled with its use. In HEVC, CABAC is used in all profiles of the standard.
context_section_description: CABAC is based on arithmetic coding, with a few innovations and changes to adapt it to the needs of video encoding standards:
  It encodes binary symbols, which keeps the complexity low and allows probability modelling for more frequently used bits of any symbol.
  The probability models are selected adaptively based on local context, allowing better modelling of probabilities, because coding modes are usually locally well correlated.
  It uses a multiplication-free range division by the use of quantized probability ranges and probability states.
  CABAC has multiple probability modes for different contexts.  It first converts all non-binary symbols to binary. Then, for each bit, the coder selects which probability model to use, then uses information from nearby elements to optimize the probability estimate.  Arithmetic coding is finally applied to compress the data.
  The context modeling provides estimates of conditional probabilities of the coding symbols. Utilizing suitable context models, a given inter-symbol redundancy can be exploited by switching between different probability models according to already-coded symbols in the neighborhood of the current symbol to encode. The context modeling is responsible for most of CABAC's roughly 10% savings in bit rate over the CAVLC entropy coding method.
  Coding a data symbol involves the following stages.
  Binarization: CABAC uses Binary Arithmetic Coding which means that only binary  decisions (1 or 0) are encoded. A non-binary-valued symbol (e.g. a transform  coefficient or motion vector) is "binarized" or converted into a binary code prior to arithmetic coding. This process is similar to the process of converting a data symbol into a variable length code but the binary code is further encoded (by the arithmetic coder) prior to transmission.
  Stages are repeated for each bit (or "bin") of the binarized symbol.
  Context model selection: A "context model" is a probability model for one or more bins of the binarized symbol. This model may be chosen from a selection of available models depending on the statistics of recently coded data symbols. The context model stores the probability of each bin being "1" or "0".
  Arithmetic encoding: An arithmetic coder encodes each bin according to the selected probability model. Note that there are just two sub-ranges for each bin (corresponding to "0" and "1").
  Probability update: The selected context model is updated based on the actual coded value (e.g. if the bin value was "1", the frequency count of "1"s is increased).
caption: CABAC method of entropy encoding used within H264 video compression standard in English
exif: {}