This invention relates to the coding/decoding of digital images.
Typically, a digital image includes macroblocks distributed in lines and columns. Each line (or horizontal row) of the image includes, for example, macroblocks of 16×16 pixels. Conventionally, a macroblock is organised into four luma blocks and two, four or eight chroma blocks according to the type of sampling.
Traditionally, the coding or decoding of an image involves processing all of its macroblocks, sequentially, line by line, from left to right over a single line, and from top to bottom from one line to the next.
The invention applies in particular, but not exclusively, to the coding or decoding of a video sequence formed by a series of images. In this case, the coding or decoding technique is implemented in a video compression or decompression algorithm. It is thus consistent with a compression/decompression standard such as (this list is not exhaustive)
It is, however, clear that the invention also applies to the coding or decoding of a fixed image.
In general, this invention can apply wherever there is a spatial dependence context for the processing of macroblocks of an image. In other words, it is assumed that to process each macroblock of the image, it is necessary to know the result of the previous processing of other macroblocks of the same image.
Such a spatial dependence context exists in particular, but not exclusively, in the methods for coding or decoding consistent with the aforementioned compression/decompression standards based on a motion estimation.
The processing of all of the macroblocks of an image by a single processor does not appear to be optimal in terms of computing time.
In addition, a multithreading technique is known, which involves optimally distributing (i.e. multithreading) the computing loads for processing over a plurality of available processors.
This known technique is used in the field of video compression, according to either a general approach or a narrow approach.
The general approach consists of distributing macro-tasks over each of the processors. For example, it is assumed that the coding of an image requires three tasks A, B and C to be executed which must be ordered as follows: A, then B, then C. It can then be imagined that to best distribute the tasks A, B and C over two processors, two threads T1 and T2 are created, with T1 managing only tasks A ad B and T2 managing only task C. This multithreading can be carried out only if T1 can work on image N while T2 works on image N−1, with N being the number of the image of a video sequence. It can be seen that this distribution is optimal only if the load used by tasks A and B is substantially equivalent to that used by task C (isodistribution of loads between processors).
A disadvantage of the multithreading technique according to the general approach is that the isodistribution of the loads between processors is almost never verified in practice. In other words, it is very difficult, and even impossible in some cases, to find a perfect balance by separating entire tasks from one another.
Another disadvantage of the multithreading technique according to the general approach is that it requires a specific implementation of the calling program, with the use of a stacking mechanism.
Yet another disadvantage of the multithreading technique according to the general approach is that it cannot be applied in the case of a spatial dependence context as described above.
The narrow approach consists of separating each task into as many basic tasks as can be executed simultaneously by a plurality of processors, when possible. For example, in the field of video compression or image compression (with the aforementioned conventional sequential processing order: line by line, from left to right over the same line, and from top to bottom from one line to the next), the image can be separated into N horizontal bands and have each of them processed by one of N processors. In this case, it is not necessary for the different threads to be mutually synchronised. They must simply inform a main thread when they have completed their processing. This provides a very balanced distribution of loads between processors.
However, a major disadvantage of the multithreading technique according to the narrow approach is that it cannot be applied in the case of a spatial dependence context as described above. Indeed, in this context, each first line of a given horizontal band (lower band) of the image cannot be processed as long as the last line of the horizontal band located above (upper band) has not been processed. The processors could therefore only act in series and not simultaneously, which counteracts any benefit of the use of this technique in this context.
The aim of the invention is in particular to overcome these various disadvantages of the prior art.
More specifically, one of the aims of this invention is to provide a method and a device for coding or decoding enabling the computing time to be optimised while being capable of being implemented in a spatial dependence context as described above.
Another aim of the invention is to provide such a method and device that can be implemented independently of any hardware or software.
These various objectives, as well as others which will be described below, are achieved by the invention with a method for coding or decoding an image including macroblocks distributed in lines and columns, the processing of at least one given macroblock, referred to as a dependent macroblock, requiring the prior processing of at least one other macroblock on which said dependent macroblock depends, in which the processing of the macroblocks is performed sequentially line by line or column by column. According to the invention, the method includes a step of multithreading the processing of the macroblocks over N processors, with N≧2, including the following steps:
The general principle of the invention therefore consists of performing multithreading according to the narrow approach, but by separating the image into perpendicular (and not parallel) bands in the direction of sequential processing of the macroblocks. This makes it possible to obtain an optimal load distribution between processors.
In other words, if the processing of macroblocks is performed sequentially line by line (classical case of a sequential processing direction that is horizontal, along a line), the image is separated into vertical bands. If, on the other hand, the processing of macroblocks is performed sequentially column by column (an unusual case today, but possible in the future for a sequential processing direction that is vertical, along a column), the image is separated into horizontal bands.
The synchronisation of processing operations carried out by the N processors enables the implementation of the general principle mentioned above in a spatial dependence context. Indeed, this synchronisation makes it possible to prevent a processor from attempting to process a given macroblock when other macroblocks on which this given macroblock is dependent have not yet been processed.
It should be noted that this invention can be implemented with any number of processors (for example, two, four, eight, . . . ).
The synchronisation of the processing operations carried out by the n processors preferably consists, for each processor of each pair of processors processing two adjacent bands, of:
Thus, the processors exchange synchronisation signals (system messages) by informing one another of the macroblocks that they have processed.
Said image advantageously belongs to the group including: video sequence images formed by a series of images; fixed images.
In an advantageous embodiment of the invention, the processing of macroblocks is performed sequentially line by line, from left to right over the same line and from top to bottom from one line to the next.
The processing of each dependent macroblock advantageously requires the prior processing, when it exists, of at least the macroblock located to the left of said dependent macroblock. Moreover, in each pair of processors processing two adjacent vertical bands, the processor that processes the left vertical band informs the other processor of each completed processing of the macroblock of the right end of one of the lines of macroblocks of said left vertical band.
According to an advantageous feature, the processing of each dependent macroblock requires the prior processing, when it exists, of at least the macroblock located above and to the right of said dependent macroblock. In addition, in each pair of processors that process two adjacent vertical bands, the processor that processes the right vertical band informs the other processor of each completed processing of the macroblock of the left end of one of the lines of macroblocks of said right vertical band.
It should be noted that this feature (information on the completed processing of the left macroblock (MBG) of a line of the right vertical band) can be combined with the previous (information on the completed processing of the right macroblock (MBD) of a line of the left vertical band). The invention thus provides an optimal solution to the classical spatial dependence context (see discussion above, in relation to
The coding or decoding is advantageously consistent with a standard belonging to the group including: H.263, H.263+, H264 and MPEG-4 Video.
This list is not exhaustive.
The invention also relates to a computer program including program code instructions for carrying out the steps of the aforementioned method, when said program is run on a computer.
The invention also relates to a device for coding or decoding an image including macroblocks distributed in lines and columns, the processing of at least one given macroblock, referred to as a dependent macroblock, requiring the prior processing of at least one other macroblock on which said dependent macroblock depends, in which the processing of the macroblocks is performed sequentially line by line or column by column, with said device including N processors, with N≧2, and means for multithreading the processing of macroblocks over said N processors, which means for multithreading the processing include:
The invention also relates to a synchronisation signal transmitted from a first to a second processor of a pair of processors that process two adjacent bands of an image, wherein said image includes macroblocks distributed in lines and columns and being separated:
so that the second processor can verify, before processing said dependent macroblock, that said at least one other macroblock on which the dependent macroblock depends has previously been processed by the first processor.
Other features and advantages of the invention will appear in the following description of a preferred embodiment of the invention, given as an indicative and non-limiting example, and appended drawings, in which:
The invention therefore relates to a method for coding or decoding an image including a step of multithreading the processing of macroblocks over N processors.
In the description below, it is assumed that, as usual, the processing of macroblocks is performed sequentially line by line, from left to right over the same line and from top to bottom from one line to the next. However, it is clear, as already indicated above, that this invention can also be applied to the case (which is uncommon today) in which the processing of macroblocks is carried out sequentially column by column.
It is also assumed that the image to which the method according to the invention is applied is included in a video sequence and that the method according to the invention is consistent with one of the following compression/decompression standards: H.263, H.263+, H.264, MPEG-4 Video, etc. It is therefore assumed that the processing of the macroblocks of an image is carried out in the spatial dependence context shown in
The method according to the invention, in view of the aforementioned hypotheses, consists of:
A specific embodiment of the method according to the invention will now be described in detail, with reference to
In this example, the image is separated into four vertical bands (N=4) of equal width (four macroblocks) hereinafter referred to as bands B1 to B4 (with the bands being numbered from left to right). Therefore, four processors are used to process each of these four vertical bands. These four processors are hereinafter referred to as P1 to P4 (with the number of the processors corresponding to the number of the bands that they process).
The operation of the method according to the invention can be summarised as follows:
In general, the principle of synchronising the processing operations carried out by the processors is based on the use of synchronisation messages (system messages). In the example above, there are three synchronisation points (one between each pair of processors (Pk, Pk+1) processing two adjacent vertical bands): one between processors P1 and P2, one between processors P2 and P3 and one between processors P3 and P4. Two types of conditions correspond to each synchronisation point:
Number | Date | Country | Kind |
---|---|---|---|
03/05531 | May 2003 | FR | national |
Filing Document | Filing Date | Country | Kind | 371c Date |
---|---|---|---|---|
PCT/FR04/01106 | 5/6/2004 | WO | 11/3/2005 |