1. Field of the Invention
The present invention relates to digital video, and more specifically, to a method of video frame compression.
2. Description of the Prior Art
Digital video is a popular means of information communication. Computer-based video conferencing and digital television are just two examples of applications of this technology. As a single digital image can contain hundreds of thousands of pixels and many sequential image frames are required to produce a quality video effect, compression schemes are required for efficiency in processing time and storage space.
In general, image compression is effected by determining correlations among regions of pixels. When high compression is required due to limits in data transmission speeds for example, either video quality must be sacrificed or additional compression hardware and software must be provided. Where low amounts of compression are tolerable, video quality can be maintained at the cost of an increase in memory demand. Among this complex arrangement of trade-offs, any increase in compression that does not significantly lower video quality or increase the necessary hardware is undoubtedly beneficial.
Practically, compression of a video frame can be realized by intra-picture encoding in which a block of pixels is compressed referencing pixel information outside the block but in the same frame, and by inter-picture encoding in which a block is compressed referencing pixel information of other frames. In compression standards, such as MPEG-4, it is convenient to define several types of frames each having different compression schemes. Commonly, these types of frames are defined as: an entirely intra-picture encoded frame (I-frame), a frame having a mixture of intra-picture and inter-picture encoded blocks (P-frame), and a frame of only inter-picture encode blocks (B-frame). The I-frame is the least compressed and has the highest picture quality, the B-frame is the most compressed and sacrifices some picture quality, and the P-frame is fairly balanced in between. Such definitions allow for controlling the trade-off between compression and quality in systems such as MPEG-4.
Once frame type definitions are decided upon, a predetermined sequence, which is typically repeating, of these frames is used to encode a video. Please refer to
A major problem with this method occurs at scene changes, such as those that frequently occur during movies. From a video compression standpoint, a scene change can be loosely defined as: when the pictures to be encoded change drastically between two neighboring frames. If the scene of the video changes at a B-frame, the reference of that B-frame (the preceding I-frame) likely contains little useful information with which to encode that B-frame (Recall that B-frames consist entirely of inter-picture encoded blocks with corresponding motion vectors referring back to a reference frame.). For example, if the I-frame 12 (
It is therefore a primary objective of the claimed invention to provide a method of video compression capable of handling a scene change occurring in an inter-coded frame (B-frame) to improve video quality.
Briefly summarized, the claimed invention method includes providing a predetermined sequence of video frames, the predetermined sequence beginning with an I-frame and ending with a P-frame. An I-frame is defined as having blocks encoded referencing intra-picture information only and a P-frame is defined as having blocks encoded referencing intra-picture or inter-picture information. Further, a B-frame is defined as having blocks encoded referencing inter-picture information only. The method further includes encoding blocks of each frame according to the order of the frame in the sequence and the frame type, determining a number of intra-picture coded blocks in an encoded P-frame, and determining that a scene change occurs when the number of intra-picture coded blocks is greater than a predetermined number. The method finally includes redefining the P-frame detected as having a scene change as an I-frame, redefining all B-frames of the sequence as P-frames, and re-encoding redefined frames.
According to the claimed invention, method further includes detecting for a scene change in the newly redefined frames. Such an iterative approach allows the exact frame in which the scene change occurs to be determined.
It is an advantage of the claimed invention that redefining frames allows a scene change to be accurately encoded thereby improving overall video quality.
These and other objectives of the claimed invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
Step 102: Select a frame sequence of I-, B-, and P-frames (for example, “I-B-B-B-P”);
Step 104: Select the first frame to be encoded (i.e. the I-frame);
Step 106: Encode the frame according to its type. Blocks of an I-frame are intra-picture encoded referencing only picture information of the current frame, blocks of a B-frame are inter-picture encoded referencing picture information of the previous I-frame, and blocks of a P-frame are intra- or inter-picture encoded depending on the relative suitability of each;
Step 108: Check the type of the current frame being encoded. This can be performed before, after, or during encoding. If the current frame is a P-frame perform step 114, otherwise continue with step 110;
Step 110: If the current frame is the last frame to be encoded, end the process. Otherwise, perform step 112;
Step 112: Select the next frame. Note that the frame sequence is repeated such that another I-frame comes after the P-frame in the exemplary sequence;
Step 114: Is a scene change detected in the P-frame? That is, does the number of intra-picture encoded blocks exceed a predetermined limit? If a scene change is detected, perform step 116. Otherwise, continue with step 110;
Step 116: Change the current frame from a P-frame to an I-frame, and change B-frames in the current frame sequence to P-frames;
Step 118: Select the first of the newly converted P-frames.
Regarding the P-frame encoding of step 106, determining whether a block is to be intra-picture encoded or inter-picture encoded is well known in the art. For example, a P-frame encoding algorithm may encode all blocks as inter-picture by default, unless such encoding results in a quality indicator value that is less than acceptable. The algorithm would select blocks with unacceptable inter-picture encoding quality to be encoded as intra-picture instead.
Regarding the scene change detection in step 114, this can be performed in several ways. In the preferred embodiment, a running total of intra-picture encoded blocks is kept while encoding a P-frame. If the running total exceeds a certain limit, then a scene change is said to be detected. For example, in a 640×480 pixel video having 16×16 pixel non-overlapping blocks (1200 blocks total), the limit of intra-picture encoded blocks can be selected as 800. Thus, if an 801st block is to be intra-picture encoded, a scene change is determined. Of course, another limiting value could be selected for a different tolerance to scene change detection. Note that, if a scene change is detected in the P-frame, the scene change may actually occur in the P-frame itself or in any preceding B-frame. The exact frame in which the scene change occurs is determined by the iterative nature of the process 100.
Please refer to
In practical application, the present invention can be implemented as part of an MPEG-4 (moving picture experts group) video compression program or device. Implementation of the above-described method 100 into an MPEG-4 system is straightforward to one of ordinary skill in the art.
In contrast to the prior art, the present invention redefines frames to accurately encode a scene change. Specifically, when a scene change is detected in a P-frame, the P-frame is converted to an I-frame and any B-frames in the same sequence are converted to P-frames. As a result, the exact frame in which the scene change occurs can be determined, and the scene change can be properly encoded.
Those skilled in the art will readily observe that numerous modifications and alterations of the device may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.