Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
METHOD OF SELECTING AN ENCODING MODE
Document Type and Number:
WIPO Patent Application WO/2006/065257
Kind Code:
A1
Abstract:
The invention is to generate an encoded version of a matrix of j transform coefficients co…cj-1 representing a block of digital video data is determined by forming a numerical signature ¡ of the matrix (100, 110) and looking up (180) a value for the information needed in an array employing the signature ¡ as an index to the array.

Inventors:
SCHWARTZ MAYER D (US)
Application Number:
PCT/US2005/004642
Publication Date:
June 22, 2006
Filing Date:
February 11, 2005
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
TUT SYSTEMS INC (US)
International Classes:
H04B1/66; G06K9/00; G06K9/62; H04L7/00
Foreign References:
US6332030B12001-12-18
Other References:
See also references of EP 1825601A4
Attorney, Agent or Firm:
Smith-hill, John (P.C. 16100 N.W., Cornell Road, Suite 22, Beaverton OR, US)
Download PDF:
Claims:
CLAIMS
1. A method for determining information needed to generate an encoded version of a matrix of j transform coefficients c0 ... cj1 representing a block of digital video data, the method comprising the steps of: a) forming a numerical signature σ of the matrix, and b) looking up a value for the information needed in an array employing the signature σ as an index to the array.
2. A method according to claim 1, comprising calculating σ using a group of the coefficients in accordance with a procedure that returns a unique value of σ for each unique set of coefficient values.
3. A method according to claim 1, wherein step a comprises: al) linearly ordering the coefficients c0, c1, ..., cj1, a2) selecting a group of m sequentially ordered coefficients cu through cv where u is less than v and v equals u + m 1, a3) mapping each coefficient Cj in the group to an unsigned integer representation ri, a4) weighting each integer representation r, to form a weighted representation wi, and a5) combining the weighted representations wu ... wv to form σ.
4. A method according to claim 3, wherein step al comprises ordering the coefficients according to a zigzag scan.
5. A method according to claim 3, wherein step al comprises ordering the coefficients according to a lefttorighttoptobottom scan.
6. A method according to claim 3, wherein each coefficient ci in the group is limited to a predefined range of possible values and the predefined range of possible values for coefficient ci is greater than the predefined range of possible values for coefficient c1+1.
7. A method according to claim 3, wherein coefficients cv+1 ... Cj.i equal zero.
8. A method according to claim 3, wherein c, is represented by a maximum number of bits b, and step a3 comprises: calculating r, for each coefficient c, in the group according to the equation: 1 11.
9. A method according to claim 3, wherein step a4 comprises: calculating w, for each coefficient c, in the group according to the equation: where tk = 0 for k = u and .
10. A method according to claim 3, wherein step a5 comprises summing the weighted representations wu ... wv to calculate σ.
11. A method according to claim 3, wherein step a further comprises: receiving an identifier associated with the matrix, and, after step a5, storing σ in a holding table using the matrix's identifier as an index.
12. A method according to claim 11, wherein the array comprises a plurality of data tables and the method further comprises, between step a and step b: receiving a communication from a requestor indicating a data table, and receiving the identifier from the requestor, step b further comprises: using the identifier as an index to the holding table to retrieve σ, and reading a value of the information needed from the indicated data table, and, after step b, the method further comprises: returning the value of the information needed to the requestor.
13. A method according to claim 1, wherein the array comprises multiple data tables and step b comprises: receiving a communication from a requestor indicating a data table, reading the value of the information needed from the indicated table, and returning the value of the information needed to the requestor.
14. A method according to claim 1, wherein, prior to step b, the method comprises calculating σ and the value of the information needed for every matrix in which the value of each coefficient falls within a predetermined range.
15. A method according to claim 14, wherein prior to step b, the method comprises creating the array, wherein the array contains the calculated values of the information needed indexed by the calculated σ values.
16. A method according to claim 1, comprising performing step a in parallel with calculating transform coefficients C0 ... Cj1.
17. A method according to claim 1, wherein the information needed is a number of bits R equivalent to the length of the encoded version of the matrix.
18. A method according to claim 1, wherein the information needed is a sequence of bits S that is equivalent to an encoded version of the matrix of transform coefficients.
19. A method of employing a mode selection function J for selecting a coding mode from a plurality of coding modes for a matrix of j transform coefficients C0 ... Cj.i representing a block of digital video data, the method comprising: a) forming a numerical signature a of the matrix, b) looking up at least one value of a parameter R in an array using σ as an index to the array, wherein J is a function of R and each value of R equals the size, in bits, of an encoded version of the matrix encoded with one of the plurality of coding modes, c) using each value of R as an input to an algorithm to determine a corresponding value of J, and d) selecting the coding mode corresponding to a minimum value of J.
20. A method according to claim 19, comprising calculating σ using a group of the coefficients in accordance with a procedure that returns a unique value of σ for each unique set of coefficient values and wherein step a comprises: al) linearly ordering the coefficients C0, ci, ..., c,.i, a2) selecting a group of m sequentially ordered coefficients cu through cv where u is less than v and v equals u + m 1 , a3) mapping each coefficient c, in the group to an unsigned integer representation r,, a4) weighting each integer representation r, to form a weighted representation W1, and a5) combining the weighted representations wu ... wv to form σ.
21. A method according to claim 19, wherein prior to step b, the method comprises calculating a a value and a value of R for each of the plurality of coding modes for every matrix in which the value of each coefficient falls within a predetermined range.
22. A method according to claim 21, wherein for every unique combination of σ and coding mode there is a single R value, and the method comprises, prior to step b, creating at least one table in which each calculated R value is stored, and creating the array, wherein the array includes said at least one table.
23. A method according to claim 19, comprising performing step a in parallel with calculating transform coefficients C0 ... Cj1.
24. A method for determining a sequence of bits S equivalent to an encoded version of a matrix of transform coefficients C0 ... Cj1 representing a block of digital video data, the method comprising: a) forming a numerical signature a of the matrix, b) looking up at least one value for a parameter R in a coding mode array using σ as an index to the array, wherein each value of R equals the size, in bits, of an encoded version of the matrix encoded with one of a plurality of coding modes, c) using each value of R as an input to a mode selection function J to determine a corresponding value of J, d) selecting the coding mode corresponding to the smallest value of J, and e) selecting a value of S from a bit stream array, the selected value being uniquely identified by σ and the selected coding mode.
25. A method according to claim 24, comprising calculating σ using a group of the coefficients in accordance with a procedure that returns a unique value of a for each unique set of coefficient values and wherein step a comprises: al) linearly ordering the coefficients c0, c1, ..., cj1, a2) selecting a group of m sequentially ordered coefficients cu through cv where u is less than v and v equals u + m 1, a3) mapping each coefficient c, in the group to an unsigned integer representation r,, a4) weighting each integer representation r, to form a weighted representation w,, and a5) combining the weighted representations wu ... wv to form a.
26. A method according to claim 24, wherein prior to step a, the method comprises calculating a σ value and a value of R and S for each of the plurality of coding modes for every matrix in which the value of each coefficient falls within a predetermined range.
27. A method according to claim 26, wherein the coding mode array comprises multiple coding mode tables and the method comprises, prior to step b, creating said coding mode tables wherein each coding mode table corresponds to a given coding mode and stores the calculated R value for each value of σ for that coding mode.
28. A method according to claim 27, wherein for every unique combination of σ and coding mode there is a single S value and the method comprises, prior to step a, storing each calculated S value in a bit stream table.
29. A method according to claim 24, comprising performing step a in parallel with calculating transform coefficients c0 ... cj1.
30. A computing machine for receiving a matrix of j transform coefficients c0 ... cj1, the coefficients representing a block of digital video data, the machine being programmed to operate on the coefficients c0 ... cj1 to determine information needed to generate an encoded version of the matrix by performing a procedure comprising the steps: a) forming a numerical signature a of the matrix, and b) looking up a value for the information needed in an array employing the signature σ as an index to the array.
31. A computing machine according to claim 30 wherein the programmed procedure comprises calculating σ using a group of the coefficients in accordance with a function that returns a unique value of σ for each unique set of coefficient values.
32. A computing machine according to claim 30, wherein step a of the programmed procedure comprises: al) linearly ordering the coefficients C0, cj, ..., Cj.i, a2) selecting a group of m sequentially ordered coefficients cu through cv where u is less than v and v equals u + m 1, a3) mapping each coefficient c, in the group to an unsigned integer representation rb a4) weighting each integer representation r, to form a weighted representation W1, and a5) combining the weighted representations wu ... wv to form σ.
33. A computing machine according to claim 32, wherein step al of the programmed procedure comprises ordering the coefficients according to a zigzag scan.
34. A computing machine according to claim 32, wherein step al of the programmed procedure comprises ordering the coefficients according to a lefttorighttop tobottom scan.
35. A computing machine according to claim 32, wherein each coefficient c, in the group is limited to a predefined range of possible values and the predefined range of possible values for coefficient c, is greater than the predefined range of possible values for coefficient C1+1.
36. A computing machine according to claim 32, wherein coefficients cv+i ... c,.i equal zero.
37. A computing machine according to claim 32, wherein c, is represented by a maximum number of bits b, and step a3 of the programmed procedure comprises: calculating r, for each coefficient c, in the group according to the equation: ri = ci + 2bi 1 1.
38. A computing machine according to claim 32, wherein step a4 of the programmed procedure comprises: calculating w, for each coefficient c, in the group according to the equation: where tk = 0 for k = u and .
39. A computing machine according to claim 32, wherein step a5 of the programmed procedure comprises summing the weighted representations wu ... wv to calculate a.
40. A computing machine according to claim 32, wherein step a of the programmed procedure further comprises: receiving an identifier associated with the matrix, and, after step a5, storing a in a holding table using the matrix's identifier as an index.
41. A computing machine according to claim 40, wherein the array comprises a plurality of data tables and the programmed procedure further comprises, between step a and step b: receiving a communication from a requestor indicating a data table, and receiving the identifier from the requestor, step b further comprises: using the identifier as an index to the holding table to retrieve σ, and reading a value of the information needed from the indicated data table, and, after step b, the programmed procedure further comprises: returning the value of the information needed to the requestor.
42. A computing machine according to claim 30, wherein the array comprises multiple data tables and step b of the programmed procedure comprises: receiving a communication from a requestor indicating a data table, reading the value of the information needed from the indicated data table, and returning the value of the information needed to the requestor.
43. A computing machine according to claim 30, wherein, prior to step b, the programmed procedure comprises calculating σ and the information needed for every matrix in which the value of each coefficient falls within a predetermined range.
44. A computing machine according to claim 43, wherein, prior to step b, the programmed procedure comprises creating the array, wherein the array contains the calculated values of the information needed indexed by the calculated σ values.
45. A computing machine according to claim 30, wherein the programmed procedure comprises performing step a in parallel with calculating transform coefficients C0 .. Cj1.
46. A computing machine according to claim 30, wherein the information needed is a number of bits R equivalent to the length of the encoded version of the matrix.
47. A computing machine according to claim 30, wherein the information needed is a sequence of bits S that is equivalent to an encoded version of the matrix of transform coefficients.
48. A computer readable medium upon which is written instructions defining a procedure for operating on a matrix of j transform coefficients Co ... Cj.i representing a block of digital video data to determine information needed to generate an encoded version of the matrix, the procedure comprising the steps: a) forming a numerical signature a of the matrix, and b) looking up a value for the information needed in an array employing the signature a as an index to the array.
49. A computer readable medium according to claim 48, wherein the procedure comprises calculating σ using a group of the coefficients in accordance with a function that returns a unique value of σ for each unique set of coefficient values.
50. A computer readable medium according to claim 48, wherein step a of the procedure comprises: al) linearly ordering the coefficients C0, C1, ..., Cj1, a2) selecting a group of m sequentially ordered coefficients cu through cv where u is less than v and v equals u + m 1, a3) mapping each coefficient c, in the group to an unsigned integer representation r,, a4) weighting each integer representation r, to form a weighted representation w,, and a5) combining the weighted representations wu ... wv to form σ.
51. A computer readable medium according to claim 50, wherein step al of the programmed procedure comprises ordering the coefficients according to a zigzag scan.
52. A computer readable medium according to claim 50, wherein step al of the programmed procedure comprises ordering the coefficients according to a lefttorighttop tobottom scan.
53. A computer readable medium according to claim 50, wherein each coefficient c, in the group is limited to a predefined range of possible values and the predefined range of possible values for coefficient c, is greater than the predefined range of possible values for coefficient c,+i .
54. A computer readable medium according to claim 50, wherein coefficients cv+i ... CJI equal zero.
55. A computer readable medium according to claim 50, wherein c, is represented by a maximum number of bits b, and step a3 of the procedure comprises: calculating r, for each coefficient c, in the group according to the equation: ri = ci + 2bi 1 1.
56. A computer readable medium according to claim 50, wherein step a4 of the procedure comprises: calculating Wk for each coefficient Ck in the group according to the equation: where tk = 0 for k = u and.
57. A computer readable medium according to claim 50, wherein step a5 of the procedure comprises summing the weighted representations wu ... wv to calculate a.
58. A computer readable medium according to claim 50, wherein step a of the procedure comprises: receiving an identifier associated with the matrix, and, after step a5, storing σ in a holding table using the matrix's identifier as an index.
59. A computer readable medium according to claim 58, wherein the array comprises a plurality of data tables and the procedure further comprises, between step a and step b: receiving a communication from a requestor indicating a data table, and receiving the identifier from the requestor, step b of the procedure further comprises: using the identifier as an index to the holding table to retrieve σ, and reading a value of the information needed from the indicated data table, and, after step b, the procedure further comprises: returning the value of the information needed to the requestor.
60. A computer readable medium according to claim 48, wherein the array comprises multiple data tables and step b of the procedure comprises: receiving a communication from a requestor indicating a data table, reading the value of the information needed from the indicated data table, and returning the value of the information needed to the requestor.
61. A computer readable medium according to claim 48, wherein prior to step b, the procedure comprises calculating σ and the value of the information needed for every matrix in which the value of each coefficient falls within a predetermined range.
62. A computer readable medium according to claim 61, wherein prior to step b, the procedure comprises creating the array, wherein the array contains the calculated values of the information needed indexed by the calculated σ values.
63. A computer readable medium according to claim 48, wherein the procedure comprises performing step a in parallel with calculating integer transform coefficients C0 ... CjI .
64. A computer readable medium according to claim 48, wherein the information needed is a number of bits R equivalent to the length of the encoded version of the matrix.
65. A computer readable medium according to claim 48, wherein the information needed is a sequence of bits S that is equivalent to an encoded version of the matrix of transform coefficients.
Description:
METHOD OF SELECTING AN ENCODING MODE

