mpeg4解码程序框架.docx
- 文档编号:12714630
- 上传时间:2023-04-21
- 格式:DOCX
- 页数:13
- 大小:137.05KB
mpeg4解码程序框架.docx
《mpeg4解码程序框架.docx》由会员分享,可在线阅读,更多相关《mpeg4解码程序框架.docx(13页珍藏版)》请在冰豆网上搜索。
mpeg4解码程序框架
解码程序流程:
1、初始化解码所需资源。
例如:
设置输入文件、输出文件,代表解码所需各缓冲区大小的结构DEC_MEM_REQS及其中各对象所占空间大小的分配,缓冲区结构DEC_BUFFERS中对象初始化,解码所需变量的结构DEC_PARAM中各对象的初始化,解码所需资源初始化decore_init()如:
MP4_STATE、MP4_TABLES、MP4_STREAM以及MP4_STATE结构中部分代表VOL、VOP头标志的对象的初始化,设置关于图像尺寸的全局变量decore_alloc(),设置YUV格式decore_setoutput()等。
2、开始计时startTimer()。
3、代表解码帧的结构DEC_FRAME中对象void*bitstream,void*bmp,longlength,intrender_flag的初始化。
4、取得视频对象层头标志,getvolhdr()。
5、取得视频对象平面组头标志,getgophdr()。
6、取得视频对象平面头标志,getvophdr()。
7、得到Mpeg4图像,get_mp4picture()。
8、停止计时,stopTimer()。
9、显示解码所用时间、帧数,帧率。
displayTimer()。
get_mp4picture()
1)if((.mba =0)),处理每个宏块macroblock()。 2)为解码的帧增加边。 make_edge() 3)为重排帧序而管理帧的缓冲postprocess()。 4)RGB转换为YUVconvert_yuv()。 5)储存YUV到输出文件store_yuv()。 6)交换当前帧和参考帧位置。 Macroblock() (1)根据prediction_type标志判断此帧是否为I帧,不是I帧的话,根据.not_coded判断此宏块是否被编码,即这个宏块有没有进一步的数据包含在码流中。 (2)处理I帧或被编码的宏块 1)判断宏块类型derived_mb_type,以便后面运动解码和纹理解码使用; 2)假设宏块类型为1或4,设置量化值quantizer,量化允许值在[1,31]之间; 3)宏块类型为0或1,求出四个相同的运动向量setMV(-1); 4)宏块类型为2,求出四个不同运动向量。 for(j=0;j<4;j++)setMV(j); 5)如果宏块类型为3,且此帧为P帧时,将运动向量设为0; 6)如果帧间编码,进行运动补偿reconstruct(),recon_comp()和纹理解码blockInter(),addblockInter(); 7)如果帧内编码,只进行纹理解码blockInter(),addblockInter(); (3)处理没有被编码的宏块 1)置运动向量为0 2)运动补偿reconstruct(),recon_comp() (4)将量化值quantizer存入量化值表quant_store[mb_ypos+1][mb_xpos+1] (5)移动宏块坐标mb_xpos、mb_ypos,定位下一个宏块。 求运动向量setMV() 1、定义相关变量,hor_mv_data,、ver_mv_data、hor_mv_res、ver_mv_res,scale_fac、high、low、range,并初始化scale_fac、high、low、range,定义差分运动向量mvd_x,、mvd_y,、运动向量预测值pmv_x,、pmv_y,解码运动向量mv_x、mv_y; 2、根据运动向量表MVtab0[]、MVtab1[]、MVtab2[],通过函数getMVdata(),从码流中获得水平运动向量数据hor_mv_data; 3、从码流中恢复参数hor_mv_res,根据参数hor_mv_data、scale_fac和hor_mv_res,计算出水平差分运动向量mvd_x; 4、根据运动向量表,通过函数getMVdata(),从码流中获得垂直运动向量数据ver_mv_data; 5、从码流中恢复参数ver_mv_res,根据变量ver_mv_data、scale_fac和ver_mv_res、计算出垂直差分运动向量mvd_y; 6、通过函数find_pmv(),计算出运动向量预测值pmv_x,、pmv_y; 7、计算解码水平运动向量mv_x=pmv_x+mvd_x,限制mv_x在范围[low: high]内; 8、计算解码垂直运动向量mv_y=pmv_y+mvd_y,限制mv_y在范围[low: high]内; 9、把计算出的运动向量mv_x、mv_y分别存入运动向量的四维数组MV[0][i][mb_ypos+1][mb_xpos+1],MV[1][i][mb_ypos+1][mb_xpos+1] 1、getvolhdr(){ if(Video_Object_start_code) vo_id if(vol_start_code){ ident, random_accessible_vol type_indication is_object_layer_identifier if(is_object_layer_identifier){ visual_object_layer_verid visual_object_layer_priority } else{ visual_object_layer_verid=1 visual_object_layer_priority=1 } aspect_ratio_info vol_control_parameters if(vol_control_parameters){ chroma_format low_delay vbv_parameters if(vbv_parameters){ first_half_bit_rate markerbit latter_half_bit_rate markerbit first_half_vbv_buffer_size markerbit latter_half_vbv_buffer_size first_half_vbv_occupancy markerbit latter_half_vbv_occupancy markerbit } } Shape markerbit time_increment_resolution markerbit fixed_vop_rate if(fixed_vop_rate) fixed_vop_time_increment if(shape! =BINARY_SHAPE_ONLY){ if(shape==RECTANGULAR){ markerbit width markerbit height markerbit } Interlaced if(visual_object_layer_verid==1) sprite_usage=1比特 else sprite_usage=2比特 not_8_bit if(not_8_bit){ quant_precision bits_per_pixel } quant_type if(quant_type){ load_intra_quant_matrix if(load_intra_quant_matrix) intra_quant_matrix load_nonintra_quant_matrix if(load_nonintra_quant_matrix) nonintra_quant_matrix } if(visual_object_layer_verid! =1) quarter_pixel complexity_estimation_disable error_res_disable data_partitioning if(data_partitioning) exit; else error_res_disable=1 scalability if(scalability) exit if(USER_DATA_START_CODE) exit } } } 2、getgophdr(){ gop_start_code time_code closed_gov broken_link } 3、getVophdr(){ vop_start_code prediction_type do{ time_base; }while(time_base==1) markerbit time_inc markerbit vop_coded if(vop_coded==0){ next_start_code() return; } if((shape! =BINARY_SHAPE_ONLY)&&(prediction_type==P_VOP)) rounding_type if(shape! =RECTANGULAR) { if(! (sprite_usage&&prediction_type==I_VOP)) { width markerbit height markerbit hor_spat_ref markerbit ver_spat_ref markerbit } change_CR_disable constant_alpha if(constant_alpha) constant_alpha_value } if(! complexity_estimation_disable){ exit } if(shape! =BINARY_SHAPE_ONLY) { intra_dc_vlc_thr if(interlaced){ exit } } if(shape! =BINARY_SHAPE_ONLY) { Quantizer if(prediction_type! =I_VOP) { fcode_for } if(! scalability) { if(shape==BINARY&&.prediction_type! =I_VOP) shape_coding_type /*motion_shape_texture()*/ } } }
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- mpeg4 解码 程序 框架