Method and apparatus for scalable motion estimation

Embodiments of the invention generally provide a method and apparatus for scalable motion estimation. One embodiment of a method for performing motion estimation includes setting a target complexity for a macroblock of a source frame and performing motion estimation for one or more partitions of the macroblock until the target complexity is met.

FIELD OF THE INVENTION

The present invention generally relates to video encoding, and more particularly relates to motion estimation.

BACKGROUND OF THE INVENTION

Motion estimation is the biggest bottleneck in terms of computational load for many conventional video encoders, because it requires processing over multiple estimated frames and multiple partition types. Numerous fast motion estimation techniques have been proposed to speed up video encoder processes. A majority of these techniques skip most search candidates that are considered unlikely to be the best match in order to reduce the overall complexity of the motion estimation technique.

Unlike full search techniques, where a search window dictates the required search operations, fast motion estimation techniques typically require a different level of complexity for different inputs. This requirement makes fast motion estimation techniques difficult to implement in hardware where timing requirements are stringent. This difficulty is exacerbated in encoders such as the known H.264 encoder, where the fast motion estimation must be performed repeatedly for every partition type and reference picture combination (which results in a larger variation of complexity from macroblock to macroblock).

Therefore, there is a need in the art for a scalable method and apparatus for fast motion estimation that efficiently speeds up the video encoding process.

SUMMARY OF THE INVENTION

Embodiments of the invention generally provide a method and apparatus for scalable motion estimation. One embodiment of a method for performing motion estimation includes setting a target complexity for a macroblock of a source frame and performing motion estimation for one or more partitions of the macroblock until the target complexity is met.

In another embodiment, a computer readable medium contains an executable program for performing motion estimation, where the program sets a target complexity for a macroblock of a source frame and performs motion estimation for one or more partitions of the macroblock until the target complexity is met.

In another embodiment, a video encoder includes an input for receiving a source frame of video, a motion estimator for setting a target complexity for a macroblock of the source frame and for performing motion estimation for one or more partitions of the macroblock until the target complexity is met, and an output for outputting the source frame in a coded form.

In another embodiment a method for performing motion estimation includes setting a target complexity for a macroblock of a source frame and performing motion estimation for one or more partitions of the macroblock, where performing motion estimation includes performing motion estimation for a first square-shaped partition of the macroblock and for a first number of reference pictures; performing motion estimation for a second square-shaped partition of the macroblock that is smaller in size than the first square-shaped partition and for the first number of reference pictures; performing motion estimation for the first square-shaped partition and for a second number of reference pictures; performing motion estimation for the second square-shaped partition and for the second number of reference pictures; performing motion estimation for a first rectangular-shaped partition of the macroblock and for the first number of reference pictures; performing motion estimation for a second rectangular-shaped partition of the macroblock and for the first number of reference pictures; performing motion estimation for the first rectangular-shaped partition and for the first number of reference pictures; and performing motion estimation for the second rectangular-shaped partition and for the first number of reference pictures, wherein the motion estimation is terminated when the target complexity is met.

DETAILED DESCRIPTION

Embodiments of the invention provide a scalable approach to motion estimation in which various steps of the motion estimation process correspond to different complexities and search qualities. In one embodiment, complexity is controlled at the partition type and reference frame level. Although embodiments of the invention are discussed in connection with a simplified hexagon search algorithm, those of skill in the art will appreciate that the present invention may be advantageously applied in connection with any kind of motion estimation search algorithm.

FIG. 1is a block diagram depicting an exemplary embodiment of a video encoder100. SinceFIG. 1is intended to only provide an illustrative example of a H.264 encoder,FIG. 1should not be interpreted as limiting the present invention. For example, the video encoder100is compliant with the H.264 standard or the Advanced Video Coding (AVC) standard. The video encoder100may include a subtractor102, a transform module, e.g., a discrete cosine transform (DCT) like module104, a quantizer106, an entropy coder108, an inverse quantizer110, an inverse transform module, e.g., an inverse DCT like module112, a summer114, a deblocking filter116, a frame memory118, a motion compensated predictor120, an intra/inter switch122, and a motion estimator124. It should be noted that although the modules of the encoder100are illustrated as separate modules, the present invention is not so limited. In other words, various functions (e.g., transformation and quantization) performed by these modules can be combined into a single module.

In operation, the video encoder100receives an input sequence of source frames. The subtractor102receives a source frame from the input sequence and a predicted frame from the intra/inter switch122. The subtractor102computes a difference between the source frame and the predicted frame, which is provided to the DCT module104. In INTER mode, the predicted frame is generated by the motion compensated predictor120. In INTRA mode, the predicted frame is zero and thus the output of the subtractor102is the source frame.