BACKGROUND OF THE INVENTION

[0001] The present invention relates to compression coding of video signals, and more particularly to a method for improving the efficiency of predicting the number of bits required to encode a matrix of transform coefficients for the International Telecommunication Union - Telecommunication Standardization Sector (ITU-T) H.264 video compression standard (H.264). As in previous video coding standards, the Video Coding Layer (VCL) of H.264 uses a hybrid of temporal and spatial prediction as well as transform coding to compress video sequences.

[0002] In the coding process, a picture is divided into slices, each slice representing a portion of the picture that can be decoded independently of the rest of the picture. The slices are divided into macrob locks. A macroblock consisting of a 16x16 block of luma samples and two corresponding 8x8 blocks of chroma samples is used as the basic H.264 processing unit. An H.264 compliant encoder will calculate a predicted value for each sample in a macroblock. The predicted values are then subtracted from the actual values to form prediction residuals. Once the prediction residuals have been calculated, they are transformed, generating 4x4 blocks of transform coefficients that are then scaled and quantized. The quantized transform coefficients are entropy encoded and transmitted. Two methods for encoding the quantized transform coefficients are supported by H.264. One is Context-Adaptive Variable Length Coding (CAVLC), the other is Context- Adaptive Binary Arithmetic Coding (CABAC). CAVLC maps syntax elements to various Variable Length Coding (VLC) tables using information from already transmitted syntax elements. This mapping improves the entropy encoding performance compared to using a single VLC table. The encoder can use a variety of methods, called coding modes, to encode a macroblock.

