(a) Field of the Invention
The invention relates to a method and an apparatus for selecting intra prediction mode and, more particularly, to a method and an apparatus for selecting intra prediction mode by using a relatively small computation load.
(b) Description of Related Art
Due to the fast advancement in information technology, sounds and images can be stored and played in digital format, and therefore the applications of video/audio information are greatly expanded. However, if the video/audio information is fully stored without being processed at all, an extremely large storage space would be needed, especially for storing video information that records images; it would disadvantage subsequent storage and transmission of the video/audio files. There have been many video-encoding technologies developed to solve the problem of over-sized video files, and the technologies are able to effectively compress the size of video files and maintain the original picture quality during playback, or maintain the distortion level of picture quality within an acceptable range during playback.
The principle of video encoding is briefly explained below. In order to get a better compression efficiency, the encoding of a series of video frames is divided into two parts: the first part is called intra-coding, which is the encoding method for a single video frame; and the second part is called inter-coding, which is a video frame reconstruction method using the preceding and following video frames to predict the current video frame.
The video encoding standard H.264/AVC (MPEG-4 Part 10 Advanced Video Coding) set by ITU-T and ISO/IEC is used as an example to described the intra-coding method. In H.264/AVC video encoding standard, a video frame is divided into a plurality of macroblocks, and each macroblock is composed of 16×16 pixels. Each macroblock is further divided into 4×4 subblocks, and hence each subblock is composed of 4×4 pixels. Intra-coding uses the values of reference pixels near a subblock to predict the values of the pixels in the subblock. As shown in
Referring to
To obtain video frames with minimized distortion level, namely, the biggest peak signal to noise ratio (PSNR), all of the nine prediction modes must be examined and the mode with a smallest error value is selected to be the prediction mode to process the subblock. It is foreseeable that a large computation load is indispensable for deciding which prediction mode to use for the prediction of each subblock. Therefore, how to effectively reduce the number of computations and quickly select a preferred prediction mode for every subblock while maintaining the picture quality close to optimized video frames is a goal to achieve at the present.
In view of the aforementioned problems, an object of the invention is to provide a method and an apparatus for selecting intra prediction mode that are able to reduce the number of computations required for selecting a preferred prediction mode for a single subblock, and at the same time maintains the picture quality that is close to optimized video frames.
To achieve the aforementioned object, a method for selecting intra prediction mode of the invention is applied in a video encoding method. The video encoding method encodes a video data stream and defines a plurality of prediction modes, and the video data includes a plurality of video frame streams, wherein the video frame is composed of a plurality of subblocks. The method for selecting intra prediction mode includes steps of: calculating an error value for each of the prediction modes in a first group, wherein the first group includes two prediction modes with an included angle (the smaller one of the two complementary included angles) between their prediction directions being the largest; calculating an error value for each of the prediction modes in a second group, wherein the prediction modes in the second group refer to the prediction modes with prediction directions near the two sides of the prediction direction of the prediction mode with smaller error value in the first group; calculating an error value for the prediction mode in a third group, wherein the prediction mode in the third group refers to the prediction mode with prediction direction adjacent to the prediction direction of the prediction mode with smaller error value in the second group; calculating an error value for a DC prediction mode in the plurality of prediction modes; and selecting a prediction mode with a smallest error value among the DC prediction mode, the prediction modes in the first group, the prediction modes in the second group, and the prediction mode in the third group, to be the intra prediction mode for encoding the subblock.
An apparatus for selecting intra prediction mode of the invention is for executing the aforementioned method, the apparatus includes an error computation unit and a selection unit. The error computation unit first calculates an error value for each of the prediction modes in a first group, an error value for each of the prediction modes in a second group, and an error value for the prediction mode in a third group, wherein the first group includes two prediction modes which have an included angle (the smaller one of the two complementary included angles) between their prediction directions being the largest, the prediction modes in the second group refer to the prediction modes with prediction directions near the two sides of the prediction direction of the prediction mode with smaller error value in the first group, and the prediction mode in the third group refers to the prediction mode with prediction direction adjacent to the prediction direction of the prediction mode with smaller error value in the second group. Moreover, the error computation unit calculates an error value for a DC prediction mode in the plurality of prediction modes. The selection unit is connected to the error computation unit via signals, and according to the computation results of the error computation unit, selects a prediction mode with a smallest error value among the DC prediction mode, the prediction modes in the first group, the prediction modes in the second group, and the prediction mode in the third group, to be the intra prediction mode for encoding the subblock.
According to the method and apparatus for selecting intra prediction mode of the invention, the number of computations can be reduced significantly and the computation load can be lowered. Furthermore, the picture quality of encoded frames is close to the picture quality of frames encoded by conventional optimization.
The method and apparatus for selecting intra prediction mode according to preferred embodiments of the invention will be described below with reference to the drawings, wherein the like reference numerals denote the like components.
Referring to
A method for selecting intra prediction mode according to a preferred embodiment of the invention includes the following steps: calculating an error value for each of the prediction modes in a first group (S41), wherein the first group includes two prediction modes with an included angle (the smaller one of the two complementary included angles) between their prediction directions being the largest; calculating an error value for each of the prediction modes in a second group (S42), wherein the prediction modes in the second group are the prediction modes with prediction directions near the two sides of the prediction direction of the prediction mode with smaller error value in the first group; calculating an error value for the prediction mode in a third group (S43), wherein the prediction mode in the third group is the prediction mode with prediction direction adjacent to the prediction direction of the prediction mode with smaller error value in the second group; calculating an error value for a DC prediction mode in the plurality of prediction modes (S44); and among the DC prediction mode, the prediction modes in the first group, the prediction modes in the second group, and the prediction mode in the third group, selecting a prediction mode with a smallest error value to be the intra prediction mode for encoding the subblock (S45). The calculating method for an error value mentioned above is to add up the absolute values of the differences between predicted values and original values of all the pixels in the subblock, wherein the predicted values are obtained by using specific prediction modes.
A video encoding method conforming to H.264/AVC video encoding standard is used as an example for describing how to select a preferred prediction mode. Referring to
In step S503, the error values of mode 5 and mode 7 are calculated, and as shown in
Step S504 is to calculate the error values of mode 6 and mode 8, and as shown in
In the aforementioned example, step S501 corresponds to step S41; steps S502 and S503 or steps S502 and S504 correspond to step S42; and steps S505 and S506, steps S505 and S507, steps S508 and S509, or steps S508 and S510 correspond to step S43. Moreover, the prediction modes in the first group are mode 0 and mode 1; the prediction modes in the second group are either mode 5 and mode 7, or mode 6 and mode 8, depending on the calculation results of the first group; and the prediction mode in the third group is either mode 3 or mode 4, depending on the calculation results of the second group. The aforementioned process shows that only the error values of six prediction modes need to be calculated to select a preferred prediction mode, rather than examining the error values of nine prediction modes. Take the process of steps S501, S502, S503, S505, S506 as an example, only the error values of modes 0, 1, 2, 5, 7, and 4 are calculated, and thus the calculation time for modes 3, 6, and 8 can be saved.
The video encoding method under H.264/AVC video encoding standard is used as an example to describe another method for selecting a preferred prediction mode. Referring to
In step S603, the error values of mode 3 and mode 4 are calculated, and as shown in
Step S604 is also to calculate the error values of mode 3 and mode 4, and the step thereafter is to judge which of the error values of mode 3 and mode 4 is smaller (S608); if the error value of mode 3 is smaller, proceed to step S609, and if the error value of mode 4 is smaller, proceed to step S610. In step S609, the error value of mode 8 is calculated, whereas in step S610, the error value of mode 6 is calculated; the prediction direction of mode 8 is between that of mode 1 and mode 3, and the prediction direction of mode 6 is between that of mode 1 and mode 4. Finally, among the prediction modes that have their error values calculated, the prediction mode with a smallest error value is selected to be the intra prediction mode for encoding the subblock (S611).
In the aforementioned example, step S601 corresponds to step S41; steps S602 and S603, or steps S602 and S604 correspond to step S42; and steps S605 and S606, steps S605 and S607, steps S608 and S609, or steps S608 and S610 correspond to step S43. Moreover, the prediction modes in the first group are mode 0 and mode 1; the prediction modes in the second group are mode 3 and mode 4; and the prediction mode in the third group is one of mode 5, mode 6, mode 7, and mode 8, depending on the calculation results of the second group. The aforementioned process shows that, for selecting a preferred prediction mode, only the error values of six prediction modes need to be calculated. Take the process of steps S601, S602, S603, S605, and S606 as an example, only the error values of modes 0, 1, 2, 3, 4, and 7 need to be calculated, and thus the calculation time of modes 5, 6, and 8 can be saved.
It is to be noted that although the aforementioned mode 2 (the DC prediction mode) is calculated along with the prediction modes in the first group, it can also be calculated independently or along with the prediction modes in the second group, the prediction mode in the third group. The error value calculation of the DC prediction mode does not relate in context with the error value calculations of the prediction modes in the first group, the second group, and the third group, and so a person skilled in the art may alter the calculation sequence thereof according to requirement.
Referring to
According to the method and apparatus for selecting intra prediction mode of the invention, a preferred prediction mode for a single subblock can be selected by calculating only six error values. Comparing to the conventional technology, which needs to calculate nine error values to select a preferred prediction mode, the invention can effectively reduce the number of computations and lower the computation load. By comparing the picture quality of the encoded video frames, similar peak signal to noise ratios are obtained, which means that the picture quality of frames encoded by the method and apparatus for selecting intra prediction mode of the invention is close to the picture quality of frames encoded by conventional optimization.
While the invention has been described by way of example and in terms of the preferred embodiment, it is to be understood that the invention is not limited to the disclosed embodiments. In other words, it is intended to include equivalent modifications and changes of the above embodiments without departing from the spirit and scope of the invention as would be apparent to those skilled in the art. For example, the video encoding method under H.264/AVC standard takes a subblock composed of 4×4 pixels as a unit to calculate the error value, but those skilled in the art can take subblocks composed of 8×8 or 16×16 pixels as a unit to calculate the error value of a specific prediction mode. Therefore, the scope of the appended claims should be accorded the broadest interpretation so as to encompass all such equivalent modifications and changes.
Number | Date | Country | Kind |
---|---|---|---|
94115963 | May 2005 | TW | national |