h264 参考列表

来源:互联网 发布:网络回合制游戏排行榜 编辑:程序博客网 时间:2024/05/21 22:33

H264中允许从多至15个帧里面选择1帧或者2帧出来作为参考进行预测,所以必须引入一个列表来管理这些参考图像,对

与P slice而言,对应 list0,对于 B slice 而言,还需要多一个 list1,因为 B slice 是进行的两次预测!(一个前向一个后向/两个前向/两个后向)

参考帧分为 long term / short term 两种,即所谓的长期参考帧和短期参考帧。其中长期参考帧用 LongTermPicNum

来进行索引,而短期参考帧则利用 frame_num 或者 POC 来进行索引(默认索引顺序即初始化顺序),再具体一点:

P slice 的短期参考利用 frame_num 来进行索引,且按照降序排列(即离当前图像最近的前向图像排在第0位)

B slice 的短期参考利用 POC 来进行索引,

对其List0而言,先按照POC降序排列处于其前向的参考帧然后再按照POC升序排列处于其后向的参考帧;

对其List1而言,先按照POC升序排列处于其后向的参考帧然后再按照POC降序排列处于其前向的参考帧。

 

对于每个MB而言,在mb_pred()中会传输其参考索引,以表明该MB从list0/list1中选择哪一个作为参考,而对于一个

Slice 而言,可能存在该 Slice 内部大多数MB都选择了某一个索引号较大的参考帧,如设定list0中的索引从0~5,而

大多数MB都选择了5,在用哥伦布码进行编码时,将会消耗较多的bit!所以在初始化排序好后,会根据当前 slice 的

具体情况,对列表进行重排序,如将此时排在索引5位置的POC与排在0位置的POC进行交换,那么mb_pred()中传输参考

索引所需的bit数就大大减少了!其中参考索引重排的语法在ref_pic_list_reordering()中有详细介绍!

那么当一帧解完后,如何处理该帧呢?需不需要将其放入参考列表中?所以在h264的bit stream中还传输了

dec_ref_pic_marking(),通过mmco这个玩意告诉我们当前的一帧接完后如何处理参考列表!

TBD:剩下的一个问题就是,为什么要分长期参考和短期参考呢?

以下是来自网上的答案,因为short term参考帧以frame_num做为索引,而frame_num是有最大值的,达到最大值后会进行

取模,所以短期参考帧不能长期存在于参考列表中,因为一旦frame_num达到最大值后取模为0,该索引就失去意义了,而长

期参考帧则不同!

/********************************************************

I guess there are two primary differences.

1) Short-term reference pictures are indexed by referring to variables

that are a function of their frame_num value. But frame_num is a modulo

counter that wraps over periodically. Therefore there is a limit on how

long a short-term reference picture can remain in the buffer -- it

cannot remain there after the frame_num value has wrapped all the way

around and crossed over the same value again. In contrast, long-term

reference pictures are referenced by an index that is explicitly

assigned to them by syntax -- their long-term frame index. So a

long-term reference picture can stay in the decoded picture buffer as

long as the encoder wants it to.

2) There is no use of temporal (picture order count) relationships when

referencing long-term reference pictures in the decoding process.

**********************************************************/

0 0
原创粉丝点击