[0003] The selection of coding modes available to the encoder for a given macroblock depends on the type of slice the macroblock belongs to. In the main profile, three slice types are supported by the H.264 standard: intra-coded (I) slices, predictive-coded (P) slices, and bi-predictive (B) slices. The specific mode selected from the modes available for coding a macroblock from a particular type of slice depends on the image content of that macroblock. There are a total of 13 intra-coding modes available to all macroblocks regardless of slice type. Additionally 5 inter-coding modes are available for P slices (plus skipped) and 23 inter-coding modes are available for B slices (plus skipped). P-slice and

B-slice macrob locks are treated similarly in terms of their division into sub-blocks and the coding modes used on the sub-blocks. However, unlike P-slice macroblocks, macroblocks from B-slices can use two distinct reference picture buffers, respectively called the first and second reference picture buffers.

[0004] Almost any encoder for the H.264 standard performs some variation of a rate- distortion (RD) optimization algorithm to determine the best coding mode for each macroblock. This process is known as mode decision. The RD optimization algorithm is applied on a macroblock by macroblock basis and attempts to find the best trade-off between the number of bits needed to encode a given macroblock versus the magnitude of the prediction residuals of the given macroblock. The trade-off function is represented by the equation:

J(MB, mode, Q) = SSD(MB) + λ(Q) * R(MB, mode, Q) (equation 1) where MB represents the given macroblock, including the original picture elements (pels), reconstructed pels and slice type. SSD is a difference term, typically a sum of squared differences, λ(Q) is a multiplier dependent on the quantizer Q and the slice type, and R is the number of bits needed to encode the macroblock. For each MB to be encoded, a transform needs to be calculated for each coding mode available for the MB's slice type. This, as well as the calculation of the SSD terms, must be done before the calculation of R(MB, mode, Q). The best trade-off is obtained by varying the mode for a given Q and MB in order to minimize the function J. In any practical implementation, Q is fixed for each macroblock.

