# Patent

## Title
Latency rate distortion optimisation

## Abstract

There is provided an improved latency rate distortion optimization apparatus comprising a forward quantize unit (1200) for processing input coefficients (Wij), an inverse quantize unit (1300) coupled to the forward quantize unit (1200), and at least one look-up-table (150) of quantize values for use by the forward (1200) and inverse (1300) quantize units, wherein the at least one look-up-table (150) of quantize values further includes any one or more of the following modified quantize multiplication factors: negative forward quantize multiplication factors (−MF); pre-shifted forward quantize multiplication factors (MFps); negative pre-shifted forward quantize multiplication factors (−MFps); negative inverse quantize multiplication factors (−V); pre-shifted inverse quantize multiplication factors (Vps); or negative pre-shifted inverse quantize multiplication factors (−Vps), and the forward quantize unit (1200) is arranged to operate on the input coefficients (Wij) using one of the modified forward quantize multiplication factors, and the inverse quantize unit (1300) is arranged to operate on the output of the forward quantize unit (1200) using one of the modified inverse quantize multiplication factors.

## Background
TECHNICAL FIELD
The invention is related to video coding in general, and in particular to an improved latency apparatus for Rate Distortion Optimisation and a method of improving latency in a Rate Distortion Optimisation apparatus.
BACKGROUND
Video compression methods are used within digital television broadcasting systems to reduce the data rate per channel while maintaining picture quality. It is a primary objective of these compression methods that the instantaneous demand of the moving television picture sequence for transmission capacity is substantially met at all times despite its varying complexity.
Typical transmission channels used to convey audio-visual material have fixed bit rates and so the varying demand of the picture sequence for capacity may not always be satisfied. It is an inevitable result of the compression process that for extremes of highly complex picture behavior, the picture quality may occasionally be compromised in order that the bit rate criteria are met. By choosing a bit rate that is too low, poor quality will result for a significant proportion of the time. Conversely, a chosen bit rate that is too high will meet quality needs, but will waste transmission capacity for a significant proportion of the time. Thus, some kind of control mechanism is required that evens out the peaks and troughs of demand so that a given fixed bit rate is adequate to deliver good picture quality at all times. Part of such control ideally should take some objective measure of the picture quality into account so that the distortion in the picture is known to some degree. The optimisation of this process is called Rate Distortion Optimisation (RDO) and is an inherent part of practical realizations of modern compression methods.
The complex compression methods currently employed have become very sophisticated and use a variety of techniques in concert to achieve the objective of coding complex picture sequences using minimum bit rate. Typically, in such methods the compressed picture sequence of the television signal is hierarchically structured at a number of levels, each enabling the full set of coding tools available to be applied efficiently.
At the highest of these levels, the picture sequence is organized into contiguous Groups of Pictures (GOP) and each group is further organized so that the first picture of each GOP is coded without reference to any other picture in the sequence. This is known as Intra-picture coding, and the resultant picture is called an I picture. Subsequent pictures in the GOP are coded differentially with respect to other pictures in the GOP including this I picture.
For example the second picture in the GOP is typically predicted directly from the first I picture and the differences between the prediction and the actual picture, typically being small, are then coded with the consequence that the bit rate requirement is reduced. The resultant picture is known as a Predicted or P picture.
The next picture of the GOP may also be predicted in turn from this P picture and this pattern may repeat for the remainder of the GOP. These P predictions are uni-directional and use past pictures to predict future ones in a sequence of mutual dependence. It is also possible to code pictures in the GOP using Bi-directional prediction (i.e. using both past and future pictures) which effectively predictively interpolates the current picture. These pictures are known as B pictures. Thus a typical GOP may have a structure such as IPPBPPB or IBBPBBP, etc, and this structure and the GOP length are arbitrary and set by the system operator to suite the needs of a given application.
In typical video systems, a two dimensional image of a scene is usually scanned in a raster fashion from top left to bottom right in a series of so-called horizontal lines, and then each scan is repeated regularly to produce a sequence. The resolution or sharpness of the picture is determined by the number of picture elements or pixels allocated to the scan. The shape of the picture, its aspect ratio, determines the relationship between the number of horizontal and vertical pixels. In broadcast systems these numbers are standardized.
It is typical of television pictures that their representation takes one of two forms. Either the individual picture scans are completed using only one pass of the image or they can be done in two parts where half the scan is done in a first pass, where only the odd numbered horizontal lines are taken, and the second half is done a second pass where the remaining even numbered lines are taken. The former scan type is called Progressive or Sequential scan, and the latter is called an Interlaced scan.
The first pass of the interlaced scan produces the so-called Top Field and the second pass the Bottom Field. The two fields together cover the same number of pixels as the complete Progressive scan, and the complete picture is called a Frame.
It is clear that any movement in the picture during the Interlace scan will result in a degree of dislocation between the pixels of each Field and that degree of dislocation will be more severe the greater the speed of motion. This dislocation can cause a significant loss of efficiency in the compression of moving pictures and so it is better to code rapidly moving picture sequences Field by Field. All currently used compression methods recognize this and allow both Field and Frame modes to be chosen as the picture behavior demands.
The ITU-T H.264 (MPEG 4 part 10) compression standard used widely in the most recent commercial video compression products includes among its features the use of GOPs and a Field/Frame mode. In particular the coding of both P and B pictures in the GOP uses Inter-Field or Frame predictive methods. In order to extract the best performance from the standard, it divides each complete picture, either a Frame or a Field, into a large number of contiguous, rectilinear blocks of pixels. The most significant of these blocks is a square group of pixels called a macroblock (MB), which is typically 16×16 luminance pixels.
The predictive coding process operates primarily at MB level and the coding of a given MB in a given picture is performed using a prediction from a block or blocks within another picture or pictures in the GOP used as references and which have already been coded. However, the H.264 Inter prediction standard allows not only whole MBs to be predicted from a number of reference pictures, but it also allows various sub-divisions or Partitions of MBs to be predicted. This added sophistication, compared to older compression standards (such as MPEG-2) contributes to the superior performance of H.264. In the particular case of encoding a B Field/Frame, the reference pictures may be from previous pictures in display order—so called reference list0 pictures—or from later pictures in display order—so called reference list1 pictures.
The Predictive process described above, operating at MB or Partition level, seeks to find blocks of pixels in selected reference pictures that match a given block in the picture currently being coded. Motion search methods are commonly used to identify a number of best match blocks, or candidates, from a set of reference pictures. These candidates can be combined in list0/list1 pairs to produce Bi-predicted candidates.
Furthermore 16×16 pixel MBs and 8×8 pixel Partitions may also be predicted using the so called Direct Mode. Hence there may be several Inter prediction candidates for each MB and each Partition which must be compared to find the best, most efficient coding. This flexibility in the number of choices available improves the performance of the method, but at the expense of the additional processing required to evaluate each of the coding options.
Each assessment must be completed within the duration period of the MB, and the computing power and speed needed to do this are challenging and so an efficient practical method of achieving the required result is extremely valuable. For example, in a high definition encoder working on a 1920×1080 pixel picture format at 60 Hz where a typical Frame period is 33.3 milliseconds there are 120×68=8160 MBs, each MB therefore having to be completely coded in 4 microseconds.
To achieve the most efficient and accurate video encoding, the comparison of the candidates ideally takes into account how high the quality of the output image will be, and also how many bits will be taken to encode the candidate. The Rate-Distortion Optimisation (RDO) technique solves this problem by taking into account both a video quality metric, measuring the Distortion as the deviation from the source material, and the bit cost for each possible decision outcome.
Currently known methods of RDO candidate assessment are inefficient in their use of available processing resources, necessitating higher powered processing resources than is strictly required. Higher powered processing resources are more expensive to implement, and require attendant increases in running costs, such as cooling requirements and power usage. Accordingly, the present invention seeks to provide an improved method and apparatus for assessing RDO candidates.
SUMMARY
Accordingly, there is provided an apparatus an improved latency rate distortion optimisation apparatus comprising a forward quantize unit for processing input coefficients (Wij), an inverse quantize unit coupled to the forward quantize unit, and at least one look-up-table of quantize values for use by the forward and inverse quantize units. The at least one look-up-table of quantize values includes any one or more of the following modified quantize multiplication factors: negative forward quantiser multiplication factors (−MF); pre-shifted forward quantiser multiplication factors (MFps); negative pre-shifted forward quantiser multiplication factors (−MFps); negative inverse quantiser multiplication factors (−V); pre-shifted inverse quantiser multiplication factors (Vps); or negative pre-shifted inverse quantiser multiplication factors (−Vps), and the forward quantiser unit is arranged to operate on the input coefficients (Wij) using one of the modified forward quantiser multiplication factors, and the inverse quantiser unit is arranged to operate on the output of the forward quantiser unit using one of the modified inverse quantiser multiplication factors.
By using pre-shifted and pre-negated forward and inverse quantiser multiplication factors (+/−MFps and +/−Vps) that are retrieved from memory during the processing of macroblock coding mode candidates, the candidate process pipeline is reduced in latency. Accordingly, all the necessary candidates can be processed within the available macroblock processing time, even for 1080p60 Hz video.
Optionally, the negative forward quantiser multiplication factor (−MF) or negative pre-shifted forward quantiser multiplication factor (−MFps) is selected for use by the forward quantiser unit in replacement of the normal positive forward quantiser multiplication factors if a respective forward quantiser input coefficient is negative, and the negative inverse quantiser multiplication factor (−V) or the negative pre-shifted inverse quantiser multiplication factor (−Vps) is selected for use by the inverse quantiser unit if the respective forward quantiser input coefficient is negative.
Optionally, the rate distortion optimisation apparatus further comprises a two-way multiplexer unit for each of the forward and inverse quantiser units, each multiplexer unit adapted to select positive or negative quantiser multiplication factors for the forward and inverse quantiser units respectively, dependent upon a most significant bit of an input quantiser coefficient of the forward quantiser unit.
Optionally, the pre-shifted quantiser multiplication factors are pre-shifted dependent upon a value derived from the Quantisation Parameter (QP) value of a macroblock under test.
Optionally, the pre-shifted forward quantiser multiplication factors are restricted to 18 bits, and the pre-shifts applied comprise:

