… for Codecs & Media
Tip #919: What is a Macroblock?
H.264 compression tracks macroblocks rather than pixels to create smaller files.
Macroblocks are at the heart of MPEG and H.264 video compression. But, what is a Macroblock?
In order to get the smallest possible files when compressing into H.264, the image is divided into “macroblocks.” (HEVC uses something similar, called a “coding tree unit.”)
Wikipedia describes a macroblock as typically consisting of 16×16 pixels, which forms a processing unit in image and video compression formats based on linear block transforms, typically the discrete cosine transform (DCT). (DCT is used in JPEG, MPEG and H.264 compression.)
A macroblock is divided further into transform blocks. Transform blocks have a fixed size of 8×8 samples. In the YCbCr color space with 4:2:0 chroma subsampling, a 16×16 macroblock consists of 16×16 luma (Y) samples and 8×8 chroma (Cb and Cr) samples. These samples are split into four Y blocks, one Cb block and one Cr block.
The reason macroblocks are important is that when media is encoded, the compression tracks the location of each macroblock from one frame to the next, rather than the full pixel data. This reduces the size of the file significantly, but at the cost of a loss of color information.