方框{}

在本文中

方法

姓名说明
框::解析读取框标题。

来源

类框{public$size;//以字节为单位。公共$type;//四个字符。公共$version;//0或实际版本(如果这是一个完整的框)。公共$flags;//0或实际值(如果这是一个完整的框)。public$content_size;//'size”减去标题大小。/***读取框标题。**@param stream$handle将从中分析标头的资源。*@param int$num_parsed_boxes解析的框总数。防止超时。*@param int$num_remaining_bytes应从资源中可用的字节数。*@return成功时发现状态或失败时出错。*/公共函数解析($handle,&$num_parsed_boxes,$num_remaining_bytes=MAX_SIZE){//参见ISO/IEC 14496-12:2012(E)4.2$header_size=8;//32b尺寸+32b类型的盒子(至少)if($header_size>$num_remaining_bytes){返回INVALID;}if(!($data=read($handle,8)){返回TRUNCATED;}$this->size=read_big_endian($data,4);$this->type=substr($data,4,4);//“box->size==1”表示应在box类型之后读取64位大小。//“box->size==0”表示此框扩展到所有剩余字节。if($this->大小==1){$header_size+=8;if($header_size>$num_remaining_bytes){return INVALID;}if(!($data=read($handle,8)){返回TRUNCATED;}//如果任何框的大小大于4GB,则停止解析。if(read_big_endian($data,4)!=0 ) {返回ABORTED;}//读取32个最不重要的位。$this->size=read_big_endian(子项($data,4,4),4);}else if($this->size==0){$this->大小=$num_remaining_bytes;}if($this->size<$header_size){return INVALID;}if($this->size>$num_remaining_bytes){return INVALID;}$has_fullbox_header=$this->类型==“meta”||$this->type==“pitm”||$this->类型==“ipma”||$this->type==“ispe”||$this->类型==“pixi”||$this->type==“iref”||$this->类型==“auxC”;if($has_fullbox_header){$header_size+=4;}if($this->size<$header_size){return INVALID;}$this->content_size=$this->大小-$header_size;//避免超时。解析的框的最大数量是任意的。++$num_parsed_boxes;如果($num_parsed_boxes>=MAX_num_boxes){返回中止;}$this->版本=0;$this->标志=0;if($has_fullbox_header){if(!($data=read($handle,4)){返回TRUNCATED;}$this->version=read_big_endian($data,1);$this->flags=read_big_endian(子项($data,1,3),3);//参见AV1图像文件格式(AVIF)8.1//在https://aomediacodec.github.io/av1-avif/#avif-框(在以下情况下可用//https://github.com/AOMedia代码/av1-avif/pull/170合并)。$is_parsable=($this->type=='meta'&&$this->版本<=0)||($this->type=='pitm'&&$this->版本<=1)||($this->type==“ipma”&&$this->版本<=1)||($this->type==“ispe”&&$this->版本<=0)||($this->type==“pixi”&&$this->版本<=0)||($this->type=='iref'&&$this->版本<=1)||($this->type=='auxC'&&$this->版本<=0);//不要认为此文件无效,请跳过无法解析的框。if(!$is_parsable){$this->type='unknownversion';}}//print_r($this);//取消注释以打印所有框。返回FOUND;}}

用户贡献的笔记

你必须登录在能够发表注释或反馈之前。