when 0≦floor(QP/6)≦3:

MFps=(MF<<3)>>floor(QP/6); and

when 4≦floor(QP/6)≦8:

MFps=((MF<<3)+2floor(QP/6)−1)>>floor(QP/6);

such that the forward quantiser unit has the function:

|Zij|=(|Wij|·MFps)+218−inter/3>>18;

where >> is a right shift, Zij is an output coefficient of the forward quantiser unit, Wij is an input coefficient of the forward quantiser unit, and inter is 1 if the macroblock under test is from an inter picture and 0 otherwise.
Optionally, the pre-shifted inverse quantiser multiplication factors have the following pre-shift applied: Vps=(V<<floor(QP/6)).
Optionally, the forward quantiser unit further comprises a multiplication unit, having a first input provided by an output of a forward quantiser two-way multiplexer unit and the input coefficient Wij of interest as a second input, and a sign function unit, where an output of the sign function unit selects the output of the forward quantiser two-way multiplexer unit to multiply with the input coefficient Wij of interest.
Optionally, the rate distortion optimisation apparatus further comprises an addition unit adapted to add a predetermined value to the output of the multiplication unit, and a conditional divider unit, wherein the conditional divider unit is operable on the predetermined value if an input picture is an inter picture, and otherwise passes through the predetermined value to the addition unit.
Optionally, the inverse quantiser unit further comprises a multiplication unit, having a first input provided by an output of an inverse quantiser two-way multiplexer unit and an absolute quantised output (|Z|) of the forward quantiser unit as a second input, where an output of the sign function unit selects the output of the inverse quantiser two-way multiplexer unit to multiply with the absolute quantised output (|Z|).
There is also provided a video encoder comprising the above described rate distortion optimisation apparatus.
There is also provided a method of improving latency in a Rate Distortion Optimisation apparatus having a forward quantiser unit and an inverse quantiser unit and at least one look up table, the method comprising one or more of the following steps: Negating a forward quantiser multiplication factor (MF) and storing the negative MF in the at least one look up table, for selection according to a sign value of an input coefficient of the forward quantiser unit. Pre-shifting a forward quantiser multiplication factor (MF) value to produce a pre-shifted forward quantiser multiplication factor (MFps) value and storing MFps in the at least one look up table. Negating the pre-shifted forward quantiser multiplication factor (MFps) and storing −MFps in the at least one look-up table. Negating an inverse quantiser multiplication factor (V) and storing the negative V in the at least one look up table, for selection according to a sign value of an input coefficient of the forward quantiser unit. Pre-shifting an inverse quantiser multiplication factor (V) value to produce a pre-shifted inverse quantiser multiplication factor (Vps) value and storing Vps in the at least one look up table. Negating the pre-shifted inverse quantiser multiplication factor (Vps) and storing −Vps in the at least one look-up table.
The term ‘negating’ is used to mean ‘to produce a negative value (of an input value)’.
The method then further comprises loading any one or more of the negative and/or pre-shifted quantiser multiplication factors from the at least one look up table, operating on the input coefficients by a forward quantiser unit using a one of the forward multiplication factors, and operating on the output of the forward quantiser unit by an inverse quantiser unit using one of the inverse multiplication factors.
Optionally, the pre-shifted forward quantiser multiplication factors are restricted to 18 bits, and the pre-shifting step comprises:

when 0≦floor(QP/6)≦3:

MFps=(MF<<3)>>floor(QP/6); and

when 4≦floor(QP/6)≦8:

MFps=((MF<<3)+2floor(QP/6)−1)>>floor(QP/6);

such that the forward quantiser unit has the function:

|Zij|=(|Wij|·MFps)+218−inter/3>>18;

