This disclosure relates to video compression, and, more particularly, to novel techniques for performing motion estimation.
The amount of data in digital video is immense. For example, each frame of a progressive scan 1080p HD video has 2,073,600 pixels (1080×1920), and each frame is typically refreshed 60 times per second. If each pixel takes 3 bytes to represent the full color value, this is 2,986 Mbit/s, it is apparent, then, that video data must be compressed to be handled efficiently.
Although the amount of video data is massive, there are two forms of redundancy that can be exploited. Firstly, in each picture most of video is a mere repetition of what is already on the screen. Secondly, even in fast-moving scenes, little of the screen changes and most of a screen is reproduced in the next frame, although the data may be shifted or located at another point on the screen. Further helping compression is the fact that the human eye acts as a filter, and for example is very insensitive to high frequencies and color. All of these factors allow video to be compressed dramatically while maintaining, at least to the human eye, a good visual quality.
The most compute-intensive portions of a video compression system, or encoder, is motion estimation. Motion estimation exploits the redundancy between frames by searching adjacent frames for similar areas of picture. Instead of sending the original pixel data, it is much more efficient to send a motion vector indicating where the similar area is and a block of (hopefully zero) differences. Each frame is tiled into groups of 16×16 pixels called macroblocks. The macroblock in modern compression systems such as H.264 can have sub-tiles, and each block or sub-block partition in an inter-coded macroblock can have a motion vector. To further compress the vector information, it is assumed that the motion vectors themselves are correlated, as for example in a camera pan. Thus a motion vector of a partition in a current frame can be predicted from its neighbors; it is the difference (often zero) between the prediction and the actual vector that is sent. In the H.264 standard, also known as the International Telecommunication Union-Telecommunications (ITU-T) H.264 standard or ISO/IEC 14496-10, which is incorporated by reference herein, the offset between two motion vectors has a quarter-pixel resolution. This resolution allows natural motions to be determined, which increases the probability of a good match and hence coding efficiency, but comes at the expense of having to match 16× the candidates during a search (compared to integer-resolution) to compute the motion vectors.
The tradeoff in computation resources required to calculate motion vectors is between computation speed and computation area. A large amount of resources may calculate motion vectors quickly, even in real time, but comes at an enormous hardware cost typically reserved for very expensive video delivery systems. At the other end of the spectrum are software systems that are inefficient, yet effective if performance speed is not the primary consideration. Some systems may calculate motion vectors for days to produce just a few minutes of compressed video, which is obviously not time efficient, but in some cases, such as for authoring video before distribution, is acceptable.
Embodiments of the invention address these and other limitations in the prior art.
The video decoder 104 decompresses the compressed video information provided by the video encoder 102. The video decoder 104 represents any suitable apparatus, system, or mechanism for decompressing video information. For example, the video decoder 104 could represent a streaming-video receiver capable of receiving streaming video from the video encoder 102 over a network 108. The video decoder 104 could also represent a DVD player or other optical disc player capable of retrieving compressed video information from an optical disc 110. The video decoder 104 could further represent a digital video recorder capable of decompressing video information stored on a hard disk drive 112. The video decoder 104 includes any hardware, software, firmware, or combination thereof for decompressing video information.
In the illustrated example, the video decoder 104 decompresses the previously compressed video information and provides the decompressed video information to a display device 106 for presentation to a viewer. The display device 106 represents any suitable device, system, or structure for presenting video information to one or more viewers. The display device 106 could, for example, represent a television, computer monitor, or projector. The video decoder 104 could provide the decompressed video information to any other or additional destination(s), such as a video cassette player (VCR), digital video recorder (DVR) or other recording device.
In the illustrated embodiment, the video encoder 102 includes a video source 114. The video source 114 provides a video information signal 116 containing video samples to be compressed by the video encoder 102. The video source 114 represents any device, system, or structure capable of generating or otherwise providing uncompressed video information. The video source 114 could, for example, include a television receiver, a VCR, a video camera, a storage device capable of storing raw video data, or any other suitable source of video information. While
A combiner 118 is coupled to the video source 114. In this document, the term “couple” and its derivatives refer to any direct or indirect communication between two or more elements, whether or not those elements are in physical contact with one another. The combiner 118 receives the video information signal 116 containing uncompressed video information from the video source 114. The combiner 118 also receives a feedback video signal 148 from other components in the video encoder 102. The feedback video signal 148 is associated with video information that has already been compressed by the video encoder 102. The combiner 118 identifies any differences between the video information signal 116 and the feedback video signal 148. The combiner 118 then outputs the identified differences as a residual signal 120. The combiner 118 represents any hardware, software, firmware, or combination thereof for combining signals, such as a subtractor.
The residual signal 120 is provided to a transform/quantize unit 122. The transform/quantize unit 122 implements various functions to process the residual signal 120. For example, the transform/quantize unit 122 may implement a transform function to convert the residual signal 120 (in the spatial domain) into discrete cosine transform (DCT) coefficients (in the frequency domain). The transform/quantize unit 122 may also quantize the DCT coefficients and output quantized DCT coefficients 124. In many video compression systems, quantization both reduces the number of bits sent, but can also zero out many of the DCT coefficients such as the high frequency terms the human eye cannot easily perceive. In some embodiments, the transform/quantize unit 122 operates on blocks of pixels from images being compressed (such as 16×16 macroblocks) and produces blocks of quantized DCT coefficients 124. The transform/quantize unit 122 includes any hardware, software, firmware, or combination thereof for transforming and quantizing video information.
The quantized DCT coefficients 124 are provided to an entropy encoder 126. The entropy encoder 126 encodes the quantized DCT coefficients 124 (along with other information) to produce compressed video information 128. The entropy encoder 126 may implement any suitable encoding technique, such as context adaptive based arithmetic coding (CABAC), context adaptive variable length coding (CAVLC) or Huffman coding. The entropy encoder 126 includes any hardware, software, firmware, or combination thereof for encoding quantized DCT coefficients 124 and other information.
The quantized DCT coefficients 124 are provided to an inverse transform/quantize unit 130. The inverse transform/quantize unit 130 processes the quantized DCT coefficients 124 and mathematically reverse the processing performed by the transform/quantize unit 122. For example, the inverse transform/quantize unit 130 could implement an inverse quantization function to produce DCT coefficients. The inverse transform/quantize unit 130 could also implement an inverse-DCT transform to produce a reconstructed residual signal 132. The reconstructed residual signal 132 might match the original residual signal 120, or the reconstructed residual signal 132 may be similar to the residual signal 120 but have some small differences. The inverse transform/quantize unit 130 includes any hardware, software, firmware, or combination thereof for performing inverse transform and inverse quantization functions.
The reconstructed residual signal 132 is provided to a combiner 134. The combiner 134 also receives the feedback video signal 148. The combiner 134 then combines the reconstructed residual signal 132 and the feedback video signal 148 to produce a combined signal 136. The combiner 134 represents any hardware, software, firmware, or combination thereof for combining signals, such as an adder.
The combined signal 136 is provided to a deblocking filter 138. The deblocking filter 138 reduces blocking artifacts in images being decompressed, such as blocking artifacts located along the boundaries of different 4×4 pixel blocks. This produces filtered video information 140. The deblocking filter 138 represents any hardware, software, firmware, or combination thereof for reducing blocking artifacts.
The filtered video information 140 is provided to a motion estimator 142 and a motion compensator 144. The motion estimator 142 also receives the original video information signal 116 and the feedback video signal 148. The motion estimator 142 uses the received information to search for and identify motion within video images being compressed, as described in detail below. The motion estimator 142 outputs motion vectors 146, which represent the identified motion in the images. The motion vectors 146 are also provided to the entropy encoder 126 for coding as part of the compressed video information 128, and to the motion compensator 144 as well. The motion estimator 142 includes any hardware, software, firmware, or combination thereof for estimating motion in video images, as is described below.
The motion compensator 144 receives the filtered video information 140 and the motion vectors 146. The motion compensator 144 uses the motion vectors 146 to fetch the appropriate block of pixels from the filtered video information 140 and add the residual information into the filtered video information 140. This produces the feedback video signal 148, which may or may not exactly match the original video information signal 116. The motion compensator 144 includes any hardware, software, firmware, or combination thereof for altering video information to introduce motion into video images.
In the illustrated example, an intra prediction unit 150 is used to process the video information when an intra prediction mode is used. Intra prediction utilizes the video data redundancy within a frame. The intra prediction mode is defined in the H.264 standard and analyzes 16×16 macroblocks within a single frame in 4×4 blocks or partitions. In some embodiments, when intra prediction mode is used, the transform/quantize unit 122 implements the intra prediction mechanism on the 4×4 partitions. The intra prediction unit 150 implements a reverse of this process and generates the feedback video signal 148 when the video encoder 102 operates in the intra prediction mode.
The video decoder 104 could include many similar components as the video encoder 102 shown in
In particular embodiments, the video encoder 102 and the video decoder 104 implement the H.264 compression scheme. The H.264 compression scheme supports several advanced video coding techniques, such as directional spatial prediction, multi-frame references, weighted prediction, de-blocking filtering, variable block size, and quarter-sample accurate motion compensations. The H.264 compression scheme also supports a small, block-based, integer, and hierarchical transform, as well as CABAC and CAVLC coding.
Although
The Sum of Absolute Differences, or SAD, is a basic comparison measure used to compare two lists of numbers. Each list member is compared against the corresponding value in the other list by subtracting the corresponding values; if the subtraction is negative, it is made positive by multiplying by −1, to give the absolute value of the difference is computed. Finally all the absolute differences are added together to give the final measure. A value of zero indicates that the two lists are identical, while a value near zero indicates a close match. A large SAD value indicates a poor match.
SAD calculations are very commonly used to compare blocks of pixels in video circuits.
4×4—16 sub-partitions
4×8—8 sub-partitions
8×4—8 sub-partitions
8×8—4 sub-partitions
16×8—2 sub-partitions
8×16—2 sub-partitions
16×16—1 sub-partition
After being combined, a minimal SAD value is determined separately for each of the 41 sub-partitions to generate the final output of 41 minimum SAD values.
Another conventional alternative SAD sub-circuit 240 is illustrated as
Embodiments of the invention use new decompositions of absolute difference to further reduce the number of gates required, and to allow the use of approximating arithmetic, if desired.
The first new decomposition is given by:
|a−b|=a+b−2 min(a,b) Equation (1)
The advantages of Equation 1 will be seen below, but one of the main concepts is that the “absolute” operation has been removed and each three of the terms on the Right Hand Side (RHS) can be treated independently.
The second new decomposition is given by:
Equation (2) also allows all the terms on the RHS to be treated independently, but has an advantage over Equation 1 in that the right-most “correction term” is small when the difference is small and is large when the difference is large. This observation has real-world applications as described below.
To compute the minimum function used by Equation 2, a minimizing circuit 250 is used, as illustrated in
A correction term to Equation 2 can be defined as follows:
To compute the correction term given by Equation 3, a correction circuit 260 illustrated in
Armed with these new decompositions, the SAD can be redefined and computed more efficiently. The first new SAD equation is given by:
In a typical system where a reference object list ai is being compared to a number of different candidate object lists bi, there are several advantages of Equation 4, such as: a) the summation of ai term is a constant for all comparisons and can be pre-computed; b) the summation of bi term is a “sliding” constant, which is easily re-used in subsequent comparisons, and can be cheaply computed, in terms of computing resources, outside the main SAD loop; and c) the final “correction term” is simply the minimum circuit of
The second new SAD equation is given by:
where each ci is computed using Equation 3. The advantages of Equation 5 are similar to Equation 4, with the difference being that each of the ci is small if the final SAD measure is small, and at least one of the ci will be large if the final SAD value is large. This can be used to decrease the hardware further by clipping large values of ci. The advantages from Equation 4 remain: a) the summation of ai term is a constant for all comparisons and can be pre-computed; b) the summation of bi term is a “sliding” constant, which can easily be re-used in subsequent comparisons, and can be cheaply computed, in terms of computing resources, outside the main SAD loop; and c) the summation of ci term is simply the correction term circuit 260 of
Integer and Fractional Samples
In video systems, the lists used for computing SADs are rectangular matrices of pixel values. Each matrix is called a pixel block and can vary in size from 4×4 to 16×16. To estimate motion, each frame is first tiled into a number of pixel blocks. Each reference pixel block is then searched in subsequent frames against similar-sized pixel blocks, offset by a vector from the original block position.
In
To search for motion, a large number of candidates are compared for each reference. If the search area is W by H pixels, then W*H candidates must be compared, with offsets ranging from (0,0) to (W−1,H−1). For example, an HD video frame has 129,600 reference blocks and if the search area is 128×64 pixels, there are over 1 billion SAD values to be computed for each frame.
By definition, if the offsets are all integral (integer) numbers of pixels, the search is an integer pixel search. This means that only motion that is aligned to the integer grid can be discovered. Since motion is unlikely to be on grid, most video systems require that fractional offsets are used in a fractional pixel search. For the common MPEG-2 video compression standard, the offset are multiples of 0.5 and are called half-pixel, or h-pel, offsets. In the more modern H.264 video compression standard, the offsets are multiples of 0.25 and are called quarter-pixel, or q-pel, offsets. The advantages of q-pel searches are that true motions can be better described. The disadvantages are that 16 times as much work needs to be done to specify motion vectors to the q-pel granularity level, as compared to the standard i-pel level, and that the original pixel block, and every candidate block, must be filtered to create the extra samples.
To create the fractional candidates, interpolation is used. An interpolation filter is applied to the original frame's integer pixels to create a pixel that has a fractional offset.
In MPEG-2, the h-pel sample x is given by simple bi-linear interpolation:
In H.264, a more complex 6-tap Wiener filter is used for the h-pel sample:
To compute the q-pel samples, simple bi-linear interpolation is then used in H.264:
The H.264 standard is very particular about the order the bi-linear filter is applied in that the inputs to Equation 8 can only be h-pel or integer-pel values, and not q-pel values. For most of the q-pel samples, this restriction is quite natural, as illustrated in
For the remaining four q-pel samples illustrated in
Embodiments of the invention, which also calculate h-pel and q-pel pixel values, uses the H.264 diagonal interpolation, but is not necessarily restricted to that scheme.
To search fractional offsets, traditionally the candidate frame is first filtered to create the new samples, effectively yielding a frame 16 times as large. The new samples are then treated as integer values and fed into a traditional SAD computation—in this case the offsets are treated as integral (integer) values that are really representing 0.25 pixel steps.
Folding the Interpolation Filter
Embodiments of the invention search for the best match, that is a minimum SAD value, using a bi-linear prediction for all fractional samples. Any SAD value difference between the bi-linear filter, and say, the Weiner filter is resolved later in a refinement process. The basic bi-linear SAD equation is given by:
where ai is the reference value and bi and ci are adjacent candidate samples and (bi+ci)/2 is the interpolated value in between pixels bi and ci.
Sum of Absolute Totals
Embodiments of the invention uses a new technique, the Sum of Absolute Totals, or SAT, to emulate a bi-linear filter with no external filtering. Examples in reference to
In
With some simple algebraic manipulation, Equations 10-12 can be re-written in AT form:
A key observation is that the AD computation becomes an absolute total of two terms, each of which is half the total of the adjacent neighbors, thus making the SAT terms defined by an iterative process. To make this clear, step through the stages to compute the samples shown in
It is simple to derive from the above discussion that the AD at any position is:
AD=|IT| Equation (16)
and the intermediate total IT is given by:
where ITm and ITn are the intermediate totals of the appropriate neighbors. The iteration stops at an integer pixel position, where the intermediate total is simply the difference between the reference value and the candidate value.
The following views of
In summary, it has been shown above that the absolute difference of bi-linear interpolation is equivalent to half the absolute total of the intermediate values, which are defined iteratively. Thus the bi-linear interpolated SAD is just the SAT of the intermediate values:
and requires no external filter of the integer samples since each of the ITi and ITj are computed by the neighbors when the neighbors compute their SAD measure.
Approximating SAT
There are two interesting approaches that can be used to compute the SAT. First, note that the intermediate terms ITi and ITj in Equation 18 are signed values. Redefine Equation 18 as:
AT=|d+e| Equation (19)
and represent the signed terms d and e in signed magnitude:
d=sd×δ
e=se×ε
where δ and ε are positive numbers and sd and se are a single bit value representing −1 or +1. The final definition for both approaches is the different sign bit, γ, which for each position in a list is given by: γ=(sd≠se)
First SAT Approximation
The first thing to note is that if γ=0 then:
AT=|d+e|=|δ+ε|=|−δ−ε|=δ+ε
If γ=1 then:
AT=|d+e|=|ε−δ|=|δ−ε|
This then allows the SAT to be defined as follows:
The critical observations of Equation 20 are:
where c is a small constant. This allows Equation 20 to be defined purely in terms of the neighbor SAD values, previously computed, and requires no summation loops:
In the interesting case when the final SAT is small, that is a good overall match, each δ and ε are close in value and the approximation is best made with a constant c=2.
Approximate SAT with Correction
In this version, the key observation is if γ=1 then:
So piecing together both cases for γ=0 and γ=1:
AT=δ+ε−2γ·min(δi,εi)
This gives the desired result where the SAT is computed from the previous SAD values with a simple to compute correction term involving the AND-function of γ and the minimum of δ and ε:
The interesting aspect of Equation 21 is that the summation term is a correction and so can be done with approximate or clipped values of δ and ε.
Sliding Arithmetic
To reduce the amount of logic when summing values, a compressed arithmetic can be used. In embodiments of the invention, a number of SAD values are compared to determine the best match, which is defined by the lowest SAD value. This means that all but one of the values are discarded during the search and any error in the SAD values that are discarded is irrelevant. This leads to the concept of using an arithmetic which is exact for small values, but uses an over-estimate when the value is large.
The basic idea is to reduce 8-bit values to a 4-bit value with a additional flag bit. All of the summation arithmetic is done on the 4-bit values to reduce the logic count.
In one embodiment of the invention the following compression scheme is used:
The flag bit is denoted by m and is set if the input value has been divided (shifted right). To decompress, a mid-tread scheme is used:
The compression logic is illustrated in
This concept is easily extended to accommodate larger numbers. The decompression logic for a 6-bit sliding number to a 10-bit unsigned number is illustrated in
In this embodiment, when four sliding values are added, the m-bit for each is checked and if any one is asserted, then all of the values are compressed so that the numbers being added are in the same scale.
Rounding
In
In case #1, all the numbers are added in range and the carry-in terms are as if there is no sliding. For case #2, the numbers have been scaled down. This means:
For case #3, the numbers have been scaled down, but some of them may be zero. In one embodiment the following scheme is used:
The number of zeros can be counted in a circuit as illustrated in
Input Filtering
The effect of using sliding arithmetic adds a filter to the results. For example if we took the following difference lists:
If no sliding arithmetic were used, the first difference list would be preferred. However the sliding arithmetic used in this embodiment “adjusts” the value 18 being it is slid and so over-estimates the SAD. Thus the second list would be chosen because the SAD value would be exact and smaller than the over-estimate skewed by the large difference of −18.
In a real-world system this could be advantageous in three ways:
Several Core elements may be combined in various ways to make practical and functional machines. A number of implementations of the integer SAD core element are shown and compared. All of these example core elements compute a 4×4 SAD, although the concepts may be used for computation of any array size.
Integer SAD Exact
There are three interesting architectures for computing the SAD at integer pixel samples, which are illustrated in
Intermediate Term
The circuit area 292 computes a 2×2 SAD value and four 2×2 SAD values are summed to create the 4×4 SAD value. Using a typical Standard Cell library, it takes 2138 equivalent NAND gates to implement the core element 290 of
Minimum Term
The circuit area 298 computes a 2×2 SAD value and four 2×2 SAD values are summed to create the 4×4 SAD value. Using a typical Standard Cell library, it takes 1994 equivalent NAND gates to implement the core element 298 of
As an example operation, assume that group a is a 2×2 block having values of {1, 2, 4, 1} and group b is a 2×2 block having values of {3, 1, 4, 4}. In operation, Equation 23 can sum the members of the two groups, a, and b at any time to compute that atot=8 and btot=12, which then sum to 20. Then, as directed by Equation 23, each minimum term for each location in the 2×2 matrices is selected and added together. Thus the minimum group is {1, 1, 4, 1}, whose members total 7. By subtracting twice this value, 14, from the originally summed value of atot+btot=20 yields a SAD of 6. If a conventional SAD process is used, it would sum the absolute differences in every common location of a and b, i.e. 2+1+0+3 which also equals a SAD of 6. Differences used by equation 23 include the fact that the sums for atot and btot can be “pre” computed and are constant values for many comparisons, and that selecting the minimum of two values is much smaller and faster in hardware than calculating an absolute value which requires two subtractions and a multiplexer.
Integer SAD Sliding
The architecture shown in this section uses the sliding arithmetic described above. The basis is the intermediate term architecture shown in
In
The initial adders subtract the reference values from the candidate values. This is done by the four initial 8-bit adders of
The final summation adder of
To complete the 4×4 SAD computation core, four instances of the 2×2 logic in
Using a typical Standard Cell library,
Integer Array
An example of an integer array is a 16×16 array of 256 instances of a 4×4 SAD core. The array takes a 4×4 array of adjacent 4×4 reference blocks that make up a 16×16 macroblock. The offset between each of the 16 4×4 reference blocks is fixed. A candidate block of size 19×19 pixels is used which fully contains each of the 4×4 blocks moving from a vector offset of (0,0) to (3,3). The 256 array of core cells generates 256 SAD4×4 values for 16 different 4×4 reference blocks, each at 16 different vector offsets.
Thus the array does a complete search in a search window of size 4×4 for a macro-block of size 16×16 in a single cycle.
One of the characteristics of the integer array is that each of the 256 matches only depends on the input pixel data, not on neighbors' results. Thus the array is simply that: an array of 256 independent elements that can be put together however desired.
Fractional Array
The fractional array is a 16×16 array of 256 “instances” of a 4×4 SAD core. The exact arrangement and count of instances will be described in various combinations below. The array takes a single 4×4 reference block. A candidate block of size 20×20 pixels is used, which fully contains the 4×4 block moving from an vector offset of (0,0) to (15,15). The 256 array of core cells generates 256 SAD4×4 values for a single 4×4 reference block at 256 different offsets.
Thus the array does a complete search in a search window of size 16×16 for a sub-block of size 4×4 in one cycle. It therefore takes 16 cycles to do a search window of size 16×16 for a macro-block of size 16×16. Note that the search window is counting interpolated points; the actual window in integer samples is 4×4 as the example is q-pel.
One of the characteristics of the fractional array is that each of the 256 matches use the same reference data and can therefore share dependent intermediate terms once the input data is presented.
A more detailed map of the fractional array is shown in
Fractional SAD Exact
There are four core types used in the fractional array: i-SAD, r-SAD, i-EDGE and r-EDGE.
The core 300 output is not just the SAD4×4 value, but the 16 intermediate terms for the neighbors. The basic equation used by
The output intermediate terms of
which are simply the outputs of the initial subtract stages, shifted right by one place. Since the ITi are signed values, the sign-bit of each is simply the carry-out term of the subtract unit.
r-SAD
The signed 8-bit adder initially has to sign extend to generate the correct sign in the carry-out term. This logic is shown in detail in
The adders 308 in
The equation used by
The output intermediate terms of
which are simply the outputs of the shaded adder stages, shifted right by one place. Since the ITi are signed values, the sign-bit of each is simply the carry-out term of the adder.
Fractional SAD Sliding
The architecture shown in this section uses the sliding arithmetic described above. Because both the i-SAD and the r-SAD perform the summation directly as shown in Equation 27, sliding arithmetic is permitted because each of the terms in the summation is:
As in the fractional array, there are four core types used in the sliding fractional array: i-SAD, r-SAD, i-EDGE and r-EDGE.
i-SAD
The outputs are not just the SAD value and its m-bit, but also 16 intermediate terms for the neighbors and an unresolved carry-in term. The basic equation used by
The output intermediate terms of
which are the outputs of the initial subtract stages, shifted right by one place. Since the ITi are signed values, the sign-bit of each is simply the carry-out term of the subtract unit.
To complete the 4×4 i-SAD computation core 310, four instances of the 2×2 logic of
The three carry-in terms available in
The shaded block 312 in
r-SAD
The adders 318 of
The outputs are not just the SAD value and its m-bit, but also 16 intermediate terms for the neighbors and an unresolved carry-in term. The equation used by
The output intermediate terms of
which are simply the outputs of the shaded adder stages, shifted right by one place. Since the ITi are signed values, the sign-bit of each is simply the carry-out term of the adder.
To complete the 4×4 i-SAD computation core, four instances of the 2×2 logic of
The three carry-in terms available in
The shaded block 322 in
H.264 Final Search
When the best matches have been determined using integer and/or fractional arrays as described, a final search block can be used that performs a detailed 5×5 search with integer samples in each corner. The offsets used in the search are shown below in
The basic architecture is shown in
The following Cycle Table shows how many cycles the combine block in
H.264 Interpolating Filter
It can be seen that there are 25 integer samples, 56 half-pel samples and 208 quarter-pel samples used for the search. Note that an extra 16 half-pel samples are also generated so that they may be used in the calculation, but are not used by the search.
The interpolation filters are implemented directly from Equation-7 and Equation-8. If implemented using a typical Standard Cell library, the cost is (56+16)*732+208*86=72,056 equivalent NAND gates.
Note that if a 16×16 macro-block refinement is being performed, each of the 16 adjacent 4×4 sub-blocks are input into the H.264 filter separately, one each cycle. The SAD array automatically reads the appropriate set of 16 values from the 16×16 reference input values at each cycle.
Combine
The combine block of
At the start of the sequence, the feed-back value in
Using a typical Standard Cell library, 25 instances of
Minimize
At the end of the cycle sequence, 25 SAD values are output from the combine block in
The outputs of
Using a typical Standard Cell library,
Rate Distance
The rate distance block of
λg(Δx,Δy)
where λ is a constant, g is some distance function and Δx and Δy are the differences of the x and y offsets from a predicted vector.
The final search block of
g(x,y)=F(x)+G(y)
F(−x)=F(x)
G(−y)=G(y)
The user pre-computes the following 10 ten values: F(0), F(1), F(2), F(3), F(4), G(0), G(1), G(2), G(3) and G(4), where the indices indicate multiples of 0.25. Since all block sizes use the same distortion function, these values are fixed once loaded into the rate distance block in
Note that only positive indices for F and G are used;
Using a typical Standard Cell library,
The inputs to
Each sub-block takes a different number of cycles to complete, ranging from 1 to 16 cycles. Any input values that are not required are ignored and can be any value; for example when matching a 4×4 sub-block, only 16 of the 256 reference values and only 81 of the 441 candidate pixel values are used.
To completely refine the results for a 16×16 macro-block,
For a 1080p HD video, there are 8100 16×16 macro-blocks. For a 500 MHz operating frequency and a 60 Hz video update rate, there are 1028 cycles available to process each macro-block. Since there are 41 different sub-blocks to refine, this leaves a budget of 25 cycles to process each sub-block.
Relative Block sizes, in equivalent NAND gates
H.264 Filter: 72,056
SAD Array: 49,850
Combine: 3,208
Minimize: 5,764
Rate Distance: 3,468
Total: 134,346
The values in this table illustrate the relative size of each block using the same metric so that the relative comparison is accurate; note that the filter and the SAD array dominate.
Determining an Output when there is More than One Minimum
In this section, a system and methods of finding more than one minimum in a set is discussed. Combinational, pipe-lined and sequential algorithms are included.
By way of an example to demonstrate the general cases, it will be assumed that 16 inputs are presented each cycle, and a minimum list of candidates accumulated over multiple cycles is generated. The output list will be of length 4, and which of two equal is chosen implicitly according to position and connections rather than according to explicit rules.
Minimum of Two
The hierarchy of
The circuit of
Sort Four Values
To sort four values the circuit of
The operation is easy to understand in that:
The circuit of
Manipulating Four-Lists
Inserting a Single Value into a Four-List
The circuit of
The following code segment explains the action of inserting a value into an array of length N that holds a sorted list.
Clearly,
Inserting a Four-List into a Four-List
The operation of
Although
Merging Two Four-Lists
16-Way Minimum
The simplest solution for computing the minimum four values of 16 inputs uses the logic of
In
As an indication of overall size, a circuit that takes 16 minimum values and generates a single minimum value takes 2,120 equivalent NAND gates using a typical Standard Cell Library.
If
Computing more than one minimum is accomplished using sorted lists. Circuits for creating a sorted list of length 2, 4 and 8 have been shown, as well as basic circuits for operating on the lists.
Finally, a hierarchical approach using a pre-sort on the inputs was shown that could compute global minima over many cycles.
The approximate cost for computing N minima compared to producing just a single minimum value has been reduced to a factor of less than N, being 1.9, 3.5 and 5.7 for N=2, 4 and 8 respectively.
Comparing when Equal
So far, the SAD values are compared and a minimum (list) found. If the smallest value appeared more than once, then which became the final value was chosen arbitrarily according to implicit connections. In this section, explicit methods of handling the case when a SAD value is equal is covered. To start, combinational circuits that efficiently compute the less-than function are shown.
Comparing Two Positive Numbers
The basic approach when comparing two positive numbers is to note that any comparison should start with the Most Significant Bits:
The advantages of this approach is that the comparison can either be greater-than or less-than and as an inherent side-effect, whether the values are equal is also generated. Determining equality may be important for greater-than-or-equal for example, or used as a basis for other decision methods.
The hierarchical nature of
The advantages of the hierarchical approach are much clearer in
Greater than
The truth table for a 1-bit ‘a’ greater-than ‘b’ is shown in the table below:
Less than
The truth table for a 1-bit ‘a’ less-than ‘b’ is shown in the table below:
Greater than or Equal
The truth table for a 1-bit ‘a’ greater-than-or-equal ‘b’ is shown in the table below:
Since the equal output term is being generated anyway, a final OR-gate can be used as shown in the table below.
0
1
The underlined terms in the truth table above are arbitrary, since in the final result q they are being OR-ed with a logic one from the “e” value, which is already known. The values in the table are chosen to make the c output one that is easily available, which is simply the “a” input. For example, a 4-bit greater-than-or-equal circuit is shown in
Less than or Equal
The truth table for a 1-bit ‘a’ less-than-or-equal ‘b’ is shown in the table below:
However, since the equal output term is being generated anyway, a final OR-gate can be used as shown in the table below:
0
1
The underlined terms in the “c” column arbitrary since in the final result q they are OR-ed with a logic one from the “e” value, which is already known. The values in the table are chosen to make the c output one that is easily available, which is simply the “b” input. For example, a 4-bit less-than-or-equal circuit is shown in
Smaller Less than
Odd Bit-Widths
In the previous examples, all of the bit-widths were a power of two. The hierarchical scheme proposed in this appendix works equally well for non-powers of two. For example,
Equal SAD/Rates
When a search compares SAD (or rate) values, there can be times when the smallest rate value(s) are not unique. In this case, there must be some scheme used to determine how a vector is chosen when the rate values are equal.
In many implementations, the decision is arbitrary, and generally depends simply on how the minimum tree is connected and whether the less-than comparison operation is exact. In this appendix, the less-than operation is exact by using a scheme such as a 16-bit version of
A clockwise spiral search is shown in
If
The Table below shows the first 16 positions in spiral order from the center.
The first pattern of interest is the order of the x-coordinates for the same y-coordinate, that is along a scan line. It can be seen by inspecting
C-Code to Determine Distance Along Spiral Path—Scan Line Progression
In the general case, examine the basic distance given by Equation 28, since the smallest distance is always closer to the origin.
d=|Δx|+|Δy| Equation (28)
The points that are equidistant using Equation 28 are on a concentric ring. The order for the concentric ring distance=3 is shown in the table below. It can be seen that an explicit order can be derived using a shift of the origin. The c-code for the general comparison routine is shown below the table.
C-Code to Determine Distance Along Spiral Path—General Case
It can be seen that the complexity of each of the two compares (scan order and the general case) is quite different, although both are easily computed; the scan-order compare is clearly much simpler.
Local and Global Minima
When a search is comparing rate values for a particular block size, a number of values are presented each cycle. All of the input rate values are compared to create local minima, that is the minima for that cycle. In general a hardware search prefers to search in scan order, and so the local minima are chosen from a set of rate values on the same scan line.
Once the local minima have been selected, they are compared to the current global minima which are then updated. The global minima may have come from any scan line. Thus the two spiral distance comparisons can be used: the simple for local minima and the more complex general case for global minima. Note that there are many local minimum comparisons made for each global minima comparison, which balances the complexity.
For 16 rate values selecting a single minimum, there are 16 comparisons performed for the local minimum and 1 comparison for the global minimum.
For 16 rate values selecting a four-list minimum, there are 32 comparisons performed for the local four-list and 4 comparisons for the global four-list.
Local Minima Comparison
For a local minimum comparison, the routine of comparison along a single scan line, reproduced above, is used. To further reduce the overhead, the x-coordinates are re-coded. To show the behavior, a stride length of 16 values is used, but this is easily extended to any stride length. There are three regions of interest:
To re-code the x-coordinates for the example stride length of 16, the following scheme is used:
As an example, assume the origin for a stride of type 3 is the 5th pixel in; L=5 and the x-coordinates for the stride are (−5, −4, −3, −2, −1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10).
The advantage of this re-coding is that each of the re-coded values are limited to a 4-bits.
The circuit of
In the circuit of
By using a single instance of
Global Minima Comparison
When comparing global minima, the position of each point can be from any pixel in the picture and so the algorithm of the general-case spiral determination C-code reproduced above must be used.
In a similar vein,
To compare two 13-bit signed numbers, subtract them as shown in
When examining the algorithm of
Systems
The various concepts, components, and sub-components described above can be assembled into various systems that perform a multitude of different useful processes.
In one system a comparison measure of two datasets is generated. Instead of generating an absolute value difference of each individual set of related components in the datasets, then summing those differences, as is one of the current well-known processes to make such a comparison measure, embodiments of the invention include a system that uses a much different process. Initially, each of the two datasets is summed independently, and without regard to direction (sign). Significantly, these totals may be pre-computed (and are constants across many comparison) before any comparison between the two sets is made. At a later time, each common location value in the dataset is evaluated to determine the set of minimum values, each of which are summed to make an interim subtotal. An amount equal to twice the subtotal is then subtracted from the previously calculated totals to generate the final comparison measure.
In another system, a different comparison value is computed, which is a total summation value rather than a sum of differences. The total summation value can be directly used to create the SAD value for interpolated positions without having to perform the interpolation. In this embodiment, while generating a SAD value, the system also generates a set of intermediate values with no overhead. The intermediate values can then be summed by neighbors to create an intermediate total, which is identical to a SAD value interpolated to the position of the neighbor. Neighbors can use intermediate values from adjacent neighbors, in which the interpolation is a ½ step, or from neighbors equidistant which creates a ½ step at a different resolution. The intermediate values are computed from a) known position values; b) values interpolated from the known position values; or c) values directly from neighbor values. The formulas for the intermediate total are given above.
In a related system, each hierarchical “level” of values for the intermediate total is created as desired and each level can be used to generate sub-level values, or interpolated values. For example a first level may include generating h-pel values from given or calculated i-pel values. Included in the first level is the possibility of generating h-pel values from h-pel values too. Then, a further sub-level of q-pel values can be generated from either the h-pel values, or even directly from the i-pel values. To generate another sub-level, additional intermediate values are calculated from values in nearby levels. These iterations can continue infinitely.
In one aspect, the sum of a pair of intermediate values can be thought of as a Sum of Absolute Differences of bi-linear interpolated (i.e., filtered) values from the starting points of the intermediate values.
Intermediate totals can be generated from any pair of intermediate values, although it is most likely that the most local of the values will be the most desirable to generate each intermediate total.
When designing a system using these embodiments, more hardware capacity directly translates to increased performance. For example, a larger search area can be searched for a given hardware capacity. Another example is that the repeating, recursive nature of the bi-linear interpolation allows the hardware to be re-used to generate a further set of sub-level values. For instance, from the known integer values, h-pel and q-pel values can be generated, as described above. If that is the extent of the available hardware, the q-pel values can then be substituted as the “new i-pel” values, and process repeated to generate ⅛ and 1/16-pel values. A further substitution of the 1/16 pels as “new i-pel” values allows the same hardware to then generate 1/32 and 1/64-pel values, all from the original set of original i-pel values and simple repetition.
A new circuit can be created as described above that generates both a SAD value and a set of Intermediate Total values, simultaneously, based on a comparison of two values, then outputs both for further processing. A related circuit adds Intermediate Total values to generate both a SAD value (interpolated) and a set of Intermediate Total values. The similarity of the two circuits gives an infinite recursion of interpolation, and a simple input multiplexer can change the same embodiment from one circuit to another for maximum flexibility.
Another new system according to embodiments of the invention involves compression whereby an n-bit multi-bit value can be stored and operated on in less than n bits. In one embodiment, if the multi-bit value is less than a threshold, then the multi-bit value is stored in the reduced-bit storage directly, with no loss of precision. If the multi-bit value is greater than the threshold, then the Least Significant Bits (LSBs) of the multi-bit value are shifted into the reduced-bit storage, and a compression flag set. To decompress, if the compression flag was not set, the bits stored in the LSBs of the reduced-bit storage are merely copied back into the multi-bit value directly. If the compression flag was set, then the bits stored in the LSBs of the reduced-bit storage are shifted (left) by the same amount they were shifted (right) during compression, and an error-minimizing value is added to the LSBs of the multi-bit value. The error minimizing value may be ½ the threshold value, or another number. The compression method when used for computing SAD is biased towards making good matches: if the match is good the SAD is exact; if any of the difference values is not a good match, the compressed value makes the final SAD larger. This provides a filtering effect by rejecting large difference spike values of a set in preference for a set of variations with no spike(s).
In one embodiment the multi-bit value is 8 bits, the reduced-bit storage is 4 bits, the threshold is 16, and the error minimizing value is 8. Such a compression system provides accuracy when needed, such as determining a minimum of several relatively similar low numbers, and is less accurate when the minimum value is very high.
Another embodiment of the invention provides for a built-in masking function used in conjunction with either the SAD engine or the Intermediate Total engine described above. In this embodiment a controllable mask bit is set for each individual ai:bi comparison. To include the particular location represented by the “i” value in the comparison, the mask bit is left unset; to ignore any location, the mask bit is set. If the mask bit is set, the comparison value is calculated as zero, i.e., there is no difference entered into the calculation, even if there is an actual difference in the two datasets. Masking allows a particular non-rectangular shape or feature to be detected or highlighted compared to regular processing.
Other embodiments of the invention are directed to manipulating numbers and values. For instance, using embodiments described above, unsorted values may be inserted into a sorted list using a minimum of hardware resources.
Other embodiments of the invention are directed to systems and methods of providing multiple values to an encoder. Compared to prior art and present day systems, which only pass a single minimum value or minimum vector, rate distorted or not, to an encoder, embodiments of the invention can work with the encoder to provide an intelligent encoder multiple value candidates to make a final encoding decision.
Whereas in currently processed video there are three different predicted vectors, one each for inter-coding, intra-coding, and skip, embodiments of the invention can provide multiple input predicted vectors, which allows the encoder much greater latitude in predicting the best encoding method. This solves a problem of inaccurate predicted vectors for which a typical motion estimation system has made assumptions that turn out to be inaccurate for a particular situation. Thus, SAD or rate calculations, as is the current state of the art, may not be good enough to allow an encoder to best encode a data stream. Providing the encoder with supplemental, efficiently calculable information, such as multiple minima and multiple predicted rate-compensated vectors, and optionally including a predicted or calculated bit-cost of each value transmitted, allows the encoder to increase its encoding efficiency.
The use of multiple predicted vectors can be efficiently generated from a small-footprint hardware cost. In typical, real-world video there are different predicted vectors dependent on how the preceding block was predicted, and embodiments of the invention can either generate estimated predicted vectors or use each of the provided vectors in calculating final values to pass to the encoder. One way to rank multiple equal values is to use a spiral test—whichever of the lowest equal values is first to appear in a spiral search is the selected value, as is described in detail above.
Although particular component blocks, sub-components, circuits, and systems to implement a variety of image processing have been described above, it is not intended that such specific references be considered as limitations upon the scope of this invention except in-so-far as set forth in the following claims.
This application is a division of U.S. patent application Ser. No. 12/778,996, filed May 12, 2010, entitled “System for Compressing and De-compressing Data Used in Video Processing,” which is currently pending, and which claims priority from U.S. provisional application 61/177,351, filed May 12, 2009, entitled “System for Creating Sum of Absolute Totals,” which is expired. This application is related to U.S. provisional application 61/177,357, filed May 12, 2009, entitled “System for Programmable Rate Distortion;” and U.S. provisional application 61/177,361, filed May 12, 2009, entitled “Deserialized System for Computing Motion Vectors,” which are incorporated by reference. This application is also related to U.S. application Ser. No. 12/778,971, filed May 12, 2010, entitled “System for Generating Difference Measurements in a Video Processor”; U.S. application Ser. No. 12/778,980, filed May 12, 2010, entitled “System for Providing Plural Vector Candidates in a Video System”; U.S. application Ser. No. 12/779,000, filed May 12, 2010, entitled “System for Sorting”; U.S. application Ser. No. 12/779,005, filed May 12, 2010, entitled “System for Programmable Rate Distortion”; and U.S. application Ser. No. 12/779,009, filed May 12, 2010, entitled “Deserialized System for Computing Motion Vectors”.
Number | Name | Date | Kind |
---|---|---|---|
4893538 | Masaki et al. | Jan 1990 | A |
5313170 | Kojima | May 1994 | A |
5793655 | Harlap et al. | Aug 1998 | A |
5960193 | Guttag et al. | Sep 1999 | A |
6175593 | Kim et al. | Jan 2001 | B1 |
6553079 | Piirainen | Apr 2003 | B1 |
7817719 | Pedersen et al. | Oct 2010 | B2 |
20020039386 | Han et al. | Apr 2002 | A1 |
20030021344 | Panusopone et al. | Jan 2003 | A1 |
20040126027 | Park et al. | Jul 2004 | A1 |
20050018772 | Sung et al. | Jan 2005 | A1 |
20050031034 | Kamaci et al. | Feb 2005 | A1 |
20050100229 | Becker et al. | May 2005 | A1 |
20050131979 | Song | Jun 2005 | A1 |
20050135481 | Sung | Jun 2005 | A1 |
20060120613 | Su et al. | Jun 2006 | A1 |
20060133506 | Dang | Jun 2006 | A1 |
20060193388 | Woods et al. | Aug 2006 | A1 |
20070064793 | Wang et al. | Mar 2007 | A1 |
20070064794 | Wang et al. | Mar 2007 | A1 |
20070076802 | Osamoto et al. | Apr 2007 | A1 |
20070121728 | Wang et al. | May 2007 | A1 |
20080002770 | Ugur et al. | Jan 2008 | A1 |
20080095237 | Hussain et al. | Apr 2008 | A1 |
20080126278 | Bronstein et al. | May 2008 | A1 |
20080175322 | Lee et al. | Jul 2008 | A1 |
20090022220 | Vatis et al. | Jan 2009 | A1 |
20090110060 | Cortes et al. | Apr 2009 | A1 |
20100150232 | Nguyen et al. | Jun 2010 | A1 |
20100201870 | Luessi et al. | Aug 2010 | A1 |
Number | Date | Country | |
---|---|---|---|
20120230434 A1 | Sep 2012 | US |
Number | Date | Country | |
---|---|---|---|
61177351 | May 2009 | US |
Number | Date | Country | |
---|---|---|---|
Parent | 12778996 | May 2010 | US |
Child | 13474990 | US |