资源描述:
《从H264的SPS中获取图像长宽》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、从H264的SPS中获取图像长宽作者:李国帅从开源项目mpegip中选取,并封装。1,调用方法#include"H264Parser.h"h264_decode_tdec;memset(&dec,0,sizeof(dec));uint8_t*buffer=(uint8_t*)cbSPS;h264_parse_sequence_parameter_set(&dec,buffer,nSPS*8);outWidth=dec.pic_width;//1920;//outHeight=dec.pic_height;//1080
2、;//2,H264Parser.h代码#pragmaonce#ifndef__H264_H__#define__H264_H__1#include#include#include"stdint.h"#include"bitstream.h"//在mpegip中得到,就不粘贴了。typedefunsignedintuint;#defineH264_START_CODE0x000001#defineH264_PREVENT_3_BYTE0x000003#pragmapack(push)#
3、pragmapack(1)typedefstructh264_decode_t{uint8_tprofile;uint8_tlevel;uint32_tchroma_format_idc;uint8_tresidual_colour_transform_flag;uint32_tbit_depth_luma_minus8;uint32_tbit_depth_chroma_minus8;uint8_tqpprime_y_zero_transform_bypass_flag;uint8_tseq_scaling_matr
4、ix_present_flag;uint32_tlog2_max_frame_num_minus4;uint32_tlog2_max_pic_order_cnt_lsb_minus4;uint32_tpic_order_cnt_type;uint8_tframe_mbs_only_flag;uint8_tpic_order_present_flag;uint8_tdelta_pic_order_always_zero_flag;int32_toffset_for_non_ref_pic;int32_toffset_f
5、or_top_to_bottom_field;uint32_tpic_order_cnt_cycle_length;int16_toffset_for_ref_frame[256];uint8_tnal_ref_idc;uint8_tnal_unit_type;uint8_tfield_pic_flag;uint8_tbottom_field_flag;uint32_tframe_num;uint32_tidr_pic_id;uint32_tpic_order_cnt_lsb;int32_tdelta_pic_ord
6、er_cnt_bottom;int32_tdelta_pic_order_cnt[2];uint32_tpic_width,pic_height;uint32_tslice_type;/*POCstate*/int32_tpic_order_cnt;/*canbe<0*/uint32_tpic_order_cnt_msb;uint32_tpic_order_cnt_msb_prev;uint32_tpic_order_cnt_lsb_prev;uint32_tframe_num_prev;int32_tframe_n
7、um_offset;int32_tframe_num_offset_prev;uint8_tNalHrdBpPresentFlag;uint8_tVclHrdBpPresentFlag;uint8_tCpbDpbDelaysPresentFlag;uint8_tpic_struct_present_flag;uint8_tcpb_removal_delay_length_minus1;uint8_tdpb_output_delay_length_minus1;uint8_ttime_offset_length;uin
8、t32_tcpb_cnt_minus1;uint8_tinitial_cpb_removal_delay_length_minus1;}h264_decode_t;staticuint8_texp_golomb_bits[]={8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3