{{Short description|Processing unit in image and video compression formats}} The '''macroblock''' is a processing unit in image and video compression formats based on linear block transforms, typically 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.<ref name=H261>{{cite web |author=ITU-T |url=http://www.itu.int/rec/T-REC-H.261 |date=March 1993 |access-date=2013-04-28 |title=Video codec for audiovisual services at p x 64 kbit/s}}</ref><ref name=H262>{{cite web |author=ITU-T |url=http://www.itu.int/rec/T-REC-H.262 |date=February 2012 |access-date=2013-04-28 |title=Advanced video coding for generic audiovisual services}}</ref><ref name=H263>{{cite web |author=ITU-T |url=http://www.itu.int/rec/T-REC-H.263 |date=January 2005 |access-date=2013-04-28 |title=Video coding for low bit rate communication}}</ref><ref name=H264>{{cite web |author=ITU-T |url=http://www.itu.int/rec/T-REC-H.264 |date=April 2013 |access-date=2013-04-28 |title=Information technology — Generic coding of moving pictures and associated audio information: Video}}</ref> In H.265/HEVC, the macroblock as a basic processing unit has been replaced by the coding tree unit.<ref name=OverviewHEVCIEEE2012>{{cite news |title=Overview of the High Efficiency Video Coding (HEVC) Standard |author=G.J. Sullivan |author2=J.-R. Ohm |author3=W.-J. Han |author4=T. Wiegand |author4-link=Thomas Wiegand |publisher=IEEE Transactions on Circuits and Systems for Video Technology |url=http://iphome.hhi.de/wiegand/assets/pdfs/2012_12_IEEE-HEVC-Overview.pdf |format=PDF |date=2012-05-25 |access-date=2013-04-26}}</ref>
==Technical details==
===Transform blocks=== A macroblock is divided into transform blocks, which serve as input to the linear block transform, e.g. the DCT. In H.261, the first video codec to use macroblocks, transform blocks have a fixed size of 8×8 samples.<ref name=H261/> 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. This design is also used in JPEG and most other macroblock-based video codecs with a fixed transform block size, such as MPEG-1 Part 2 and H.262/MPEG-2 Part 2. In other chroma subsampling formats, e.g. 4:0:0, 4:2:2, or 4:4:4, the number of chroma samples in a macroblock will be smaller or larger, and the grouping of chroma samples into blocks will differ accordingly.
In more modern macroblock-based video coding standards such as H.263 and H.264/AVC, transform blocks can be of sizes other than 8×8 samples. For instance, in H.264/AVC main profile, the transform block size is 4×4.<ref name=H264/> In H.264/AVC High profile, the transform block size can be either 4×4 or 8×8, adapted on a per-macroblock basis.<ref name=H264/>
===Prediction blocks=== Distinct from the division into transform blocks, a macroblock can be split into prediction blocks. In early standards such as H.261, MPEG-1 Part 2, and H.262/MPEG-2 Part 2, motion compensation is performed with one motion vector per macroblock.<ref name=H261/><ref name=H262/> In more modern standards such as H.264/AVC, a macroblock can be split into multiple variable-sized prediction blocks, called partitions.<ref name=H264/> In an inter-predicted macroblock in H.264/AVC, a separate motion vector is specified for each partition.<ref name=H264/> Correspondingly, in an intra-predicted macroblock, where samples are predicted by extrapolating from the edges of neighboring blocks, the predicted direction is specified on a per-partition basis.<ref name=H264/> In H.264/AVC, prediction partition size ranges from 4×4 to 16×16 samples for both inter-prediction (motion compensation) and intra-prediction.<ref name=H264/>
==Bitstream representation== A possible bitstream representation of a macroblock in a video codec which uses motion compensation and transform coding is given below.<ref name="D-Marshall">{{cite web |url=http://www.cs.cf.ac.uk/Dave/Multimedia/node248.html |title=Intra Frame Coding |last=Marshall |first=Dave |date=2001-04-10 |access-date=2014-02-13 |work=Multimedia Module No: CM0340}}</ref> It is similar to the format used in H.261.<ref name=H261/> <pre> +------+------+-------+--------+-----+----+----+--------+ | ADDR | TYPE | QUANT | VECTOR | CBP | b0 | b1 | ... b5 | +------+------+-------+--------+-----+----+----+--------+ </pre> * 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)
==Macroblocking== {{Main|Compression artifact}} The term ''macroblocking'' is commonly used to refer to block coding artifacts.
==See also== * 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 * Pixelation
==References== <references/>
{{Compression methods}}
Category:Video compression Category:Image compression Category:Data compression