Reference Pictures in H.264/AVC
Okay, let us look at how we can signal the modifications in the reference picture lists, if any, to the decoder. We will use specific fields of the slice headers for this job.
Changing the number of active reference pictures
When set, the flag called num_ref_idx_active_override_flag
in the slice header signals overwriting the num_ref_idx_l0_active_minus1
and num_ref_idx_l1_active_minus1
values in the PPS for the current slice (and only for the current slice) with the corresponding values in the slice header.
The end result is that, at the decoder side, all entries of the reference lists past the corresponding positions are ignored.
Changing the order of the reference pictures in the list
Sometimes we might want to reorder the reference frame list just for a particular slice. When such a change is made, the flag ref_pic_list_reordering_flag_l0
in the slice header needs to be set to notify the decoder that there is a change. This is followed by inserting a pair of values for reordering_of_pic_nums_idc
and abs_diff_pic_num_minus1
fields for each reordering we have.
Basically, nth such syntax pair signals the frame_num
offset of the reference frame that will be placed nth in the list. The absolute value of the offset is given by abs_diff_pic_num_minus1+1
, while the sign is determined by reordering_of_pic_nums_idc
. Then the frame, for which frame_num = last_reordered_frame_num + offset
, is put in the nth place in the list, while the rest is shifted. The initial value of the last_reordered_frame_num
is the frame_num
of the slice, and it is updated with each reordering. Obviously, the number of the reorderings cannot exceed num_ref_idx_l0_active_minus1+1
.
Marking the decoded reference pictures
Finally, we can mark a reference picture as short-term, long-term or unused by setting the adaptive_ref_pic_marking_mode_flag
field in the slice header. Otherwise, the decoder falls back to the default sliding window reference picture marking mode. This flag is followed by a number of memory_management_control_operation
fields, which is summarized as follows.
MMCO | Explanation |
---|---|
0 | end the loop |
1 | mark short-term picture unused |
2 | mark long-term picture unused |
3 | mark short-term long-term |
4 | specify MaxLongTermFrameIdx |
5 | mark all ref. pictures unused |
6 | mark this picture long-term |