Macroblock is a processing unit in image and video compression formats based on linear block transforms, such as the discrete cosine transform (DCT). A macroblock typically consists of 16×16 samples, and is further subdivided into transform blocks, and may be further subdivided into prediction blocks. Formats which are based on macroblocks include JPEG, where they are called MCU blocks, H.261, MPEG-1 Part 2, H.262/MPEG-2 Part 2, H.263, MPEG-4 Part 2, and H.264/MPEG-4 AVC. In H.265/HEVC, the macroblock as basic processing unit been replaced by the coding tree unit.
How transform blocks are combined to form a macroblock is a design choice which is influenced by transform block size, whether the content is progressive or interlaced, and the chroma subsampling format. Early designs such as H.261 exclusively operated on YCbCr data with 4:2:0 chroma subsampling and a fixed transform block size of 8×8. In that case, 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. This basic design is also used in most macroblock-based video coding formats and in JPEG. For other chroma subsampling formats, e.g. 4:0:0, 4:1:1, 4:2:2 or 4:4:4, different groupings of pixels into transform blocks are necessary.
More modern macroblock based codecs such as H.263 and H.264/AVC allow the use of transform blocks sizes other than 8×8 samples. For instance, in the H.264/AVC main profile, the transform block size is 4×4. Further possible is a macroblock-adaptive transform size, as in H.264/AVC High profile, where 8×8 and 4×4 transform size can be switched on a macroblock level.
In addition to segmenting a macroblock into transform blocks, a macroblock can also be segmented into multiple prediction blocks. In early standards such as H.261 and H.262/MPEG-2 Part 2, motion compensation was performed on a macroblock-level. In more modern standards such as H.264/AVC, a macroblock is split into variable-sized partitions for the purpose of prediction and motion compensation. In H.264/AVC, prediction partition size ranges from 4×4 to 16×16 pixels.
+------+------+-------+--------+-----+----+----+--------+ | ADDR | TYPE | QUANT | VECTOR | CBP | b0 | b1 | ... b5 | +------+------+-------+--------+-----+----+----+--------+
- ADDR - address of block in image
- TYPE - identifies type of macroblock (intra frame, inter frame, bi-directional inter frame)
- QUANT - quantization value to vary quantization
- VECTOR - motion vector
- CBP - Coded Block Pattern, this is bit mask indicating for which blocks coefficients are present.
- bN - the blocks (4 Y, 1 Cr, 1 Cb)
At low bit rates, any lossy block-based coding scheme introduces visible artifacts in pixel blocks and at block boundaries. These boundaries can be transform block boundaries, prediction block boundaries, or both, and may coincide with macroblock boundaries. Bitstream errors, which can be caused by transmission errors, lead to incorrectly decoded macroblocks. The term macroblocking can refer to any of these effects. Other names for macroblocking include tiling, mosaicing, pixelating, quilting, and checkerboarding.
Block-artifacts are a result of the very principle of block transform coding. The transform (for example the discrete cosine transform) is applied to a block of pixels, and to achieve lossy compression, the transform coefficients of each block are quantized. The lower the bit rate, the more coarsely the coefficients are represented and the more coefficients are quantized to zero. Statistically, images have more low-frequency than high-frequency content, so it is the low-frequency content that remains after quantization, which results in blurry, low-resolution blocks. In the most extreme case only the DC-coefficient, that is the coefficient which represents the average color of a block, is retained, and the transform block is only a single color after reconstruction.
Because this quantization process is applied individually in each block, neighboring blocks quantize coefficients differently. This leads to discontinuities at the block boundaries. These are most visible in flat areas, where there is little detail to mask the effect.
Artifacts can occur at edges of motion compensation prediction blocks. In motion compensated video compression, the current picture is predicted by shifting blocks (macroblocks, partitions, or prediction units) of pixels from previously decoded frames. If two neighboring blocks use different motion vectors, there will be a discontinuity at the edge of the two blocks.
Artifacts at block boundaries can be reduced by applying a deblocking filter. If the deblocking filter is applied only at the decoder, it is a form of post-processing. Consumer equipment often calls this post-processing "MPEG Noise Reduction". Alternatively, the deblocking filter can be applied both at the decoder and at the encoder. The deblocked picture is then used as a reference picture for motion compensation, which improves coding efficiency by preventing a propagation of block artifacts across frames. This is referred to as an in-loop deblocking filter. Standards which specify an in-loop deblocking filter include VC-1, H.263 Annex J, H.264/AVC, and H.265/HEVC. The removal of artifacts which are caused by bit-stream errors is a form of error concealment.
- JPEG, H.261, MPEG-1 Part 2, H.262/MPEG-2 Part 2, H.263 and H.264
- Coding tree unit
- Discrete cosine transform
- Video compression picture types
- Compression artifact
- Deblocking filter
- ITU-T (1993-03). "Video codec for audiovisual services at p x 64 kbit/s". Retrieved 2013-04-28.
- ITU-T (2012-02). "Advanced video coding for generic audiovisual services". Retrieved 2013-04-28.
- ITU-T (2005-01). "Video coding for low bit rate communication". Retrieved 2013-04-28.
- ITU-T (2013-04). "Information technology - Generic coding of moving pictures and associated audio information: Video". Retrieved 2013-04-28.
- G.J. Sullivan; J.-R. Ohm; W.-J. Han; T. Wiegand (2012-05-25). "Overview of the High Efficiency Video Coding (HEVC) Standard" (PDF). IEEE Transactions on Circuits and Systems for Video Technology. Retrieved 2013-04-26.
- Intra Frame Coding
- The MPEG handbook by John Watkinson.
- "PC Magazine, Definition of blocking artifacts".