[0005] Due to the entropic nature of the encoding, a large number of transform coefficients tend to equal positive one, negative one or zero. Non-zero coefficients tend to be found in the upper left hand portion of a given matrix and the coefficients in the bottom right hand corner of the matrix tend to equal zero, as shown in FIG. 1 for a generic transform coefficient matrix. That is why the H.264 standard specifies two different "zig-zag scans" (one for frame encoding and a different one for field encoding) to re-order the matrix coefficients in the sequence C 0 -Ci 5 such that the coefficients more likely to be non-zero are ordered first, followed by the coefficients more likely to equal zero. This prevents the encoder from having to take up bandwidth transmitting a string of essentially null information. Much of the compute time of an H.264 video encoder is spent minimizing J(MB, mode, Q). This necessitates calculating R(MB, mode, Q) for all applicable coding modes for every single macroblock. Calculation of R(MB, mode, Q) is a very

computationally intensive process. Therefore, in order to have a good real-time encoder, R(MB, mode, Q) needs to be calculated in as efficient a manner as possible. [0006] What is needed is a method for quickly determining R(MB, mode, Q) that works on most H.264 transform matrices.

SUMMARY OF THE INVENTION

[0007] hi accordance with a first aspect of the invention there is provided a method for determining information needed to generate an encoded version of a matrix of j transform coefficients C 0 ... C j .i representing a block of digital video data, the method comprising forming a numerical signature σ of the matrix, and looking up a value for the information needed in an array employing the signature σ as an index to the array. [0008] hi accordance with a second aspect of the invention there is provided a method of employing a mode selection function J for selecting a coding mode from a plurality of coding modes for a matrix of j transform coefficients C 0 ... C 1-I representing a block of digital video data, the method comprising forming a numerical signature a of the matrix, looking up at least one value of a parameter R in an array using a as an index to the array, wherein J is a function of R and each value of R equals the size, in bits, of an encoded version of the matrix encoded with one of the plurality of coding modes, using each value of R as an input to an algorithm to determine a corresponding value of J, and selecting the coding mode corresponding to a minimum value of J.