The DCT module104transforms the difference signal from the pixel domain to the frequency domain using a DCT algorithm to produce a set of coefficients. The quantizer106quantizes the DCT coefficients. The entropy coder108codes the quantized DCT coefficients to produce a coded frame.

The inverse quantizer110performs the inverse operation of the quantizer106to recover the DCT coefficients. The inverse DCT module112performs the inverse operation of the DCT module104to produce an estimated difference signal. The estimated difference signal is added to the predicted frame by the summer114to produce an estimated or frame, which is coupled to the deblocking filter116. The deblocking filter deblocks the estimated frame and stores the estimated frame or reference frame in the frame memory118. The motion compensated predictor120and the motion estimator124are coupled to the frame memory118and are configured to obtain one or more previously estimated frames (previously coded frames).

The motion estimator124also receives the source frame. The motion estimator124performs a motion estimation algorithm using the source frame and a previous estimated frame (i.e., reference frame) to produce motion estimation data. For example, the motion estimation data includes motion vectors and minimum sums of absolute differences (SADs) for the macroblocks of the source frame. The motion estimation data is provided to the entropy coder108and the motion compensated predictor120. The entropy coder108codes the motion estimation data to produce coded motion data. The motion compensated predictor120performs a motion compensation algorithm using a previous estimated frame and the motion estimation data to produce the predicted frame, which is coupled to the intra/inter switch122. Motion estimation and motion compensation algorithms are well known in the art.

To illustrate, the motion estimator124may include mode decision logic126. The mode decision logic126can be configured to select a mode for each macroblock in a predictive (INTER) frame. The “mode” of a macroblock is the partitioning scheme. That is, the mode decision logic126selects MODE for each macroblock in a predictive frame, which is defined by values for MB_TYPE and SUB_MB_TYPE.

The above description only provides a brief view of the various complex algorithms that must be executed to provide the encoded bitstreams generated by an H.264 encoder.

Embodiments of the invention provide a scalable approach to motion estimation in which various steps of the motion estimation process correspond to different complexities and search qualities. In one embodiment, complexity is controlled at the partition type and reference frame level.

FIGS. 2A-2Bpresent a flow diagram illustrating one embodiment of a method200for performing motion estimation for a macroblock of a source frame, according to the present invention. The method200may be implemented, for example, at the motion estimator124ofFIG. 1.

The method200is initialized at step202, and proceeds to step204, where the motion estimator selects the source macroblock for which the motion estimation is to be performed. In step206, the motion estimator sets a motion estimation cost for all partitions of the source macroblock to a maximum possible value. For example, the maximum possible value can be the highest possible value allowed by the particular hardware and/or software implementations of the motion estimator.

In step208, the motion estimator computes a target complexity for the source macroblock. The target complexity represents a “budget” or maximum number of searches that may be performed for the source macroblock. In one embodiment the target complexity is derived from a metric based on an SAD count (i.e., how many SAD computations can be performed).

In step210, the motion estimator performs motion estimation for a first square-shaped partition of the source macroblock and using a number, x, of reference frames for predictive pictures or a number, y, of reference frames for bi-predictive pictures. For a predictive picture, x is one or more reference frames; for a bi-predictive picture, y is two or more reference frames. For example, the method200may start out by using 1 reference frame for a predictive picture, or two reference frames for a bi-predictive picture. In one embodiment, the first square-shaped partition is a 16×16 partition. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used.

In step212, the motion estimator determines whether the motion estimation performed in step210has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step212that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step212that the target complexity has not been met, the motion estimator proceeds to step214and performs motion estimation for a second square-shaped partition of the source macroblock, again using x reference frames for predictive pictures or y reference frames for bi-predictive pictures, where x and y have the values discussed previously. In one embodiment, the second square-shaped partition is smaller in size than the first square-shaped partition, such that motion estimation is performed square-shaped partitions in order of decreasing size. In a further embodiment, the second square-shaped partition is an 8×8 partition. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used.

In step216, the motion estimator determines whether the motion estimation performed in step214has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step216that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step216that the target complexity has not been met, the motion estimator proceeds to step218and performs motion estimation for the first square-shaped partition of the source macroblock using at least one additional reference frame. For instance, if 1 reference frame was used in step210for a predictive picture, at least two reference frames are used for the predictive picture in step218. If two reference frames were used in step210for a bi-predictive picture, at least three reference frames are used for the bi-predictive picture in step218. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used.

