HM Encoder Code Reading (21)--The concept of entropy coding and its application in HEVC

Source: Internet
Author: User

Entropy coding transforms a series of element symbols used to represent video sequences into a stream of compressed streams for transmission or storage.

The amount of information is measured by quantity, obviously, it is related to the degree of elimination of uncertainty, the greater the uncertainty, the more information. The magnitude of uncertainty is correlated with the probability of event occurrence, so uncertainty can be measured and further information can be measured.
Suppose the probability space of a source (that is, where the information is generated) is: X, which represents the set of symbols produced by the source, and P (X) represents the set of probabilities produced by the symbol.
So, the amount of information for a source symbol Xi is defined as: I (xi) =log (1/p (xi)). So the information entropy of this source (i.e. the amount of this source contains) is the mathematical expectation of the quantity of each source symbol: E[i (Xi)].
That is, entropy can represent the size of information.
The information of the source output is encoded by a certain method, which is entropy coding. Usually, there are two ways to encode: (1) variable-length coding (Huffman encoding is a variable-length encoding) is a prefix encoding (that is, any one code word is not a prefix of another code word). One of the most widely used is the exponential Columbus code. The variable length encoding for each message of the source specifies a code word of different lengths. (2) Arithmetic code. The essence of arithmetic coding is to assign a code word to the entire input sequence. It is therefore possible to assign a code word with a length of less than 1 for a single character in the mean sense.
The exponential Columbus code consists of two parts: prefix and suffix, both of which depend on the order K of the exponential Columbus code. Assuming that the exponential Columbus code is n, the order is K, the following is its encoding step: (1) Convert N to binary number, remove the lowest k bit, and then add 1 (2) to calculate the number of bits left, minus 1, This is the number of prefix 0 that needs to be increased (3) to replace the K bits removed in step (1) Back to the end of the bit string. If n=4,k=1, then: (1) turn n into binary that is 100, remove the back 1 bits to 10, plus 1 becomes 11 (2) 11 of the bit number is 2, so need to precede (2-1) 0. becomes 011 (3) to make up the removed bits, that is, 0110.
Arithmetic Coding steps: (1) set the current interval [l,h] to [0,1] at the beginning (2) for each event, the encoder is processed according to steps a and B: a) The encoder divides the current interval into sub-intervals, each event a B) and the size of a sub-interval is proportional to the probability of the next occurrence. The sub-interval selected by the encoder corresponds to the next occurrence and treats it as a new interval (3) The bottom boundary of the current interval of the last output is the arithmetic encoding of the given sequence. Here is an example: Suppose the source symbol is {a,b,c,d}, the probability of these symbols occurring is {0.1,0.4,0.2,0.3}, so the interval [0,1] is divided into 4 sub-intervals: [0,0.1], [0.1,0.5], [0.5,0.7], [0.7,1]
In HEVC, the 0-order exponential Columbus code is used to encode parameters for the video parameter set (VPS), sequence parameter set (SPS), image parameter set (PPS), and title information. The Cabac (context-adaptive binary arithmetic encoding) is used for other parameters as well as the encoding of the residual coefficients.
0-Order exponent Columbus Code: (1) consists of a prefix and a suffix, the length of the prefix and the length of the suffix satisfies: Lprefix-lsuffix = 1. (2) The prefix has the form of a unary code, that is: 000 ... 001, where 0 of the number M equals: m=log2 (Codenum + 1); Codenum is calculated by the symbol to be coded V: if V is greater than 0, then Codenum = 2v-1, otherwise codenum=-2v. (3) The suffix part is the binary of the following values: The three basic steps of CODENUM+1-2^M&NBSP;CABAC are: (1) binary. Methods such as truncation of the binary binary (TR), fixed length code (FL), exponential Columbus (EGK) (note that it can also be used for binary) are generally used, and two methods are described below.      ① truncation of binary binary. Known threshold value Cmax, les parameter R, the value of the syntax element V. Truncated les codes are stitched together by prefixes and suffixes.       prefix value p=v>>r. If p is less than cmax>>r, then the prefix consists of P 1 and a 0. If p is greater than or equal to Cmax>>r, the prefix is made up of cmax>>r 1.       There is no suffix when the syntax element V is greater than or equal to Cmax, when V is less than Cmax, the suffix value s=v-(p<<r), the suffix code is the two-tuple string of s, and the length is R.      ② of fixed length binary. Convert directly to a fixed-length binary symbol string. (2) Context modeling. In general, different grammatical elements are not completely independent, so you can conditionally encode based on the syntax elements that are already encoded, which is called context. These contextual information is usually made into tables.      ① in the encoding process, the context probability model used by the syntax element is identified by a unique context index number r, each of which involves two probabilistic model variables: The maximum probability symbol MPs and the probability State index. MPs indicates that the bin to be coded is likely to appear in symbols (0 or 1), and corresponding to the symbol that the bin is not likely to be encoded is the minimum probability symbol LPS.      ② in Cabac, the probability of LPs is set to 64 representative values, each corresponding to LPs one by one.      ③ Encoder initializes the division sign variable for the context model MPs and      ④ after acquiring the initial probabilistic model variable, the current symbol (or grammatical element) can be two-dollar arithmetic encoding and probabilityModel parameter updates to implement context-adaptive encoding.      ⑤ Update method: If the encoded symbol equals MPs, then update the  = transidxmps () by looking up the table; otherwise, if it is 0, then the interchange LPs and MPs then update, otherwise only update, = Transidxlps () (3) binary arithmetic code. There are two modes: Normal mode, bypass mode.      1, normal mode. Suppose the interval length of the current encoder is R, and the lower limit of the interval is L.          ① Calculate index value = (r>>6) &3         ② check table get LPs corresponding sub-range = Rangetablps[][], then =-         ③ If the current binary symbol bin equals MPs, then as the next symbol of the encoding interval r, the lower bound l is unchanged; if bin equals LPs, Then as the next symbol of the coding interval r, the interval lower bound l to add the length. The context is then updated with more current symbol values.     &NBSP;2, bypass mode. This mode does not require adaptive updating of probabilities, but instead encodes a fixed probability of 0.5 for each of the 0 and 1 probabilities. In order to make the interval division more simple, we use the method of preserving the length of the coded interval and doubling the lower L value to achieve the interval division.

HM Encoder Code Reading (21)--The concept of entropy coding and its application in HEVC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.