Abstract:
A method of compressing video data having at least one frame having at least one block and each block having an array of pixels is provided. The method transforms the pixels of each block into coefficients and creates an optimal transmission order of the coefficients. The method also optimizes the speed of processing compressed video data by partitioning the data bitstream and coding each partition independently. The method also predicts fractional pixel motion by selecting an interpolation method for each given plurality or block of pixels depending upon at least one metric related to each given block and varies the method from block to block. The method also enhances error recovery for a current frame using a frame prior to the frame immediately before the current frame as the only reference frame for lessening quality loss during data transmission. Enhanced motion vector coding is also provided.

Description:
CROSS-REFERENCE TO RELATED APPLICATIONS 
       [0001]    This application is a continuation of U.S. Utility patent application Ser. No. 11/170,629, filed on Jun. 28, 2005, which in turn claims the benefit of U.S. Provisional Patent Application No. 60/583,872, filed Jun. 28, 2004, both of which are incorporated herein by reference in their entirety. 
     
    
     COMPUTER PROGRAM LISTING APPENDIX 
       [0002]    Two compact discs (in duplicate) have been submitted containing a computer program listing; the contents of the compact discs are incorporated by reference herein in their entirety. The following files are on the compact discs: 
         [0000]    
       
         
               
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 05/25/2004 12:57 PM 
                 1,333 alloccommon.c 
               
               
                   
                 05/17/2004 04:34 PM 
                 128 alloccommon.h 
               
               
                   
                 06/07/2004 07:17 AM 
                 38,579 bitstream.c 
               
               
                   
                 05/25/2004 08:51 AM 
                 1,126 block.h 
               
               
                   
                 05/25/2004 05:56 AM 
                 2,590 blockd.h 
               
               
                   
                 05/25/2004 02:12 PM 
                 3,687 boolhuff.c 
               
               
                   
                 03/01/2004 04:36 PM 
                 927 boolhuff.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 7,948 cclib.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 12,448 colorcnv.cpp 
               
               
                   
                 02/10/2004 06:04 PM 
                 549 colorcnv.h 
               
               
                   
                 05/25/2004 07:00 AM 
                 101 common_types.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 35,067 config_dlg.cpp 
               
               
                   
                 02/20/2004 09:53 AM 
                 6,601 config_onyx.cpp 
               
               
                   
                 05/25/2004 08:51 AM 
                 16,741 context.c 
               
               
                   
                 02/10/2004 06:04 PM 
                 1,856 CPUIdLib.h 
               
               
                   
                 02/18/2004 10:53 AM 
                 1,516 dboolhuff.c 
               
               
                   
                 02/18/2004 10:54 AM 
                 757 dboolhuff.h 
               
               
                   
                 05/20/2004 09:34 AM 
                 3,712 dct.c 
               
               
                   
                 02/10/2004 06:04 PM 
                 56 dct.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 1,659 debugmodes.c 
               
               
                   
                 06/07/2004 07:17 AM 
                 8,835 decodemv.c 
               
               
                   
                 04/23/2004 11:08 AM 
                 119 decodemv.h 
               
               
                   
                 05/25/2004 05:56 AM 
                 8,502 decodframe.c 
               
               
                   
                 05/18/2004 07:19 AM 
                 4,157 demode.c 
               
               
                   
                 05/07/2004 02:37 PM 
                 409 demode.h 
               
               
                   
                 03/03/2004 04:11 PM 
                 783 dequantize.c 
               
               
                   
                 03/03/2004 04:11 PM 
                 66 dequantize.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 6,566 detokenize.c 
               
               
                   
                 02/10/2004 06:04 PM 
                 55 detokenize.h 
               
               
                   
                 02/20/2004 09:53 AM 
                 9,641 duck_dxl.h 
               
               
                   
                 02/20/2004 09:53 AM 
                 560 duck_mem.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 2,515 dxl_plugin.h 
               
               
                   
                 04/23/2004 11:08 AM 
                 8,781 dxvdecode.cpp 
               
               
                   
                 02/10/2004 06:04 PM 
                 1,532 dxvdecode.hpp 
               
               
                   
                 05/17/2004 04:34 PM 
                 1,665 encintra4x4.c 
               
               
                   
                 05/07/2004 02:37 PM 
                 917 encintra4x4.h 
               
               
                   
                 06/07/2004 07:17 AM 
                 17,949 encodeframe.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 2,572 encodeintra.c 
               
               
                   
                 05/10/2004 12:16 PM 
                 356 encodeintra.h 
               
               
                   
                 05/25/2004 08:51 AM 
                 2,975 encodemb.c 
               
               
                   
                 05/20/2004 09:34 AM 
                 366 encodemb.h 
               
               
                   
                 05/25/2004 08:51 AM 
                 19,336 encodemv.c 
               
               
                   
                 05/25/2004 08:51 AM 
                 505 encodemv.h 
               
               
                   
                 05/13/2004 11:46 AM 
                 10,123 entropy.c 
               
               
                   
                 05/13/2004 11:46 AM 
                 2,709 entropy.h 
               
               
                   
                 05/12/2004 04:57 PM 
                 12,173 entropymode.c 
               
               
                   
                 05/12/2004 04:57 PM 
                 298 entropymode.h 
               
               
                   
                 03/01/2004 04:36 PM 
                 733 entropymv.c 
               
               
                   
                 03/01/2004 04:36 PM 
                 1,205 entropymv.h 
               
               
                   
                 03/08/2004 10:42 AM 
                 2,098 extend.c 
               
               
                   
                 03/08/2004 10:42 AM 
                 170 extend.h 
               
               
                   
                 05/10/2004 12:38 PM 
                 512 filter.c 
               
               
                   
                 03/08/2004 05:09 PM 
                 355 filter.h 
               
               
                   
                 05/13/2004 11:46 AM 
                 6,650 filter_c.c 
               
               
                   
                 05/10/2004 12:38 PM 
                 11,075 filter_mmx.c 
               
               
                   
                 05/10/2004 12:38 PM 
                 6,716 Filter_wmt.c 
               
               
                   
                 05/25/2004 08:51 AM 
                 3,146 findnearmv.c 
               
               
                   
                 05/25/2004 08:51 AM 
                 550 findnearmv.h 
               
               
                   
                 05/25/2004 05:56 AM 
                 312 header.h 
               
               
                   
                 03/03/2004 04:11 PM 
                 3,572 idct.c 
               
               
                   
                 02/10/2004 06:04 PM 
                 58 idct.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 1,084 invtrans.c 
               
               
                   
                 03/25/2004 12:49 PM 
                 173 invtrans.h 
               
               
                   
                 05/06/2004 09:10 AM 
                 24,908 maskedmse_xmm.c 
               
               
                   
                 04/23/2004 01:48 PM 
                 4,716 maskedsad_xmm.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 14,979 mcomp.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 503 mcomp.h 
               
               
                   
                 05/25/2004 08:51 AM 
                 1,472 modecont.c 
               
               
                   
                 04/23/2004 11:08 AM 
                 33 modecont.h 
               
               
                   
                 04/23/2004 11:08 AM 
                 1,504 modecont2.c 
               
               
                   
                 04/23/2004 04:41 PM 
                 11,070 modecontext.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 9,085 modecosts.c 
               
               
                   
                 05/18/2004 06:48 AM 
                 37 modecosts.h 
               
               
                   
                 05/03/2004 05:23 PM 
                 16,169 mse_xmm.c 
               
               
                   
                 04/23/2004 11:08 AM 
                 99 mv.h 
               
               
                   
                 02/20/2004 09:52 AM 
                 3,537 on2_mem.h 
               
               
                   
                 02/20/2004 09:52 AM 
                 3,245 on2_mem_tracker.h 
               
               
                   
                 05/17/2004 04:35 PM 
                 9,448 onyx.cpp 
               
               
                   
                 05/04/2004 01:08 PM 
                 1,257 onyx.h 
               
               
                   
                 06/07/2004 07:16 AM 
                 1,077 onyxc_int.h 
               
               
                   
                 03/03/2004 04:11 PM 
                 1,742 onyxd.cpp 
               
               
                   
                 05/04/2004 01:08 PM 
                 614 onyxd.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 14,398 onyxdxv.c 
               
               
                   
                 06/24/2004 08:21 AM 
                 3,573 onyxd_if.c 
               
               
                   
                 05/17/2004 04:34 PM 
                 361 onyxd_int.h 
               
               
                   
                 04/23/2004 04:41 PM 
                 13,825 onyxvfw.cpp 
               
               
                   
                 02/10/2004 06:04 PM 
                 2,511 onyxvfw.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 29,286 onyxvfw2.cpp 
               
               
                   
                 06/24/2004 08:21 AM 
                 20,363 onyx_if.c 
               
               
                   
                 06/07/2004 07:17 AM 
                 1,269 onyx_int.h 
               
               
                   
                 02/20/2004 09:53 AM 
                 299 onyx_settings.h 
               
               
                   
                 04/23/2004 04:41 PM 
                 1,645 parms.cpp 
               
               
                   
                 06/22/2005 01:58 PM 
                 0 patent.txt 
               
               
                   
                 05/17/2004 05:13 PM 
                 2,327 pickintra.c 
               
               
                   
                 05/07/2004 03:04 PM 
                 120 pickintra.h 
               
               
                   
                 06/24/2004 08:21 AM 
                 11,659 postproc.c 
               
               
                   
                 06/07/2004 10:17 AM 
                 136 postproc.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 3,324 psnr.c 
               
               
                   
                 02/10/2004 06:04 PM 
                 123 psnr.h 
               
               
                   
                 04/23/2004 04:41 PM 
                 1,851 quantize.c 
               
               
                   
                 03/25/2004 12:49 PM 
                 189 quantize.h 
               
               
                   
                 06/07/2004 07:17 AM 
                 32,495 rdopt.c 
               
               
                   
                 05/25/2004 05:56 AM 
                 278 rdopt.h 
               
               
                   
                 05/12/2004 04:57 PM 
                 888 recon.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 146 recon.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 1,933 reconinter.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 198 reconinter.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 9,302 reconintra.c 
               
               
                   
                 05/07/2004 02:37 PM 
                 335 reconintra.h 
               
               
                   
                 05/20/2004 09:34 AM 
                 10,809 reconintra4x4.c 
               
               
                   
                 05/20/2004 09:34 AM 
                 67 reconintra4x4.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 2,898 regentry.cpp 
               
               
                   
                 02/10/2004 06:04 PM 
                 925 regentry.h 
               
               
                   
                 05/07/2004 02:37 PM 
                 5,187 resource.h 
               
               
                   
                 03/08/2004 05:09 PM 
                 372 sad.c 
               
               
                   
                 03/08/2004 05:09 PM 
                 483 sad.h 
               
               
                   
                 05/04/2004 01:08 PM 
                 17,812 sad16x16_wmt.c 
               
               
                   
                 04/23/2004 11:08 AM 
                 3,872 sad16x16_xmm.c 
               
               
                   
                 05/10/2004 12:39 PM 
                 2,639 sad4x4_xmm.c 
               
               
                   
                 05/17/2004 05:13 PM 
                 596 setupintrarecon.c 
               
               
                   
                 05/07/2004 02:38 PM 
                 78 setupintrarecon.h 
               
               
                   
                 02/10/2004 06:12 PM 
                 295 StdAfx.cpp 
               
               
                   
                 02/10/2004 06:12 PM 
                 769 StdAfx.h 
               
               
                   
                 05/17/2004 04:34 PM 
                 1,353 textblit.c 
               
               
                   
                 05/25/2004 08:51 AM 
                 7,314 tokenize.c 
               
               
                   
                 05/07/2004 02:37 PM 
                 569 tokenize.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 7,721 vfwTemplate.h 
               
               
                   
                 02/10/2004 06:04 PM 
                 32,216 vfw_config_dlg.cpp 
               
               
                   
                 06/24/2004 08:22 AM 
                 66 vpvfwver.h 
               
               
                   
                 04/16/2004 09:23 AM 
                 1,545 yuvconfig.c 
               
               
                   
                 04/09/2004 09:30 AM 
                 615 yuvConfig.h 
               
               
                   
                   
               
             
          
         
       
     
         [0003]    These files are exact ASCII versions of identically-titled non-ASCII files submitted with the initial provisional application referenced above. 
       COPYRIGHT NOTICE 
       [0004]    A portion of the disclosure of this document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of this document or the disclosure as they appear in the USPTO files or records, but otherwise reserves all copyright rights. 
       BACKGROUND OF THE INVENTION 
       [0005]    1. Field of the Invention 
         [0006]    The invention relates to video compression and encoding methods, and more specifically to video compression methods that employ techniques to increase efficiency, compactability, and transmission of digital image and video data. 
         [0007]    2. Description of Related Art 
         [0008]    Digital pictorial information, whether derived from an analogue source by a process of digitization or directly from a digital device, consists of huge volumes of data. As the ability of devices to capture higher resolution images improves so too does the amount of data required for their digital representation. If stored in raw format a single image may well require tens of mega-bytes of disk space. 
         [0009]    The problem is further exacerbated when considering digital video data, especially for high definition video. A two-hour movie when stored in raw form at the highest resolution ATSC frame size (1920×1080 pixels at 30 frames per second) requires almost 641 Gbyte of disk space. At a data rate of almost 89 Mbyte/s the bandwidth required for transmission goes way beyond what is currently available. 
         [0010]    The encoding operation may be considered to be a three-stage process. First, a block predictor, created from data already available to the decoder, is subtracted from the original data to form a prediction error signal. Second, the prediction error is block transformed and quantized. Finally, the transform coefficients are entropy coded to form a binary bitstream that constitutes the compressed frame. 
         [0011]    The prediction stage may involve spatial or temporal prediction for video. For image compression, with no available temporal data, the only prediction mode available is spatial. 
         [0012]    Many of the more successful algorithms have a two-dimensional block transform method at their core, partitioning each frame into rectangular blocks (usually 8×8 or 4×4) and applying the transform to each. Compression is achieved by coding the transform coefficients more efficiently than the original spatial data can be coded. 
         [0013]    The Discrete Cosine Transform (DCT) has received the most attention over the last thirty years or so, being the transform of choice in all of the MPEG video compression and the original JPEG image compression International Standards. 
         [0014]    Another aspect of the invention covers the ability to reuse prior transmitted motion vectors, which may not appear directly adjacent to the current block, and to use statistics on these prior transmitted motion vectors to lessen the cost of encoding new motion vectors. 
         [0015]    Motion fields tend to track real objects that move from one frame to the next. These objects typically cover more than the typical block size. There is usually reasonable consistency of motion vectors from one block to the next. Prior art makes use of this consistency by predicting a new motion vector from the motion vectors of the surrounding blocks and then encoding the difference between the real motion vector and the predicted motion vector. The prior art also uses a smaller subset of blocks in the prediction, typically four surrounding motion vectors (left, above left, above, and above right). 
         [0016]    In the prior art, digital image/video compression systems use various techniques of prediction to reduce data redundancy. In block-based systems, to efficiently encode a block of pixels, a prediction block is constructed based on previously decoded data. That prediction block is subtracted from the source data and the residual signal is encoded using techniques such as transform coding. At the decoder the prediction block may be created from data that has already been decoded and the prediction error signal added back in to produce the reconstructed block. 
         [0017]    The terms intra- and inter-prediction indicate that the prediction block is formed from data from the same image/video frame and previously decoded frame(s), respectively. 
         [0018]    Sub Pixel motion estimation is used to build a prediction of a block that has moved from one frame to the next by something other than a whole pixel value. In sub-pixel motion estimation, the system attempts to estimate what would have happened to the block if the real object moved by a non-integral amount. 
         [0019]    The prior art used a fixed set of interpolating filters to predict ½, ¼, and even ⅛ pixel moves. The problem with this technique is two fold: the longer the filter is the more likely you are to reproduce an image artifact and two shorter filters perform a less accurate interpolation and thus tend to blur real image detail. 
         [0020]    The prior art, including some standards based codecs such as H.264, describes the use of various types of filters for smoothing the discontinuities that arise between blocks coded using discrete cosine transforms (DCT) or other similar block based transforms. 
         [0021]    The problem with conventional loop filters is that they typically either fail to adequately remove false block discontinuities or over smooth the reconstructed image and hence suppress real image detail. 
         [0022]    This invention relates to an improved method for loop filtering that includes adaptive techniques that maximize the beneficial effects of the filter and minimize the artifacts. 
       SUMMARY OF THE INVENTION 
       [0023]    This invention covers a novel approach to encoding motion vectors that makes use of motion vectors from surrounding blocks in a way that differs from prior art. 
         [0024]    The current invention is based on the premise that a better prediction can be found by performing a motion search on multiple subdivisions of the same set of pixels. These subdivisions can be selected from a dictionary of subdivisions or derived from a set of ‘subdividing’ functions. 
         [0025]    The current invention may be integrated into any image or video compression algorithm that involves a block transform. 
         [0026]    For purpose of the current invention the term image refers to a rectangular array that contains either raw pixel values or prediction error values. 
         [0027]    Before the block transform is applied a process is carried out to sub-divide the image into a set of fixed partitions (for instance 16×16 blocks of pixels). Then these fixed partitions are subdivided in multiple ways using either a fixed set of subdivisions or a set of functions that produce an arbitrary set of subdivisions. A motion search is performed on each of the subdivisions and the best subdivision in a rate distortion sense is selected. The best subdivision can either be directly encoded in the bitstream or it can be signaled through transmitted motion vectors on a more atomic subdivision level. 
         [0028]    The benefit to an encoding in which the modes and motion vectors are encoded on an atomic level is that arbitrary patterns of motion vectors can be encoded efficiently. 
         [0029]    Generally, an aspect of the invention includes a method for determining motion vectors during video compression. Multiple subdivisions are performed on an image or part of an image, and motion estimation is performed on each of segment of every subdivision. It is determined which of the subdivisions is the best using a metric, and a statistics based lossless coding technique is used to encode the motion vectors generated by the compression process 
         [0030]    Preferably, the subdivisions are provided from a set of labeling functions, which subdivide the image using criteria that differs from other labeling functions in the set. 
         [0031]    Subdivision functions are preferably based on one or more of the following functions: 
         [0032]    a. Blocks with variances within a certain threshold are given the same label 
         [0033]    b. Blocks with average pixel intensities within a given threshold are given the same label 
         [0034]    c. Blocks with error scores within a certain threshold are given the same label. 
         [0035]    In addition or in the alternative, a specific dictionary of predefined subdivisions may be used. 
         [0036]    The metric used to choose between the different subdivisions is preferably a combination of at least one of the following: rate distortion, sum squared prediction error, or sum absolute difference error score. 
         [0037]    The invention also includes a method for encoding motion vectors. An image or part of an image is broken up into a set of smaller partitions. For each partition, a mode is encoded which includes the following: left motion vector, above motion vector, zero motion vector, and/or new motion vector. For each partition whose mode was new, motion vector encode a motion vector into the bitstream 
         [0038]    This invention also presents a new set of methods for intra-prediction in image and video compression, which include the “TrueMotion” intra-prediction mode, the “Left Predictor” intra-prediction mode, the “Above Predictor” intra-prediction mode, context based intra-prediction mode encoding, cost biased intra-prediction mode selection, and frame adaptive intra-prediction mode entropy encoding. 
         [0039]    The current invention also uses the known technique of motion compensation to build a predictor for each inter coded block in the frame via sub-pixel motion. As mentioned above, prior art compression techniques use a fixed set of interpolating filters to predict  1 / 2 ,  1 / 4 , and ⅛ pixel moves. The problem with this technique is two-fold: the longer the filter is the more likely you are to reproduce an image artifact, and two shorter filters perform a less accurate interpolation and thus tend to blur real image detail. 
         [0040]    This invention solves these problems by performing adaptive pixel analysis on the prediction filter and by picking between a set of filters that have different lengths. Shorter pixel filters are chosen when the results are less likely to be damaging. Longer filters are chosen when the clarity of the reconstructed frame is more important. 
         [0041]    In another aspect of the invention, as mentioned above, the prior art predicts a new motion vector from the motion vectors of the surrounding blocks and then encoding the difference between the real motion vector and the predicted motion vector. The prior art also uses a smaller subset of blocks in the prediction. Typically four surrounding motion vectors: left, above left, above, and above right. 
         [0042]    By contrast, the inventive method improves upon prior art by not just predicting the motion vector, but also by using statistics generated in the examination of the motion vectors of surrounding pixels as contextual information for encoding the motion vectors. 
         [0043]    Specifically, the invention includes a method for encoding motion vectors of images in block based video compression algorithms, comprising the steps of: 
         [0044]    i) Subdividing each image into a set of fixed partitions; 
         [0045]    ii) Further subdividing each partition into segments according to a plurality of alternative subdivisions, each segment comprising one or more blocks of pixels; 
         [0046]    iii) Selecting an optimal motion vector for each segment in each alternative subdivision based on an error score for each segment; 
         [0047]    iv) Calculating a combined error score for each alternative subdivision equal to the sum of the error scores for each segment of the subdivision; 
         [0048]    v) Selecting the subdivision with the lowest combined error score and encoding the motion vectors that were selected for the selected subdivision in step iv) into the bitstream. 
         [0049]    Preferably, the optimal motion vector selection step iii) of a current partition uses motion vectors selected from a previously encoded partition. The combined error score calculating step iv) of a current partition preferably uses error scores calculated from a previously encoded partition. The subdivision selecting step v) of a current partition may use the subdivision selected from a previously encoded partition. The plurality of alternative subdivisions may be a fixed set of subdivisions, or a set of subdivisions derived from labeling functions, or both a first set of fixed subdivisions and a second set of subdivisions that are derived from labeling functions. The set of labeling functions includes at least one of the following: grouping blocks into segments according to variance; or grouping blocks into segments according to average pixel intensity; or grouping blocks into segments according to error score. Multiple subdivisions may be created using each labeling function of different thresholds. 
         [0050]    The motion vector selecting step iii) may further include at least one of the following steps: performing a motion search for each block or segment and encoding the resulting new motion vectors; or using the same motion vector as the block or segment to the left of the current block or segment; or using the same motion vector as the block or segment above the current block or segment; or using a zero motion vector (0,0); or using a previously encoded motion vector from a block or segment that is not immediately adjacent to the current block or segment. 
         [0000]    The error score basis for selecting the motion vector in step iii) may include a rate distortion calculation, or alternatively a prediction error calculated either as the sum squared error or the sum of absolute differences. 
         [0051]    In another aspect of the invention, a method for encoding motion vectors in video compression is provided, including the steps of: 
         [0052]    Subdividing each image into a set of fixed partitions, and for a given partition: 
         [0053]    a) Examining the surrounding partitions&#39; motion vectors in an order based on the proximity to the given partition; 
         [0054]    b) Counting how many times each motion vector appears in the surrounding partitions; 
         [0055]    c) Using a subset of these counts for one or more of the following:
       i) Determining which motion vector is re-used as a reference; or   ii) As context for losslessly encoding which motion vector is re-used as a reference; or   iii) As context for losslessly encoding a new motion vector.       
 
         [0059]    The counts from step b) may be distance weighted. Optionally, this method may further include: 
         [0060]    Creating an N dimensional array as the lossless encoding context of c) ii) where N is the number of different motion vectors used in neighboring partitions; and 
         [0061]    Using the count of each different motion vector to index each dimension of the array, 
         [0062]    Wherein the value stored in the array is a set of probabilities that determine which motion vector to use as reference. Optionally, a function on the counts from step b) may be used to determine a set of probabilities that determine the motion vector to use as a reference. 
         [0063]    In another aspect of the invention, a method of encoding video and or image data is provided having the steps of
       a) Subdividing each image into a set of fixed partitions;   b) Giving each pixel in the partition a predicted value using any one or more of the following equations:       
 
         [0000]    
       
      
       X 
       ij 
       =L 
       i 
       +A 
       j 
       −C;  
      
     
         [0000]        X   ij =( Li   −1 +2 L   i   +L   i+1 +2)/4; 
         [0000]        X   ij =( Aj   −1 +2 A   j   +A   j+1 +2)/4; 
         [0000]    Where i and j represent the row and column position of X ij  within a partition, L i  is the pixel from the column left to the partition in the same row of X ij , A j  is the pixel from the row above but in the same column of X ij , C is the pixel on the intersection of the row above and the column left to the partition, 
         [0066]    c) Subtracting the predicted values from the source pixel values; 
         [0067]    d) Quantizing and transforming the resultant value from step c) using a transform function into transform coefficients; and 
         [0068]    e) Losslessly encoding the transform coefficients of step d) into the bitstream. 
         [0069]    In another aspect of the invention, a method for intra prediction for use in block based video compression/decompression algorithms is provided having the following steps: 
         [0070]    Subdividing each image into a set of fixed partitions; 
         [0071]    Provisionally encoding each partition using a plurality of different prediction modes in which pixels in the current partition are predicted by previously decoded pixels within the same image from the row above and the column to the left of the current partition, said provisional encoding done by giving each pixel in the partition a predicted value using at least one of the following equations: 
         [0000]        X   ij   =L   i   +A   j   −C;  or 
         [0000]        X   ij =( Li   −1 +2 L   i   +L   i+1 +2)/4; or 
         [0000]        X   ij =( Aj   −1 +2 A   j   +A   j+1 +2)/4; 
         [0072]    Selecting the optimal mode using either a true rate distortion metric or a combination of a prediction error metric and a factor or function relating changes in bit cost or estimated bit cost for encoding the partition to changes in prediction error; 
         [0073]    Encoding the selected optimal mode and transmitting the selected optimal mode within the bitstream, and encoding the partition in accordance with the selected optimal mode, 
         [0074]    Wherein the selected optimal mode is encoded using a conditional probability distribution indexed or otherwise accessed according to the prediction modes of the previously encoded partitions above and to the left of the current partition. 
         [0075]    Optionally, the provisional encoding step entails using any two or more of the specified equations. Optionally, the conditional probability distribution is defined by a table of constants. 
         [0076]    The probability distribution may be updated on a per frame basis according to statistics gathered relating to the frequencies or conditional frequencies of each mode in at least one prior frame. The probability distribution may be a fixed baseline distribution. As another alternative, the probability distribution is updated for an image only when the number of bits used to update the probability distribution plus the number of bits required to encode all the prediction modes within the image using the updated probability distribution is less than the number of bits required to encode all the prediction modes using either the baseline probability distribution or the unchanged probability distribution from the previous frame. 
         [0077]    The decision of intra prediction mode for a partition may be based on a metric that combines the cost of the modes with error scores of the modes, where the cost of an intra prediction mode of a partition is calculated using Shannon cost of each mode calculated by the conditional probability distribution of the intra prediction modes for the partition and the error score of the mode is calculated using the differences between the predicted pixels values and the actual pixel values for the partition. 
         [0078]    Optionally, the following steps may be included: multiplying the cost of each mode with a constant; adding the multiplied cost of each mode to the error score for the mode; and selecting the intra prediction mode with lowest combined score for the partition. 
         [0079]    In another aspect of the invention, a method for inter prediction of blocks of pixels using motion vectors in a video compression algorithm is provided, having the following steps: 
         [0080]    Specifying the location of a block in a previously decoded reference frame to be used as predictor, relative to the spatial position of the block being predicted, by a two-dimensional motion vector; 
         [0081]    Specifying the motion vector to ½ or ¼ pixel precision in the luma domain and ¼ or ⅛ pixel precision in U and V; 
         [0082]    Where a fractional pixel vector is used, deriving the predictor block by applying a 6-tap 2 dimensional interpolation filter, whose coefficients, when implemented as a separable 2-dimensional filter such that the prediction block is first filtered in one dimension (horizontal or vertical) and the resulting filtered data block is then filtered in the other dimension, are as follows: 
         [0000]    
       
         
               
               
               
               
               
               
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 2 
                 −11 
                 108 
                 36 
                 −8 
                 1 
                 (¼ pixel) 
               
               
                   
                 3 
                 −16 
                 77 
                 77 
                 −16 
                 3 
                 (½ pixel) 
               
               
                   
                 1 
                 −8 
                 36 
                 108 
                 −11 
                 2 
                 (¾ pixel) 
               
               
                   
                   
               
             
          
         
       
     
         [0083]    In another aspect of the invention, a method for inter prediction of blocks of pixels using motion vectors in a video compression algorithm is provided, having the following steps: 
         [0084]    Specifying the location of a block in a previously decoded reference frame to be used as predictor, relative to the spatial position of the block being predicted, by a two-dimensional motion vector; 
         [0085]    Specifying the motion vector to ½ or ¼ pixel precision in the luma domain and ¼ or ⅛ pixel precision in U and V; 
         [0086]    Where a fractional pixel vector is used, deriving the predictor block by applying of an interpolation filter selected from a plurality of possible filters according to the content of the data being filtered, 
         [0087]    Wherein the plurality of interpolation filters includes a 6-tap 2 dimensional interpolation filter, whose coefficients, when implemented as a separable 2-dimensional filter such that the prediction block is first filtered in one dimension (horizontal or vertical) and the resulting filtered data block is then filtered in the other dimension, are as follows: 
         [0000]    
       
         
               
               
               
               
               
               
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 2 
                 −11 
                 108 
                 36 
                 −8 
                 1 
                 (¼ pixel) 
               
               
                   
                 3 
                 −16 
                 77 
                 77 
                 −16 
                 3 
                 (½ pixel) 
               
               
                   
                 1 
                 −8 
                 36 
                 108 
                 −11 
                 2 
                 (¾ pixel) 
               
               
                   
                   
               
             
          
         
       
     
         [0088]    In either of the immediately preceding embodiments, the filter is implemented using floating point or fixed point arithmetic, or the filter may not be implemented as a separable 2 dimensional filter. One of the filters that may optionally be selected may be a 2-tap bi-linear filter, a 4-tap bi-cubic filter, or a 6-tap filter. The basis for selecting between the pluralities of possible filters may be the magnitude of the sum of inter-pixel differences. The basis for selecting between the interpolation filters may include the following steps: 
         [0089]    Defining a first sum of differences between horizontally neighboring pixels in a block; 
         [0090]    Defining a second sum of differences between vertically neighboring pixels in a block; 
         [0091]    If the first sum of differences is less than a first threshold, selecting the bi-linear filter; 
         [0092]    If the first sum of differences is greater than the first threshold but less than a second threshold, selecting the bi-cubic filter; 
         [0093]    If the first sum of differences is greater than the second threshold but less than a third threshold, selecting the 6-tap filter; 
         [0094]    If the second sum of differences is less than the first threshold, selecting the bi-linear filter; 
         [0095]    If the second sum of differences is greater than the first threshold but less than the second threshold, selecting the bi-cubic filter; 
         [0096]    If the second sum of differences is greater than the second threshold but less than the third threshold, selecting the 6-tap filter, 
         [0097]    Wherein the first, second, and third thresholds may either be derived by the encoder and the values coded in the bitstream, or have fixed values known to both encoder and decoder. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         [0098]      FIG. 1  is a schematic of an example set of 16×16 block subdivisions. 
           [0099]      FIG. 2  is a diagram showing the step-by-step generation of subdivisions. 
           [0100]      FIG. 3  is a diagram showing the preferred bin weightings for block X. 
           [0101]      FIG. 4  is a diagram showing calculations of tallies for block X. 
           [0102]      FIG. 5  is a diagram showing the relative position of previously coded pixels C, A i , and L i  and the block being predicted X ij  in the image/frame. 
           [0103]      FIG. 6  is a diagram a number of blocks including block B rc  of an image/video frame. 
           [0104]      FIG. 7  is a graph depicting the transfer function of bi-linear, bi-cubic, and the inventive 6-tap filters as gain as a function of frequency. 
       
    
    
     DESCRIPTION OF THE PREFERRED EMBODIMENTS 
       [0105]    Description will now be given of the invention with reference to the attached  FIGS. 1-7 . It should be understood that these figures are exemplary in nature and in no way serve to limit the scope of the invention, which is defined by the claims appearing herein below. 
         [0106]    Motion Modes and Masked Motion Compression. 
         [0107]      FIG. 1  is an example set of 16×16 block subdivisions. Each letter in the blocks represents a 4×4 set of pixels within a 16 by 16 block of pixels. 
         [0108]    The invention is accomplished using the logic demonstrated with the following pseudo-code. 
         [0109]    Pseudo-Code for Selecting Motion Vectors, Table 1
       Determine a set of subdivisions to test   For each sub-division
           For each labeled segment within a subdivision   
           Calculate the rate-distortion value (see Table II) for each of the following:
           1) Use the MV (motion vector) from segment left   1) Use the MV from segment above   2) Use no MV   Set segment my to the my from above that gives you the lowest rate distortion value   
           If that rate distortion value is above a preset threshold
           Find the best motion vector for the current labeled segment
               Calculate the rate distortion value for that segment   If that value &lt;less than current segment rate distortion value
                   Set segment my to best my   
                   
               Add the current segment&#39;s rate distortion value to the current subdivision&#39;s rate distortion value   
           If the current subdivision&#39;s rate distortion value is less than the best subdivision&#39;s rate distortion value yet seen
           Record each of the subdivision&#39;s best segment MVs   
               
 
         [0126]    Determining a Segment&#39;s Rate Distortion Value Table II
       Segment Rate Distortion Value=0   For each block within a segment   Rate=
           # bits to encode mode (left, above, zero, or new MV)   +# bits to encode motion vector (only for new motion vector)   +# bits to encode residual error signal the block)   
           Block Distortion=sum squared error for each pixel within the block   Block Rate Distortion Value=   Rate*Rate Factor+Distortion*Distortion Factor   Segment Rate Distortion Value=   Segment Rate Distortion Value+Block Rate Distortion Value       
 
         [0138]    Encoding the Modes Table III
       For each block within each partition
           If MV of the current block is the same as the my of the left block encode “left”   Else if MV of the current block is the same as the my of the above block encode “above”   Else if the MV of the current block is (0,0) encode “zero”   Else encode “new motion vector”   
               
 
         [0144]    This invention also covers the use of special labeling functions to create an arbitrary set of subdivisions. The goal in the design of these functions is to produce segments of different size and shape; the hope is that one of these segments will best match the moving objects on the screen and thus produce a better prediction for the current block. The current embodiment of this invention specifies a set of possible functions for use as follows:
       1. Blocks with variances within a certain threshold are given the same label   2. Blocks with average pixel intensities within a given threshold are given the same label   3. Blocks with error scores within a certain threshold are given the same label.       
 
         [0148]    The invention also covers a method for generating different subdivisions that includes picking one of the above functions and applying it multiple times with a different threshold for each desired subdivision. This method is illustrated in  FIG. 2 . 
         [0149]    The thresholds can be selected dynamically to best insure that different labeling is set up. 
         [0150]    Step 1—Calculate average pixel intensity 
         [0151]    Step 2—Assign first block label A 
         [0152]    Step 3—GO through the remaining blocks in raster order as follows: 
         [0153]    If difference between current and left block is less than threshold &amp; also less than or equal to the difference between the current and above block 
         [0154]    Assign the block the same label as the left block 
         [0155]    Else if difference between current block and the above block &lt;threshold 
         [0156]    Assign the block the same label as the above block 
         [0157]    Else 
         [0158]    Assign the block the next labeled value 
         [0159]    Step 4 Reapply with different thresholds (e.g., sample labeling thresholds of 2, 4, 9, and 15 are shown in  FIG. 2 ). 
         [0160]    Another aspect of the invention covers the ability to reuse prior transmitted motion vectors, which may not appear directly adjacent to the current block, and to use statistics on these prior transmitted motion vectors to lessen the cost of encoding new motion vectors. 
         [0161]    Motion fields tend to track real objects that move from one frame to the next. These objects typically cover more than the typical block size. There is reasonable consistency of motion vectors from one block to the next. Prior art makes use of this consistency by predicting a new motion vector from the motion vectors of the surrounding blocks and then encoding the difference between the real motion vector and the predicted motion vector. 
         [0162]    This invention covers a novel approach to encoding motion vectors that makes use of motion vectors from surrounding blocks in a way that differs from prior art. 
         [0163]    Surrounding blocks are tallied into 4 different bins:
       Bin  1  is used to tally blocks with no motion vector   Bin  2  is used to tally blocks in which the nearest motion vector appears   Bin  3  tallies blocks in which the next closest motion vector appears   Bin  4  tallies blocks that can&#39;t fit into any of the other bins.       
 
         [0168]    In the preferred embodiment the block tally is weighted by the block&#39;s closeness to the block whose motion vector is being encoded (see  FIG. 3 ). 
         [0000]    
       
         
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
           
               
                   
                   
               
             
             
               
                   
                 Set nearestMv to 0,0 
               
               
                   
                 Set nearMv to 0,0 
               
               
                   
                 For each block = 1 to 12 
               
             
          
           
               
                   
                 If mv[block]! = 0,0 
               
             
          
           
               
                   
                 nearestMv = mv[block] 
               
               
                   
                 Bin[2] += binWeighting[block] 
               
               
                   
                 Break; 
               
             
          
           
               
                   
                 Else 
               
             
          
           
               
                   
                 Bin[1] += binWeighting[block] 
               
             
          
           
               
                   
                 For each block = block to 12 
               
             
          
           
               
                   
                 If mv[block] == 0,0 
               
             
          
           
               
                   
                 Bin[1] += binWeighting[block] 
               
             
          
           
               
                   
                 Else if mv[block] == nearestMV 
               
             
          
           
               
                   
                 Bin[2] += binWeighting[block] 
               
             
          
           
               
                   
                 Else 
               
             
          
           
               
                   
                 NearMV = mv[block] 
               
               
                   
                 Bin[3] += binWeighting[block] 
               
               
                   
                 Break 
               
             
          
           
               
                   
                 For each block = block to 12 
               
             
          
           
               
                   
                 If mv[block] = 0,0 
               
             
          
           
               
                   
                 Bin[1] += binWeighting[block] 
               
             
          
           
               
                   
                 Else if mv[block] == nearestMV 
               
             
          
           
               
                   
                 Bin[2] += binWeighting[block] 
               
             
          
           
               
                   
                 Else if mv[block] = nearMV 
               
             
          
           
               
                   
                 Bin[3] += binWeighting[block] 
               
             
          
           
               
                   
                 Else 
               
             
          
           
               
                   
                 Bin[4] += binWeighting[block] 
               
               
                   
                   
               
             
          
         
       
     
         [0169]    These counts in each bin are used in a number of different ways: 
         [0170]    1) A mode is encoded which can be one of the following:
       a. No motion vector   b. Nearest motion vector   c. Next Nearest Motion Vector   d. New Motion Vector   e. Subdivided Motion Vector       
 
         [0176]    The mode refers to what motion vector is used for the block. 
         [0177]    2) The context used to encode this mode is the counts associated with the 4 bins (see ______ 
         [0178]    Using Bin Counts to Entropy Encode Modes Table IV 
         [0179]    3) The motion vector associated with the bin with the highest count is used as a prediction for a new motion vector if the mode is new motion vector. (If the bin is bin  4  then the predicted motion vector is 0,0) 
         [0180]    Using Bin Counts to Entropy Encode Modes Table IV
       A. Calculate Probability of Nearest MV mode Given Bin  1  is the size it is (see  FIG. 4 )   B. If Mode is Nearest MV   C. Shannon Encode a 1 with probability given from step A   D. Else   E. Shannon Encode a 0 with probability given from step A   F. Calculate Probability of Zero MV mode Given Bin  0  is the size it is (see  FIG. 4 )   G. If Mode is Zero MV 2   H. Shannon Encode a 1 with probability given from step F   I. Else   J. Shannon Encode a 0 with probability given from step F   K. Calculate Probability of Near MV mode Given what Bin  2  is (see  FIG. 4 )   L. If Mode is near MV   M. Shannon Encode a 1 with probability given from step K   N. Else   O. Shannon Encode a 0 with probability given from step K   P. Calculate Probability of New MV mode Given what Bin  3  is (see  FIG. 4 )   Q. If Mode is new MV   R. Shannon Encode a 1 with probability given from step P   S. Else   T. Shannon Encode a 0 with probability given from step P
           The probabilities can either be given by a straight function an example follows:   
               
 
         [0000]      Probability=BinCount[1]/30.0               Or the value to use can be calculated via a lookup table                 
         [0000]      Probability= P [BinCount[1]]Intra-Prediction 
         [0203]    The current invention defines a set of block predictors that use data from one or more previously decoded blocks to produce the closest approximation to data in the block that is being predicted. 
         [0204]    In the preferred embodiment various block sizes are used, but the invention may be applied to blocks of arbitrary size which may include, but is not limited to, the set 16×16, 8×16, 16×8, 8×8, 8×4, 4×8 and 4×4. For the purposes of description of the various prediction modes we consider the case where the block size is 4×4. The methods presented may easily be extended to arbitrary block sizes without loss of generality. 
         [0205]      FIG. 5  shows the relative position of the pixels in previously decoded blocks and those of the block that have to be predicted. In the sections that follow reference should be made to this figure. 
         [0000]    
       
         
               
               
               
               
               
               
               
             
           
               
                   
                   
               
               
                   
                 C 
                 A 0   
                 A 1   
                 A 2   
                 A 3   
                 A 4   
               
               
                   
                   
               
             
             
               
                   
                 L 0   
                 X 00   
                 X 01   
                 X 02   
                 X 03   
                   
               
               
                   
                 L 1   
                 X 10   
                 X 11   
                 X 12   
                 X 13   
               
               
                   
                 L 2   
                 X 20   
                 X 21   
                 X 22   
                 X 23   
               
               
                   
                 L 3   
                 X 30   
                 X 31   
                 X 32   
                 X 33   
               
               
                   
                   
               
             
          
         
       
     
         [0206]      FIG. 5  Relative positions of the previously decoded pixels C, Ai and L i  and the block being predicted X ij  in the image/frame. 
         [0207]    The values L i  refer to pixels in the block to the left of the current block, which is referred to as the “Left” block. Similarly, the values A i  and C refer to pixels in the blocks above the current block, which is referred to as the “Above” block. 
         [0208]    “TrueMotion” Intra-Prediction Mode One prediction mode used in the current invention is defined by the following equation to calculate 
         [0000]    
       
      
       X 
       ij 
       =L 
       i 
       +A 
       j 
       −C;  
      
     
         [0209]    “Above Predictor” Intra-Prediction Mode 
         [0000]    A further prediction mode, called the “Above Predictor”, in the current invention is defined by the following equation to calculate Xij: 
         [0000]        X   ij =( Li   −1 +2 L   i   +L   i+1 +2)/4 
         [0000]    It is essentially a weighted predictor based on previously decoded pixel values from the blocks directly above the block being predicted. As these values come from previously decoded blocks these values will be available at the decoder when required. 
         [0210]    “Left Predictor” Intra-Prediction Mode 
         [0000]    A further prediction mode, called the “Left Predictor”, in the current invention is defined by the following equation: 
         [0000]        X   ij =( Aj   −1 +2 A   j   +A   j+1 +2)/4 
         [0000]    It is essentially a weighted predictor based on previously decoded pixel values from the block to the left of the block being predicted. As these values come from previously decoded blocks these values will be available at the decoder when required. 
         [0211]    Context Based Intra-Prediction Mode Encoding 
         [0212]    The current invention embodies a new context based encoding scheme for encoding intra-prediction mode decisions. This encoding method is used to encode an intra-prediction mode for a block in cases where both the left and above block are also coded using an intra-prediction mode. 
         [0213]    As shown in  FIG. 6 , block Brc is located in the r th  block row and the c th  block column of the current image/video frame. 
         [0214]    From experiments, the intra-prediction mode of block B rc , Mode rc , is found to be closely correlated to the intra-prediction modes of blocks and B rc(1) , when intra-prediction is used for both B (r-1)c  and B r(c-1) . 
         [0215]    In the current invention both the encoder and decoder maintain a conditional probability distribution of intra-prediction modes for a particular frame. The conditional probability model, or context, consists of the intra-prediction modes used to code the blocks immediately to the left of and above the current block: 
         [0216]    Prob (MCURRENT|M LEFT =m LEFT , M ABOVE =m ABOVE ) 
         [0217]    Where M CURRENT  represents the intra-prediction mode of the current block, M ABOVE  and M LEFT  represent the modes of the two neighboring blocks and m ABOVE  and m LEFT  represent the actual mode used in the neighboring blocks. 
         [0218]    In other words, for every possible combination of intra-prediction modes that the above and left blocks may use, a probability distribution is created for the set of possible values for the current block mode. 
         [0219]    For a particular intra-predicted block the selected mode is then encoded into the bitstream as follows:
       Find the intra-prediction mode for the current block, Mode CURRENT      Determine the intra-prediction mode used by the left block, Mode LEFT      Determine the intra-prediction mode used by the above block, Mode ABOVE      Look-up the conditional probability for Mode CURRENT  for the context (Mode LEFT , Mode ABOVE ), P(Mode CURRENT |Mode LEFT , Mode ABOVE )   Use this probability to encode the mode decision using, for example, an arithmetic or Huffman coder.   In the preferred embodiment the above conditional probability distributions are used to encode each intra-prediction mode using an arithmetic encoder.       
 
         [0226]    Cost Biased Intra-Prediction Mode Selection 
         [0000]    The selection of a prediction mode to use for a particular block is commonly based solely on minimizing the prediction error as measured by some defined error metric. Many such metrics have been used in the prior art examples being the sum of absolute differences, the sum of squared differences, and the variance. 
         [0227]    The major problem with this method of selecting mode is that it does not consider the cost of encoding the prediction mode decision itself in to the bitstream, resulting in a possibly non-optimal solution. For example, if the mode that produces the smallest prediction error requires significantly more bits to encode in the bitstream than an alternative mode that has only a slightly larger prediction error, it may be better to use the alternative prediction mode to achieve a more optimal cost-compression trade-off. 
         [0228]    To overcome this problem, the current invention embodies a cost biased strategy in selecting best overall intra-prediction mode for each intra-predicted block. The basic idea is to consider the overall encoding cost of each prediction mode, including both the signaling cost of the mode choice and the cost of coding the prediction error signal, and select the intra-prediction mode with best overall efficiency. 
         [0229]    The current invention converts the cost of each prediction mode into a quantity that is added into the prediction error resulting from coding using that mode. The mode with the smallest aggregate error score is then selected. The decision process for each block involves the following steps:
       a. Find the intra-prediction mode of the block above and the block to the left, m ABOVE  and m LEFT ,   b. Find the probability distribution P(Mode CURRENT |Mode LEFT , Mode ABOVE ),   c. Use Shannon theory to convert the probability distribution to number of bits necessary to encode each prediction mode: Bits m ,   d. Calculate the error metric sum of squared differences for each prediction mode: SSD m ,
           Calculate SSD(m)+Bits(m)*C, where C is an empirical value that measures the amount of SSD per bit when the difference signal is encoded using transform coding. C is dependent upon the quantizer level and is commonly referred to as a rate distortion metric.   
           e. The Intra-prediction mode resulting in the smallest value in step (e) is then chosen.       
 
         [0236]    6. Frame Adaptive Intra-Prediction Entropy Encoding 
         [0000]    The content of video changes from frame to frame, which means the probability distribution described in sections 4 and 5 could change accordingly. The actual probability distribution of each video frame provides the best coding efficiency for that frame. 
         [0237]    However, any updating of such a distribution involves an overhead cost of transmitting the updates in the compressed bitstream. The current invention presents a method to determine when an update is appropriate. 
         [0238]    The process proceeds as follows:
       a) Remember the conditional mode probability distribution for the previous frame, or known baseline if no previous frame exists, P PREVIOUS ,   b) Count the number of times each mode is selected in the current frame to produce the conditional mode probability distribution for the current frame, P CURRENT ,   c) Encode all modes using the previous frame probability distribution, resulting in B PREVIOUS  bits,   d) Encode all modes using the current frame probability distribution, resulting in B CURRENT  bits,   e) Calculate the number of bits required to update the probability distribution from that used for the previous frame and that computed from the current frame, B UPDATE ,   f) If (B CURRENT +B UPDATE )&lt;B PREVIOUS  then it is cost effective to transmit the update and use it to encode modes in the current frame. Otherwise, use the existing mode probability distribution.       
 
         [0245]    Sub-Pixel Filtering 
         [0000]    A two-dimensional motion vector specifies the location, relative to the spatial position of the block being predicted, of the block in a previously decoded reference frame to be used as predictor. A decoded prediction error signal is subsequently added to the prediction block to create the final reconstructed block. 
         [0246]    Motion vector components are specified to ¼ sample accuracy for luma blocks, the vector for the corresponding chroma blocks is derived from this. In the preferred embodiment the YUV 4:2:0 color space is used as the internal coding format. In this format the distance between two chroma samples is twice that of the distance between luma samples. Consequently, if the luma components of a motion vector are specified to ¼ sample accuracy, then the chroma components are at ⅛ th  sample values. 
         [0247]    To handle all cases a separate filter is specified for each of the eight ⅛ th  sample positions, i.e. at positions {0, ⅛, ¼, ⅜, ½, ⅝, ¾, ⅞} between pixels. The first of these positions is, trivially, the position of the pixel value itself and requires no interpolation. 
         [0248]    In order to generate the values at fractional locations between pixels, some form of interpolation process is applied. The preferred embodiment specifies an interpolation algorithm that employs a set of separable two-dimensional filters. 
         [0249]    For each inter-coded luma block that has a non-zero motion vector, data from the reference frame at a location relative to the current block as specified by the non-fractional part of the motion vector is first filtered horizontally to produce the fractional horizontal position data. The resulting data is then filtered vertically to produce the required result. Applying the vertical filter before the horizontal is equally valid, but may produce different results. In each case the particular filter used is determined by the fractional part of the motion vector component. For example, if the motion vector were (4½, ¾) then the horizontal and vertical filters corresponding to the ½ and ¾ positions would be used, respectively. 
         [0250]    Negative motion vector components require slightly different selection. For example, the component −3¾ actually lays ¼ of the way between the two pixel positions and so requires selection of the ¼ position filter. 
         [0251]    In the preferred embodiment three families of filter are used as follows:
       Two-tap bi-linear filter (see Table V),   Four tap bi-cubic filter (alpha=−0.5) (see Table VI)   6-tap filter (see Table VII)       
 
         [0000]    
       
         
               
               
               
               
             
               
               
               
               
             
           
               
                   
                   
               
               
                   
                 Position/Tap 
                 t 0   
                 t 1   
               
               
                   
                   
               
             
             
               
                   
               
             
          
           
               
                   
                 0 
                 128 
                 0 
               
               
                   
                 ⅛ 
                 112 
                 16 
               
               
                   
                 ¼ 
                 96 
                 32 
               
               
                   
                 ⅜ 
                 80 
                 48 
               
               
                   
                 ½ 
                 64 
                 64 
               
               
                   
                 ⅝ 
                 48 
                 80 
               
               
                   
                 ¾ 
                 32 
                 96 
               
               
                   
                 ⅞ 
                 16 
                 112 
               
               
                   
                   
               
             
          
         
       
     
         [0000]    
       
         
               
             
               
               
               
               
               
               
             
               
               
               
               
               
               
             
           
               
                 TABLE 5 
               
             
             
               
                   
               
               
                 Coefficients of the 2-tap Bi-linear Filter (Normalized to 128) 
               
             
          
           
               
                   
                 Position/Tap 
                 t −1   
                 t 0   
                 t 1   
                 t 2   
               
               
                   
                   
               
             
          
           
               
                   
                 0 
                 0 
                 128 
                 0 
                 0 
               
               
                   
                 ⅛ 
                 −6 
                 123 
                 12 
                 −1 
               
               
                   
                 ¼ 
                 −9 
                 111 
                 29 
                 −3 
               
               
                   
                 ⅜ 
                 −9 
                 93 
                 50 
                 −6 
               
               
                   
                 ½ 
                 −8 
                 72 
                 72 
                 −8 
               
               
                   
                 ⅝ 
                 −6 
                 50 
                 93 
                 −9 
               
               
                   
                 ¾ 
                 −3 
                 29 
                 111 
                 −9 
               
               
                   
                 ⅞ 
                 −1 
                 12 
                 123 
                 −6 
               
               
                   
                   
               
             
          
         
       
     
         [0000]    
       
         
               
             
               
               
               
             
               
               
               
               
               
               
               
               
             
               
               
               
               
               
               
               
               
             
           
               
                 TABLE 7 
               
             
             
               
                   
               
               
                 Coefficients of the 6-tap Filter (Normalized to 128) 
               
             
          
           
               
                   
                 Tap 
                   
               
             
          
           
               
                   
                 Position 
                 t −2   
                 t −1   
                 t 0   
                 t 1   
                 t 2   
                 t 3   
               
               
                   
                   
               
             
          
           
               
                   
                 0 
                 0 
                 0 
                 128 
                 0 
                 0 
                 0 
               
               
                   
                 ⅛ 
                 0 
                 −6 
                 123 
                 12 
                 −1 
                 0 
               
               
                   
                 ¼ 
                 2 
                 −11 
                 108 
                 36 
                 −8 
                 1 
               
               
                   
                 ⅜ 
                 0 
                 −9 
                 93 
                 50 
                 −6 
                 0 
               
               
                   
                 ½ 
                 3 
                 −16 
                 77 
                 77 
                 −16 
                 3 
               
               
                   
                 ⅝ 
                 0 
                 −6 
                 50 
                 93 
                 −9 
                 0 
               
               
                   
                 ¾ 
                 1 
                 −8 
                 36 
                 108 
                 −11 
                 2 
               
               
                   
                 ⅞ 
                 0 
                 −1 
                 12 
                 123 
                 −6 
                 0 
               
               
                   
                   
               
             
          
         
       
     
         [0255]    In the tables, each row specifies a set of filter taps for the generation of the specified ⅛th pixel position. The taps are applied to a contiguous set of pixels in the appropriate direction, horizontal or vertical, such that the taps t 0  and t 1  are applied to the pixels closest to the fractional position being interpolated. All of the filters are normalized to 128 to permit integer only implementation. After the application of the filter the values are re-normalized and clipped back to the range 0 to 255. 
         [0256]    The bi-linear filter is the simplest to implement but can produces result that appear blurred due to its narrow pass-band. This filter is used in areas of low variation to suppress noise and reduce any coding artifact that may be present. 
         [0257]    The alpha=−0.5 bi-cubic filter is a reasonable compromise 4-tap filter. It produces sharper results than the bilinear filter without introducing ringing artifacts since it has sub-unit gain throughout the entire frequency spectrum. 
         [0258]    The first two filters both exist as prior art and have been extensively used. The six-tap filter, however, forms part of the current invention. The filter taps were derived to produce the widest possible pass-band in the transfer function, whilst containing virtually no above unit gain throughout the frequency spectrum. 
         [0259]      FIG. 7  plots the transfer functions for all three-filter families at the ½ pixel position. 
         [0260]      FIG. 7  Transfer Function of Bi-Linear, Bi-Cubic and on 2 6-Tap Filters. 
         [0000]    The selection of which filter family to use for a particular block is based on the content of the data being filtered. In a preferred embodiment, the magnitude of the sum of inter-pixel differences in the direction that the filter is to be applied is used to select between filter types as follows: 
         [0000]    
       
         
               
             
               
               
             
               
             
               
               
             
               
             
               
               
             
               
             
               
               
             
               
             
               
               
             
               
             
               
               
             
           
               
                   
               
             
             
               
                 HDiff = Sum of differences between horizontally neighboring pixels in 
               
               
                 block; 
               
               
                 VDiff = Sum of differences between vertically neighboring pixels in 
               
               
                 block; 
               
               
                 If (HDiff &lt; T 0 ) 
               
             
          
           
               
                   
                 HFilter = Bi-Linear Filter; 
               
             
          
           
               
                 Else if (HDiff &lt; T 1 ) 
               
             
          
           
               
                   
                 Filter = Bi-Cubic Filter; 
               
             
          
           
               
                 Else if (HDiff &lt; T 2 ) 
               
             
          
           
               
                   
                 HFilter = 6-tap Filter; 
               
             
          
           
               
                 If (VDiff &lt; T 0 ) 
               
             
          
           
               
                   
                 VFilter = Bi-Linear Filter; 
               
             
          
           
               
                 Else if (VDiff &lt; T 1 ) 
               
             
          
           
               
                   
                 VFilter = Bi-Cubic Filter; 
               
             
          
           
               
                 Else if (VDiff &lt; T 2 ) 
               
             
          
           
               
                   
                 VFilter = 6-tap Filter; 
               
               
                   
                   
               
             
          
         
       
     
         [0261]    Where the thresholds T 0 , T 1 , and T 2  may either be derived by the encoder and the values coded in the bitstream, or have fixed values known to both encoder and decoder. 
         [0262]    Output from the filter is positioned at its center in the sense that, for a length N filter (where N is even), the first N/2 filter taps are multiplied by the N/2 pixels directly to the left of (or above) the position being interpolated, and the final N/2 taps multiplied by the N/2 pixels directly to the right of (or below) the position being interpolated. The final output value is the sum of these N products, appropriately rounded and normalized. 
         [0263]    It should be noted that pixels outside of the block are used during the filtering process since the filter extends beyond the bounds of the block boundary at either end. To this end the reference frame must be padded beyond its boundary by repeating the value of the edge pixel as required. 
         [0264]    The filtering process is summarized by the following pseudo-code. The pseudo-code makes the assumption that the filter is 6-tap. Smaller filters must be padded with zeros and have the coefficients centered, e.g. the two-tap and four-tap filters are specified as {0, 0, t0, t1, 0, 0} and {0, t−1, t0, t1, t2, 0}, respectively: 
         [0000]    
       
         
               
               
               
             
               
               
             
               
               
             
               
             
               
               
               
             
               
             
               
               
               
             
               
               
               
             
               
               
               
             
               
             
               
               
               
             
               
               
             
               
               
             
               
               
             
               
             
               
               
             
               
             
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
             
               
             
               
               
             
               
             
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
             
               
               
               
             
               
               
               
             
               
               
             
               
             
           
               
                   
               
             
             
               
                 #define FILTER_WEIGHT 
                 128 
                 // Sum of the filter taps 
               
             
          
           
               
                 #define FILTER_SHIFT 
                 7 // Number of bits to shift output from 
               
             
          
           
               
                   
                 // filter by to effect normalization 
               
             
          
           
               
                 void FilterBlock2d 
               
               
                 ( 
               
             
          
           
               
                   
                  unsigned char *SrcPtr, 
                 // Pointer to prediction block data in reference 
               
             
          
           
               
                 frame 
               
             
          
           
               
                   
                  unsigned char *OutputPtr, 
                 // Pointer to output block being interpolated 
               
             
          
           
               
                   
                 int SrcPixelsPerLine, 
                 // Number of pixels in input &amp; output line 
               
             
          
           
               
                   
                 short *HFilter, 
                 // Pointer to array containing 6-tap Horizontal Filter 
               
               
                   
                 short *VFilter 
                 // Pointer to array containing 6-tap Vertical Filter 
               
             
          
           
               
                 ) 
               
               
                 { 
               
             
          
           
               
                   
                  int FData[9*4]; 
                 // Temp data bufffer used in filtering 
               
             
          
           
               
                   
                 // Note: SrcPtr points to the block of pixels in the prediction frame 
               
               
                   
                 // that the non-fractional part of the motion vector indicates. 
               
               
                   
                  // Step 1: Filter block horizontally using specified filter: 
               
               
                   
                  FilterBlockHorizontally ( SrcPtr-(2*SrcPixelsPerLine), SrcPixelsPerLine, 
               
             
          
           
               
                   
                 FData, 9, 4, HFilter ); 
               
             
          
           
               
                   
                  // Step 2: Filter block vertically using specified filter: 
               
               
                   
                  FilterBlockVertically ( FData+8, 4, OutputPtr, 4, 4, VFilter ); 
               
             
          
           
               
                 } 
               
               
                 void FilterBlockHorizontally 
               
               
                 ( 
               
             
          
           
               
                   
                 unsigned char *SrcPtr, 
               
               
                   
                 int SrcPixelsPerLine, 
               
               
                   
                 int *OutputPtr, 
               
               
                   
                 int OutputHeight, 
               
               
                   
                 int OutputWidth, 
               
               
                   
                 int *Filter 
               
             
          
           
               
                 ) 
               
               
                 { 
               
             
          
           
               
                   
                 int i, j; 
               
               
                   
                  int Temp; 
               
               
                   
                 for ( i=0; i&lt;OutputHeight; i++ ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 for ( j=0; j&lt;OutputWidth; j++ ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 // Apply filter: 
               
             
          
           
               
                   
                 Temp = 
                 ((int)SrcPtr[−2] * Filter[0]) + 
               
             
          
           
               
                   
                 ((int)SrcPtr[−1] * Filter[1]) + 
               
               
                   
                 ((int)SrcPtr[ 0] * Filter[2]) + 
               
               
                   
                 ((int)SrcPtr[ 1] * Filter[3]) + 
               
               
                   
                 ((int)SrcPtr[ 2] * Filter[4]) + 
               
               
                   
                 ((int)SrcPtr[ 3] * Filter[5]); 
               
             
          
           
               
                   
                 // Add in the rounding value based on filter-tap sum: 
               
               
                   
                 Temp += (FILTER_WEIGHT &gt;&gt; 1); 
               
               
                   
                 // Normalize output to range 0-255: 
               
               
                   
                 Temp = Temp &gt;&gt; FILTER_SHIFT; 
               
               
                   
                 if ( Temp &lt; 0 ) 
               
             
          
           
               
                   
                 Temp = 0; 
               
             
          
           
               
                   
                 else if ( Temp &gt; 255) 
               
             
          
           
               
                   
                 Temp = 255; 
               
             
          
           
               
                   
                 // Store output value: 
               
               
                   
                 OutputPtr[j] = Temp; 
               
               
                   
                 SrcPtr++; 
               
             
          
           
               
                   
                   } 
               
               
                   
                   // Move to start of next row: 
               
             
          
           
               
                   
                 SrcPtr 
                 += SrcPixelsPerLine − OutputWidth; 
               
               
                   
                 OutputPtr 
                 += OutputWidth; 
               
             
          
           
               
                   
                  } 
               
             
          
           
               
                 } 
               
               
                 void FilterBlockVertically 
               
               
                 ( 
               
             
          
           
               
                   
                 int *SrcPtr, 
               
               
                   
                 int SrcPixelsPerLine, 
               
               
                   
                 unsigned char *OutputPtr, 
               
               
                   
                 int OutputHeight, 
               
               
                   
                 int OutputWidth, 
               
               
                   
                 int *Filter 
               
             
          
           
               
                 ) 
               
               
                 { 
               
             
          
           
               
                   
                  int i, j; 
               
               
                   
                  int Temp; 
               
               
                   
                 for ( i=0; i&lt;OutputHeight; i++ ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 for ( j=0; j&lt;Output Width; j++ ) 
               
               
                   
                 { 
               
             
          
           
               
                   
                 // Apply filter: 
               
             
          
           
               
                   
                 Temp = 
                 ((int)SrcPtr[−2*SrcPixelsPerLine] * Filter[0]) + 
               
             
          
           
               
                   
                 ((int)SrcPtr[−1*SrcPixelsPerLine] * Filter[1]) + 
               
               
                   
                 ((int)SrcPtr[ 0*SrcPixelsPerLine] * Filter[2]) + 
               
               
                   
                 ((int)SrcPtr[ 1*SrcPixelsPerLine] * Filter[3]) + 
               
               
                   
                 ((int)SrcPtr[ 2*SrcPixelsPerLine] * Filter[4]) + 
               
               
                   
                 ((int)SrcPtr[ 3*SrcPixelsPerLine] * Filter[5]); 
               
             
          
           
               
                   
                 // Add in the rounding value based on filter-tap sum: 
               
               
                   
                 Temp += (FILTER_WEIGHT &gt;&gt; 1); 
               
               
                   
                 // Normalize output to range 0-255: 
               
               
                   
                 Temp = Temp &gt;&gt; FILTER_SHIFT; 
               
               
                   
                 if ( Temp &lt; 0 ) 
               
             
          
           
               
                   
                 Temp = 0; 
               
             
          
           
               
                   
                 else if ( Temp &gt; 255 ) 
               
             
          
           
               
                   
                 Temp = 255; 
               
             
          
           
               
                   
                 // Store output value: 
               
               
                   
                 OutputPtr[j] = (unsigned char)Temp; 
               
               
                   
                 SrcPtr++; 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                   
                  // Move to start of next row: 
               
             
          
           
               
                   
                  SrcPtr 
                 += SrcPixelsPerLine − OutputWidth; 
               
             
          
           
               
                   
                  OutputPtr 
                 += OutputWidth; 
               
             
          
           
               
                   
                 } 
               
             
          
           
               
                 } 
               
               
                   
               
             
          
         
       
     
         [0265]    Having described the invention, it is to be understood that the invention is defined not by the above description but by the claims appearing herein below. Various modifications that may be made by one of ordinary skill in the art are considered to be within the scope of the invention.