entropy encoding and decoding a sequence of symbols using probability mixing is disclosed. A method includes selecting models that include a first model and a second model, for at least a symbol, at a position of the symbols, determining a mixed probability using the first model and the second model, and coding the symbol using the mixed probability. Determining the mixed probability for the symbol includes determining, using the first model, a first conditional probability for coding the symbol, determining, using the second model, a second conditional probability for coding the symbol, and determining, using the first conditional probability and the second conditional probability, the mixed probability for coding the symbol. The first conditional probability is a conditional probability of the symbol given a sub-sequence of the sequence up to the position. The second conditional probability being a conditional probability of the symbol given the sub-sequence.
|
18. An apparatus for entropy decoding a sequence of symbols, the apparatus comprising:
a memory; and
a processor, wherein the memory includes instructions executable by the processor to:
select models comprising a first model and a second model, the first model being different from the model;
determine, for a symbol at a position of the symbols, a mixed probability using the first model and the second model by instructions to:
determine, using the first model, a first conditional probability for coding the symbol, the first conditional probability being a conditional probability of the symbol having a certain value xi given that previous symbols in the sequence of symbols at positions j, where j<i, have respective values xj; and
determine, using the second model, a second conditional probability for coding the symbol, the second conditional probability being a conditional probability of the symbol having the certain value xi given that the previous symbols in the sequence of symbols at the positions j, where j<i, have the respective values xj; and
decode, from a compressed bitstream, the symbol using the mixed probability.
1. A method for entropy coding a sequence of quantized transform coefficients of a transform block, comprising:
selecting, for a quantized transform coefficient at a position i in a scan order of the transform block, probability distribution models comprising a first probability model and a second probability model, the first probability model is selected based on a first context and the second probability model is selecting based on a second context that is different from the first context;
determining, for coding the quantized transform coefficient at the position i, a mixed probability using the first probability model and the second probability model, by steps including steps (a)-(c):
(a) determining, using the first probability model, a first conditional probability for coding the quantized transform coefficient, the first conditional probability being a conditional probability of the quantized transform coefficient at the position i having a certain value xi given that previous quantized transform coefficients at positions j, where j<i in the scan order having respective values xj in the transform block;
(b) determining, using the second probability model, a second conditional probability for coding the quantized transform coefficient, the second conditional probability being a conditional probability of the quantized transform coefficient at the position i having the certain value xi given that the previous quantized transform coefficients at the positions j having the respective values xj in the transform block; and
(c) determining, using the first conditional probability and the second conditional probability, the mixed probability for coding the quantized transform coefficient at the position i; and
coding the quantized transform coefficient at the position i using the mixed probability.
12. An apparatus for entropy coding a quantized transform block, the apparatus comprising:
a memory; and
a processor, wherein the memory includes instructions executable by the processor to:
select, for a quantized transform coefficient at a position i in a scan order of the quantized transform block, probability distributions comprising a first probability distribution and a second probability distribution for coding a token indicative of the quantized transform coefficient at the position i of the quantized transform block, wherein
the first probability distribution being different from the second probability distribution,
the token is selected from an alphabet of tokens,
the first probability distribution comprises first probability values for the tokens of the alphabet of tokens and the first probability distribution selected based on a first context, and
the second probability distribution comprises second probability values for the tokens of the alphabet of tokens and the second probability distribution selected based on a second context that is different from the first context;
determine a mixed probability for coding the token using the first probability distribution and the second probability distribution by instructions to:
determine, using the first probability distribution, a first conditional probability for coding the token, the first conditional probability being a conditional probability of the token having a certain value xi given that previous quantized transform coefficients at positions j, where j<i in the scan order have respective indicative token xj; and
determine, using the second probability distribution, a second conditional probability for coding the token, the second conditional probability being a conditional probability of the token having the certain value xi given that the previous quantized transform coefficients at the positions j, where j<i in the scan order have the respective indicative token xj; and
code the token using the mixed probability.
2. The method of
combining the first conditional probability and the second conditional probability using a linear combination that uses a first weight and a second weight.
3. The method of
determining the first weight using a hypothetical arithmetic coding to determine a length of a codeword for coding a sub-sequence of the sequence of quantized transform coefficients up to the quantized transform coefficient at the position i; and
determining the first weight using the length.
4. The method of
determining a rate resulting from coding a subset of the quantized transform coefficients of the quantized transform coefficients, the subset of the quantized transform coefficients including quantized transform coefficients at scan order positions that are before the position i; and
determining the first weight using the determined rate.
5. The method of
6. The method of
7. The method of
looking up the rate in a lookup table using probability values as inputs.
8. The method of
mixing the first probability model and the second probability model to generate a first intermediate conditional probability;
mixing the third probability model and the fourth probability model to generate a second intermediate conditional probability; and
mixing the first intermediate conditional probability and the second intermediate conditional probability to generate a conditional probability to be used for coding the quantized transform coefficient at the position i.
9. The method of
10. The method of
11. The method of
13. The apparatus of
combine the first conditional probability and the second conditional probability using a linear combination that uses a first weight and a second weight, wherein
the first weight is based on a first length of a first codeword for coding tokens corresponding to previously coded tokens using the first conditional probability, and
the second weight is based on a second length of a second codeword for coding tokens corresponding to the previously coded tokens using the second conditional probability.
14. The apparatus of
determine the first length and the second length by instructions to:
convert the first probability distribution to a first binary distribution;
convert the second probability distribution to a second binary distribution;
determine the first length using the first binary distribution; and
determine the second length using the second binary distribution.
15. The apparatus of
the first probability distribution is an initial probability distribution for coding the quantized transform coefficients of the quantized transform block, and
the second probability distribution is based on statistics of a coding unit.
17. The apparatus of
|
This application claims priority to and the benefit of U.S. Provisional Application Patent Ser. No. 62/551,341, filed Aug. 29, 2017, the entire disclosure of which is hereby incorporated by reference.
Digital video streams may represent video using a sequence of frames or still images. Digital video can be used for various applications including, for example, video conferencing, high definition video entertainment, video advertisements, or sharing of user-generated videos. A digital video stream can contain a large amount of data and consume a significant amount of computing or communication resources of a computing device for processing, transmission, or storage of the video data. Various approaches have been proposed to reduce the amount of data in video streams, including compression and other encoding techniques.
Encoding based on motion estimation and compensation may be performed by breaking frames or images into blocks that are predicted based on one or more prediction blocks of reference frames. Differences (i.e., residual errors) between blocks and prediction blocks are compressed and encoded in a bitstream. A decoder uses the differences and the reference frames to reconstruct the frames or images.
An aspect is a method for entropy coding a sequence of symbols including selecting models that include a first model and a second model, for at least a symbol, at a position of the symbols, determining a mixed probability using the first model and the second model, and coding the symbol using the mixed probability. Determining the mixed probability for the symbol includes determining, using the first model, a first conditional probability for coding the symbol, determining, using the second model, a second conditional probability for coding the symbol, and determining, using the first conditional probability and the second conditional probability, the mixed probability for coding the symbol. The first conditional probability is a conditional probability of the symbol given a sub-sequence of the sequence up to the position. The second conditional probability being a conditional probability of the symbol given the sub-sequence.
Another aspect is an apparatus for entropy coding a quantized transform block including a memory and a processor. The memory includes instructions executable by the processor to select probability distributions comprising a first probability distribution and a second probability distribution for coding a token indicative of a quantized transform coefficient of the quantized transform block, determine a mixed probability for coding the token using the first probability distribution and the second probability distribution, and code the token using the mixed probability. The token is selected from an alphabet of tokens. The first probability distribution includes first probability values for the tokens of the alphabet of tokens. The second probability distribution includes second probability values for the tokens of the alphabet of tokens.
Yet another aspect is an apparatus for entropy decoding a sequence of symbols including a memory and a processor. The memory includes instructions executable by the processor to select models including a first model and a second model, determine, for a symbol at a position of the symbols, a mixed probability using the first model and the second model, and decode, from a compressed bitstream, the symbol using the mixed probability.
These and other aspects of the present disclosure are disclosed in the following detailed description of the embodiments, the appended claims, and the accompanying figures.
The description herein refers to the accompanying drawings wherein like reference numerals refer to like parts throughout the several views.
As mentioned above, compression schemes related to coding video streams may include breaking images into blocks and generating a digital video output bitstream using one or more techniques to limit the information included in the output. A received encoded bitstream can be decoded to re-create the blocks and the source images from the limited information. Encoding a video stream, or a portion thereof, such as a frame or a block, can include using temporal or spatial similarities in the video stream to improve coding efficiency. For example, a current block of a video stream may be encoded based on identifying a difference (residual) between the previously coded pixel values and those in the current block. In this way, only the residual and parameters used to generate the residual need be added to the encoded bitstream. The residual may be encoded using a lossy quantization step.
As further described below, the residual block can be in the pixel domain. The residual block can be transformed into the frequency domain resulting in a transform block of transform coefficients. The transform coefficients can be quantized resulting into a quantized transform block of quantized transform coefficients. The quantized coefficients can be entropy encoded and added to an encoded bitstream. A decoder can receive the encoded bitstream, entropy decode the quantized transform coefficients to reconstruct the original video frame.
Entropy coding is a technique for “lossless” coding that relies upon probability models that model the distribution of values occurring in an encoded video bitstream. By using probability models based on a measured or estimated distribution of values, entropy coding can reduce the number of bits required to represent video data close to a theoretical minimum. In practice, the actual reduction in the number of bits required to represent video data can be a function of the accuracy of the probability model, the number of bits over which the coding is performed, and the computational accuracy of fixed-point arithmetic used to perform the coding.
In an encoded video bitstream, many of the bits are used for one of two things: either content prediction (e.g., inter mode/motion vector coding, intra prediction mode coding, etc.) or residual coding (e.g., transform coefficients). Encoders may use techniques to decrease the amount of bits spent on coefficient coding. For example, a coefficient token tree (which may also be referred to as a binary token tree) specifies the scope of the value, with forward-adaptive probabilities for each branch in this token tree. The token base value is subtracted from the value to be coded to form a residual then the block is coded with fixed probabilities. A similar scheme with minor variations including backward-adaptivity is also possible. Adaptive techniques can alter the probability models as the video stream is being encoded to adapt to changing characteristics of the data. In any event, a decoder is informed of (or has available) the probability model used to encode an entropy-coded video bitstream in order to decode the video bitstream.
As described above, entropy coding a sequence of symbols is typically achieved by using a probability model to determine a probability p for the sequence and then using binary arithmetic coding to map the sequence to a binary codeword at the encoder and to decode that sequence from the binary codeword at the decoder. The length (i.e., number of bits) of the codeword is given by −log2(p). The efficiency of entropy coding can be directly related to the probability model.
Given a probability p(xn) of a sequence of symbols xn, a good entropy coding engine, such as a well-designed binary arithmetic coding engine, can produce from the probability p(xn) a binary string of length −log2(p(xn)). As the length of the string is an integer number, “a binary string of length −log2(p(xn))” means a binary string having a length that is the smallest integer that is greater than −log2(p(xn)). Herein, when referring to a sequence of symbols, a superscript of i refers to a sequence having a length of i symbols, and a subscript of i refers to the symbol at position i in the sequence. For example, x5 refers to a sequence of five (5) symbols, such as 11010; whereas x5 refers to the symbol in the 5th position, such as the last 0 in the sequence 11010. As such the sequence xn can be expressed as xn=x1x2 . . . xn.
In some implementations, a symbol can refer to a token that is selected from a non-binary token alphabet that includes N tokens. As such, the symbol (i.e., token) can have one of N values. The token can be a token that is used to code, and is indicative of, a transform coefficient. In such cases, “a sequence of symbols xn” refers to the list of tokens x1, x2, . . . , xn used to code the transform coefficients at scan positions 1, 2, . . . , n, respectively, in a scan order.
As used herein, probability values, such as the probability p(xi) of the sub-sequence xi, can have either floating-point or fixed-point representations. Accordingly, operations applied to these values may use either floating-point arithmetic or fixed-point arithmetic.
Given two probabilities p1(xn) and p2(xn) such that p1(xn)<p2(xn), the probability p1(xn) results in a codeword that is no shorter than the probability p2(xn). That is, a smaller probability typically produces a longer codeword than a larger probability.
The underlying probability model from which symbols are emitted in video coding is typically unknown and/or is likely too complex to be fully described. As such, designing a good model for use in entropy coding can be a challenging problem in video coding. For example, a model that works well for one sequence may perform poorly for another sequence. That is, given a first model and a second model, some sequences might compress better using the first model while other sequences might compress better using the second model.
In some video systems, it is possible to code (i.e., signal in an encoded bitstream) an optimal model for encoding a sequence. For example, given a sequence to be encoded, a video system may encode the sequence according to all or a subset of available models and then select the model that results in the best compression result. That is, it is possible to code the selection of a particular model among a set of more than one models for the sequence. In such a system, a two-pass process may be, implicitly or explicitly, performed: a first pass to determine the optimal model and a second to encode using the optimal model. A two-pass process may not be feasible in, e.g., real-time applications and other delay-sensitive applications.
As mentioned above, multiple models (i.e., models 1, . . . , M) may be available for entropy coding. For a sequence of symbols to be compressed without loss of information, mixing a finite number of models for arithmetic coding can be as good selecting the best one model, asymptotically. This follows from the fact that the log (i.e., logarithm) function is a concave function and that the −log function is a convex function.
From the foregoing, and for a finite sequence xn=x1x2 . . . xn of length n, inequality (1) follows:
−log(Σk=1Mwkpk(xn))≤Σk=1Mwk(−log pk(xn)) (1)
In the inequality (1), wk denotes a weighting factor of the kth model and pk(xn) denotes the joint probability of xn given by model k. As described above, given a probability pk(xn) (i.e., the probability given by model k of the sequence xn) and xn as the input, an entropy coding engine can map xn into a binary codeword of length that is approximately equal to −log pk(xn).
From the inequality (1), it follows that taking the linear (i.e., weighted) sum of the probabilities (i.e., Σk=1Mwkpk(xn)) for the available models and then taking the logarithm of the linear sum is always less than or equal to taking the logarithms of the probabilities (log pk(xn)) of the models 1, . . . , M and then performing a linear sum using the same weighting factors {wk}. That is, the left-hand-side of the inequality (1) is always less than or equal to the right-hand-side of the inequality.
It also follows from the inequality (1) that, given M models, it is more advantageous to mix the probabilities of the models 1, . . . , M before entropy coding a symbol. That is, it may be more advantageous to mix the probabilities of multiple models before entropy coding than to choose models according to probabilities and using each model to individually code a sequence of bits. Mixing distinct models is likely to improve compression performance (i.e. reduces compression rate) and is no worse than selecting and coding the best model and then to code a sequence using the selected model.
The probability pk(xn) is a joint probability of the sequence xn. That is, given the sequence xn=x1x2 . . . xn, the joint probability pk(xn) is the probability that the first symbol is x1, the second symbol is x2, . . . , and the nth symbol is xn. As coding xn jointly can incur significant delay in processing and can incur a high computational complexity, mixing has found limited use, if at all, in video coding.
A model, as used herein, can be, or can be a parameter in, a lossless (entropy) coding. A model can be any parameter or method that affects probability estimation for the purpose of entropy coding. For example, a model can define the probability to be used to encode and decode the decision at an internal node in a token tree (such as described with respect to
Implementations according to this disclosure can efficiently mix multiple models for entropy coding in real-time or delay sensitive applications, including video coding, to reduce the number of bits required to represent video data. Mixing models can be used for encoding any value that is coded using entropy coding. For example, two or more probability models can be mixed in order to entropy code quantized transform coefficients. The benefits of implementations according to this disclosure include 1) improved compression performance and 2) the mixing of probabilities from multiple models in a single-pass coding process that does not sacrifice compression performance or incur a high computational cost.
Mixing for entropy coding in video compression is described herein first with reference to a system in which the teachings may be incorporated.
A network 104 can connect the transmitting station 102 and a receiving station 106 for encoding and decoding of the video stream. Specifically, the video stream can be encoded in the transmitting station 102 and the encoded video stream can be decoded in the receiving station 106. The network 104 can be, for example, the Internet. The network 104 can also be a local area network (LAN), wide area network (WAN), virtual private network (VPN), cellular telephone network, or any other means of transferring the video stream from the transmitting station 102 to, in this example, the receiving station 106.
The receiving station 106, in one example, can be a computer having an internal configuration of hardware such as that described in
Other implementations of the video encoding and decoding system 100 are possible. For example, an implementation can omit the network 104. In another implementation, a video stream can be encoded and then stored for transmission, at a later time, to the receiving station 106 or any other device having memory. In one implementation, the receiving station 106 receives (e.g., via the network 104, a computer bus, and/or some communication pathway) the encoded video stream and stores the video stream for later decoding. In an example implementation, a real-time transport protocol (RTP) is used for transmission of the encoded video over the network 104. In another implementation, a transport protocol other than RTP may be used, e.g., an HTTP-based video streaming protocol.
When used in a video conferencing system, for example, the transmitting station 102 and/or the receiving station 106 may include the ability to both encode and decode a video stream as described below. For example, the receiving station 106 could be a video conference participant who receives an encoded video bitstream from a video conference server (e.g., the transmitting station 102) to decode and view and further encodes and transmits its own video bitstream to the video conference server for decoding and viewing by other participants.
A CPU 202 in the computing device 200 can be a central processing unit. Alternatively, the CPU 202 can be any other type of device, or multiple devices, capable of manipulating or processing information now existing or hereafter developed. Although the disclosed implementations can be practiced with a single processor as shown, e.g., the CPU 202, advantages in speed and efficiency can be achieved using more than one processor.
A memory 204 in the computing device 200 can be a read-only memory (ROM) device or a random access memory (RAM) device in an implementation. Any other suitable type of storage device can be used as the memory 204. The memory 204 can include code and data 206 that is accessed by the CPU 202 using a bus 212. The memory 204 can further include an operating system 208 and application programs 210, the application programs 210 including at least one program that permits the CPU 202 to perform the methods described here. For example, the application programs 210 can include applications 1 through N, which further include a video coding application that performs the methods described here. The computing device 200 can also include a secondary storage 214, which can, for example, be a memory card used with a computing device 200 that is mobile. Because the video communication sessions may contain a significant amount of information, they can be stored in whole or in part in the secondary storage 214 and loaded into the memory 204 as needed for processing.
The computing device 200 can also include one or more output devices, such as a display 218. The display 218 may be, in one example, a touch sensitive display that combines a display with a touch sensitive element that is operable to sense touch inputs. The display 218 can be coupled to the CPU 202 via the bus 212. Other output devices that permit a user to program or otherwise use the computing device 200 can be provided in addition to or as an alternative to the display 218. When the output device is or includes a display, the display can be implemented in various ways, including by a liquid crystal display (LCD), a cathode-ray tube (CRT) display or light emitting diode (LED) display, such as an organic LED (OLED) display.
The computing device 200 can also include or be in communication with an image-sensing device 220, for example, a camera or any other image-sensing device 220 now existing or hereafter developed that can sense an image such as the image of a user operating the computing device 200. The image-sensing device 220 can be positioned such that it is directed toward the user operating the computing device 200. In an example, the position and optical axis of the image-sensing device 220 can be configured such that the field of vision includes an area that is directly adjacent to the display 218 and from which the display 218 is visible.
The computing device 200 can also include or be in communication with a sound-sensing device 222, for example, a microphone or any other sound-sensing device now existing or hereafter developed that can sense sounds near the computing device 200. The sound-sensing device 222 can be positioned such that it is directed toward the user operating the computing device 200 and can be configured to receive sounds, for example, speech or other utterances, made by the user while the user operates the computing device 200.
Although
Whether or not the frame 306 is divided into the segments 308, the frame 306 may be further subdivided into blocks 310, which can contain data corresponding to, for example, 16×16 pixels in the frame 306. The blocks 310 can also be arranged to include data from one or more segments 308 of pixel data. The blocks 310 can also be of any other suitable size such as 4×4 pixels, 8×8 pixels, 16×8 pixels, 8×16 pixels, 16×16 pixels or larger.
When the video stream 300 is presented for encoding, the frame 306 can be processed in units of blocks. At the intra/inter prediction stage 402, a block can be encoded using intra-frame prediction (also called intra-prediction) or inter-frame prediction (also called inter-prediction), or a combination of both. In any case, a prediction block can be formed. In the case of intra-prediction, all or a part of a prediction block may be formed from samples in the current frame that have been previously encoded and reconstructed. In the case of inter-prediction, all or part of a prediction block may be formed from samples in one or more previously constructed reference frames determined using motion vectors.
Next, still referring to
The quantization stage 406 converts the transform coefficients into discrete quantum values, which are referred to as quantized transform coefficients, using a quantizer value or a quantization level. For example, the transform coefficients may be divided by the quantizer value and truncated. The quantized transform coefficients are then entropy encoded by the entropy encoding stage 408. Entropy coding may be performed using any number of techniques, including token and binary trees. The entropy-encoded coefficients, together with other information used to decode the block, which may include for example the type of prediction used, transform type, motion vectors and quantizer value, are then output to the compressed bitstream 420. The information to decode the block may be entropy coded into block, frame, slice and/or section headers within the compressed bitstream 420. The compressed bitstream 420 can also be referred to as an encoded video stream or an encoded video bitstream, and the terms will be used interchangeably herein.
The reconstruction path in
Other variations of the encoder 400 can be used to encode the compressed bitstream 420. For example, a non-transform based encoder 400 can quantize the residual signal directly without the transform stage 404 for certain blocks or frames. In another implementation, an encoder 400 can have the quantization stage 406 and the dequantization stage 410 combined into a single stage.
When the compressed bitstream 420 is presented for decoding, the data elements within the compressed bitstream 420 can be decoded by the entropy decoding stage 502 to produce a set of quantized transform coefficients. The dequantization stage 504 dequantizes the quantized transform coefficients (e.g., by multiplying the quantized transform coefficients by the quantizer value), and the inverse transform stage 506 inverse transforms the dequantized transform coefficients using the selected transform type to produce a derivative residual that can be identical to that created by the inverse transform stage 412 in the encoder 400. Using header information decoded from the compressed bitstream 420, the decoder 500 can use the intra/inter-prediction stage 508 to create the same prediction block as was created in the encoder 400, e.g., at the intra/inter prediction stage 402. At the reconstruction stage 510, the prediction block can be added to the derivative residual to create a reconstructed block. The loop filtering stage 512 can be applied to the reconstructed block to reduce blocking artifacts. As such, the loop filtering stage 512 can apply deblocking filtering. Other filtering can be applied to the reconstructed block. In an example, the post filtering stage 514 is applied to the reconstructed block to reduce blocking distortion, and the result is output as an output video stream 516. The output video stream 516 can also be referred to as a decoded video stream, and the terms will be used interchangeably herein.
Other variations of the decoder 500 can be used to decode the compressed bitstream 420. For example, the decoder 500 can produce the output video stream 516 without the post filtering stage 514. In some implementations of the decoder 500, the post filtering stage 514 is applied before the loop filtering stage 512. Additionally, or alternatively, the encoder 400 includes a deblocking filtering stage in addition to the loop filtering stage 416.
The quantized transform block 604 can be a block of size similar to the size of the current block 620. The quantized transform block 604 includes non-zero coefficients (e.g., a coefficient 608) and zero coefficients (e.g., a coefficient 610). As described above, the quantized transform block 604 contains quantized transform coefficients for the residual block corresponding to the current block 620. Also as described above, the quantized transform coefficients are entropy coded by an entropy-coding phase, such as the entropy coding stage 408 of
Entropy coding a quantized transform coefficient can involve the selection of a context model (also referred to as probability context model, probability model, model, and context) which provides estimates of conditional probabilities for coding the binary symbols of a binarized transform coefficient as described below with respect to
To encode a transform block, a video coding system may traverse the transform block in a scan order and encode (e.g., entropy encode) the quantized transform coefficients as the quantized transform coefficients are respectively traversed (i.e., visited). In a zigzag scan order, such as the scan order 602, the top left corner of the transform block (also known as the DC coefficient) is first traversed and encoded, the next coefficient in the scan order (i.e., the transform coefficient corresponding to the location labeled “1”) is traversed and encoded, and so on. In the zigzag scan order (i.e., scan order 602), some quantized transform coefficients above and to the left of a current quantized transform coefficient (e.g., a to-be-encoded transform coefficient) are traversed first. Other scan orders are possible. A one-dimensional structure (e.g., an array) of quantized transform coefficients can result from the traversal of the two-dimensional quantized transform block using the scan order.
In some examples, encoding the quantized transform block 604 can include determining the non-zero map 606, which indicates which quantized transform coefficients of the quantized transform block 604 are zero and which are non-zero. A non-zero coefficient and a zero coefficient can be indicated with values one (1) and zero (0), respectively, in the non-zero map. For example, the non-zero map 606 includes a non-zero 607 at Cartesian location (0, 0) corresponding to the coefficient 608 and a zero 608 at Cartesian location (2, 0) corresponding to the coefficient 610.
In some examples, encoding the quantized transform block 604 can include generating and encoding the end-of-block map 622. The end-of-block map indicates whether a non-zero quantized transform coefficient of the quantized transform block 604 is the last non-zero coefficient with respect to a given scan order. If a non-zero coefficient is not the last non-zero coefficient in the transform block, then it can be indicated with the binary bit zero (0) in the end-of-block map. If, on the other hand, a non-zero coefficient is the last non-zero coefficient in the transform block, then it can be indicated with the binary value one (1) in the end-of-block map. For example, as the quantized transform coefficient corresponding to the scan location 11 (i.e., the last non-zero quantized transform coefficient 628) is the last non-zero coefficient of the quantized transform block 604, it is indicated with the end-of-block value 624 of one (1); all other non-zero transform coefficients are indicated with a zero.
In some examples, encoding the quantized transform block 604 can include generating and encoding the sign map 626. The sign map 626 indicates which non-zero quantized transform coefficients of the quantized transform block 604 have positive values and which quantized transform coefficients have negative values. Transform coefficients that are zero need not be indicated in the sign map. The sign map 626 illustrates the sign map for the quantized transform block 604. In the sign map, negative quantized transform coefficients can be indicated with a −1 and positive quantized transform coefficients can be indicated with a one (1).
As described above with respect to
In some video coding systems, a binary decision determining whether (or not) a current token is equal to the EOB token of the current block is coded immediately after an nonzero coefficient is decoded or at the first scan position (DC). In an example, for a transform block of size M×N, where M denotes the number of columns and N denotes the number of rows in the transform block, the maximum number of times of coding whether a current token is equal to the EOB token is equal to M×N. M and N can take values, such as the values 2, 4, 8, 16, 32, and 64. As described below, the binary decision corresponds to the coding of a “1” bit corresponding to the decision to move from the root node 701 to the node 703 in the coefficient token tree 700. Herein, “coding a bit” can mean the outputting or generating of a bit in the codeword representing a transform coefficient being encoded. Similarly, “decoding a bit” can mean the reading (such as from an encoded bitstream) of a bit of the codeword corresponding to a quantized transform coefficient being decoded such that the bit corresponds to a branch being traversed in the coefficient token tree.
Using the coefficient token tree 700, a string of binary digits is generated for a quantized coefficient (e.g., the coefficients 608, 610 of
In an example, the quantized coefficients in an N×N block (e.g., quantized transform block 604) are organized into a 1D (one-dimensional) array (herein, an array u) following a prescribed scan order (e.g., the scan order 602 of
To encode and decode the coefficients u[i], . . . , u[N*N−1], for i=0 to N*N−1, a token t[i] is generated at each position i<=eob. The token t[i], for i<eob, can be indicative of the size and/or size range of the corresponding quantized transform coefficient at u[i]. The token for the quantized transform coefficient at eob can be an EOB_TOKEN, which is a token that indicates that the 1D array u contains no non-zero coefficients following the eob position (inclusive). That is, t[eob]=EOB_TOKEN indicates the EOB position of the current block. Table I provides a listing of an example of token values, excluding the EOB_TOKEN, and their corresponding names according to an implementation of this disclosure.
TABLE I
Token
Name of Token
0
ZERO_TOKEN
1
ONE_TOKEN
2
TWO_TOKEN
3
THREE_TOKEN
4
FOUR_TOKEN
5
DCT_VAL_CAT1 (5, 6)
6
DCT_VAL_CAT2 (7-10)
7
DCT_VAL_CAT3 (11-18)
8
DCT_VAL_CAT4 (19-34)
9
DCT_VAL_CAT5 (35-66)
10
DCT_VAL_CAT6 (67-2048)
In an example, quantized coefficient values are taken to be signed 12-bit integers. To represent a quantized coefficient value, the range of 12-bit signed values can be divided into 11 tokens (the tokens 0-10 in Table I) plus the end of block token (EOB_TOKEN). To generate a token to represent a quantized coefficient value, the coefficient token tree 700 can be traversed. The result (i.e., the bit string) of traversing the tree can then be encoded into a bitstream (such as the bitstream 420 of
The coefficient token tree 700 includes the tokens EOB_TOKEN (token 702), ZERO_TOKEN (token 704), ONE_TOKEN (token 706), TWO_TOKEN (token 708), THREE_TOKEN (token 710), FOUR_TOKEN (token 712), CAT1 (token 714 that is DCT_VAL_CAT1 in Table I), CAT2 (token 716 that is DCT_VAL_CAT2 in Table I), CAT3 (token 718 that is DCT_VAL_CAT3 in Table I), CAT4 (token 720 that is DCT_VAL_CAT4 in Table I), CAT5 (token 722 that is DCT_VAL_CAT5 in Table I) and CAT6 (token 724 that is DCT_VAL_CAT6 in Table I). As can be seen, the coefficient token tree maps a single quantized coefficient value into a single token, such as one of the tokens 704, 706, 708, 710 and 712. Other tokens, such as the tokens 714, 716, 718, 720, 722 and 724, represent ranges of quantized coefficient values. For example, a quantized transform coefficient with a value of 37 can be represented by the token DCT_VAL_CAT5 the token 722 in
The base value for a token is defined as the smallest number in its range. For example, the base value for the token 720 is 19. Entropy coding identifies a token for each quantized coefficient and, if the token represents a range, can form a residual by subtracting the base value from the quantized coefficient. For example, a quantized transform coefficient with a value of 20 can be represented by including the token 720 and a residual value of 1 (i.e., 20 minus 19) in the encoded video bitstream to permit a decoder to reconstruct the original quantized transform coefficient. The end of block token (i.e., the token 702) signals that no further non-zero quantized coefficients remain in the transformed block data.
To encode or decode a token t [i] by using a binary arithmetic coding engine (such as by the entropy encoding stage 408 of
If a current coefficient is zero, and there are no more non-zero values for the remaining transform coefficients, the token 702 (i.e., the EOB_TOKEN) is added into the bitstream. This is the case, for example, for the transform coefficient at scan order location 12 of
Essentially, a “0” bit is added to the codeword upon traversal to a left child node and a “1” bit is added to the codeword upon traversal to a right child node. A similar process is undertaken by a decoder when decoding a codeword from a compressed bitstream. The decoder reads a bit from bit stream. If the bit is a “1,” the coefficient token tree is traversed to the right and if the bit is a “0,” the tree is traversed to the left. The decoder reads then a next bit and repeats the process until traversal of the tree reaches a leaf node (i.e., a token). As an example, to encode a token t [i]=THREE_TOKEN, starting from the root node (i.e., the root node 701), a binary string of 111010 is encoded. As another example, decoding the codeword 11100 results in the token TWO_TOKEN.
Note that the correspondence between “0” and “1” bits to left and right child nodes is merely a convention used to describe the encoding and decoding processes. In some implementations, a different convention, for example, in one where “1” corresponds to the left child node, and “0” corresponds to the right child node, can be used. As long as both the encoder and the decoder adopt the same convention, the processes described herein apply.
Since an EOB_TOKEN is only possible after a nonzero coefficient, when u[i−1] is zero (that is, when the quantized transform coefficient at location i−1 of the 1D array u is equal to zero), a decoder can infer that the first bit must be 1. The first bit has to be 1 since, in traversing the tree, for a transform coefficient (e.g., transform coefficient at the zigzag scan order location 2 of
As such, a binary flag checkEob can be used to instruct the encoder and the decoder to skip encoding and decoding the first bit leading from the root node in the coefficient token tree 700. In effect, when the binary flag checkEob is 0 (i.e., indicating that the root node should not be checked), the root node 701 of the coefficient token tree 700 is skipped and the node 703 becomes the first node of coefficient token tree 700 to be visited for traversal. That is, when the root node 701 is skipped, the encoder can skip encoding and the decoder can skip decoding and can infer a first bit (i.e., a binary bit “1”) of the encoded string.
At the start of encoding or decoding a block, the binary flag checkEob can be initialized to 1 (i.e., indicating that the root node should be checked). The following steps illustrate an example process for decoding quantized transform coefficients in an N×N block.
At step 1, the binary flag checkEob is set to zero (i.e., checkEob=0) and an index i is also set to zero (i.e., i=0).
At step 2, a token t[i] is decoded by using either
1) the full coefficient token tree (i.e., starting at the root node 701 of the coefficient token tree 700) if the binary flag checkEob is equal to 1 or
2) using the partial tree (e.g., starting at the node 703) where the EOB_TOKEN is skipped, if checkEob is equal to 0.
At step 3, If the token t[i]=EOB_TOKEN, then the quantized transform coefficients u[i], . . . , u[N*N 1] are all to zero and the decoding process terminates; otherwise, extra bits can be decoded if necessary (i.e., when t[i] is not equal to the ZERO_TOKEN) and reconstruct u[i].
At step 4, the binary flag checkEob is set to 1 if u[i] is equal to zero, otherwise checkEob is set to 0. That is, checkEob can be set to the value (u[i]!=0).
At step 5, the index i is incremented (i.e., i=i+1).
At step 6, the steps 2-5 are repeated until all quantized transform coefficients have been decoded (i.e., until the index i=N*N) or until the EOB_TOKEN is decoded.
At step 2 above, decoding a token t[i] can include the steps of determining a context ctx, determining a binary probability distribution (i.e., a model) from the context ctx, and using a boolean arithmetic code to decode a path from the root node of the coefficient token tree 700 to a leaf node by using the determined probability distributions. The context ctx can be determined using a method of context derivation. The method of context derivation can use one or more of the block size, plane type (i.e., luminance or chrominance), the position i, and previously decoded tokens t [0], . . . , t[i−1] to determine the context ctx. Other criteria can be used to determine the context ctx. The binary probability distribution can be determined for any internal node of the coefficient token tree 700 starting from the root node 701 when checkEOB=1 or from the node 703 when checkEOB=0.
In some coding systems, the probability used to encode or decode a token t[i] given a context ctx may be fixed and does not adapt in a picture (i.e., a frame). For example, the probability may be either a default value that is defined for the given context ctx or the probability may be coded (i.e., signaled) as part of the frame header for that frame. Coding the probability for every context in coding a frame can be costly. As such, an encoder may analyze, for each context, whether it is beneficial to code the context's associated probability in the frame header and signal its decision to the decoder by using a binary flag. Furthermore, coding the probability for a context may use prediction to reduce cost (e.g., in bit rate) where the prediction may be derived from the probability of the same context in a previously decoded frame.
In some coding systems, instead of traversing a coefficient token tree, such as the coefficient token tree 700, to code a transform coefficient, each token can be associated with a value that is coded. As such, instead of a coding binary symbols (i.e., selected from an alphabet comprised of the symbols {0, 1}), an alphabet of symbols that includes more than two symbols is used for coding transform coefficients. In an example, the alphabet includes 12 symbols, namely {EOB_TOKEN, ZERO_TOKEN, ONE_TOKEN, TWO_TOKEN, THREE_TOKEN, FOUR_TOKEN, DCT_VAL_CAT1, DCT_VAL_CAT2, DCT_VAL_CAT3, DCT_VAL_CAT4, DCT_VAL_CAT5, DCT_VAL_CAT6}. As such, the alphabet for coding transform coefficients includes 12 symbols, which are also referred to as tokens. Other token alphabets that include more, less, or other tokens are possible. An alphabet that includes only the symbols { 0, 1} is referred to herein as a binary alphabet. An alphabet that includes symbols other than and/or in addition to the symbols { 0, 1} is referred to herein as a non-binary alphabet. Each of the tokens can be associated with a value. In an example, the EOB_TOKEN can have a value of 255. Each of the other tokens can each be associated with a different value.
In the binarization step, a coefficient x is first binarized into a binary string by using the tree 800. The binarization process may binarize the unsigned value of the coefficient x. For example, binarizing the coefficient 628 (i.e., the value −1), binarizes the value 1. This results in traversing the tree 800 and generating the binary string 10. Each of the bits of the binary string 10 is referred to as a bin.
In the context derivation step, for each bin to be coded, a context is derived. A context can be derived from information such as one or more of the block size, plane type (i.e., luminance or chrominance), block position of the coefficient x, and previously decoded coefficients (e.g., a left and/or above neighboring coefficients, if available). Other information can be used to derive the context.
In the binary arithmetic coding step, given a context, a bin is coded by using, e.g., a binary arithmetic coding engine into a binary codeword together with a probability value associated with the context.
The steps of coding a transform coefficient can include a step that is referred as context update. In the context update step, after a bin is coded, the probability associated with the context is updated to reflect the value of the bin.
Mixing of probability models is now described for coding (i.e., encoding or decoding) a sequence xn of length n. For simplicity, two (2) models are used. However, this disclosure is not so limited and any number of models can be mixed.
For any sub-sequence of length i of the sequence xn where 1≤i≤n, probability pk(xi) denotes the probability of the subsequence xi estimated by using the model k, where k=1, 2. Using a corresponding weighting factor wk for each model, the two models can be mixed using equation (2):
{tilde over (p)}(xi)=Σk=12wkpk(xi), for each i (2)
In equation (2), {tilde over (p)}(xi) is the mixed probability of the sub-sequence xi. As such, the mixing can produce partial (or intermediate) results for each sub-sequence xi. The sub-sequence xi is xi=x1x2x3 . . . xi. The first model (i.e., k=1) produces the sub-sequence probability p1(xi); and the second model (i.e., k=2) produces the sub-sequence probability p2(xi).
In an example, and as it may not be known a priori which model should have the priority, a simple mixture can be used. For example, uniform weighting can be used. That is, the weight factors wk can be chosen such that wk=½. As such, the equation (2) can be re-written as:
The mixed probability {tilde over (p)}(xi) is the probability of a sub-sequence. However, arithmetic coding is performed on a symbol-by-symbol basis (i.e., not on sequences of symbols). As such, the mixed probability {tilde over (p)}(xi) cannot directly be used for entropy coding. This can be addressed by converting the mixed probability {tilde over (p)}(xi) into a product of conditional probabilities as described below. Let {tilde over (p)}(xi/xi−1) denote the conditional probability of a symbol at position i having a certain value given that the previous symbols result in the sub-sequence xi−1. That is, the mixed probability {tilde over (p)}(xi) can be given by equation (4):
{tilde over (p)}(xi)={tilde over (p)}(x1)*{tilde over (p)}(x2|x1)* . . . *{tilde over (p)}(xi|xi−1) (4)
Using the elementary conditional probability formula P(A|B)=P(A∩B)/P(B), where P(A∩B) is the probability of both events A and B occurring, the equation (4) can be rewritten as equation (5):
{tilde over (p)}(xi|xi−1)={tilde over (p)}(xi∩xi−1)/{tilde over (p)}(xi−1)={tilde over (p)}(xi)/{tilde over (p)}(xi−1) (5)
It is noted that the mixed probability of both xi and xi−1 occurring is the same as the mixed probability of xi alone because the sub-sequence xi includes the sub-sequence xi−1 and has the symbol xi.
The equation (5) can be rewritten using the equation (3). That is, each of the sub-sequence mixed probabilities (i.e., the numerator and denominator) of equation (5) can be rewritten in terms of the model probabilities. The equation (5) can be rewritten as equation (6):
Multiplying the first quantity and the second quantity of the equation (6) each by a factor equaling one (1) (i.e.,
respectively), equation (7) is obtained:
Equation (7) can be written as equation (8):
{tilde over (p)}(xi|xi−1)=wi,1*p1(xi|xi−1)+wi,2*p2(xi|xi−1) (8)
It is noteworthy that the conditional probabilities of p1(xi|xi−1) and p2(xi|xi−1) are available as a result of the encoding (and, similarly, decoding) of a sequence up to the ith symbol by using model 1 and model 2, respectively. That is, starting from respective initial states, each model k can maintain and keep track of the conditional probabilities pk(xi|xi−1) throughout the coding process. For example, after a symbol xi is coded (e.g., encoded or decoded), the probability pk(xi|xi−1) can be updated to obtain pk(xi+1|xi) for the next symbol xi+1. The probabilities can be updated using a same prescribed process by an encoder and a decoder. The encoder and the decoder can follow the same prescribed process for maintaining and updating the probabilities for a model k. In some implementations, the maintaining and updating of the probabilities is not performed each time a symbol xi is coded. As such, the probability pk(xi|xi−1) can have a form pk(xi|ck,i) where ck,i can be referred to as the context used to code xi. Each model k can have a respective method to derive the respective context ck,i from xi−1 and other information available for the model k. The probabilities pk(xi|ck,i) can be stored and maintained in a memory where the context ck,i can be used as an index to access the memory. In implementations according to this disclosure, the conditional probabilities are mixed and the sequence is then encoded (or decoded) using the mixed probability (i.e., {tilde over (p)}(xi|xi−1)).
In equation (8), wi,1 and wi,2 are weights that are respectively equal to
and p1(xi|xi−1) and p2 (xi|xi−1) are respectively equal to
As such, the mixed probability p(xi|xi−1) is now expressed as a linear combination of the conditional probability of the first model (i.e., p1(xi|xi−1)) and the conditional probability of the second model (i.e., p2(xi|xi−1)) where each of the conditional probabilities is multiplied by a respective weighting factor. It is worth pointing out that even if both model 1 and model 2 are memoryless (i.e., pk(xi)=Πj=1ipk(xj)), the mixed probability
in general, does not have a simple product form, such as Πj−1i{tilde over (p)})xj). Furthermore, the weights wi,1 and wi,2 can have different values for different symbols. That is, the weights wi,1 and wi,2 can vary at different values of i.
When the joint distributions are mixed using the equation (3), uniform weighting factors (i.e., ½) were used. However, when conditional probabilities are mixed (as in the equation (8)), the weighting (i.e., wi,1 for the first model and wi,2 for the second model) may no longer be uniform. The weight wi,1 for the conditional probability of the first model is equal to the joint probability of xi−1 given by the first model divided by the sum of the joint probability of xi−1 given by the first model and the joint probability of xi−1 given by the second model. Similarly for weight wi,2. In equation (8), for the sub-sequence xi−1, the first model provides a first probability and the second model provides a second probability and the weighting factor for the conditional probability of xi given xi−1 is equal to the probability given by each of the first model and the second model divided by the sum of the joint probabilities given by both models. That is, in the mixing of the conditional probabilities, if, for example, the first model provides a higher probability for the sub-sequence then the first model ends up having a higher weighting factor (i.e., weight wi,1) than that of the second model.
The joint probabilities are real numbers and the calculating of the weights wi,1 and wi,2 involves the division of real numbers. As such, the computing of the weights wi,1 and wi,2 may be complex and expensive. It is desirable to approximate the weights wi,1 and wi,2 with fixed-point representations such that, for example, the exact number of bits to represent each of the weights can be known and such that division operations can be avoided.
As described above, there is a correlation and/or relationship between the probability of a codeword and the length, in bits, of the codeword generated using the probability of the codeword. Namely, the length (i.e., number of bits) of the codeword is given by −log2(p). The lengths of the codewords generated by each model can be used to approximate the weights wi,1 and wi,2. That is, −log(pk(xi−1)) can be approximated by the codeword length lk(xi−1) in bits resulting from using model k, for k=1, 2, to encode xi−1. As such, the weight wi,1 (and, similarly, the weight wi,2) can be approximated using equation (9):
When l2(i−1) is equal to l1(i−1), then it follows that wi,1=wi,2=0.5. Assuming, without losing generality, that l1(i−1) is smaller than l2(i−1), then the equation (9) can result by expanding the denominator and then eliminating 2−l
To determine a length lk(xi) according to a model k of a sub-sequence of length i, a hypothetical encoding process can be used. A hypothetical encoding process is a process that carries out the coding steps but does not generate actual codewords or output bits into an encoded bitstream. Since the purpose is to estimate lk(xi), which are interpreted in some applications as a bitrate (or a simply rate), a hypothetical encoding process may be regarded or called a rate estimation process. The hypothetical encoding process, using a probability model, computes or estimates the codeword length for a sequence. The codeword length may be determined (i.e., measured) with or without generating a codeword. For example, at time instance i, coding the sequence xi−1 using a first model generates a codeword of length l1(i−1) and using a second model generates a codeword of length l2(i−1). In an example, multiple hypothetical encoders can be available and executing in parallel. For example, a standard rate estimator for an arithmetic encoder can be available for each model. Each rate estimator can provide (or, can be used to provide) an estimate of the length of the codeword that may be produced by the encoder for a sub-sequence given a model.
Given two competing models at a time instance i, if the first model provides less bits than the second model, then the weight assigned (using equation 9) to the first model will be greater than the weight assigned to the second model for the sequence up to the symbol at position xi−1. Eventually (i.e., when encoding the sequence xn is completed using the mixed probability), the winning model (i.e., the model with higher weight) is the model that produces less bits, which is a desired result of compression.
The weight wi,1 is approximated (in equation (9)) using a power of 2 and, as such, can be efficiently computed.
The weight wi,1 can be further simplified. The right-hand-side of the equation (9) is of the form 1/(1−r) where r=−2l
wi,1≈Σj=0∞(−2l
As such, wi,1*p1(xi|xi−1) of the equation (8) can be rewritten as in equation (11):
wi,1p1(xi|xi−1)=Σj=0∞(−2l
In equation (11), 2j[l
The weight wi,2 can be computed using equation (12):
The quantity wi,2*p2(xi|xi−1) of equation (8) can be computed using equation (13):
wi,2p2(xi|xi−1)=2l
As in equation (11), the right hand side of equation (13) can be simplified by truncating the infinite sum into a finite sum when p2 (xi|xi−1) has a fixed-point representation.
As described above, mixing of joint probabilities of models can use simple uniform mixing as it may not be known a priori which model provides better compression. The uniform mixing of the joint probabilities uses conditional probabilities and results in the selection of a winning model (i.e., a model with higher weighting).
Some video data can be non-stationary within a frame/picture. That is, the statistics of one transform block may be substantially different from, e.g., the immediately subsequent transform block. As such, mixing of probability models can be used to adapt the probability distributions to the local statistics of a current transform block being coded. Using mixing of probabilities to adapt to the local statistics of a current block is referred to herein as local mixing for a transform block.
Since, as mentioned above, the statistics of a current block may be significantly different from those of a previous transform block, in the case of local mixing for a transform block, the coding history of previous transform blocks is not used for the current block. As such, the mixing of probability models can start at the boundaries of the current transform block.
In local mixing for a transform block, the sub-sequence xi of equation (2) (i.e., {tilde over (p)}(xi)=Σk=12wkpk(xi), for each i) can represent the quantized transform coefficients of the quantized transform block being coded and k can represent models for coding the transform coefficients (i.e., the subsequence) xi. Examples of the models include a context model, a speed or method (e.g. Laplace, Good-Turing, the Krichevsky-Trofimov estimator, or other method) of adapting probabilities, an initial distribution, other model, or a combination thereof. As such, the sequence xi can represent all the coded coefficients (i.e., coded quantized transform coefficients) of a transform block (i.e., a quantized transform block) up to and including a current quantized transform coefficient. As indicated above, the coefficients of a transform block are coded in a scan order. As such, the sub-sequence xi includes all the transform coefficients that precede the current coefficient xi (i.e., the sequence of coefficients xi−1) in the scan order and includes the current coefficient xi. The index i can, in the case of local mixing, represent, or be indicative of, the scan position in a scan order.
The process 900 can be implemented in an encoder such as the encoder 400 of
The process 900 uses at least two probability models to encode the sequence of symbols xn. The process 900 can use any number of probability models. However, for simplicity only two (2) models (i.e., a first model and a second model) are used to illustrate the process 900. The process 900 encodes each of the symbols of the sequence the symbols by mixing the probabilities of the first model and the second model.
At 902, the process 900 initializes a counter i to zero (0), a first sub-sequence length (i.e., first length l1) to 0, and a second sub-sequence length (i.e., second length l2) to zero (0). The counter i is used for each symbol of the sequence xn. The first length l1 and the second length l2 are as described above. That is, the first length l1 and the second length l2 can correspond, respectively, to the lengths of codewords generated by arithmetic coding engines using, respectively, the first model and the second model.
At 904, the process 900 computes the conditional probabilities p1(xi|xi−1) and p2(xi|xi−1) as described above. The conditional probability p1(xi|xi−1) is the conditional probability of the symbol at position i of the sequence of symbols given the probability of the subsequence xi−1 (i.e., the sub-sequence up to and excluding the symbol xi). Similarly for p2(xi|xi−1).
At 906, the process 900 computes the mixed probability {tilde over (p)}(xi|xi−1) for the symbol xi. The process 900 computes the mixed probability described in equation (4) above. The process 900 can compute the mixed probability using the equations 8, 11, and 13. At 908, the process 900 encodes the symbol xi using the computed mixed conditional probability.
At 910, the process 900 updates the first length l1 and the second length l2. As described above, hypothetical arithmetic encoders can be used at 910. The first length l1 is updated to include the additional codeword length (i.e., bits) added to the hypothetical codeword added by the first model when encoding the symbol xi. The second length l2 is updated to include the additional codeword length (i.e., bits) added to the hypothetical codeword added by the second model when encoding the symbol xi. The process 900, updates the first length l1 and the second length l2 using, respectively, l1=l1−log (p1(xi|xi−1)) and l2=l2−log (p2(xi|xi−1)). In an implementation, the values −log(p1(xi|xi−1)) and −log(p2(xi|xi−1)) can be computed and/or approximated by using a lookup table (i.e., looked up in a lookup table). Note that the probabilities p1(xi|xi−1) and p2(xi|xi−1) are probabilities between zero (0) and one (1). The conditional probabilities p1(xi/xi−1) and p2(xi/xi−1) can each be represented and/or approximated using fixed-point representations (e.g., 8-bit integer fixed-point representation). As such, both −log(p1(xi|xi−1)) and −log(p2(xi|xi−1)) can be estimated by using a lookup table. The 8-bit integers (i.e., which represent the probability values p1(xi|xi−1) or p2(xi|xi−1)) can be used as inputs (i.e., indexes) into the lookup table. In general, the size of the lookup table depends upon the width of the fixed point representation of p1(xi|xi−1) and p2(xi|xi−1). That is, the larger the width, the higher the precision in estimating −log(p1(xi|xi−1)) and −log(p2(xi51 xi−1)).
At 912, the counter i is incremented so that the next symbol xi+1 is processed. At 914, if all the symbols have been processed (i.e. i=n+1), then the process terminates at 916. Otherwise, the process returns to 904 to process the next symbol.
The process 1000 can be used to decode a sequence of symbols from an encoded bitstream. For example, the process 1000 can receive an encoded bitstream, such as the compressed bitstream 420 of
In some implementations of the processes 900 or 1000, the block 906 may be performed every number of steps (e.g., S>1) to further save (e.g., reduce) computational complexity or to improve throughput. Throughput can be measured in the number symbols processed (coded or decoded) in one clock cycle. For example, when the number of steps S=2, block 906 may be performed only when i is odd or even, but not both. In another implementation of the processes 900 or 1000, block 906 may be performed at a predefined subset of all possible indices of i.
The foregoing described the use of uniform weighting of the models. However, implementations according to this disclosure can use non-uniform prior weights. In non-uniform weighting using M number of models, at least some of the weights wk can be set to values that are not equal to 1/M (i.e., wk≠1/M).
For simplicity, the foregoing (e.g., the processes 900 and 1000) describes the use of two models: a first model and a second model. However, implementations according to this disclosure can be extended to any number of models. For example, for a number of model M≥2, and assuming uniform weighting factors wk (i.e., wk=1/M), then the weights wi,k can be approximated using formula (14):
In formula 14, lk(xi−1) denotes the codeword length, in bits, resulting from using model k, 1≤k≤M, to encode the sub-sequence xi−1.
In the descriptions of
At 910 of
In the case of non-binary alphabets, the lookup table can be a multi-dimensional lookup table. For example, given a non-binary alphabet of 12 symbols, 11 inputs are required for the lookup in the lookup table.
In some implementations, such a complex (i.e., multi-dimensional) lookup table can be avoided by converting the probability distributions associated with the non-binary alphabet symbols into binary distributions. The binary distributions can be represented as a binary tree. The converting of the probability distributions of the non-binary alphabet into binary trees can be implicit or explicit. For example, assuming that the non-binary alphabet is a ternary alphabet (a, b, c) and that the non-binary probability distribution is given by a three-tuple (p_a, p_b, p_c), where p_a, p_b, and p_c are positive real numbers, where p_a+p_b+p_c=1, and where p_a, p_b, and p_c correspond respectively to the probability of symbol a, symbol b, and symbol c. In an example of converting the probability distribution (p_a, p_b, p_c) into binary distributions, the symbols b and c can be combined into as a single symbol bc. As such, a first binary distribution (p_a, p_b+p_c) for (a, bc) is obtained. To further determine the symbol b or the symbol c from the combined symbol bc, a second binary distribution (p_b/(p_b+p_c), p_c/(p_b+p_c)) can be obtained. For any distribution defined on a non-binary alphabet, the above conversion can be applied repeatedly (or recursively) to obtain an equivalent sequence of binary distributions.
Any binary tree can be used. Using
The binary distributions of the internal nodes of the derived tree can be used as inputs to the lookup table to determine a codeword length. For example, to estimate the cost of coding a token of the non-binary alphabet, the tree can be traversed up from the token to the root. The probabilities encountered in the traversal (i.e., the probabilities of the internal nodes) can be summed (i.e., added) and the sum can be used as the input into the lookup table.
In some implementations, the lookup table can be computed offline and can be available to the codec when encoding and/or decoding. In some implementation, the lookup table can be computed online. That is, the lookup table can be computed by a codec while coding. In some implementations, the lookup table can be periodically computed (e.g., updated, recomputed, etc.). In some implementations, the lookup table is recomputed if the alphabet size (i.e., the number of symbols in the alphabet) does not exceed a threshold number of symbols. The threshold number of symbols can be 12, 16, or any other threshold number.
Periodically computing the lookup table can mean computing the lookup table at the beginning of a coding unit, a super block, a transform block, or some other unit of a frame of video, that estimates the cost of coding each symbol in the alphabet.
In equations 9-13, only differences in codeword lengths are used. For example, the different l1(xi−1)−l2(xi−1) is used in equation 10. As such, it may not be necessary to maintain (e.g., keep track of) the set of codeword lengths values {lk} for all models k. As such, in some implementations of 910 of
In an example, where K (>2) models are used, storage complexity associated with codeword lengths {lk} can be reduced using the following steps:
In another implementation, in the first step, j can be selected such that lk≥lj for all 1≤k≤K. That is, only non-negative differences are stored (i.e., lk−lj≥0). The index j, which is the index within {lk} that holds the minimum value, may be maintained and/or updated since the index that holds the minimum value in {lk} may change. By storing only positive length differences, additional storage for storing sign bits (i.e., associated with negative values) can be saved (i.e., not used).
At 1302, the process 1300 converts a probability distribution associated with the alphabet (i.e., the probability values associated with each symbol of the non-binary alphabet) into binary distributions. In an example, the probability mass function (PMF) can be converted into the binary distributions. In another example, the cumulative distribution function (CDF) of the probability distribution can be converted into the binary distributions. As mentioned above, the binary distributions are generated either implicitly or explicitly by using a full binary tree.
At 1304, the process 1300 uses the binary distributions to estimate (i.e., look up) the codeword length in bits (or their scaled version). The block 1304 can be used by the process 900 at 906. The block 1304 can be used by the process 1000 at 906.
In the case where more than two (2) models are mixed, a binary tree can be used to compute (i.e., determine, generate, etc.) the conditional probabilities. That is, the factors wi,kpk(xi|xi−1) of equation (8) can be recursively computed using the above-described processes. Recursively computing means combining the probabilities of two (2) models at a time to produce intermediate conditional probabilities. The intermediate conditional probabilities are then combined, two at a time. In the case where the number of models M is a power of 2 (i.e., M=2m), the factors wi,kpk(xi|xi−1) of equation (8) can be recursively computed by applying the above described processes on a full binary tree such as described with respect to
The process described with respect to
Referring to
As another example, suppose, for example, there are two models, model A and model B, and the prior weights for the two models are (¼, ¾). Implementations according to this disclosure, can expand the model set to a set of 4 models, where the first model corresponds to the model A, the remaining three models correspond to the model B, and the prior for the four models is (¼, ¼, ¼, ¼).
In the foregoing, stationary sources are described. A stationary source means that the mixing for the symbol xi uses all the history of the sub-sequence xi−1 to determine wi,k. As such, the statistics do not change over the source of the coding process. However, in the cases where the sources may be non-stationary, implementations according this this disclosure can adapt to the local statistics for better compression performance using a sliding window. The sliding window as length L of bits indicating the number of previous bits (i.e., the probabilities of the number of the previous bits) to be used in the mixing process. That is, the sliding window represents how far back into the sequence to remember: only symbols inside the sliding window are used to estimate the weighting factors. More specifically, only the probabilities of those symbols inside the sliding window are used to estimate the weighting factors.
As such, instead of using {tilde over (p)}(xi|xi−1) to code xi, {tilde over (p)}(xi|x−L . . . xi−1) where the length L≥1 is the length of the sliding window and where xi−L . . . xi−1 is the sub-sequence starting at bit i−L and ending at bit i−1. When the length L is known, a process according to this disclosure can perform the following steps for two models:
At step 1, initialize i=1, l1=0, l2=0. The step 1 can be as described with respect to 902 of
At step 2, the process computes pi(xi|xi−L . . . xi−1) and p2(xi|xi−L . . . xi−1) according to the first model and the second model.
At step 3, the process computes the mixed probability {tilde over (p)}(xi|xi−L . . . xi−1) according to the equations 15 and 16:
At step 4, the process encodes (when implemented by an encoder) or decodes (when implemented by a decoder) xi by using {tilde over (p)}(xi|xi−L . . . xi−1).
At step 5, the process updates l1 to l1=l1−log p1(xi|xi−L . . . xi−1) and updates l2 to l2=l2−log p2(xi|xi−L . . . xi−1). If the process is encoding/decoding outside the window (i.e., i≥L), then the process updates l1,−L=l1,−L−log p1(xi−L|xi−2L . . . xi−L−1) and l2,−L=l2,−L−log p2(xi−L|xi−2L . . . xi−L−1).
At step 6, i is increased by 1 (i.e., i=i+1).
At step 7, the process repeats the steps 2-6 until all the bits of the sequence xn are processed (i.e., i=n+1).
In the sliding window described above, l1(xi−1)−l1(xi−L−1)=l1−l1,−L and l2(xi−1) l2(xi−L−1)=l2l2,−L. As such, l1(xi−1)−l1(xi−L−1) can be regarded as the codeword length produced by using the first model to code xi−L . . . xi−1 and l2(xi−1)−l2(xi−L−1) can be regarded as the codeword length produced by using the second model to code xi−L . . . xi−1.
In the case of local mixing for a transform block, described above, when a new transform block starts (i.e., when the coding of a transform block starts), the codeword lengths {lk} can be reset for all models k so that all models can be equally considered at the beginning of coding the new (i.e., current) transform block. As such, when the coding of a current transform block is completed, the lengths lk are reset to zero for the coding of the next transform block.
In some implementations, local mixing can be applied to other coding units. For example, the lengths lk can be reset at the start of a coding unit other than the transform block. For example, the coding unit can be a super block (e.g., a block of size 64×64). As such, lengths lk can be reset at the start of a super block. The lengths lk can be reset at the start coding units of other sizes (e.g., 128×128).
In the case of a sliding window described above, the memory step (i.e., the length L) is fixed. In the case of local mixing, the memory step is adapted to the transform block size. For example, a first transform block may be a 4×4 transform block, a second transform block may be 16×16, and so on. As such, the lengths lk are reset after different number of coefficients are coded, depending on the block size and/or the location of the last non-zero coefficient in the quantized transform block.
When implemented by an encoder, the process 1200 can receive the sequence of symbols from a quantization step, such as the quantization stage 406 of
At 1202, the process 1200 selects models to be mixed. The models can include a first model and a second model. As used in this disclosure, “select” means to identify, construct, determine, specify or other select in any manner whatsoever.
For at least a symbol (e.g., xi), at a position (e.g., i) of the symbols, the process 1200 performs blocks including the blocks 1204-1208 to determine a mixed probability using the first model and the second model. The blocks 1204-1208 can be performed for all symbols of the sequence of symbols.
At 1204, the process 1200 determines, using the first model, a first conditional probability for coding the symbol. The first conditional probability is the conditional probability of the symbol given a sub-sequence of the sequence. In an example, the sub-sequence of the sequence can mean the sub-sequence xi−1. In another example, wherein a sliding window is being used, the sub-sequence of the sequence consists of a predetermined number of symbols of the sequence before the position. The predetermined number of symbols can be as described with respect to the sliding window length L. As such the sub-sequence of the sequence can be the sub-sequence xi−L . . . xi−1. At 1206, the process 1200 determines, using the second model, a second conditional probability for coding the symbol. The second conditional probability is a conditional probability of the symbol given the sub-sequence as described with respect to the block 1204.
At 1208, the process 1200 determines, using the first conditional probability and the second conditional probability, a mixed probability for coding the symbol. The mixed probability can be as described with respect to 906 of
At 1210, the process 1200 codes the symbol using the mixed probability as described, for example, with respect to the 908 (when implemented by an encoder) and 1002 (when implemented by a decoder).
In an implementation of the process 1200, the models can include a third model and a fourth model and determining the mixed probability using the first model and the second model can include mixing the first model and the second model to generate a first intermediate conditional probability, mixing the third model and the fourth model to generate a second intermediate conditional probability, and mixing the first intermediate conditional probability and the second intermediate conditional probability to generate a conditional probability to be used for coding the symbol. In an implementation, the first model and the fourth model are a same model.
The process 1400 can be implemented by an encoder or a decoder. When implemented by an encoder, “coding” means encoding in an encoded bitstream, such as the compressed bitstream 420 of
When implemented by an encoder, the process 1400 can receive the quantized transform block from a quantization step, such as the quantization stage 406 of
At 1402, the process 1400 selects probability distributions for coding a token indicative of a quantized transform coefficient of the quantized transform block. Two or more probability distributions can be selected. In an example, the probability distributions include a first probability distribution and a second probability distribution. Each of the probability distributions provides probability values (e.g., first probability values and second probability values) corresponding to the tokens of the alphabet. For example, if the non-binary alphabet includes N (e.g., 16) symbols, then the probability distribution can include N probability values.
At 1404, the process 1400 determines a mixed probability for coding the token using the first probability distribution and the second probability distribution. The mixed probability can be determined as described above with respect to
In an implementation, determining the mixed probability can also include combining the first conditional probability and the second conditional probability using a linear combination that uses a first weight and a second weight. The first weight can be based on a first length of a first codeword for coding tokens corresponding to the previously coded tokens using the first conditional probability. The second weight can be based on a second length of a second codeword for coding tokens corresponding to the previously coded tokens using the second conditional probability.
In an implementation, the first weight and the second weight can be determined by converting the first probability distribution to a first binary distribution, converting the second probability distribution to a second binary distribution, determining the first length using the first binary distribution, and determining the second length using the second binary distribution.
In an implementation, the first probability distribution can be an initial probability distribution for coding the quantized transform coefficients of the quantized transform block. That is, the first probability distribution can be a probability distribution that is selected based on a context for coding the quantized transform coefficient. In an implementation, and when implemented by a decoder, the initial probability can be decoded from the encoded bitstream.
The second probability distribution can be based on statistics of a coding unit. As such, the second probability distribution can be modified (e.g., updated) as quantized coefficients are coded to reflect the actual statistics of the coding unit. The coding unit can be the quantized transform block. The coding unit can be a super block that includes the quantized transform block.
At 1406, the process 1400 codes the token using the mixed probability.
For simplicity of explanation, the processes 900, 1000, 1200, 1300, and 1400 are each depicted and described as a series of blocks, steps, or operations. However, the blocks, steps, or operations in accordance with this disclosure can occur in various orders and/or concurrently. Additionally, other steps or operations not presented and described herein may be used. Furthermore, not all illustrated steps or operations may be required to implement a technique in accordance with the disclosed subject matter.
A technique known as context-tree weighting (CTW) is a lossless data compression algorithm that uses mixing. To code a binary sequence xn of length n, CTW estimates a probability function p(xn) as a linear mixture of 2K probability functions pi(xn), each of which is estimated by assuming a finite memory binary tree source and has the same weighting factor. Contrastingly, implementations according to this disclosure can work with any models. Furthermore, the symbol-by-symbol weighting factor computation described herein can use length functions to approximate probabilities of sub-sequences, which is much simplified in comparison to existing solutions that maintain and compute joint probabilities.
The aspects of encoding and decoding described above illustrate some encoding and decoding techniques. However, it is to be understood that encoding and decoding, as those terms are used in the claims, could mean compression, decompression, transformation, or any other processing or change of data.
The words “example” or “implementation” are used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “example” or “implementation” is not necessarily to be construed as preferred or advantageous over other aspects or designs. Rather, use of the words “example” or “implementation” is intended to present concepts in a concrete fashion. As used in this application, the term “or” is intended to mean an inclusive “or” rather than an exclusive “or.” That is, unless specified otherwise, or clear from context, “X includes A or B” is intended to mean any of the natural inclusive permutations. That is, if X includes A; X includes B; or X includes both A and B, then “X includes A or B” is satisfied under any of the foregoing instances. In addition, the articles “a” and “an” as used in this application and the appended claims should generally be construed to mean “one or more” unless specified otherwise or clear from context to be directed to a singular form. Moreover, use of the term “an implementation” or “one implementation” throughout is not intended to mean the same embodiment or implementation unless described as such.
Implementations of transmitting station 102 and/or receiving station 106 (and the algorithms, methods, instructions, etc., stored thereon and/or executed thereby, including by encoder 400 and decoder 500) can be realized in hardware, software, or any combination thereof. The hardware can include, for example, computers, intellectual property (IP) cores, application-specific integrated circuits (ASICs), programmable logic arrays, optical processors, programmable logic controllers, microcode, microcontrollers, servers, microprocessors, digital signal processors or any other suitable circuit. In the claims, the term “processor” should be understood as encompassing any of the foregoing hardware, either singly or in combination. The terms “signal” and “data” are used interchangeably. Further, portions of transmitting station 102 and receiving station 106 do not necessarily have to be implemented in the same manner.
Further, in one aspect, for example, transmitting station 102 or receiving station 106 can be implemented using a general purpose computer or general purpose processor with a computer program that, when executed, carries out any of the respective methods, algorithms and/or instructions described herein. In addition, or alternatively, for example, a special purpose computer/processor can be utilized which can contain other hardware for carrying out any of the methods, algorithms, or instructions described herein.
Transmitting station 102 and receiving station 106 can, for example, be implemented on computers in a video conferencing system. Alternatively, transmitting station 102 can be implemented on a server and receiving station 106 can be implemented on a device separate from the server, such as a hand-held communications device. In this instance, transmitting station 102 can encode content using an encoder 400 into an encoded video signal and transmit the encoded video signal to the communications device. In turn, the communications device can then decode the encoded video signal using a decoder 500. Alternatively, the communications device can decode content stored locally on the communications device, for example, content that was not transmitted by transmitting station 102. Other transmitting station 102 and receiving station 106 implementation schemes are available. For example, receiving station 106 can be a generally stationary personal computer rather than a portable communications device and/or a device including an encoder 400 may also include a decoder 500.
Further, all or a portion of implementations of the present disclosure can take the form of a computer program product accessible from, for example, a tangible computer-usable or computer-readable medium. A computer-usable or computer-readable medium can be any device that can, for example, tangibly contain, store, communicate, or transport the program for use by or in connection with any processor. The medium can be, for example, an electronic, magnetic, optical, electromagnetic, or a semiconductor device. Other suitable mediums are also available.
The above-described embodiments, implementations and aspects have been described in order to allow easy understanding of the present disclosure and do not limit the present disclosure. On the contrary, the disclosure is intended to cover various modifications and equivalent arrangements included within the scope of the appended claims, which scope is to be accorded the broadest interpretation so as to encompass all such modifications and equivalent structure as is permitted under the law.
Patent | Priority | Assignee | Title |
Patent | Priority | Assignee | Title |
8798137, | Feb 29 2008 | City University of Hong Kong | Bit rate estimation in data or video compression |
20050169374, | |||
20050190992, | |||
20070016418, | |||
20070233477, | |||
20090219991, | |||
20100239015, | |||
20110002554, | |||
20110200104, | |||
20120170857, | |||
20150350652, | |||
20160100189, | |||
EP2945383, | |||
EP3182705, |
Executed on | Assignor | Assignee | Conveyance | Frame | Reel | Doc |
Nov 28 2017 | GOOGLE LLC | (assignment on the face of the patent) | / | |||
Nov 28 2017 | HE, DAKE | GOOGLE LLC | ASSIGNMENT OF ASSIGNORS INTEREST SEE DOCUMENT FOR DETAILS | 044272 | /0041 |
Date | Maintenance Fee Events |
Nov 28 2017 | BIG: Entity status set to Undiscounted (note the period is included in the code). |
Apr 17 2023 | M1551: Payment of Maintenance Fee, 4th Year, Large Entity. |
Date | Maintenance Schedule |
Oct 15 2022 | 4 years fee payment window open |
Apr 15 2023 | 6 months grace period start (w surcharge) |
Oct 15 2023 | patent expiry (for year 4) |
Oct 15 2025 | 2 years to revive unintentionally abandoned end. (for year 4) |
Oct 15 2026 | 8 years fee payment window open |
Apr 15 2027 | 6 months grace period start (w surcharge) |
Oct 15 2027 | patent expiry (for year 8) |
Oct 15 2029 | 2 years to revive unintentionally abandoned end. (for year 8) |
Oct 15 2030 | 12 years fee payment window open |
Apr 15 2031 | 6 months grace period start (w surcharge) |
Oct 15 2031 | patent expiry (for year 12) |
Oct 15 2033 | 2 years to revive unintentionally abandoned end. (for year 12) |