由于FRUC复杂度过高,目前还未被写入标准,所以这篇博客的标题头为H266/JEM以示区别。
实际上是一种基于帧率上变换的特殊Merge模式,编码端不传输运动信息,仅仅传输一个标志位Flag,解码端通过某种运算导出运动信息。分为两个方法:双向匹配(bilateral matching,简称BM)和模板匹配(template matching,简称TM)。
双向匹配主要通过在两个不同参考图片中,沿着当前CU的运动轨迹找到两个块之间最匹配的运动信息来导出当前CU的MV。
假设运动是连续的,那么指向两个参考块的运动矢量MV0和MV1应该是和时域距离成正比的,(TD0和TD1,当前帧与两个参考帧之间时域距离,即POC之间的差值)。最特殊的情况,当TD0=TD1时,当前帧正好在两个参考帧的正中间,那么双向匹配也就变成了基于双向MV的镜像(即MV0和MV1大小相等,方向相反)。
模板匹配主要通过在当前帧的template(当前块的上方和左方相邻块)和参考帧的编码块(大小尺寸与template相同)中找到最匹配的块。
TM除了应用到FRUC模式中,还被使用在AMVP模式里面。在HEVC中,AMVP列表长度为2,通过TM获取的MV如果与AMVP列表中的MV不同,那么该MV被插入到AMVP列表的首位(即AMVP中的第二位被移出列表)。当TM应用于AMVP时,只使用CU级别的搜索。
FRUC模式中的运动信息获取主要分为两个步骤,CU级和Sub-CU级。
在CU级别,先获得整个WxH大小的CU的MV(通过TM或BM获得);Sub-CU级别,再搜索得到Sub-CU的MV。
如果使用BM方法,那么在假设运动是连续的前提条件下,通过候选列表中的有效MV来生成一对MV(???没太懂);例如,候选列表中的一个有效MV为reference list A中的(MVa, refa),那么与其配对的MV将在reference list B中的参考帧refb中找到,这样可以保证refa和refb时域上在当前帧的不同方向。如果reference list B中找不到这样的refb,那么refb被判定为与refa不同的参考帧,且它与当前帧的时域距离是reference list B中最小的(???没懂)。当refb确定之后,MVb通过将MVa进行scaling得到。
(原文:When using bilateral matching, each valid MV of a merge candidate is used as an input to generate a MV pair with the assumption of bilateral matching. For example, one valid MV of a merge candidate is (MVa, refa) at reference list A. Then the reference picture refb of its paired bilateral MV is found in the other reference list B so that refa and refb are temporally at different sides of the current picture. If such a refb is not available in reference list B, refb is determined as a reference which is different from refa and its temporal distance to the current picture is the minimal one in list B. After refb is determined, MVb is derived by scaling MVa based on the temporal distance between the current picture and refa, refb.
)
Before coding a frame, interpolated motion field is generated for the whole picture based on unilateral ME. Then the motion field may be used later as CU level or sub-CU level MV candidates.
First, the motion field of each reference pictures in both reference lists is traversed at 4×4 block level. For each 4×4 block, if the motion associated to the block passing through a 4×4 block in the current picture (as shown in Figure 21) and the block has not been assigned any interpolated motion, the motion of the reference block is scaled to the current picture according to the temporal distance TD0 and TD1 (the same way as that of MV scaling of TMVP in HEVC) and the scaled motion is assigned to the block in the current frame. If no scaled MV is assigned to a 4×4 block, the block’s motion is marked as unavailable in the interpolated motion field.
当MV指向一个分像素样点位置时,那么运动补偿需要插值(因为MV指向的参考块没有准确落在每一个像素点上)。
不同阶段的matching cost不相同
FRUC模式中,仅仅通过luma获得的MV应用于Luma和Chroma。当MV确定之后,最终MC通过8-taps和4-taps插值滤波器进行。
MV refinement is a pattern based MV search with the criterion of bilateral matching cost or template matching cost. In the JEM, two search patterns are supported – an unrestricted center-biased diamond search (UCBDS) and an adaptive cross search for MV refinement at the CU level and sub-CU level, respectively. For both CU and sub-CU level MV refinement, the MV is directly searched at quarter luma sample MV accuracy, and this is followed by one-eighth luma sample MV refinement. The search range of MV refinement for the CU and sub-CU step are set equal to 8 luma samples.
由于BM需要沿着当前CU的运动轨迹从两个不同的块中获取MV,因此BM总是使用双向预测。但是TM可以是list0方向的单向预测、list1方向的单向预测或双向预测,具体选取规则如下:
If costBi <= factor * min (cost0, cost1)
bi-prediction is used;
Otherwise, if cost0 <= cost1
uni-prediction from list0 is used;
Otherwise,
uni-prediction from list1 is used;
。。。只看文档好像理解得很模糊,之后有时间看了代码再补充。