PoC has made the following analysis for the importance of reordering and marking of reference sequence initialization:
Frame encoding is discussed as follows:
When pic_order_cnt_type = 0, the PoC has no direct relationship with frame_num. It is explicitly displayed in the bit stream as pic_order_cnt_lsb, and pic_order_cnt_lsb is only a low POC, the corresponding high position picordercntmsb does not appear in the bit stream. This requires the encoder or decoder to carry the picordercntmsb in the case of pic_order_cnt_lsb. Maxpicordercntlsb can be obtained in SPS to control carry. Assume that maxpicordercntlsb = 64 and prevpicordercntmsb = 0 are as follows:
I p B... no mmco = 5 or IDR... P B
PoC: 0 6 2 60 56 58 2 62 0 6 2 4
Total POC 0 6 2 60 56 58 66 62 64 70 66 68
Here, the variable prevpicordercntlsb should be the pic_order_cnt_lsb of the previous reference frame. For P of pic_order_cnt_lsb = 2, calculate its POC. In this case, prevpicordercntlsb = 60, obviously the condition prevpicordercntlsb> pic_order_cnt_lsb & (prevPicOrderCntLsb-pic_order_cnt_lsb)> = 64/2,
Because it is a reference frame, its prevpicordercntmsb = prevpicordercntmsb + 64 = 64. In this case, topfiledordercnt = 64 + 2 = 66;
Then calculate B of pic_order_cnt_lsb = 62. At this time, prevpicordercntmsb = 64, while prevpicordercntlsb = 2, which is obviously satisfied
Prevpicordercntlsb <pic_order_cnt_lsb & (pic_order_cnt_lsb-prevPicOrderCntLsb)> = 64/2,
Picordercntmsb = prevpicordercntmsb-prevpicordercntlsb = 64-2 = 62. Because it is not a reference frame, prevpicordercntmsb is still kept as 64. Obviously, prevpicordercntmsb should be a multiple of maxpicordercntlsb. For B with pic_order_cnt_lsb = 0, the above two conditions are not met, so its picordercntmsb = 64.
Prevpicordercntmsb and prevpicordercntlsb are selectively reset when IDR or mmco is 5. If field encoding is considered here, the following situations occur:
I p B... no mmco = 5 or IDR... PT Pb BT BB PT Pb BT bb
PoC: 0 6 2 60 61 56 57 58 2 3 62 63 0 1
Total POC 0 6 2 60 56 58 66 62 64
When the poc of Pt is 60, mmco = 5 is included. Because it is not a base field, prevpicordercntlsb is 60, if mmco = 5 is included when the pt poc is 61, prevpicordercntlsb = 0; therefore, when the frame is encoded, mmco = 5 only resets prevpicordercntmsb, but prevpicordercntlsb should not be reset. In the field encoding, mmco = 5 is reset to prevpicordercntmsb only when the base field appears, and prevpicordercntlsb is 0. Make sure that prevpicordercntlsb starts from the top field and is an even number (it should not be so simple. There should be further reasons. Let me know what I want to know)
When pic_order_cnt_type = 1, consider the following sequence
For frame encoding, offset_for_top_to_bottom_field = 0; for field encoding, offset_for_top_to_bottom_field = 1;
Sequence 1: I p B loop 1
Frame_num: 0 1 2
PoC: 0 4 2
P B loop 2
Frame_num: 2 3
PoC: 8 6
P B cycle 3
Frame_num: 3 4
PoC: 12 10
In this case
For
Duration = 1, num_ref_frames_in_pic_order_cnt_cycle indicates the total number of reference frames in the last cycle of IDR. offset_for_ref_frame [0] = 4, offset_for_ref_frame indicates the offset between reference frames after IDR.
If you want to calculate the poc of the p frame of POC = 12, how can we get it? First, if you know frame_num = 3, num_ref_frames_in_pic_order_cnt_cycle = 1, offset_for_ref_frame [0] = 4, you can get
Absframenum = 3, picordercntcyclecnt = (3-1)/1 = 2; framenuminpicordercntcycle = (3-1) % 1 = 0;
Expecteddeltaperpicordercntcycle = 0
For (I = 0; I <num_ref_frames_in_pic_order_cnt_cycle; I ++)
Expecteddeltaperpicordercntcycle + = offset_for_ref_frame [I]
Then expecteddeltaperpicordercntcycle = 4;
Expectedpicordercnt = picordercntcyclecnt * expecteddeltaperpicordercntcycle
For (I = 0; I <= framenuminpicordercntcycle; I ++)
Expectedpicordercnt = expectedpicordercnt + offset_for_ref_frame [I]
Then expectedpicordercnt = 12;
Because it is P-slice, the slice header is
Delta_pic_order_cnt [0] = 0; delta_pic_order_cnt [1] = 0;
Topfieldordercnt = 12; bottomfieldordercnt = 12;
Sequence 2: I p B loop 1
Frame_num: 0 1 2 2
PoC: 0 6 2 4
P B loop 2
Frame_num: 2 3 3
PoC: 12 8 10
P B cycle 3
Frame_num: 3 4 4
PoC: 18 14 16
In this case
For
Num_ref_frames_in_pic_order_cnt_cycle = 1,
Offset_for_ref_frame [0] = 6.
If you want to calculate the POC of B frame of POC = 16, how can we get it? First, if you know frame_num = 4, num_ref_frames_in_pic_order_cnt_cycle = 1, offset_for_ref_frame [0] = 6, you can get
Absframenum = 4-1 (because frame B is not used for reference), picordercntcyclecnt = (3-1)/1 = 2; framenuminpicordercntcycle = (3-1) % 1 = 0;
Expecteddeltaperpicordercntcycle = 6;
Because offset_for_non_ref_pic =-2 * (number of consecutive B frames), Here it should be-4
Expectedpicordercnt = 14; you can obtain,
In slice_header, delta_pic_order_cnt [0] = 2, delta_pic_order_cnt [1] = 0;
Topfieldordercnt = 16; bottomfieldordercnt = 16;
Sequence 2: I p B cycle 1
Frame_num: 0 1 2 2 3 3 4 4 4
PoC: 0 4 2 10 6 8 18 12 14 16
P B cycle 2
Frame_num: 4 5 5 6 6 6 7 7 7
PoC: 22 20 28 24 26 36 30 32 34
P B cycle 3
Frame_num: 7 8 8 9 9 10 10 10
PoC: 40 38 46 42 44 54 48 50 52
In this case
For
Num_ref_frames_in_pic_order_cnt_cycle = 3,
Offset_for_ref_frame [3] = {4, 6, 8 }.
If you want to calculate the poc of the p frame of POC = 54, how can we get it? First, if you know frame_num = 9, num_ref_frames_in_pic_order_cnt_cycle = 3, offset_for_ref_frame [3] = {, 8}, you can get
Absframenum = 9, picordercntcyclecnt = (9-1)/3 = 2; framenuminpicordercntcycle = (9-1) % 3 = 2;
Expecteddeltaperpicordercntcycle = 18;
Expectedpicordercnt = 18*2 + 4 + 6 + 8 = 54,
In slice_header, delta_pic_order_cnt [0] = 0, delta_pic_order_cnt [1] = 0;
Topfieldordercnt = 54; bottomfieldordercnt = 54;
If you want to calculate the POC of B frame with POC = 50, how can we get it? Because it is B frame
Absframenum = 10-1 = 9, picordercntcyclecnt = (9-1)/3 = 2; framenuminpicordercntcycle = (9-1) % 3 = 2;
Since the number of consecutive B-frames changes, the average value is 2. In this case, offset_for_non_ref_pic =-4,
Expectedpicordercnt = 18*2 + 4 + 6 + 8-4 = 50; In slice_header, delta_pic_order_cnt [0] = 0, delta_pic_order_cnt [1] = 0;
When pic_order_cnt_type = 2
POC is derived from frame_num. This is relatively simple, but note that in this case there is no continuous non-reference image (annotation ), in addition, the decoded output sequence is the same as the displayed output sequence (comment), which means that no frame B is displayed, but non-reference P fields can appear, this is also why temppicordercnt = 2 * (framenumoffset + frame_num)-1 when nal_ref_idc = 0. This ensures that the POC of the reference field is always an even number and greater than the other field of the same frame.
In combination with the three POC types, type 2 should be the least bit, because it is obtained directly from frame_num, but the sequence method has the largest limit;
Type 1, only a certain amount of BIT is required to indicate some information in the SPS and also indicate the POC change in the slice header, but it is less bit than the type 0, however, the sequence is not random and requires periodic changes. For Type 0, bits are most used because the LSB of POC needs to be encoded. The advantage is that the sequence can be random.