In step220, the motion estimator determines whether the motion estimation performed in step218has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step220that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step220that the target complexity has not been met, the motion estimator proceeds to step222and performs motion estimation for the second square-shaped partition of the source macroblock using at least one additional reference frame. For instance, if one reference frame was used for a predictive picture in step214, at least two reference frames are used for the predictive picture in step222. If two reference frames were used for a bi-predictive picture in step214, at least three reference frames are used for the bi-predictive picture in step222. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used.

In step224, the motion estimator determines whether the motion estimation performed in step222has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step224that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step224that the target complexity has not been met, the motion estimator proceeds to step226and performs motion estimation for a first rectangular-shaped partition of the source macroblock using a number, x, of reference frames for predictive pictures or a number, y, of reference frames for bi-predictive pictures, where x and y have the values discussed previously. In one embodiment, the first rectangular-shaped partition is a 16×8 partition. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used.

In step228, the motion estimator determines whether the motion estimation performed in step226has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step228that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step228that the target complexity has not been met, the motion estimator proceeds to step230and performs motion estimation for a second rectangular-shaped partition of the source macroblock using a number, x, of reference frames for predictive pictures or a number, y, of reference frames for bi-predictive pictures, where x and y have the values discussed previously. In one embodiment, the second rectangular-shaped partition is an 8×16 partition.

In step232, the motion estimator determines whether the motion estimation performed in step230has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step232that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step232that the target complexity has not been met, the motion estimator proceeds to step234and performs motion estimation for the first rectangular-shaped partition of the source macroblock using at least one additional reference frame. For instance, if one reference frame was used for a predictive picture in step226, at least two reference frames are used for the predictive picture in step234. If two reference frames were used for a bi-predictive picture in step226, at least three reference frames are used for the bi-predictive picture in step234. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used.

In step236, the motion estimator determines whether the motion estimation performed in step234has caused the target complexity to be met (e.g., whether the maximum number of searches has been performed). If the motion estimator concludes in step234that the target complexity has been met, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Alternatively, if the motion estimator concludes in step236that the target complexity has not been met, the motion estimator proceeds to step238and performs motion estimation for the second rectangular-shaped partition of the source macroblock using at least one additional reference frame. For instance, if one reference frame was used for a predictive picture in step230, at least two reference frames are used for the predictive picture in step238. If two reference frames were used for a bi-predictive picture in step230, at least three reference frames are used for the bi-predictive picture in step238. In one embodiment, the motion estimation is performed in accordance with a simplified hexagon search, although other search algorithms may be used. Once motion estimation in accordance with step238has been completed, the motion estimator proceeds to step240and selects a next source macroblock for motion estimation (i.e., motion estimation for the current source macroblock is terminated).

Embodiments of the invention thereby control complexity at the partition type and reference frame level. Processing on different partitions and reference frame levels is ordered to allow complexity to be scaled from low to high. Although the above discussion refers to processing of four different partition sizes, those skilled in the art will appreciate that other and additional partition sizes, as well as reference frame levels, may be implemented for processing in accordance with the method200.

Moreover, in further embodiments of the method200, if the target complexity is not met by conclusion of step238, additional motion estimation may be performed on the square-shaped partitions for increasing numbers of reference frames (e.g., (3,4), (4,5), etc.).

FIG. 3is a high level block diagram of the present motion estimation method that is implemented using a general purpose computing device300. In one embodiment, a general purpose computing device300comprises a processor302, a memory304, a motion estimation module305and various input/output (I/O) devices306such as a display, a keyboard, a mouse, a modem, a microphone, a speaker, a network connection and the like. In one embodiment, at least one I/O device is a storage device (e.g., a disk drive, flash memory, an optical disk drive, a floppy disk drive). It should be understood that the motion estimation module305can be implemented as a physical device or subsystem that is coupled to a processor through a communication channel.

Alternatively, the motion estimation module305can be represented by one or more software applications (or even a combination of software and hardware, e.g., using Application-Specific Integrated Circuits (ASIC)), where the software is loaded from a storage medium (e.g., I/O devices606) and operated by the processor302in the memory304of the general purpose computing device300. Additionally, the software may run in a distributed or partitioned fashion on two or more computing devices similar to the general purpose computing device300. Thus, in one embodiment, the motion estimation module305for speeding up video encoder processes described herein with reference to the preceding figures can be stored on a computer readable medium or carrier (e.g., RAM, magnetic or optical drive or diskette, and the like).

Thus, the present invention represents a significant advancement in the field of video encoding. Embodiments of the invention provide a scalable approach to motion estimation in which various steps of the motion estimation process correspond to different complexities and search qualities.