H264 中的參考幀列表

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.

**********************************************************/
————————————————
版權聲明:本文爲CSDN博主「Zhou-Jimmy」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/zhoujunming/article/details/2715215

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章