转 slice_header header 跳转

http://blog.sina.com.cn/s/blog_4171e65d0100o4pt.html

T264_slice_t结构体中的字段是要写入编码的码流供解码器取得参数1.结构体typedef struct
{
int32_t first_mb_in_slice; //一般为0,一个slice为一帧图像,所以为0first_mb_in_slice specifies the addressof the first macroblock in the slice. When arbitrary slice order isnot allowed as specified in Annex A, the value of first_mb_in_sliceshall not be less than the value of first_mb_in_slice for any otherslice of the current picture that precedes the current slice indecoding order.同一帧中,按编码顺序,first_mb_in_slice是增加的
int32_tslice_type;//标识 I/B/P...slice_type specifiesthe coding type of the slice according to below tableslice_typeName of slice_type
0P (P slice)
1B (B slice)
2I (I slice)
3SP (SP slice)
4SI (SI slice)
5P (P slice)
6B (B slice)
7I (I slice)
8SP (SP slice)
9SI (SIslice)
int32_t pic_id; //T264里设置为0pic_parameter_set_id specifies thepicture parameter set in use. The value of pic_parameter_set_idshall be in the range of 0 to 255,inclusive.
int32_tframe_num;//t->frame_num编码顺序,IDR帧是为0frame_num is used as an identifier forpictures and shall be represented by log2_max_frame_num_minus4 + 4bits in the bitstream.
int32_t idr_pic_id; //IDR帧的序号,每遇到一个IDR加1,并且模65536idr_pic_id identifies an IDR picture.The values of idr_pic_id in all the slices of an IDR picture shallremain unchanged. When two consecutive access units in decodingorder are both IDR access units, the value of idr_pic_id in theslices of the first such IDR access unit shall differ from theidr_pic_id in the second such IDR access unit. The value ofidr_pic_id shall be in the range of 0 to 65535,inclusive.

int32_t pic_order_cnt_lsb; //poc显示序号//T264_seq_set_t中的字段max_pic_加4后是它的bit位数pic_order_cnt_lsb specifies the pictureorder count modulo MaxPicOrderCntLsb for the top field of a codedframe or for a coded field. The size of the pic_order_cnt_lsbsyntax element is log2_max_pic_order_cnt_lsb_minus4 + 4 bits. Thevalue of the pic_order_cnt_lsb shall be in the range of 0 toMaxPicOrderCntLsb – 1,inclusive.
int32_t delta_pic_order_cnt_bottom;delta_pic_order_cnt_bottom specifies thepicture order count difference between the bottom field and the topfield of a coded frame as follows. When this syntax element is notpresent in the bitstream for the current slice, it shall beinferred to be equal to 0.
int32_t direct_spatial_mv_pred_flag;direct_spatial_mv_pred_flag specifiesthe method used in the decoding process to derive motion vectorsand reference indices for inter prediction as follows.
- If direct_spatial_mv_pred_flag is equal to 1, the derivationprocess for luma motion vectors for B_Skip, B_Direct_16x16, andB_Direct_8x8 in subclause 8.4.1.2 shall use spatial direct modeprediction as specified in subclause 8.4.1.2.2.
- Otherwise (direct_spatial_mv_pred_flag is equal to 0), thederivation process for luma motion vectors for B_Skip,B_Direct_16x16, and B_Direct_8x8 in subclause 8.4.1.2 shall usetemporal direct mode prediction as specified in subclause8.4.1.2.3.

int32_t num_ref_idx_active_override_flag; //0时不重新设置参考帧数目,1时,重新设置num_ref_idx_active_override_flag equalto 0 specifies that the values of the syntax elementsnum_ref_idx_l0_active_minus1 and num_ref_idx_l1_active_minus1specified in the referred picture parameter set are in effect.num_ref_idx_active_override_flag equal to 1 specifies that thenum_ref_idx_l0_active_minus1 and num_ref_idx_l1_active_minus1specified in the referred picture parameter set are overridden forthe current slice (and only for the current slice) by the followingvalues in the slice header.
ITU-T Rec. H.264 (03/2005) – Prepublished version 92
When the current slice is a P, SP, or B slice and field_pic_flag isequal to 0 and the value of
num_ref_idx_l0_active_minus1 in the picture parameter set exceeds15, num_ref_idx_active_override_flag shall be equal to 1.
When the current slice is a B slice and field_pic_flag is equal to0 and the value of num_ref_idx_l1_active_minus1 in the pictureparameter set exceeds 15, num_ref_idx_active_override_flag shall beequal to1.
int32_tslice_qp_delta;//本slice的qp值slice_qp_delta specifies the initialvalue of QPY to be used for all the macroblocks in the slice untilmodified by the value of mb_qp_delta in the macroblock layer. Theinitial QPY quantisation parameter for the slice is computed as:SliceQPY = 26 + pic_init_qp_minus26 + slice_qp_delta
The value of slice_qp_delta shall be limited such that SliceQPY isin the range of -QpBdOffsetY to +51, inclusive.
int32_t ref_pic_list_reordering_flag_l0;ref_pic_list_reordering_flag_l0 equal to1 specifies that the syntax element reordering_of_pic_nums_idc ispresent for specifying reference picture list 0.ref_pic_list_reordering_flag_l0 equal to 0 specifies that thissyntax element is not present.int32_t no_output_of_prior_pics_flag; //T264里设置为0no_output_of_prior_pics_flag specifieshow the previously-decoded pictures in the decoded picture bufferare treated after decoding of an IDR picture. See Annex C. When theIDR picture is the first IDR picture in the bitstream, the value ofno_output_of_prior_pics_flag has no effect on the decoding process.When the IDR picture is not the first IDR
picture in the bitstream and the value of PicWidthInMbs,FrameHeightInMbs, or max_dec_frame_buffering derived from theactive sequence parameter set is different from the value ofPicWidthInMbs, FrameHeightInMbs, or max_dec_frame_buffering derivedfrom the sequence parameter set active for the preceding sequence,no_output_of_prior_pics_flag equal to 1 may be inferred by thedecoder, regardless of the actual value ofno_output_of_prior_pics_flag.
int32_t long_term_reference_flag; //T264里设置为0long_term_reference_flag equal to 0specifies that the MaxLongTermFrameIdx variable is set equal to “nolong-term frame indices” and that the IDR picture is marked as“used for short-term reference”. long_term_reference_flag equa to 1specifies that the MaxLongTermFrameIdx variable is set equal to 0and that the current IDR picture is marked “used for long-termreference” and is assigned LongTermFrameIdx equal to 0. Whennum_ref_frames is equal to 0,
long_term_reference_flag shall be equal to 0.
int32_t adaptive_ref_pic_marking_mode_flag; //T264里设置为0adaptive_ref_pic_marking_mode_flagselects the reference picture marking mode of the currently decodedpicture as specified in Table 7-8.adaptive_ref_pic_marking_mode_flag shall be equal to 1 when thenumber of frames, complementary field pairs, and non-paired fieldsthat are currently marked as "used for long-term reference" isequal to Max( num_ref_frames, 1 ).

int32_t cabac_init_idc;cabac_init_idc specifies the index fordetermining the initialisation table used in the initialisationprocess for context variables. The value of cabac_init_idc shall bein the range of 0 to 2, inclusive.
} T264_slice_t;2.初始化//slice头部的控制信息的初始化
void
slice_header_init(_R T264_t* t, _RWT264_slice_t* slice)
{
slice->first_mb_in_slice = 0;
slice->slice_type =t->slice_type;
slice->pic_id = 0;
slice->idr_pic_id = t->idr_pic_id;
slice->pic_order_cnt_lsb = t->poc % (1 <<(t->ss.max_pic_order + 4));
slice->frame_num = t->frame_num;
slice->direct_spatial_mv_pred_flag =t->param.direct_flag;
slice->ref_pic_list_reordering_flag_l0 = 0;
slice->no_output_of_prior_pics_flag = 0;
slice->long_term_reference_flag = 0;
slice->adaptive_ref_pic_marking_mode_flag = 0;
slice->slice_qp_delta = 0;//for CABAC

if( t->param.cabac )
{
t->slice.cabac_init_idc= T264_cabac_model_get( &t->cabac, t->slice_type );
}
}
3.写入码流Slice headersyntaxslice_header( ){CDescriptor
first_mb_in_slice2ue(v)
slice_type2ue(v)
pic_parameter_set_id2ue(v)
frame_num2u(v)
if(!frame_mbs_only_flag ){
field_pic_flag2u(1)
if(field_pic_flag)
bottom_field_flag2u(1)
}
if( nal_unit_type= = 5)
idr_pic_id2ue(v)
if(pic_order_cnt_type == 0 ){
pic_order_cnt_lsb2u(v)
if( pic_order_present_flag&& !field_pic_flag)
delta_pic_order_cnt_bottom2se(v)
}
if(pic_order_cnt_type = = 1 &&!delta_pic_order_always_zero_flag ){
delta_pic_order_cnt[0]2se(v)
if(pic_order_present_flag&& !field_pic_flag)
delta_pic_order_cnt[1]2se(v)
}
if( redundant_pic_cnt_present_flag)
redundant_pic_cnt2ue(v)
if(slice_type = = B)
direct_spatial_mv_pred_flag2u(1)
if( slice_type = = P | | slice_type = = SP| | slice_type = = B ){
num_ref_idx_active_override_flag2u(1)
if(num_ref_idx_active_override_flag ){
num_ref_idx_l0_active_minus12ue(v)
if(slice_type = = B)
num_ref_idx_l1_active_minus12ue(v)
}
}
ref_pic_list_reordering()2
if(( weighted_pred_flag&& ( slice_type = =P | | slice_type= = SP ) ) | |
(weighted_bipred_idc == 1&&slice_type = = B) )
pred_weight_table()2
if( nal_ref_idc != 0)
dec_ref_pic_marking()2
if(entropy_coding_mode_flag&&slice_type !=I &&slice_type != SI)
cabac_init_idc2ue(v)
slice_qp_delta2se(v)
if( slice_type == SP || slice_type == SI ){
if(slice_type = = SP)
sp_for_switch_flag2u(1)
slice_qs_delta2se(v)
}
if( deblocking_filter_control_present_flag) {
disable_deblocking_filter_idc2ue(v)
if(disable_deblocking_filter_idc!= 1 ){
slice_alpha_c0_offset_div22se(v)
slice_beta_offset_div22se(v)
}
}
if(num_slice_groups_minus1 > 0&&
slice_group_map_type>= 3&& slice_group_map_type <=5)
slice_group_change_cycle2u(v)
}
//根据t->slice_type的不同,向bitstream中写入一个slice的头部的控制bitvoid
slice_header_write(_R T264_t* t, _RWT264_slice_t* slice)
{
eg_write_ue(t->bs, slice->first_mb_in_slice);
eg_write_ue(t->bs, slice->slice_type);
eg_write_ue(t->bs, slice->pic_id);
eg_write_direct(t->bs, slice->frame_num,t->ss.log2_max_frame_num_minus4 + 4);//frame_mbs_only_flag=1(在seq_set_init中设置),所以不写field_pic_flagbottom_field_flagif (t->nal.nal_unit_type ==NAL_SLICE_IDR) //NAL_SLICE_IDR==5
{
eg_write_ue(t->bs, slice->idr_pic_id); //如果是IDR帧,需要写入此IDR的ID
}
if (t->ss.pic_order_cnt_type == 0)
{ //这个条件一定成立,seq_set_init中pic_order_cnt_type=0,并且其他地方没有改变
eg_write_direct(t->bs, slice->pic_order_cnt_lsb,t->ss.max_pic_order + 4);
}//接下来写入参考帧的数目num_ref_idx_l0_active_minus1 specifiesthe maximum reference index for reference picture list 0 that shallbe used to decode the slice. The range ofnum_ref_idx_l0_active_minus1 is specified as follows.
– If field_pic_flag is equal to 0, num_ref_idx_l0_active_minus1shall be in the range of 0 to 15, inclusive. When MbaffFrameFlag isequal to 1, num_ref_idx_l0_active_minus1 is the maximum index valuefor the decoding of frame macroblocks and 2 *num_ref_idx_l0_active_minus1 + 1 is the maximum index value for thedecoding of field macroblocks.
– Otherwise (field_pic_flag is equal to 1),num_ref_idx_l0_active_minus1 shall be in the range of 0 to 31,inclusive.
num_ref_idx_l1_active_minus1 has the samesemantics as num_ref_idx_l0_active_minus1 with l0 and list 0replaced by l1 and list 1,respectively.
if (t->slice_type == SLICE_P)
{
// num_ref_idx_active_override_flag
if (t->refl0_num == t->param.ref_num) //num_ref_idx_active_override_flag=0
{
eg_write_direct1(t->bs, 0); //相同写入0表示不变
}
else //num_ref_idx_active_override_flag=1
{
eg_write_direct1(t->bs, 1); //不同写入1,然后写入数目
eg_write_ue(t->bs, t->refl0_num - 1);
}
t->ps.num_ref_idx_l0_active_minus1 = t->refl0_num - 1;
t->ps.num_ref_idx_l1_active_minus1 = 0;//p帧不使用list1
}
else if (t->slice_type == SLICE_B)
{
// direct_spatial_mv_pred_flag
eg_write_direct1(t->bs,slice->direct_spatial_mv_pred_flag);
// num_ref_idx_active_override_flag
{
eg_write_direct1(t->bs, 1); //num_ref_idx_active_override_flag=1
eg_write_ue(t->bs, t->refl0_num - 1);
eg_write_ue(t->bs, t->refl1_num - 1);
}
t->ps.num_ref_idx_l0_active_minus1 = t->refl0_num - 1;
t->ps.num_ref_idx_l1_active_minus1 = t->refl1_num - 1;
}

if(slice->slice_type != SLICE_I&& slice->slice_type != SLICE_SI )
{
eg_write_direct1(t->bs,slice->ref_pic_list_reordering_flag_l0);
if (slice->slice_type == SLICE_B)
eg_write_direct1(t->bs,slice->ref_pic_list_reordering_flag_l0);
}if (t->nal.nal_ref_idc != 0)
{

if (t->nal.nal_unit_type == NAL_SLICE_IDR)
{
eg_write_direct1(t->bs, slice->no_output_of_prior_pics_flag);//T264里设置为0
eg_write_direct1(t->bs, slice->long_term_reference_flag);//T264里设置为0
}
else
{
eg_write_direct1(t->bs,slice->adaptive_ref_pic_marking_mode_flag); //T264里设置为0
}
}//for CABAC
if(t->ps.entroy_coding_mode_flag!=0&& t->slice_type!= SLICE_I)
{
eg_write_ue(t->bs,t->slice.cabac_init_idc);
}eg_write_se(t->bs, t->qp_y - t->param.qp);
if (t->ps.deblocking_filter_control_present_flag) //为1,写入是否有去块效应滤波器
{
eg_write_ue(t->bs, t->param.disable_filter);
}
}4.解码过程解码器中的slice header程序,实现对sliceheader的解码过程,与编码器中的相对
void
T264dec_parse_slice_header(T264_t*t)
{
(转)slice_header header 跳转
t->slice.first_mb_in_slice = eg_read_ue(t->bs);
assert(t->slice.first_mb_in_slice == 0);
t->slice_type = t->slice.slice_type =eg_read_ue(t->bs);
t->slice.pic_id =eg_read_ue(t->bs);
t->slice.frame_num = eg_read_direct(t->bs,t->ss.log2_max_frame_num_minus4 + 4);
if (t->nal.nal_unit_type == NAL_SLICE_IDR)
{
t->slice.idr_pic_id = eg_read_ue(t->bs);
}
if (t->ss.pic_order_cnt_type == 0)
{
t->poc = t->slice.pic_order_cnt_lsb =eg_read_direct(t->bs, t->ss.max_pic_order + 4);
}
if (t->slice_type == SLICE_P)
{
t->refl1_num = 0;
t->refl0_num = t->ps.num_ref_idx_l0_active_minus1 + 1;
// num_ref_idx_active_override_flag
if (eg_read_direct(t->bs, 1)) //如果参考帧数目有变化,读取新的值
{
t->refl0_num = eg_read_ue(t->bs) + 1; //P时,只有list0
}
}
else if (t->slice_type == SLICE_B)
{
// direct_spatial_mv_pred_flag
t->param.direct_flag = t->slice.direct_spatial_mv_pred_flag =eg_read_direct(t->bs, 1);
t->refl1_num = 1;
t->refl0_num = t->ps.num_ref_idx_l0_active_minus1 + 1;
// num_ref_idx_active_override_flag
if (eg_read_direct(t->bs, 1))//如果参考帧数目有变化,读取新的值
{
t->refl0_num = eg_read_ue(t->bs) +1; //B帧时有list0和list1
t->refl1_num = eg_read_ue(t->bs) + 1;
}
}
if(t->slice.slice_type != SLICE_I &&t->slice.slice_type != SLICE_SI )
{ //ref_pic_list_reordering0,T264中必为0,所以只需要跳过就可以
eg_read_skip(t->bs, 1);
if (t->slice.slice_type == SLICE_B)
eg_read_skip(t->bs, 1); //ref_pic_list_reordering1,T264中必为0,所以只需要跳过就可以
} if(t->nal.nal_ref_idc != 0)
{

if (t->nal.nal_unit_type == NAL_SLICE_IDR)
{
eg_read_direct(t->bs, 1); //T264里设置no_output_of_prior_pics_flag为0
eg_read_direct(t->bs, 1); //T264里设置long_term_reference_flag为0
}
else
{
eg_read_direct(t->bs, 1); //T264里设置adaptive_ref_pic_marking_mode_flag为0
}
}
//for dec CABAC
if(t->ps.entroy_coding_mode_flag!=0&& t->slice_type!= SLICE_I)
{
t->slice.cabac_init_idc= eg_read_ue(t->bs);
}
t->qp_y = eg_read_se(t->bs) + t->ps.pic_init_qp_minus26 +26;
if (t->ps.deblocking_filter_control_present_flag)
{ //deblocking_filter_control_present_flag!=0时,码流中才有need_deblock
t->need_deblock = !eg_read_ue(t->bs);
}
}

  

爱华网本文地址 » http://www.aihuau.com/a/25101011/63848.html

更多阅读

怎么转呼啦圈 精 软性呼啦圈怎么转

怎么转呼啦圈 精——简介呼啦圈大家都很喜欢的运动。不但很有意思,还可以帮助身体脂肪运动起来。那么怎么转呼啦圈呢?下面的方法希望能够帮到大家。怎么转呼啦圈 精——方法/步骤怎么转呼啦圈 精 1、呼啦圈呼啦圈是分不同重量型

玩转小米:2 破解小米收费主题等的最新方法

玩转小米:[2]破解小米收费主题等的最新方法——简介 小米官方主题授权已改变机制,笔者之前发布的破解方法已经失效。但,上有政策,下有对策,不要低估我们米粉的力量!现已有最新的破解方法,亲测可行! 本经验就介绍一下:破解小米商店收费主题等

php 页面三种跳转 php跳转到指定页面

方法一:使用PHP自带函数Header("Location: 网址");说明:必须在网页没有任何输出的时候执行,要特别要注意空格。去空格的方法参照如下第4问即,这句话要放在网页开始的时候,放在body里或后面都会出错,方法二:利用metaecho "<meta http-equiv=

火影忍者分析==禁术,秽土转生-药师兜 药师兜秽土转生所有人

因为学习忙,很久没有上过论坛来了。抽空写了一篇分析,发的有点晚了。大家见谅。最近药师兜的登场实在是吓了我一跳。而且一上来就展现了他不凡的实力,其中最重要的就是它使用出的秽土转生。以下是我对秽土转生的分析:⑴秽土转生的条件:在

声明:《转 slice_header header 跳转》为网友你给的是温暖分享!如侵犯到您的合法权益请联系我们删除