h264 u(v) decode of frame_num, pic_order_cnt_lsb and slice_group_change_cycle

来源:互联网 发布:ipv4网络访问权限win10 编辑:程序博客网 时间:2024/06/16 06:13

According to "Slice Header Syntax" (described in ITU-T Rec. h264), frame_num,pic_order_cnt_lsb and slice_group_change_cycle have u(v) descriptor, which is the unsigned integer using variable number of bits


The doc states that

"the number of bits varies in a manner dependent on the value of other syntax elements."

Do you know how to figure out the number of bits used to store frame_num,pic_order_cnt_lsb and slice_group_change_cycle?

[The cited documentation points to read_bits(n) function, unfortunately I cannot figure it out by myself. Can you help?]


Answer

frame_num

is used as an identifier for pictures and shall be represented by log2_max_frame_num_minus4 + 4 bits in the bitstream.

Here is what FFmpeg does, for example:

log2_max_frame_num_minus4 = get_ue_golomb(&h->gb);// ...sps->log2_max_frame_num = log2_max_frame_num_minus4 + 4;// ...h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);

pic_order_cnt_lsb

specifies the picture order count modulo MaxPicOrderCntLsb for the top field of a coded frame or for a coded field.The size of the pic_order_cnt_lsb syntax element is log2_max_pic_order_cnt_lsb_minus4 + 4 bits.

The value of the pic_order_cnt_lsb shall be in the range of 0 to MaxPicOrderCntLsb – 1, inclusive.

slice_group_change_cycle

The value of slice_group_change_cycle is represented in the bitstream by the following number of bits Ceil( Log2( PicSizeInMapUnits ÷ SliceGroupChangeRate + 1 ) )

Example of bit reading: SliceHeader.cpp, line 170


0 0