Where >> is a right shift, Zij is an output coefficient of the forward quantiser unit, Wij is an input coefficient of the forward quantiser unit, and inter is 1 if the macroblock under test is from an inter picture and 0 otherwise.
Optionally, the step of pre-shifting the inverse quantiser multiplication factors (Vps) comprises the shift: Vps=(V<<floor(QP/6)).
Optionally, the latency is reduced by removing calculation steps from the real time calculation portion of the Rate Distortion Optimisation method through pre-calculating adapted forward and inverse quantiser multiplication factors.
There is also provided RDO apparatus or a video encoder adapted to carry out any of the described method.
There is also provided a computer-readable medium, carrying instructions, which, when executed, causes computer logic to carry out any of the described method. Optionally, the quantiser values for use with the forward quantiser are stored in a first look-up-table and quantiser values for use with the inverse quantiser are stored in a second look-up-table.
Optionally, the one or more look-up-table further comprises one or more of the following sets of quantiser values: floor(QP/6), forward quantiser multiplication factor (MF) values for positions (0,0), (2,0), (2,2) and (0,2), forward quantiser multiplication factor (MF) values for positions (1,1), (1,3), (3,1) and (3,3), forward quantiser multiplication factor (MF) values for all other positions, inverse quantiser multiplication factor (V) values for positions (0,0), (2,0), (2,2) and (0,2), inverse quantiser multiplication factor (V) values for positions (1,1), (1,3), (3,1) and (3,3), and inverse quantiser multiplication factor (V) values for all other positions.
There is also provided an RDO apparatus comprising a look-up table storing a plurality of pre-determined values, a forward quantiser unit, comprising a first multiplication sub-unit, adapted to multiply a first pre-determined input value from the look-up table with an input coefficient, a conditional divider unit, for conditionally dividing a second pre-determined value from the look-up table, dependent upon an input picture type, a two input addition unit having a first input coupled to the output of the multiplication sub-unit and a second input coupled to the conditional divider unit, a sign function unit, for providing a sign value of the input coefficient to output from the forward quantiser unit, and a two way multiplexer to select and provide the first pre-determined input value to the multiplication sub-unit based upon the output of the sign function unit. The RDO apparatus may also further comprise an inverse quantiser comprising a second multiplication unit having as a first input the absolute value output of the forward quantiser, and as a second input a third predetermined input value dependent selected by a two-way multiplexer unit based upon the output of the sign function unit.
There is also provided a method of processing an input coefficient in an RDO apparatus having a forward quantiser unit, an inverse quantiser unit, and a look-up table including a plurality of multiplication factors for use by the forward and inverse quantiser units, the method comprising generating any one or more of the following modified multiplication factors: negative forward quantiser multiplication factors (−MF); pre-shifted forward quantiser multiplication factors (−MFps); negative pre-shifted forward quantiser multiplication factors (MFps); negative inverse quantiser multiplication factors (−V); pre-shifted inverse quantiser multiplication factors (Vps); negative pre-shifted inverse quantiser multiplication factors (Vps); and further comprising operating on the input coefficients using one of the modified multiplication factors.
The step of operating on the input coefficients further comprises operating on the input coefficients using the forward quantiser unit, and operating on the output of the forward quantiser unit by an inverse quantiser unit, where the forward quantiser unit uses a one of the forward quantiser multiplication factors −MF, MFps or −MFps) and the inverse quantiser unit uses a one of the inverse quantiser multiplication factors (−V, Vps or −Vps).
A computer-readable medium, carrying instructions, which, when executed, causes computer logic to carry out any of the above method.
An Inter picture is a Predicted (P) or Bi-Predicted (B) picture, and an Intra picture is an I picture. A picture may be referred to as a slice.
Existing decoding hardware may be used with the described improved RDO apparatus and method. Hence embodiments of the present invention are particularly beneficial when used to upgrade coding performance of digital video encoders that encode under older compression standards. This is because such an upgrade improves encoding performance without affecting the ability of existing decoders to decode the video data stream produced. Hence, quality of the overall system is improved without having to wholly replace the existing video decoding hardware at the receiver end. When dealing with an installed user base, this is an important consideration.



BRIEF DESCRIPTION OF THE DRAWINGS
An apparatus and method for Rate Distortion Optimisation will now be described, by way of example only, and with reference to the accompanying drawings in which:
FIG. 1 shows the dependencies and block processing order for intra 4×4 modes in RDO;
FIG. 2 shows a single RDO processing pipeline for 4×4 blocks;
FIG. 3 shows a more detailed view of the processing cycles used by the pipeline of FIG. 2;
FIG. 4 shows how dual RDO processing pipelines can be used for 4×4 blocks;
FIG. 5 shows a schematic diagram of a forward quantiser;
FIG. 6 shows a schematic diagram of an inverse quantiser;
FIG. 7 shows a dual RDO processing pipeline for 4×4 blocks;
FIG. 8 shows the dependencies and block processing order for intra 8×8 modes in RDO;
FIG. 9 shows a conventional single RDO processing pipeline for 8×8 blocks;
FIG. 10 shows a more detailed view of the processing cycles used by the pipeline of FIG. 9;
FIG. 11 shows a more detailed view of the processing cycles used by an RDO processing pipeline for 4×4 blocks adapted according to an embodiment of the present invention;
FIG. 12 shows a schematic diagram of an improved forward quantiser according to an embodiment of the present invention;
FIG. 13 shows a schematic diagram of an improved inverse quantiser according to an embodiment of the present invention;
FIG. 14 shows an RDO apparatus according to an embodiment of the present invention;
FIG. 15 shows a more detailed view of the processing cycles used by an RDO processing pipeline for 8×8 blocks adapted according to an embodiment of the present invention;
FIG. 16 shows a method of improving latency in an RDO apparatus according to an embodiment of the present invention;
FIG. 17 shows a schematic diagram of a macroblock prediction block according to an embodiment of the present invention;
FIG. 18 shows overview schematic diagram of a video encoder according to an embodiment of the present invention.



DETAILED DESCRIPTION
An embodiment of the invention will now be described with reference to the accompanying drawings in which the same or similar parts or steps have been given the same or similar reference numerals.
The following description is cast in terms of an improvement to the H.264 video coding standard. However, it may equally be applied to any video encoding method having similar RDO decision constraints and quantisation method.
For a broadcast video encoder, a hardware design implemented using a Field Programmable Gate Array (FPGA) or Application Specific Integrated Circuit (ASIC) can be used to efficiently perform Rate Distortion Optimisation processing of all options (inter candidates and/or intra modes). A pipelined design can efficiently process the data within the macroblock period if the candidates or modes are processed contiguously such that the pipe is kept full.
Keeping the pipeline latency to a minimum improves the performance of the pipeline for processing any type of options (inter candidates, intra 16×16 modes, intra 8×8 modes, intra 4×4 modes), but it is particularly important for intra 4×4 modes and intra 8×8 modes.
The H.264 forward quantiser method is conventionally expressed as:

|Zij|=(|Wij|·MF+f)>>qbits

sign(Zij)=sign(Wij)

where Wij is the input coefficient, Zij is the output coefficient, f is 2 qbits/3 for Intra blocks or 2 qbits/6 for Inter blocks, qbits=15+floor(QP/6) and MF is given in table below:















Positions
Positions




(0, 0), (2, 0), 
(1, 1), (1, 3), 
All Other 


QP mod 6
(2, 2), (0, 2)
(3, 1), (3, 3)
positions


