[0009] In accordance with a third aspect of the invention there is provided a method for determining a sequence of bits S equivalent to an encoded version of a matrix of transform coefficients C 0 ... C j .i representing a block of digital video data, the method comprising forming a numerical signature σ of the matrix, looking up at least one value for a parameter R in a coding mode array using σ as an index to the array, wherein each value of R equals the size, in bits, of an encoded version of the matrix encoded with one of a plurality of coding modes, using each value of R as an input to a mode selection function J to determine a corresponding value of J, selecting the coding mode corresponding to the smallest value of J, and selecting a value of S from a bit stream array, the selected value being uniquely identified by σ and the selected coding mode.

[0010] hi accordance with a fourth aspect of the invention there is provided a computing machine for receiving a matrix of j transform coefficients C 0 ... c } . \ , the coefficients representing a block of digital video data, the machine being programmed to operate on the coefficients C 0 ... C j .i to determine information needed to generate an encoded version of the

matrix by performing a procedure comprising the steps of forming a numerical signature σ of the matrix, and looking up a value for the information needed in an array employing the signature σ as an index to the array.

[0011] In accordance with a fifth aspect of the invention there is provided a computer readable medium upon which is written instructions defining a procedure for operating on a matrix of j transform coefficients C 0 ... C j-1 representing a block of digital video data to determine information needed to generate an encoded version of the matrix, the procedure comprising the steps forming a numerical signature σ of the matrix, and looking up a value for the information needed in an array employing the signature σ as an index to the array.

BRIEF DESCRIPTION OF THE DRAWINGS

[0012] For a better understanding of the invention, and to show how the same may be carried into effect, reference will now be made, by way of example, to the accompanying drawings, in which

FIG. 1 is shows a 4x4 matrix of H.264 transform coefficients, the same 4x4 matrix showing the ordering of the zig-zag scan, and the reordered coefficients of the matrix,

FIG. 2 is a flow chart describing a method embodying the present invention for determining the number of bits needed to encode a 4x4 H.264 transform coefficient matrix,

FIG. 3 A shows the range of valid values of three H.264 transform coefficients when their binary representations are limited to 3 bits, 2 bits and 2 bits respectively,

FIG. 3B shows the range of possible values of a mapping of the three transform coefficients of FIG 3 A to unsigned integer representations,

FIG. 3 C shows the mapping of 4 possible coefficient values to their corresponding unsigned integer representations when the coefficients magnitude is limited to 4 bits,

FIG. 4 shows the possible valid values of the weighted representations of 3 coefficients C 0 , ci and C 2 when their binary representations are limited to 3 bits, 2 bits and 2 bits respectively,

