PAFF 和MBAFF:当对隔行扫描图像进行编码时,每帧包括两个场,由于两个场之间存在较大的扫描间隔,这样,对运动图像来说,帧中相邻两行之间的空间相关性相对于逐行扫描时就会减小,因此这时对两个场分别进行编码会更节省码流。对帧来说,存在三种可选的编码方式:将两场合并作为一帧进行编码(frame 方式)或将两场分别编码(field 方式)或将两场合并起来作为一帧,但不同的是将帧中垂直相邻的两个宏块合并为宏块对进行编码;前两种称为PAFF 编码,对运动区域进行编码时field 方式有效,对非运区域编码时,由于相邻两行有较大的相关性,因而frame 方式会更有效。当图像同时存在运动区域和非运动区域时,在MB 层次上,对运动区域采取field 方式,对非运动区域采取frame 方式会更加有效,这种方式就称为MBAFF,预测的单位是宏块对。
在隔行扫描帧中,当有移动的对象或摄像机移动时,与逐行相比,两个相邻行倾向减少统计的相关性,这种情况应比每场分别压缩更为有效。为了达到高效率,H.264/AVC在编码帧时,有以下可选方案:
● 结合两场成一个完整帧,作为帧编码,称为帧模式。
● 两场分别编码,称为场模式。
● 结合两场成一个完整帧,作为帧压缩。在编码时,划分垂直相邻的两个宏块对成两个场宏块对或帧宏块,再进行编码。
每帧图像可自适应选择3种模式之一进行编码。在前两种之间进行选择称为图像自适应帧/场编码(PAFF),当一帧作为两场编码时,每场划分为宏块,编码方式与帧编码方式很相似,主要有下面的例外:
● 运动补偿用参考场,而不是参考帧。
● 变换系数的“之字型”扫描方式不同。
● 宏块水平边沿去块滤波器的强度不选用“强”,因为场行在空间上是两倍帧行的距离。
在研制H.264/AVC标准时,据报道,采用ITU-601分辨率,PAFF编码技术与帧编码相比可减少码率16%到20%。
如果图像由运动区和非运动区混合组成,非运动区用帧模式、运动区用场模式是最有效的编码方法。因此每个垂直宏块对(16×32)可独立选择编码(帧/场)模式。这种编码选择称为宏块自适应帧/场编码(MBAFF)。对于帧模式宏块对,每个宏块包含帧行,对于场模式宏块对,顶部宏块包含顶场行,底部宏块包含底场行。
处理场宏块对的每个宏块与帧PAFF模式相似,然而,因为在MBAFF帧中发生场/帧宏块对混合,需要修改用作下列用途的方法:
● 之字型扫描。
● 运动矢量预测。
● 帧内预测模式的预测。
● 帧内预测帧采样精度。
● 去块效应滤波器。
● 上下文模型的熵编码。
主要思想是尽可能保留多的空间一致性,MBAFF帧的空间相邻的规范相当复杂,下面讲到的空间相邻都是指非MBAFF帧。
MBAFF 和PAFF的另一个重要区别是:使用MBAFF方法,一个场不能使用同一帧的另一个场中的宏块作为运动补偿参考。这样,有时PAFF比MBAFF编码更有效,特别是在快速全局运动、变换场景、图像刷新等情况下。
在开发MBAFF标准期间,据报道,采用ITU-601分辨率,MBAFF编码技术比PAFF相比可减少码率14%到16%。
Macroblock-Adaptive Frame/Field Coding
MBAFF, or Macroblock-Adaptive Frame/Field Coding, is a video encoding feature of MPEG-4 AVC that allows a single frame to be encoded partly progressive and partly interlaced. Maintaining the quality of interlaced video can be a challenge in video encoding because of the larger spaces between horizontal lines in the same field. MBAFF allows an AVC encoder to examine each block in a frame to look for similarities between interlaced fields. When there is no motion the fields will tend to be very similar, resulting in better quality if you encode the block as progressive video. For blocks where there is motion from one field to another the quality is more likely to suffer if encoded progressive, so these blocks can remain interlaced.
In addition to quality improvements, progressive frames require fewer bits making them more compressible for the same quality as interlaced frames. This also applies to individual macroblocs, meaning that by using MBAFF you may greatly improve quality for a given bitrate. Since all the decisions required for MBAFF are made by the encoder it can slow encoding speeds greatly. Being a relatively new technology it's also not supported well among AVC playback software. Unlike many of AVC's advance features, though, MBAFF doesn't affect decoder speed.