0
13107
5243
8066


1
11916
4660
7490


2
10082
4194
6554


3
 9362
3647
5825


4
 8192
3355
5243


5
 7282
2893
4559









The H.264 inverse quantiser method is conventionally expressed as:

′Wij=Zij·Vij·2floor(QP/6) 

where Zij is the input coefficient, ′Wij is the reconstituted output coefficient and Vij is given in the table below:


















Positions
Positions





(0, 0), (2, 0), 
(1, 1), (1, 3), 
All Other 



QP mod 6
(2, 2), (0, 2)
(3, 1), (3, 3)
positions









0
10
16
13



1
11
18
14



2
13
20
16



3
14
23
18



4
16
25
20



5
18
29
23










Conventional implementations of the H.264 forward quantiser method and H.264 inverse quantiser method have pipeline latencies of 6 and 3 (as shown in FIGS. 5 and 6). These latencies significantly contribute to the total RDO engine pipeline latency as shown in FIG. 3.
FIG. 5 shows an implementation of the forward quantiser 500 where the input coefficient Wn first enters a 1 cycle latency absolute value block 510 to give |W|. This is fed into one input of a 2 cycle latency multiplier 530. The other input to the multiplier 530 is the forward quantiser multiplication factor (MF) input. The multiplier 530 feeds a 1 cycle latency adder 550. The other input to the adder 550 is the value of T (see above), which is calculated by block 560. Block 560 has an input of ‘qbits’, which is calculated by a further adder 540 adding 15 to the input floor(QP/6). The value of ‘qbits’ is also fed to a variable shifter 570 which shifts the output of the adder 550 by ‘qbits’ to give |Z|. The value of |Z| is fed into a two's complement block 580 which negates the value of |Z| if sign(W) is negative to produce the output Z. The sign block 520 simply uses the most significant bit of the input Wij to give sign(Wij).
FIG. 6 shows the corresponding implementation of the inverse quantiser 600 where the inputs Z and V are fed to a multiplier 610. The output of the multiplier is fed to a variable shifter 620 which shifts by the output of the multiplier 610 by the value floor(QP/6). The output of the shifter 620 is the output Wij, which is the reconstituted output coefficient of the inverse quantiser 600.
The intra 4×4 mode and intra 8×8 mode processing in a 1080p60 (i.e. high definition 1080 line progressive picture at 60 Hz) video encoder are used as examples to show how this latency is a problem.
Infra 4×4 Mode RDO Example
Processing all the intra 4×4 modes within a macroblock period is challenging due to the dependency of a particular 4×4 block's prediction on the previously encoded 4×4 blocks. This dependency can be seen in FIG. 1.
Processing of a particular 4×4 block can generally only start once the previous block has completed. This means that the 4×4 blocks cannot all be processed in parallel, and if processed in a pipeline the blocks cannot be contiguous, as shown in FIG. 1. The actual dependencies are determined by the nine encoding types (types 0-8, shown in box 100 of FIG. 1). The labelling order of 4×4 partitions 120 of a macroblock under test 110 are shown on the right hand side of FIG. 1.
The dependencies make the pipeline inefficient and increase the overall time required to process the intra 4×4 options. The overall time must be less than the macroblock processing period.
For a 1080i60 (i.e. high definition 1080 line interlaced picture at 60 Hz) video encoder the macroblock period is 4 μs, but for the 1080p60 encoder mentioned previously, the macroblock period is only 2 μs.
For a current generation FPGA, a clock speed of 200 Mhz is reasonable. This allows only 400 clock cycles per macroblock for a 1080p60 encoder, and 800 cycles for a 1080i60 encoder.
Unless both the reconstructed and original bitstream data for every option under assessment are processed and stored during their assessment (which uses substantial memory resources), then some cycles (approx. 82) out of the macroblock period are taken up with the top level RDO decision making between intra and inter options, and the eventual chosen macroblock run, where the reconstructed data and bitstream data for the chosen mode are re-generated and stored.
This leaves a maximum overall time of 318 cycles for each 1080p60 RDO engine pipeline, and 718 cycles for each 1080i60 RDO engine pipeline.
For a pipeline latency of 26 clock cycles, as shown in FIG. 3, the overall time for processing all intra 4×4 options in a single RDO engine pipeline is (26+9)*16=560 cycles. This is 35 cycles for each of the sixteen 4×4 blocks assessed.
While this is within the cycles available for processing a 1080i macroblock, it is greater than the 318 cycles available for processing a 1080p macroblock.
Two intra 4×4 RDO engine pipelines may be run in parallel to decrease the overall time taken to process all coding modes. This is shown in more detail in FIG. 4, where each pipeline is shown on a chart of pipeline number (440, 450) vs time 430. The dependencies are shown as arrows 420 where the arrows point from a particular 4×4 block towards the 4×4 block it depends upon. Therefore, for the arrow 420, it shows that 4×4 block 13 depends on 4×4 block 7 being already encoded.
The first pipeline 440 processes the upper 4×4 blocks of each 8×8 block, while the second pipeline 450 processes the lower 4×4 blocks of each 8×8 block. If the second pipeline 450 starts two 4×4 blocks after the first pipeline 440, then all the prediction dependencies are satisfied (as shown in FIG. 7), but the overall time is only reduced to (26+9)*10=350 cycles. The sixteen 4×4 blocks are still being processed, but the overlap of 12 out of the 16 results in a total pipeline length of 10. This is still greater than the 318 cycles available.
One solution to this is to reduce the number of prediction modes processed to fit within the macroblock period. For example, only five modes may be used: (26+5)*10=310 cycles. However, using less modes is detrimental to encoder performance.
Intra 8×8 Mode RDO Example
Processing all the intra 8×8 modes within a macroblock period is also challenging due to the dependency of a particular 8×8 block's prediction on the previously encoded 8×8 blocks, see FIG. 8.
Processing of a particular 8×8 block can only start once the previous block has completed. This means that the 8×8 blocks cannot be processed contiguously either, as shown in FIG. 9, making the pipeline inefficient and increasing the overall time required to process the intra 8×8 options. The overall time must be less than the macroblock processing period.
As discussed above, the maximum overall time of 318 cycles is available for 1080p60 encoding of a macroblock.
For a pipeline latency of 46 clock cycles, as shown in FIGS. 10a/b, the overall time for processing all intra 8×8 options in a single RDO engine pipeline is (46+(9*4))*4=328 cycles, as each 8×8 block takes four cycles to process, and there are nine modes and four 8×8 blocks in a macroblock.
While this is within the cycles available for processing a 1080i macroblock, it is greater than the 318 cycles available for processing a 1080p macroblock.
One solution to this is to reduce the number of prediction modes processed, in order to fit all the processing within the macroblock period. For example, six mode assessments would result in (46+(6*4))*4=280 cycles used. However, this is again detrimental to encoder performance.
Accordingly, there is provided a forward quantiser/inverse quantiser (or scaling operation) implementation which reduces the latency of a pipelined RDO engine in an FPGA or ASIC. The proposed solution reduces the overall time required to process all the options for a macroblock of interest, and gives a more efficient hardware design than existing implementations. The proposed solution applies when processing any options (inter, intra 4×4, intra 8×8, intra 16×16, etc) within an RDO apparatus or engine, but is particularly useful for processing intra 4×4 and intra 8×8 modes within the available macroblock period, as the processing of the 4×4 modes and 8×8 modes has the tightest processing budget as described above.
The proposed solution reduces the latency of the forward quantiser and inverse quantiser blocks by 4 clock cycles overall. This is achieved in four steps:

    1. The H.264 forward quantiser method requires multiplication of the absolute value of each input coefficient by a multiplication factor (MF). The proposed hardware solution achieves both the absolute value calculation and the multiplication in a single step (of 2 cycles) to save 1 clock cycle from the forward quantiser.
    2. The penultimate step of the H.264 forward quantiser method requires that the output coefficient (Zij) is shifted by qbits. The proposed hardware solution achieves this shift by shifting the MF instead, which saves another 1 clock cycle from the forward quantiser.
    3. The final step of the H.264 forward quantiser method requires that the sign of each output coefficient (Zij) is set to that of the input coefficient (Wij). In the proposed hardware solution, the forward quantiser output coefficients are passed on to the inverse quantiser as a separate sign and absolute value, which saves another 1 clock cycle from the forward quantiser.
    4. The final step of the H.264 inverse quantiser method requires that the output coefficient (Zij) is multiplied by 2 to the power of floor(QP/6) (which is equivalent to a shift by floor(QP/6), when carried out in the binary domain). The proposed hardware solution achieves this shift by shifting the multiplication factor (V) instead, which saves 1 clock cycle from the inverse quantiser.


The invention is particularly useful for processing intra 4×4 modes due to the dependency of each 4×4 block's prediction on the previously encoded 4×4 block. For this case, the gaps between each of the 4×4 blocks in the pipeline are equal to the latency of the pipeline as shown in FIG. 2. Hence, reducing the latency of the pipeline by even 1 clock cycle will reduce the overall cycles required and improve the efficiency of the pipeline significantly.
The proposed hardware solution reduces the latency of the forward quantiser and inverse quantiser blocks by four clock cycles overall and saves resource in the entropy coder. The four steps for reducing pipeline latency are described in more detail below. FIGS. 12 and 13 show all four implemented in the improved lower latency forward 1200 and inverse quantisers 1300.
FIG. 12 shows a forward quantiser according to an embodiment of the present invention. The forward quantiser now comprises fewer overall components, but an increase in input values derived from a Look-up table.
In particular, positive and negative pre-shifted forward quantiser multiplication factors are provided to a multiplication sub-unit 1230 via a two-way multiplexer 1210, whose output is selected by the most significant bit (i.e. sign, in two's compliment) of the input coefficient Wij. The other input to the multiplication sub-unit 1230 is the input coefficient itself, and the output of the multiplication sub-unit 1230 is one input into an addition sub-unit 1240. The other input to the addition sub-unit 1240 is the output of a conditional divider unit 1250, which divides a predetermined input value from the look-up table by two if the input picture is an inter picture, or leaves the predetermined input value unaltered if the input picture is an intra picture.
The output of the addition sub-unit 1240 is then right-shifted (>>) by 18 in a fixed right-shift operation 1260 to produce the absolute value of the forward quantised coefficients (|Z|). Since this right-shifting operation is of fixed size, it can be achieved in the same clock cycle (i.e. it is zero latency).
The predetermined input value is a constant and is 218/3.
Meanwhile, a sign calculation unit, 1220 determines the sign (positive or negative nature) of the input coefficient Wij, and provides this value to control the multiplexer 1210, and also outputs this value to the inverse quantiser, for use in inverse quantising the output of the forward quantiser 1200.
FIG. 13 shows an inverse quantiser 1300 according to an embodiment of the present invention. The inverse quantiser 1300 now also comprises fewer overall components, but again uses an increase in input values derived from a Look-up table.
In particular, the inverse quantiser 1300 now simply comprises a multiplication sub-unit 1320 to multiply |Z| (one of the outputs of the forward quantiser unit 1200), by +/−V, pre-shifted by QP/6, as described in more detail below. The selection is again carried out by a two-way multiplexer 1310, based upon the most significant bit (in two's compliment) of the original input coefficient to the forward quantiser unit 1200, Wij.
The output of the inverse quantiser unit 1300 is a reconstituted output coefficient ′Wij.
FIG. 14 shows how a whole RDO engine (a.k.a. Transform Quantise (TQ) loop) operates when an embodiment of the present invention is implemented.
The control state machine 110 provides the source and matching predicted data in 4×4 pixel blocks. This data is stored in the source/predicted stores unit 120 and passed on to the residual calculation block 130. The determined residual (i.e. difference between the source and predicted pixels) is processed by the transform unit 140 to produce the transform coefficients Wij of the 4×4 pixel block being processed, it is these transform coefficients that are quantised by the forward quantiser 1200 adapted according to the present invention. The output of the forward quantiser 1200 is then fed to a residual bits estimator 155, which calculates the approximate number of bits required to encode the data, and separately to the inverse quantiser 1300 adapted according to the present invention.
The inverse quantiser 1300 is immediately followed by the inverse transform unit 170, which carries out the inverse transform function. Within the reconstruction and distortion calculation block 180, the output of the inverse transform unit 170 is added to the predicted data retrieved from the predicted store 120 to produce the reconstructed (recon) data.
The difference between this recon data and the source is the distortion introduced by the quantisation process, which is fed to the RDO best candidate decision block 185. The sum and langrangian multiplication block 160 takes the residual bits estimate, adds an overhead bits estimate (for the mb_type and other macroblock level coding syntax elements) before multiplying the result by lambda and passing the result to the RDO best candidate decision block 185. The RDO best candidate decision block 185 then has both the terms of the RDO equation and can calculate an RDO score for the mode/candidate being processed.
FIG. 16 shows a high level flow diagram of the proposed method for improving latency in a rate distortion optimisation apparatus. The process comprises a number of negating (i.e. producing negative values corresponding to a given positive input value) and pre-shifting steps carried out on the forward and negative multiplication factors MF and V, each including a storage sub-step.
As can be seen from the four steps described above, and the more detailed description below, the improvements in latency of the forward and inverse quantisers provided by this solution are the result of carrying out certain calculations (pre-shifting and/or negating) on the multiplication factors in advance, and storing the results in a look-up table for use later on.
The exact order in which the negating and pre-shifting steps is carried out is not critical (other than the negating of pre-shifted values must occur after the respective pre-shifting step has been carried out, but it does not have to be immediately after the pre-shifting), and the content and order can depend on the particular implementation. This is because the two actions, pre-shifting and negating, independently provide an improvement in the latency of the overall RDO apparatus, but carrying out both provides an improvement that is the sum of the improvements provided by each individually. Hence, for a maximum reduction in latency, all the improvements are used, i.e. negating and pre-shifting of the forward and inverse quantisation factors (MF and V), and so the simply negated forward and inverse multiplication factors are not required, as the negated pre-shifted multiplication factors (−MFps and −Vps) already incorporate the improvement brought by negating. For example, in the full (i.e. maximised reduction in latency) implementation of FIG. 12, the negated forward multiplication factor (−MF) and negated inverse multiplication factors (−V) are not used, since the negated pre-shifted versions (−MFps and −Vps) will suffice. Lesser implementations may use the negating portions only, or the pre-shifting portions only
The exemplary order shown in FIG. 16 comprises a first step of negating the forward quantiser multiplication factor (MF) at step 1610 to produce a negative forward quantiser multiplication factor (−MF), a second step of pre-shifting the forward quantiser multiplication factor (MF) 1620 to produce a pre-shifted forward quantiser multiplication factor (MFps), a third step of negating the pre-shifted forward quantiser multiplication factor (MFps) 1630 to produce a negative pre-shifted forward quantiser multiplication factor (−MFps), a fourth step of negating the inverse quantiser multiplication factor (V) 1640 to produce a negative inverse quantiser multiplication factor (−V), a fifth step of pre-shifting the inverse quantiser multiplication factor (MF) 1650 to produce a pre-shifted inverse quantiser multiplication factor (Vps), a sixth step of negating the pre-shifted inverse quantiser multiplication factor (Vps) 1660 to produce a negative pre-shifted inverse quantiser multiplication factor (−Vps), and then determining an optimum coding dependent on the stored negated (i.e. negative) and/or pre-shifted forward and inverse quantisation multiplication factors.
Each negating or pre-shifting step includes the storage of the resultant negated and/or pre-shifted multiplication factor into a look-up table of values used by the forward and inverse quantisers.
FIG. 17 shows how five RDO engines (1710-1750) are used at the macroblock prediction level. The intra 4×4 TQ loop 1710 finds the best possible intra 4×4 predicted macroblock. The intra 8×8 TQ loop 1720 finds the best possible intra 8×8 predicted macroblock. The intra 16×16 TQ loop 1730 finds the best possible intra 16×16 predicted macroblock. The chroma TQ loop 1740 finds the best possible intra chroma prediction mode and also provides an inter chroma RDO score to the inter TQ loop. The inter TQ loop 1750 finds the best possible inter macroblock type from the inter predicted candidates provided by the refinement search.
The Motion Vector (MV) prediction block 1760 calculates the direct mode MV and provides MV prediction data to the inter TQ loop 1750. The best macroblock mode decision block 1780 takes the best RDO scores from the four luma TQ loops, adds the appropriate chroma RDO score and then decides on the best macroblock to encode. The reconstructed data for the chosen macroblock is passed on the deblocking filter and the data to be encoded into the bitstream is passed on to the entropy coder.
FIG. 18 shows the macroblock prediction block 1700 in the context of the whole encoder. The motion Field Programmable Gate Array 1810, or equivalent ASIC or the like, performs motion estimation which provides the inter candidates, which once refined by the refinement search 1830 are passed to the macroblock prediction (RDO) block 1700. The deblocking filter 1840 smooths the chosen macroblock reconstructed data before the recon store 1850 saves it as possible reference for future inter candidates. The entropy coder 1870 processes the chosen macroblock bitstream data to produce the bitstream Network Adaptation Layer (NAL) units, which are packetised into the transport stream by the TS packetiser 1880.
The forward and inverse quantiser functions in more detail:
Step 1: Selecting Pre-Calculated Positive and Negative Forward Quantiser Multiplication Factors (MF) to Avoid Absolute Value Calculation
The H.264 forward quantiser method requires multiplication of the absolute value of each input coefficient by a multiplication factor (MF). Conventionally the absolute value calculation and multiplication would be separate steps. The absolute value calculation would have a 1 cycle latency and the multiplication would have a 2 cycle latency.
The proposed solution achieves both the absolute value calculation and the multiplication in a single step. It does this by fetching pre-calculated MFs from a look-up table (LUT). Thus, the proposed solution uses the fact that these MFs can be selected to be negative for no extra latency, by storing negative versions of the MFs as well as the positive versions. Negative values are selected if the input coefficient is negative, so that a signed multiplier can be used to always give an unsigned result. This saves 1 clock cycle from the forward quantiser.
The H.264 forward quantiser method is conventionally expressed as:

|Zij|=(|Wij|·MF+f)>>qbits

sign(Zij)=sign(Wij)

This can be expressed using a new variable sMF as:

sMF=MF when sign(Wij)=+ve 

sMF=−MF when sign(Wij)=−ve 

|Zij|=(Wij·sMF+f)>>qbits

sign(Zij)=sign(Wij)

The above described arithmetic reduction avoids the step of finding the absolute value. The LUT which provides the forward quantiser multiplication factor (MF) can also provide a negated forward quantiser multiplication factor (−MF), such that the calculation of sMF is just a 2-way multiplex operation. As Wij is a two's complement value, the multiplexer control is simply the most significant bit of Wij.
Step 2: Pre-Shifting the Forward Quantiser Multiplication Factor (MF)
The penultimate step of the H.264 forward quantiser method requires that the output coefficient is shifted by qbits. Conventionally, this variable shift would have a 1 cycle latency.
However, the proposed solution achieves this shift by pre-shifting the forward quantiser multiplication factor (MF) instead. As the forward quantiser multiplication factor is fetched from a LUT, the LUT can be modified to provide pre-shifted forward quantiser multiplication factors (MFps), and negative pre-shifted forward quantiser multiplication factors (−MFps). This saves another 1 clock cycle from the forward quantiser.
The H.264 forward quantiser method is conventionally expressed as:

|Zij|=(|Wij|·MF+f)>>qbits

where f is 2 qbits/3 for Intra blocks or 2 qbits/6 for Inter blocks, and

qbits=15+floor(QP/6)

This can be expressed as:

|Zij|=(((|Wij|·(MF<<8)+128)>>floor(QP/6))+223−inter/3)>>23

where inter=1 if macroblock is a inter macroblock, 0 otherwise, and the value 128 is a rounding factor.

The above equation would require a 23 bit multiplier to implement, compared to 18 for the conventional implementation. However, through experimentation, it has been found that it is acceptable to use an approximation to this function as the forward quantiser does not need to match the decoder. Thus, these functions may use an 18-bit multiplier and have been shown to have no significant encoder performance degradation:
In particular, the equation changes to as follows:

When 0≦floor(QP/6)≦3:

|Zij|=(((|Wij|·(MF<<3))>>floor(QP/6))+218−inter/3)>>18

When 4≦floor(QP/6)≦8:

|Zij|=(((|Wij|·(MF<<3)+2floor(QP/6)−1)>>floor(QP/6))+218−inter/3)>>18

As QP can only range from 0 to 51 in H.264, floor(QP/6) may only be in the range 0 to 8. The floor function rounds down to the nearest integer.
As QP is constant during a macroblock (MB) period, it can be used to pre-fetch pre-shifted forward quantiser multiplication factor (MFps) values from the LUT:

When 0≦floor(QP/6)≦3:

LUT=MFps=(MF<<3)>>floor(QP/6)

When 4≦floor(QP/6)≦8:

LUT=MFps=((MF<<3)+2floor(QP/6)−1)>>floor(QP/6)

This leaves the forward quantiser with the function:

|Zij|=(|Wij|·LUD+218−inter/3)>>18

Step 3: Selecting Pre-Calculated Positive and Negative Inverse Quantiser Multiplication Factors (V) to Avoid Two's Complement Calculation
The final step of the H.264 forward quantiser method requires that the sign of each output coefficient is set to that of the input coefficient. Conventionally, this would require 1 clock cycle to perform the two's complement calculation. The forward quantiser output coefficients are sent to the inverse quantiser 1300 and the entropy coder 1870.
The first stage of the inverse quantiser method is a signed multiplication of the input coefficient by a multiplication factor (V).
The proposed solution utilizes the fact that the inverse quantiser multiplication factor (V) can be selected to be negative for no extra latency, as it is read from a LUT. The forward quantiser output coefficients are passed on as a separate sign and absolute value and the sign is used to select negative or positive Vs. This saves another 1 clock cycle from the inverse quantiser. The first stage of the entropy coding method requires that the sign and absolute value be found for each input coefficient, so passing these separately from the forward quantiser also saves resources in the entropy coder 1870.
The H.264 forward quantiser method is conventionally expressed as:

|Zij|=(|Wij|·MF+f)>>qbits

sign(Zij)=sign(Wij)

The H.264 inverse quantiser method is conventionally expressed as:

′Wij=Zij·Vij·2floor(QP/6) 

Where ′Wij is the inverse quantiser output coefficient, i.e. a reconstituted version of the input coefficient to the forward quantiser unit 1200 (Wij).
This can be expressed as:

Zij=(|Wij|·MF+f)>>qbits

sVij=Vij when sign(Wij)=+ve 

sVij=−Vij when sign(Wij)=−ve 

′Wij=Zij·sVij·2floor(QP/6) 

The above substitution avoids the step of finding the two's complement value for the forward quantiser output if it is negative by performing the sign change using a negative multiplication factor. The LUT which provides can also provide −Vij, such that the calculation of sVij is just a 2-way multiplex operation.
Step 4: Pre-Shifting Inverse Quantiser Multiplication Factor (V)
The final step of the H.264 inverse quantiser method requires that the output coefficient is shifted by floor(QP/6) bits. Conventionally, this variable shift would have a 1 cycle latency.
The proposed solution achieves this shift by pre-shifting the inverse quantiser multiplication factor (V) instead. As V is fetched from a LUT, the LUT is modified to provide pre-shifted inverse quantiser multiplication factors (Vps), and negative pre-shifted inverse multiplication factors (−Vps). This saves 1 clock cycle from the inverse quantiser.
The H.264 inverse quantiser method is conventionally expressed as:

′Wij=Zij·Vij·2floor(QP/6) 

As QP is constant during a macroblock period, it can be used to pre-fetch shifted +/−Vps values from the LUT:

LUT=Vij·2floor(QP/6) 

This leaves the inverse quantiser with the function:

′Wij=Zij·LUT 

Where LUT is the output value from the look-up table, being either Vps or −Vps.

In the binary (i.e. digital) domain, the function Vij·2floor(QP/6) is the same as a left shift of floor(QP/6), i.e:

LUT=V<<floor(QP/6)

The proposed hardware solution may be implemented only in part, with only one or more of the improvements implemented, each contributing their respective saving in cycles spent process a candidate. However, preferably, the solution implements all of the improvements to provide the full four cycle per RDO calculation reduction in the number of processing cycles required. It is this full implementation that is shown here in FIGS. 12 and 13, and the accompanying description, thus only +/−MFps and +/−Vps are used.
The following examples show how the full implementation improves the latency of the RDO pipeline.
Intra 4×4 Mode RDO Example
The described four cycle reduction in the latency of the pipeline reduces the overall cycles taken to process all intra 4×4 modes by four cycles per 4×4 block. For the new pipeline latency of 22 clock cycles, as shown in FIG. 11, the overall time for processing all intra 4×4 options using two RDO engine pipelines will be (22+9)*10=310 cycles. This allows all of the intra 4×4 prediction modes to be processed within the 1080p60 macroblock period, hence improving encoder performance compared to the previous solution of reducing the number of modes assessed.
Intra 8×8 Mode RDO Example
The described four cycle reduction in the latency of the pipeline reduces the overall time taken to process all intra 8×8 modes by four clock cycles per 8×8 block. For the new pipeline latency of 42 clock cycles, as shown in FIG. 15, the overall time for processing all intra 4×4 options using two RDO engine pipelines will be (42+(9*4))*4=312 cycles. This allows all of the intra 4×4 prediction modes to be processed within the 1080p60 MB period, again showing an improved encoder performance compared to the previous solution of reducing the number of modes assessed.
Embodiments of the invention provide a pipelined RDO design, such as that shown in FIG. 14 to process RDO options more efficiently and in less overall clock cycles. Thus, the efficiency improvement allows more options (inter candidates or intra modes) to be processed by the hardware resources taken up by an RDO engine. Generally RDO comparison of more options will give higher video encoding performance.
There may be a particularly significant improvement for processing intra 4×4 modes and intra 8×8 modes, allowing all modes to be evaluated within a 1080p60 macroblock period.
The above described method may be carried out by any suitably adapted or designed hardware. Portions of the method may also be embodied in a set of instructions, stored on a computer readable medium, which when loaded into a computer, Digital Signal Processor (DSP) or similar, causes the computer to carry out the hereinbefore described method.
Equally, the method may be embodied as a specially programmed, or hardware designed, integrated circuit which operates to carry out the described RDO method when loaded into said integrated circuit. The integrated circuit may be formed as part of a general purpose computing device, such as a PC, and the like, or it may be formed as part of a more specialised device, such as a hardware video encoder, or the like.
One exemplary hardware embodiment is that of a Field Programmable Gate Array (FPGA) programmed to provide the described apparatus and/or to carry out the described RDO method, the FPGA being located on a daughterboard of a rack mounted video encoder held in a video production suite, location video support van/uplink van or the like, for use in, for example, television broadcasting or video production.
Another exemplary hardware embodiment of the present invention is that of hardware video encoder device embodied as one or more Application Specific Integrated Circuits (ASICs).
It will be apparent to the skilled person that the exact order and content of the steps carried out in the method described herein may be altered according to the requirements of a particular set of execution parameters, such as speed, quality or output bit rate of the video, and the like. Furthermore, it will be apparent that different embodiments of the disclosed apparatus may selectively implement certain features of the present invention in different combinations, according to the requirements of a particular implementation of the invention as a whole. Accordingly, the claim numbering is not to be construed as a strict limitation on the ability to move features between claims, and as such portions of dependent claims maybe utilised freely.

## Claims

1. An improved latency rate distortion optimisation apparatus comprising:
a forward quantiser unit for processing input coefficients (Wij);
an inverse quantiser unit coupled to the forward quantiser unit; and
at least one look-up-table of quantiser values for use by the forward and inverse quantiser units;
wherein the at least one look-up-table of quantiser values further includes any one or more of the following modified quantiser multiplication factors:
negative forward quantiser multiplication factors (−MF);
pre-shifted forward quantiser multiplication factors (MFps);
negative pre-shifted forward quantiser multiplication factors (−MFps);
negative inverse quantiser multiplication factors (−V);
pre-shifted inverse quantiser multiplication factors (Vps), wherein the pre-shifted quantiser multiplication factors are pre-shifted dependent upon a value derived from a Quantization parameter (QP) value of a macroblock under test; or
negative pre-shifted inverse quantiser multiplication factors (−Vps); and

the forward quantiser unit is arranged to operate on the input coefficients (Wij) using one of the modified forward quantiser multiplication factors; and
the inverse quantiser unit is arranged to operate on the output of the forward quantiser unit using one of the modified inverse quantiser multiplication factors.

2. The rate distortion optimisation apparatus of claim 1, wherein the negative forward quantiser multiplication factor (−MF) or negative pre-shifted forward quantiser multiplication factor (−MFps) is selected for use by the forward quantiser unit in replacement of the normal positive forward quantiser multiplication factors if a respective forward quantiser input coefficient is negative; and
wherein the negative inverse quantiser multiplication factor (−V) or the negative pre-shifted inverse quantiser multiplication factor (−Vps) is selected for use by the inverse quantiser unit if the respective forward quantiser input coefficient is negative.

3. The rate distortion optimisation apparatus of claim 2, further comprising a two-way multiplexer unit for each of the forward and inverse quantiser units, each multiplexer unit adapted to select positive or negative quantiser multiplication factors for the forward and inverse quantiser units respectively, dependent upon a most significant bit of an input quantiser coefficient of the forward quantiser unit.

4. The rate distortion optimisation apparatus of claim 1, wherein the pre-shifted forward quantiser multiplication factors are restricted to 18 bits, and the pre-shifts applied comprise:


when 0≦floor(QP/6)≦3:



MFps=(MF<<3)>>floor(QP/6); and



when 4≦floor(QP/6)≦8:



MFps=((MF<<3)+2floor(QP/6)−1)>>floor(QP/6);


such that the forward quantiser unit has the function:


|Zij|=(|Wij|·MFps)+218−inter/3>>18;

wherein Zij is an output coefficient of the forward quantiser unit, Wij is an input coefficient of the forward quantiser unit, and inter is 1 if the macroblock under test is from an inter picture and 0 otherwise.

5. The rate distortion optimisation apparatus of claim 1, wherein the pre-shifted inverse quantiser multiplication factors have the following pre-shift applied:


Vps=(V>>floor(QP/6)).

6. The rate distortion optimisation apparatus of claim 1, wherein the forward quantiser unit further comprises:
a multiplication unit, having a first input provided by an output of a forward quantiser two-way multiplexer unit and the input coefficient Wij of interest as a second input; and
a sign function unit;
wherein an output of the sign function unit selects the output of the forward quantiser two-way multiplexer unit to multiply with the input coefficient Wij of interest.

7. The rate distortion optimisation apparatus of claim 6, further comprising:
an addition unit adapted to add a predetermined value to the output of the multiplication unit; and
a conditional divider unit, wherein the conditional divider unit is operable on the predetermined value if an input picture is an inter picture, and otherwise passes through the predetermined value to the addition unit.

8. The rate distortion optimisation apparatus of claim 1, wherein the inverse quantiser unit further comprises:
a multiplication unit, having a first input provided by an output of an inverse quantiser two-way multiplexer unit and an absolute quantised output (|Z|) of the forward quantiser unit as a second input;
wherein an output of the sign function unit selects the output of the inverse quantiser two-way multiplexer unit to multiply with the absolute quantised output (|Z|).

9. A video encoder comprising a rate distortion optimisation apparatus comprising:
a forward quantiser unit for processing input coefficients (Wij);
an inverse quantiser unit coupled to the forward quantiser unit; and
at least one look-up-table of quantiser values for use by the forward and inverse quantiser units;
wherein the at least one look-up-table of quantiser values further includes any one or more of the following modified quantiser multiplication factors:
negative forward quantiser multiplication factors (−MF);
pre-shifted forward quantiser multiplication factors (MFps), wherein the pre- shifted quantiser multiplication factors are pre-shifted dependent upon a value derived from a Quantisation Parameter (QP) value of a macroblock under test;
negative pre-shifted forward quantiser multiplication factors (−MFps);
negative inverse quantiser multiplication factors (−V);
pre-shifted inverse quantiser multiplication factors (Vps); or
negative pre-shifted inverse quantiser multiplication factors (−Vps); and

the forward quantiser unit is arranged to operate on the input coefficients (Wij) using one of the modified forward quantiser multiplication factors; and
the inverse quantiser unit is arranged to operate on the output of the forward quantiser unit using one of the modified inverse quantiser multiplication factors.

10. A method of improving latency in a Rate Distortion Optimisation apparatus having a forward quantiser unit and an inverse quantiser unit and at least one look up table, the method comprising one or more of steps:
negating a forward quantiser multiplication factor (MF) and storing the negative MF in the at least one look up table, for selection according to a sign value of an input coefficient of the forward quantiser unit;
pre-shifting a forward quantiser multiplication factor (MF) value to produce a pre-shifted forward quantiser multiplication factor (MFps) value and storing MFps in the at least one look up table;
negating the pre-shifted forward quantiser multiplication factor (MFps) and storing −MFps in the at least one look-up table;
negating an inverse quantiser multiplication factor (V) and storing the negative V in the at least one look up table, for selection according to a sign value of an input coefficient of the forward quantiser unit;
pre-shifting an inverse quantiser multiplication factor (V) value to produce a pre-shifted inverse quantiser multiplication factor (Vps) value and storing Vps in the at least one look up table, wherein the step of pre-shiftinq the inverse quantiser multiplication factors (Vps) comprises the shift Vps=(V<<floor (QP/6));
negating the pre-shifted inverse quantiser multiplication factor (Vps) and storing −Vps in the at least one look-up table;
wherein the method further comprises:
loading any one or more of the negative and/or pre-shifted quantiser multiplication factors from the at least one look up table;
operating on the input coefficients by a forward quantiser unit using a one of the forward multiplication factors; and
operating on the output of the forward quantiser unit by an inverse quantiser unit (1300) using one of the inverse multiplication factors.

11. The method of claim 10, wherein the pre-shifted forward quantiser multiplication factors are restricted to 18 bits, and the pre-shifting step comprises:


when 0≦floor(QP/6)≦3:



MFps=(MF<<3)>>floor(QP/6); and



when 4≦floor(QP/6)≦8:



MFps=((MF<<3)+2floor(QP/6)−1)>>floor(QP/6);


such that the forward quantiser unit has the function:


|Zij|=(|Wij|·MFps)+218−inter/3>>18;

wherein Zij is an output coefficient of the forward quantiser unit, Wij is an input coefficient of the forward quantiser unit, and inter is 1 if the macroblock under test is from an inter picture and 0 otherwise.

12. The method of claim 10, wherein the latency is reduced by removing calculation steps from the real time calculation portion of the Rate Distortion Optimisation method through pre-calculating adapted forward and inverse quantiser multiplication factors.