FIG. 5 shows the range of possible signature values for various sets of values of coefficients Co, C 1 and C 2 when their binary representations are limited to 3 bits, 2 bits and 2 bits respectively, and

FIG. 6 shows a block diagram of a computing machine capable of implementing the method shown in FIG. 2.

DETAILED DESCRIPTION

[0013] FIG. 2 illustrates a flow chart depicting a method for determining the value of R(MB, mode, Q) for an H.264 transform coefficient matrix. FIG. 2 is provided to assist in understanding the functional steps of the method but should not be regarded as illustrating the method's only possible implementation.

[0014] Referring to FIG. 2, the input to step 100 is an H.264 transform coefficient matrix calculated from a macroblock of digital video data. The matrix is to be encoded using CAVLC encoding and contains n coefficients, where n can equal 16 or 4. hi step 100, the coefficients are linearly ordered from C 0 through C (n-1) by the zig-zag scan or field scan, as shown in FIG. 1.

[0015] Referring again to FIG. 2, in step 110, the coefficients are split into two groups. The first group is a sub-set of m coefficients C 0 - c m- i, or ci - c m , where the value of m is implementation dependent. The sub-set begins with C 0 or ci depending on the type of macroblock the matrix was created from. A sub-set created from a 4x4 residual block or from a 4x4 block of DC values for an Intra- 16x16 macroblock contains coefficients Co through C m- I. A sub-set created from a 4x4 residual block of AC coefficients for an Intra- 16x16 macroblock or from a 4x4 residual block of AC coefficients for chroma samples contain coefficients C 1 through c m and coefficient C 0 (the DC coefficient) is discarded. The second group is composed of the remaining coefficients c m through c n- i or c m+ i through c n- i. [0016] For 2x2 matrices of DC values for the chroma coefficient transforms, the coefficients are ordered Co - C 3 and are read out in a left-to-right, top-to-bottom scan in step 100 and the value of m is generally set to 4 in step 110.

[0017] All subsequent operations performed on a sub-set are identical, regardless of whether the sub-set begins with C 0 or ci, or if the current matrix is a 4x4 matrix or a 2x2 matrix. For the purpose of clarity, a 4x4 matrix and a sub-set of coefficients C 0 through c m-1 will be assumed for all further examples unless otherwise noted. [0018] Referring again to FIG. 2, in steps 120 and 130 the coefficients are tested to determine if they adhere to certain rules. Matrices whose coefficients adhere to these rules are deemed valid. In a valid matrix each coefficient Cj, for i less than m, has a value that can be expressed by no more than a certain, implementation dependent, number of bits b; and

each coefficient c,, for i greater than or equal to m, is equal to zero. Generally, the value of b, is greater than or equal to the value of b, + i.

[0019] In step 120, the coefficients in the second group are tested to determine whether each coefficient c m - Ci 5 equals zero. This is done because the second group is not used by the method to determine R(MB, mode, Q) and therefore must not contain any information about the coefficients' macroblock. If any coefficient in the second group has a non-zero value, then the matrix is not valid and R(MB, mode, Q) must be found by an alternative method, which may be the computationally intensive conventional method. For a 2x2 matrix with m equal to 4, all the matrix coefficients are used by the method and step 120 is not applicable.

[0020] In accordance with the H.264 standard, each coefficient has a range of possible values defined by the number of bits used to represent that coefficient. Because H.264 transform coefficients are 16 bit integers, each coefficient has

2 16 = 65,536 possible values. Since the transform uses signed integers and includes zero, each coefficient can be in the range:

C m in = -2 15 = -32,768 to c max = 2 15 - l = 32,767.

However, the method does not need to be able to determine R(MB, mode, Q) for the full range of possible coefficient values to be able to function for the majority of matrices encountered by the encoder. For many matrices, a coefficient c, will generally fall into a range that requires less than 16 bits to represent. For instance, coefficients are often in the range of -1 to 1 and require only two bits, e.g. one magnitude bit and one sign bit, to represent.

[0021] Li step 130, a test is performed on the ordered sub-set of coefficients C 0 - c m- i to determine whether they fall into a pre-specified range of valid values. A valid value of c, must be capable of being represented by a number of bits b,. For instance, if b 3 = 4, then c 3 must fall in the range of -7 through 8, the minimum and maximum values that can be represented by 3 magnitude bits and 1 sign bit. If the magnitude of the coefficient c, is too large to be represented by b, - 1 bits then the encoder must revert to the alternative method of determining R(MB, mode, Q).

