⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 info.c

📁 在x86平台上运行不可信任代码的sandbox。
💻 C
📖 第 1 页 / 共 2 页
字号:
    if(ci->map_type[i]<0 || ci->map_type[i]>=VI_MAPB)goto err_out;    ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb);    if(!ci->map_param[i])goto err_out;  }    /* mode settings */  ci->modes=oggpack_read(opb,6)+1;  /*vi->mode_param=_ogg_calloc(vi->modes,sizeof(void *));*/  for(i=0;i<ci->modes;i++){    ci->mode_param[i]=_ogg_calloc(1,sizeof(*ci->mode_param[i]));    ci->mode_param[i]->blockflag=oggpack_read(opb,1);    ci->mode_param[i]->windowtype=oggpack_read(opb,16);    ci->mode_param[i]->transformtype=oggpack_read(opb,16);    ci->mode_param[i]->mapping=oggpack_read(opb,8);    if(ci->mode_param[i]->windowtype>=VI_WINDOWB)goto err_out;    if(ci->mode_param[i]->transformtype>=VI_WINDOWB)goto err_out;    if(ci->mode_param[i]->mapping>=ci->maps)goto err_out;  }    if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */  return(0); err_out:  vorbis_info_clear(vi);  return(OV_EBADHEADER);}/* The Vorbis header is in three packets; the initial small packet in   the first page that identifies basic parameters, a second packet   with bitstream comments and a third packet that holds the   codebook. */int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){  oggpack_buffer opb;    if(op){    oggpack_readinit(&opb,op->packet,op->bytes);    /* Which of the three types of header is this? */    /* Also verify header-ness, vorbis */    {      char buffer[6];      int packtype=oggpack_read(&opb,8);      memset(buffer,0,6);      _v_readstring(&opb,buffer,6);      if(memcmp(buffer,"vorbis",6)){	/* not a vorbis header */	return(OV_ENOTVORBIS);      }      switch(packtype){      case 0x01: /* least significant *bit* is read first */	if(!op->b_o_s){	  /* Not the initial packet */	  return(OV_EBADHEADER);	}	if(vi->rate!=0){	  /* previously initialized info header */	  return(OV_EBADHEADER);	}	return(_vorbis_unpack_info(vi,&opb));      case 0x03: /* least significant *bit* is read first */	if(vi->rate==0){	  /* um... we didn't get the initial header */	  return(OV_EBADHEADER);	}	return(_vorbis_unpack_comment(vc,&opb));      case 0x05: /* least significant *bit* is read first */	if(vi->rate==0 || vc->vendor==NULL){	  /* um... we didn;t get the initial header or comments yet */	  return(OV_EBADHEADER);	}	return(_vorbis_unpack_books(vi,&opb));      default:	/* Not a valid vorbis header type */	return(OV_EBADHEADER);	break;      }    }  }  return(OV_EBADHEADER);}/* pack side **********************************************************/static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){  codec_setup_info     *ci=vi->codec_setup;  if(!ci)return(OV_EFAULT);  /* preamble */    oggpack_write(opb,0x01,8);  _v_writestring(opb,"vorbis", 6);  /* basic information about the stream */  oggpack_write(opb,0x00,32);  oggpack_write(opb,vi->channels,8);  oggpack_write(opb,vi->rate,32);  oggpack_write(opb,vi->bitrate_upper,32);  oggpack_write(opb,vi->bitrate_nominal,32);  oggpack_write(opb,vi->bitrate_lower,32);  oggpack_write(opb,ilog2(ci->blocksizes[0]),4);  oggpack_write(opb,ilog2(ci->blocksizes[1]),4);  oggpack_write(opb,1,1);  return(0);}static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){  char temp[]="Xiph.Org libVorbis I 20030909";  int bytes = strlen(temp);  /* preamble */    oggpack_write(opb,0x03,8);  _v_writestring(opb,"vorbis", 6);  /* vendor */  oggpack_write(opb,bytes,32);  _v_writestring(opb,temp, bytes);    /* comments */  oggpack_write(opb,vc->comments,32);  if(vc->comments){    int i;    for(i=0;i<vc->comments;i++){      if(vc->user_comments[i]){	oggpack_write(opb,vc->comment_lengths[i],32);	_v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);      }else{	oggpack_write(opb,0,32);      }    }  }  oggpack_write(opb,1,1);  return(0);} static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){  codec_setup_info     *ci=vi->codec_setup;  int i;  if(!ci)return(OV_EFAULT);  oggpack_write(opb,0x05,8);  _v_writestring(opb,"vorbis", 6);  /* books */  oggpack_write(opb,ci->books-1,8);  for(i=0;i<ci->books;i++)    if(vorbis_staticbook_pack(ci->book_param[i],opb))goto err_out;  /* times; hook placeholders */  oggpack_write(opb,0,6);  oggpack_write(opb,0,16);  /* floors */  oggpack_write(opb,ci->floors-1,6);  for(i=0;i<ci->floors;i++){    oggpack_write(opb,ci->floor_type[i],16);    if(_floor_P[ci->floor_type[i]]->pack)      _floor_P[ci->floor_type[i]]->pack(ci->floor_param[i],opb);    else      goto err_out;  }  /* residues */  oggpack_write(opb,ci->residues-1,6);  for(i=0;i<ci->residues;i++){    oggpack_write(opb,ci->residue_type[i],16);    _residue_P[ci->residue_type[i]]->pack(ci->residue_param[i],opb);  }  /* maps */  oggpack_write(opb,ci->maps-1,6);  for(i=0;i<ci->maps;i++){    oggpack_write(opb,ci->map_type[i],16);    _mapping_P[ci->map_type[i]]->pack(vi,ci->map_param[i],opb);  }  /* modes */  oggpack_write(opb,ci->modes-1,6);  for(i=0;i<ci->modes;i++){    oggpack_write(opb,ci->mode_param[i]->blockflag,1);    oggpack_write(opb,ci->mode_param[i]->windowtype,16);    oggpack_write(opb,ci->mode_param[i]->transformtype,16);    oggpack_write(opb,ci->mode_param[i]->mapping,8);  }  oggpack_write(opb,1,1);  return(0);err_out:  return(-1);} int vorbis_commentheader_out(vorbis_comment *vc,    				      ogg_packet *op){  oggpack_buffer opb;  oggpack_writeinit(&opb);  if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;  op->packet = _ogg_malloc(oggpack_bytes(&opb));  memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));  op->bytes=oggpack_bytes(&opb);  op->b_o_s=0;  op->e_o_s=0;  op->granulepos=0;  return 0;}int vorbis_analysis_headerout(vorbis_dsp_state *v,			      vorbis_comment *vc,			      ogg_packet *op,			      ogg_packet *op_comm,			      ogg_packet *op_code){  int ret=OV_EIMPL;  vorbis_info *vi=v->vi;  oggpack_buffer opb;  private_state *b=v->backend_state;  if(!b){    ret=OV_EFAULT;    goto err_out;  }  /* first header packet **********************************************/  oggpack_writeinit(&opb);  if(_vorbis_pack_info(&opb,vi))goto err_out;  /* build the packet */  if(b->header)_ogg_free(b->header);  b->header=_ogg_malloc(oggpack_bytes(&opb));  memcpy(b->header,opb.buffer,oggpack_bytes(&opb));  op->packet=b->header;  op->bytes=oggpack_bytes(&opb);  op->b_o_s=1;  op->e_o_s=0;  op->granulepos=0;  /* second header packet (comments) **********************************/  oggpack_reset(&opb);  if(_vorbis_pack_comment(&opb,vc))goto err_out;  if(b->header1)_ogg_free(b->header1);  b->header1=_ogg_malloc(oggpack_bytes(&opb));  memcpy(b->header1,opb.buffer,oggpack_bytes(&opb));  op_comm->packet=b->header1;  op_comm->bytes=oggpack_bytes(&opb);  op_comm->b_o_s=0;  op_comm->e_o_s=0;  op_comm->granulepos=0;  /* third header packet (modes/codebooks) ****************************/  oggpack_reset(&opb);  if(_vorbis_pack_books(&opb,vi))goto err_out;  if(b->header2)_ogg_free(b->header2);  b->header2=_ogg_malloc(oggpack_bytes(&opb));  memcpy(b->header2,opb.buffer,oggpack_bytes(&opb));  op_code->packet=b->header2;  op_code->bytes=oggpack_bytes(&opb);  op_code->b_o_s=0;  op_code->e_o_s=0;  op_code->granulepos=0;  oggpack_writeclear(&opb);  return(0); err_out:  oggpack_writeclear(&opb);  memset(op,0,sizeof(*op));  memset(op_comm,0,sizeof(*op_comm));  memset(op_code,0,sizeof(*op_code));  if(b->header)_ogg_free(b->header);  if(b->header1)_ogg_free(b->header1);  if(b->header2)_ogg_free(b->header2);  b->header=NULL;  b->header1=NULL;  b->header2=NULL;  return(ret);}double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){  if(granulepos>=0)    return((double)granulepos/v->vi->rate);  return(-1);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -