H265 seq 参数集数据语法 table 需要
H265 seq parameter set data Syntax table required
我一直在寻找 H265 的 seq 参数集语法 table 很长时间,但找不到。我有 H264 语法 table,我用它来解析 h264 文件并且工作正常。我正在尝试对 H265 视频文件做同样的事情以获得分辨率。我有解析器,我从中导出了我的版本-> 供参考 https://github.com/virinext/hevcesbrowser
注意:使用 Hevcbrowser 源我可以看到并理解值和类型,但我没有得到相同的所以语法 table 会有所帮助
需要知道 H265 的 Ue U 或 Se 等类型及其值
.详情请参考此图片
Table of H264 Sps parameter syntax
int32_t CtbLog2SizeY = m_spsMap[spsId] -> log2_min_luma_coding_block_size_minus3 + 3 + m_spsMap[spsId] -> log2_diff_max_min_luma_coding_block_size;
uint32_t CtbSizeY = 1 << CtbLog2SizeY;
uint32_t PicWidthInCtbsY = m_spsMap[spsId] -> pic_width_in_luma_samples / CtbSizeY;
我希望 PicWidthInCtbsY 为 640
int h265_parser_sps(unsigned char * buffer, unsigned int bufferlen, int *width,int * height)
{
unsigned int StartBit=0;
de_emulation_prevention(buffer,&bufferlen);
uint32_t sps_video_parameter_set_id = 0;
uint32_t sps_max_sub_layers_minus1 = 0;
bool sps_temporal_id_nesting_flag;
uint32_t sps_seq_parameter_set_id = 0;
uint32_t chroma_format_idc;
bool separate_colour_plane_flag = false;
uint32_t pic_width_in_luma_samples=0;
uint32_t pic_height_in_luma_samples=0;
bool conformance_window_flag;
uint32_t conf_win_left_offset;
uint32_t conf_win_right_offset;
uint32_t conf_win_top_offset;
uint32_t conf_win_bottom_offset;
uint32_t bit_depth_luma_minus8;
uint32_t bit_depth_chroma_minus8;
uint32_t log2_max_pic_order_cnt_lsb_minus4;
bool sps_sub_layer_ordering_info_present_flag;
bool rbsp_stop_one_bit;
u(16,buffer,StartBit);//nal_unit_header
sps_video_parameter_set_id = u(4,buffer,StartBit);
sps_max_sub_layers_minus1 = u(3,buffer,StartBit);
sps_temporal_id_nesting_flag = u(1,buffer,StartBit);
cout<<"sps_video_parameter_set_id:"<<sps_video_parameter_set_id<<endl;
cout<<"sps_max_sub_layers_minus1:"<<sps_max_sub_layers_minus1<<endl;
cout<<"sps_temporal_id_nesting_flag:"<<sps_temporal_id_nesting_flag<<endl;
h265_parse_ptl(sps_max_sub_layers_minus1,buffer,StartBit,bufferlen);
sps_seq_parameter_set_id = Ue(buffer,bufferlen,StartBit);
cout<<"sps_seq_parameter_set_id:"<<sps_seq_parameter_set_id<<endl;
//p_sps = &sps[sps_seq_parameter_set_id];
chroma_format_idc = Ue(buffer,bufferlen,StartBit);
cout<<"chroma_format_idc:"<<chroma_format_idc<<endl;
if (3 == chroma_format_idc)
{
separate_colour_plane_flag = u(1,buffer,StartBit);
}
else
separate_colour_plane_flag = 0;
cout<<"separate_colour_plane_flag:"<<separate_colour_plane_flag<<endl;
pic_width_in_luma_samples = Ue(buffer,bufferlen,StartBit);
pic_height_in_luma_samples = Ue(buffer,bufferlen,StartBit);
cout<<"pic_width_in_luma_samples:"<<pic_width_in_luma_samples<<endl;
cout<<"pic_height_in_luma_samples:"<<pic_height_in_luma_samples<<endl;
*width=pic_width_in_luma_samples;
*height=pic_height_in_luma_samples;
conformance_window_flag = u(1,buffer,StartBit);
cout<<"conformance_window_flag:"<<conformance_window_flag<<endl;
if (conformance_window_flag)
{
conf_win_left_offset = Ue(buffer,bufferlen,StartBit);
conf_win_right_offset = Ue(buffer,bufferlen,StartBit);
conf_win_top_offset = Ue(buffer,bufferlen,StartBit);
conf_win_bottom_offset = Ue(buffer,bufferlen,StartBit);
}
bit_depth_luma_minus8 = Ue(buffer,bufferlen,StartBit);
bit_depth_chroma_minus8 = Ue(buffer,bufferlen,StartBit);
log2_max_pic_order_cnt_lsb_minus4 = Ue(buffer,bufferlen,StartBit);
cout<<"bit_depth_luma_minus8:"<<bit_depth_luma_minus8<<endl;
cout<<"bit_depth_chroma_minus8:"<<bit_depth_chroma_minus8<<endl;
cout<<"log2_max_pic_order_cnt_lsb_minus4:"<<log2_max_pic_order_cnt_lsb_minus4<<endl;
sps_sub_layer_ordering_info_present_flag = u(1,buffer,StartBit);
cout<<"sps_sub_layer_ordering_info_present_flag:"<<sps_sub_layer_ordering_info_present_flag<<endl;
int i;
uint32_t *sps_max_dec_pic_buffering_minus1 = new uint32_t[sps_max_sub_layers_minus1 + 1];
uint32_t *sps_max_num_reorder_pics = new uint32_t[sps_max_sub_layers_minus1 + 1];
uint32_t *sps_max_latency_increase_plus1 = new uint32_t[sps_max_sub_layers_minus1 + 1];
for (i = (sps_sub_layer_ordering_info_present_flag ? 0 : sps_max_sub_layers_minus1); i <= sps_max_sub_layers_minus1; i++ )
{
sps_max_dec_pic_buffering_minus1[i] = Ue(buffer,bufferlen,StartBit);
sps_max_num_reorder_pics[i] = Ue(buffer,bufferlen,StartBit);
sps_max_latency_increase_plus1[i] = Ue(buffer,bufferlen,StartBit);
}
uint32_t log2_min_luma_coding_block_size_minus3;
uint32_t log2_diff_max_min_luma_coding_block_size;
uint32_t log2_min_transform_block_size_minus2;
uint32_t log2_diff_max_min_transform_block_size;
uint32_t max_transform_hierarchy_depth_inter;
uint32_t max_transform_hierarchy_depth_intra;
bool scaling_list_enabled_flag;
log2_min_luma_coding_block_size_minus3 = Ue(buffer,bufferlen,StartBit);
log2_diff_max_min_luma_coding_block_size = Ue(buffer,bufferlen,StartBit);
log2_min_transform_block_size_minus2 = Ue(buffer,bufferlen,StartBit);
log2_diff_max_min_transform_block_size = Ue(buffer,bufferlen,StartBit);
max_transform_hierarchy_depth_inter = Ue(buffer,bufferlen,StartBit);
max_transform_hierarchy_depth_intra = Ue(buffer,bufferlen,StartBit);
scaling_list_enabled_flag = u(1,buffer,StartBit);
你只需要H.265/HEVC的规范文档,你可以找到here。显然这是一份相当长的文件。你应该寻找正确的 table.
我一直在寻找 H265 的 seq 参数集语法 table 很长时间,但找不到。我有 H264 语法 table,我用它来解析 h264 文件并且工作正常。我正在尝试对 H265 视频文件做同样的事情以获得分辨率。我有解析器,我从中导出了我的版本-> 供参考 https://github.com/virinext/hevcesbrowser
注意:使用 Hevcbrowser 源我可以看到并理解值和类型,但我没有得到相同的所以语法 table 会有所帮助
需要知道 H265 的 Ue U 或 Se 等类型及其值 .详情请参考此图片 Table of H264 Sps parameter syntax
int32_t CtbLog2SizeY = m_spsMap[spsId] -> log2_min_luma_coding_block_size_minus3 + 3 + m_spsMap[spsId] -> log2_diff_max_min_luma_coding_block_size;
uint32_t CtbSizeY = 1 << CtbLog2SizeY;
uint32_t PicWidthInCtbsY = m_spsMap[spsId] -> pic_width_in_luma_samples / CtbSizeY;
我希望 PicWidthInCtbsY 为 640
int h265_parser_sps(unsigned char * buffer, unsigned int bufferlen, int *width,int * height)
{
unsigned int StartBit=0;
de_emulation_prevention(buffer,&bufferlen);
uint32_t sps_video_parameter_set_id = 0;
uint32_t sps_max_sub_layers_minus1 = 0;
bool sps_temporal_id_nesting_flag;
uint32_t sps_seq_parameter_set_id = 0;
uint32_t chroma_format_idc;
bool separate_colour_plane_flag = false;
uint32_t pic_width_in_luma_samples=0;
uint32_t pic_height_in_luma_samples=0;
bool conformance_window_flag;
uint32_t conf_win_left_offset;
uint32_t conf_win_right_offset;
uint32_t conf_win_top_offset;
uint32_t conf_win_bottom_offset;
uint32_t bit_depth_luma_minus8;
uint32_t bit_depth_chroma_minus8;
uint32_t log2_max_pic_order_cnt_lsb_minus4;
bool sps_sub_layer_ordering_info_present_flag;
bool rbsp_stop_one_bit;
u(16,buffer,StartBit);//nal_unit_header
sps_video_parameter_set_id = u(4,buffer,StartBit);
sps_max_sub_layers_minus1 = u(3,buffer,StartBit);
sps_temporal_id_nesting_flag = u(1,buffer,StartBit);
cout<<"sps_video_parameter_set_id:"<<sps_video_parameter_set_id<<endl;
cout<<"sps_max_sub_layers_minus1:"<<sps_max_sub_layers_minus1<<endl;
cout<<"sps_temporal_id_nesting_flag:"<<sps_temporal_id_nesting_flag<<endl;
h265_parse_ptl(sps_max_sub_layers_minus1,buffer,StartBit,bufferlen);
sps_seq_parameter_set_id = Ue(buffer,bufferlen,StartBit);
cout<<"sps_seq_parameter_set_id:"<<sps_seq_parameter_set_id<<endl;
//p_sps = &sps[sps_seq_parameter_set_id];
chroma_format_idc = Ue(buffer,bufferlen,StartBit);
cout<<"chroma_format_idc:"<<chroma_format_idc<<endl;
if (3 == chroma_format_idc)
{
separate_colour_plane_flag = u(1,buffer,StartBit);
}
else
separate_colour_plane_flag = 0;
cout<<"separate_colour_plane_flag:"<<separate_colour_plane_flag<<endl;
pic_width_in_luma_samples = Ue(buffer,bufferlen,StartBit);
pic_height_in_luma_samples = Ue(buffer,bufferlen,StartBit);
cout<<"pic_width_in_luma_samples:"<<pic_width_in_luma_samples<<endl;
cout<<"pic_height_in_luma_samples:"<<pic_height_in_luma_samples<<endl;
*width=pic_width_in_luma_samples;
*height=pic_height_in_luma_samples;
conformance_window_flag = u(1,buffer,StartBit);
cout<<"conformance_window_flag:"<<conformance_window_flag<<endl;
if (conformance_window_flag)
{
conf_win_left_offset = Ue(buffer,bufferlen,StartBit);
conf_win_right_offset = Ue(buffer,bufferlen,StartBit);
conf_win_top_offset = Ue(buffer,bufferlen,StartBit);
conf_win_bottom_offset = Ue(buffer,bufferlen,StartBit);
}
bit_depth_luma_minus8 = Ue(buffer,bufferlen,StartBit);
bit_depth_chroma_minus8 = Ue(buffer,bufferlen,StartBit);
log2_max_pic_order_cnt_lsb_minus4 = Ue(buffer,bufferlen,StartBit);
cout<<"bit_depth_luma_minus8:"<<bit_depth_luma_minus8<<endl;
cout<<"bit_depth_chroma_minus8:"<<bit_depth_chroma_minus8<<endl;
cout<<"log2_max_pic_order_cnt_lsb_minus4:"<<log2_max_pic_order_cnt_lsb_minus4<<endl;
sps_sub_layer_ordering_info_present_flag = u(1,buffer,StartBit);
cout<<"sps_sub_layer_ordering_info_present_flag:"<<sps_sub_layer_ordering_info_present_flag<<endl;
int i;
uint32_t *sps_max_dec_pic_buffering_minus1 = new uint32_t[sps_max_sub_layers_minus1 + 1];
uint32_t *sps_max_num_reorder_pics = new uint32_t[sps_max_sub_layers_minus1 + 1];
uint32_t *sps_max_latency_increase_plus1 = new uint32_t[sps_max_sub_layers_minus1 + 1];
for (i = (sps_sub_layer_ordering_info_present_flag ? 0 : sps_max_sub_layers_minus1); i <= sps_max_sub_layers_minus1; i++ )
{
sps_max_dec_pic_buffering_minus1[i] = Ue(buffer,bufferlen,StartBit);
sps_max_num_reorder_pics[i] = Ue(buffer,bufferlen,StartBit);
sps_max_latency_increase_plus1[i] = Ue(buffer,bufferlen,StartBit);
}
uint32_t log2_min_luma_coding_block_size_minus3;
uint32_t log2_diff_max_min_luma_coding_block_size;
uint32_t log2_min_transform_block_size_minus2;
uint32_t log2_diff_max_min_transform_block_size;
uint32_t max_transform_hierarchy_depth_inter;
uint32_t max_transform_hierarchy_depth_intra;
bool scaling_list_enabled_flag;
log2_min_luma_coding_block_size_minus3 = Ue(buffer,bufferlen,StartBit);
log2_diff_max_min_luma_coding_block_size = Ue(buffer,bufferlen,StartBit);
log2_min_transform_block_size_minus2 = Ue(buffer,bufferlen,StartBit);
log2_diff_max_min_transform_block_size = Ue(buffer,bufferlen,StartBit);
max_transform_hierarchy_depth_inter = Ue(buffer,bufferlen,StartBit);
max_transform_hierarchy_depth_intra = Ue(buffer,bufferlen,StartBit);
scaling_list_enabled_flag = u(1,buffer,StartBit);
你只需要H.265/HEVC的规范文档,你可以找到here。显然这是一份相当长的文件。你应该寻找正确的 table.