[0022] The values of m and b 0 - b m- i define a set of valid matrices. During an initialization phase of the H.264 encoder, for every transformed matrix type (Intra, D. C, Inter, etc.) the value ofR(MB, mode, Q) is calculated for each valid matrix using the alternative method

for each potential coding mode. The R(MB, mode, Q) values are then stored in an array of addressable locations. Preferably, the addressable locations are organized as nine look-up tables, where each table corresponds to the R(MB, mode, Q) values for a specific matrix type: 4 for matrices of luma coefficients from a frame type picture, 4 for matrices of luma coefficients from a field type picture and 1 for matrices of chroma coefficients Also stored in the look-up tables is the number of non-zero coefficients in the matrix, which is needed for generating the encoded version of the matrix. The number of valid matrices, and thus the number of required entries L in each of the look-up tables is a function of m and b 0 - b m-

Unique signatures are calculated for all valid matrices and are used as indices to the tables. If a matrix's coefficients pass steps 120 and 130 the method knows that a value of R(MB, mode, Q) can be found in the look-up tables and the matrix's unique index in the look-up tables must then be calculated.

[0023] While the method uses nine logical tables to form the array of addressable locations, no specific configuration of physical tables is required. For instance, rather than use nine different physical tables, a single physical table with nine addressable fields could be used. [0024] hi step 140, if the matrix is valid, each coefficient c, in the sub-set is mapped to an unsigned integer representation r,: r, = c 1 + 2 bl - 1 - l.

Referring to FIGs. 3 A - 3 C, this mapping shifts the coefficients from a range centered at zero on the number line (FIG. 3A), to a new range centered at 2 bl " ' - 1 (FIG. 3B). Using the example of b 3 = 4 (FIG. 3C):

[0025] In step 150, the mapped representations r 0 - r m- i are weighted, such that r, is weighted more heavily than r,.i :

w k = 2 tk r k where t k = 0 for k = 0, and

In binary, the weighting is accomplished by shifting r k to the left t k times. Referring to FIG. 4, if m = 3 and b 0-2 = [3, 2, 2] as in the above example, then t 0-2 = [0, 3, 5]. In binary, the weighting is accomplished by shifting r k to the left t k times. Because ro has valid values of [0, 1, 2, 3, 4, 5, 6, 7], valid values of w 0 are:

W 0- Ci = 2 t0 r 0-d = 2 0 [0, 1, 2, 3, 4, 5, 6, 7] = [0, 1, 2, 3, 4, 5, 6, 7] or w 0-b = r 0-b ≪ to = [000 b , ..., 111b] ≪ 0 = [000 b , .., 111 b ]. (Note that the subscript b on a number denotes a binary representation; also that [a b , C b , d b ] « x denotes shifting the binary representations of a, c and d to the left x number of times). For W 1 , T 1 has valid values of [0, 1, 2, 3], so valid values of wi are: wi_ d = 2 t1 r 1-d = 8r 1-d = 8[0, 1, 2, 3] = [0, 8, 16, 24] or w 1-b = r 1-b ≪ ti = [00 b , 01 b , 10 b , 11 b ] ≪ 3 =

[00000 b ,01000 b , 10000 b ,11000 b ].

For w 2 , r 2 has valid values of [0, 1, 2, 3], so valid values for W 2 are: w 2-d = 2 t2 r 2-d = 2 5 [0, 1, 2, 3] = [0, 32, 64, 96] or w 2-b = r 2-b ≪ t 2 = [00b, 01b, 10b, 11b] ≪ 5 =

[0000000 b , 0100000 b , 1000000 b , 1100000 b ] .

[0026] Referring again to FIG. 2, in step 160, the weighted representations w 0 - w m-1 are summed to form a signature σ for the matrix. The mapping and weighting of the coefficients in the previous steps ensures a unique signature is created for each valid set of coefficients. For this example:

[0027] The possible valid signature values range from 0 through 2^ b0 + bl + b2) . \ Referring to FIG. 5, for the example of m = 3, b 0 = 3, bi = 2 and b 2 = 2. If:

[c 0 , c 1 , c 2 ] = [c 0-min , c 1-min , c 2-min ] = [-2 b0 - 1 + 1, -2 b1 - 1 + 1, -2 b2 - 1 + 1]

= [-3, -1, -1], then:

[w 0 , w,, w 2 ] = [0, 0, 0] (see FIG. 4) and

σ min = 0 + 0 + 0 = 0. Whereas, if: ', 2 b2 - 1 J

then: and

[0028] Referring again to FIG. 5, the method creates a unique signature for each valid matrix. For given values of m and bo - b m- i, the set of valid coefficients with the lowest possible values will generate a signature of 0, the next lowest valued set of valid coefficients will generate a signature of 1 and so on, with no gaps or overlaps. Calculating σ in binary shows this more effectively. For the above example: 10b, 10b], then:

and

[0029] Referring again to FIG. 2, in step 170, the signatures of valid matrices are stored in a buffer with an identifier associated with the matrix's macroblock (CUR_MB_ID). If an invalid matrix is encountered an invalid signature is stored in the buffer instead. When the encoder needs to make the mode decision for a particular macroblock, the mode decision algorithm will query the buffer by sending the macroblock's identifier on the MB_ID signal and the buffer will respond by activating the MB_SIG_FOUND signal and sending the matrix's signature a to the look-up tables. If the transform matrix is valid, the valid signature will be passed to the look-up tables.

[0030] In step 180, in response to the MB_SIG_FOUND signal from step 170, one of the nine tables containing the values of R(MB, mode, Q) for all valid matrices is addressed by the encoder's mode decision algorithm via the TRANSFORM & CONTEXT request. The value ofR(MB, mode, Q) for the macroblock specified by the MB ED signal and the mode specified by the TRANSFORM & CONTEXT request is returned to the mode decision algorithm. If the macroblock in question has an invalid transform matrix, then a special value is returned to the mode decision algorithm indicating that R(MB, mode, Q) must be found using the alternative method.

[0031] The mode decision algorithm will, if applicable, make requests for several different values OfR(MB, mode, Q) for a given macroblock. The mode decision algorithm compares the values returned in response to the requests and selects a desired coding mode based on the values.

[0032] Because the calculation of a matrix's signature is less computationally demanding than calculating R(MB, mode, Q) in the conventional way, this method can be implemented with any computer architecture to save processing time. However, the greatest benefit can be attained using an architecture that provides multiple functional execution units capable of operating concurrently, such as the Texas Instruments TMS320C64x family of processors. When the method is implemented on such an architecture, the calculation of the signature can be interleaved with the calculation of the transform coefficient matrix using functional units not otherwise in use during a given clock cycle. For a given macroblock, functional units not in use during the calculation of Cj for i < m can be delegated to testing the validity of C M and calculating Wj.j. During the calculation of coefficients c m - Ci 5 the weighted representations wo - w m-1 can be summed to find a. The value of σ can be stored and when the encoder subsequently needs to make the mode decision for the macroblock, the values of R(MB, mode, Q) for each available mode can be looked up in the tables. Thus, for a valid matrix, the computation time of R(MB, mode, Q) is effectively zero compared to the alternative method and no time is lost to the encoder if an invalid matrix is encountered. Source code implementing such a "zero computation time" embodiment of the present invention is attached hereto as Appendix A (in Appendix A, note that a "||" character at the beginning of an instruction indicates that the instruction is to be executed in parallel with the previous instruction).

[0033] In another embodiment of the invention during the initialization phase of the H.264 encoder, in addition to the value of R(MB, mode, Q) being calculated for each valid matrix, the actual bit stream necessary to the transform for performing the CAVLC encoding is

calculated and stored in the look-up tables. Because the actual CAVLC bit streams will use the same signatures as indexes as the numbers of bits and number of non-zero transform coefficients, they can all be stored in the same table. During operation, after the appropriate mode has been determined by using the signature of the matrix to minimize J(MB, mode, Q), the signature is used to access the actual bit stream required for the particular matrix and encoding mode.

[0034] It will be appreciated that the invention is not restricted to the particular embodiment that has been described, and that variations may be made therein without departing from the scope of the invention as defined in the appended claims and equivalents thereof. For example, it will be appreciated that generally an H.264 encoder embodying the present invention will require a macroblock identifier as an input to step 170 so that a value of σ can be associated with the macroblock and subsequently accessed upon the request of the mode decision algorithm. However if the encoder is operating in lock-step, the table in step 170 could be replaced with a First In, First Out (FIFO) style buffer of such a length that a macroblock's signature σ will be out put from step 170 at precisely the time the mode decision algorithm will be querying step 180 for the macroblock's R(MB, mode, Q) value. This modification would also obviate the need for the MB ID signal from the mode decision algorithm.

[0035] Unless the context indicates otherwise, a reference in a claim to the number of instances of an element, be it a reference to one instance or more than one instance, requires at least the stated number of instances but is not intended to exclude from the scope of the claim a structure having more instances of that element than stated.

*

the

[0] )

) [0] [3] [2] [2] ) [3] +t[0] [3])

+fc [01 f 3] ) +t [11 [3]

+t [ 0] [1 ] +t [0] [3] ) )

)

[0] [IJ [3] +t [Il [3] )

[1] [1] +t [1] [3] )

f J)

[3] not zero

[1] not zero