static int _vorbis_skip_comment(oggpack_buffer *opb) { int i,vendorlen,comments; vendorlen=oggpack_read32(opb,32); if(vendorlen<0) goto err_out; oggpack_adv(opb,vendorlen*8); comments=oggpack_read32(opb,32); if(comments<0) goto err_out; for(i=0;i<comments;i++){ int len=oggpack_read32(opb,32); if(len<0) goto err_out; oggpack_adv(opb,len*8); } if(oggpack_read1(opb)!=1) goto err_out; /* EOP check */ oggpack_adv(opb,7); // byte alignment return(0); err_out: return(OV_EBADHEADER); }
static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb) { int i; int vendorlen=oggpack_read32(opb,32); if(vendorlen<0) goto err_out; vc->vendor=_ogg_calloc(vendorlen+1,1); _v_readstring(opb,vc->vendor,vendorlen); vc->comments=oggpack_read32(opb,32); if(vc->comments<0) goto err_out; vc->user_comments=_ogg_calloc(vc->comments+1,sizeof(*vc->user_comments)); vc->comment_lengths=_ogg_calloc(vc->comments+1, sizeof(*vc->comment_lengths)); for(i=0;i<vc->comments;i++){ int len=oggpack_read32(opb,32); if(len<0) goto err_out; vc->comment_lengths[i]=len; vc->user_comments[i]=_ogg_calloc(len+1,1); _v_readstring(opb,vc->user_comments[i],len); } if(oggpack_read1(opb)!=1) goto err_out; /* EOP check */ oggpack_adv(opb,7); // byte alignment return(0); err_out: vorbis_comment_clear(vc); return(OV_EBADHEADER); }
static PyObject * py_ogg_oggpack_adv(PyObject *self, PyObject *args) { oggpack_buffer * b; int bits; int size; PyArg_ParseTuple(args, "s#i", &b, &size, &bits); oggpack_adv(b, bits); Py_INCREF(Py_None); return Py_None; };
/* * Class: org_tritonus_lowlevel_ogg_Buffer * Method: adv * Signature: (I)V */ JNIEXPORT void JNICALL Java_org_tritonus_lowlevel_ogg_Buffer_adv (JNIEnv* env, jobject obj, jint nBits) { oggpack_buffer* handle; if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_ogg_Buffer_adv(): begin\n"); } handle = getHandle(env, obj); oggpack_adv(handle, nBits); if (debug_flag) { fprintf(debug_file, "Java_org_tritonus_lowlevel_ogg_Buffer_adv(): end\n"); } }
static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb) { codec_setup_info *ci=vi->codec_setup; if(!ci) return(OV_EFAULT); if(oggpack_read32(opb,32)!=0) // version return(OV_EVERSION); vi->channels=vi->outchannels=oggpack_read24(opb,8); vi->rate =oggpack_read32(opb,32); oggpack_adv(opb,32); // bitrate_upper vi->bitrate_nominal=oggpack_read32(opb,32); oggpack_adv(opb,32); // bitrate_lower ci->blocksizes[0]=1<<oggpack_read24(opb,4); ci->blocksizes[1]=1<<oggpack_read24(opb,4); if(vi->rate<1) goto err_out; if(vi->channels<1) goto err_out; if(ci->blocksizes[0]<8) goto err_out; if(ci->blocksizes[1]<ci->blocksizes[0]) goto err_out; if(oggpack_read1(opb)!=1) goto err_out; /* EOP check */ oggpack_adv(opb,7); // byte alignment return(0); err_out: vorbis_info_clear(vi); return(OV_EBADHEADER); }
static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb) { codec_setup_info *ci=vi->codec_setup; int i; if(!ci) return(OV_EFAULT); ci->books=oggpack_read24(opb,8)+1; for(i=0;i<ci->books;i++){ ci->book_param[i]=_ogg_calloc(1,sizeof(*ci->book_param[i])); if(vorbis_staticbook_unpack(opb,ci->book_param[i])) goto err_out; } { int times=oggpack_read24(opb,6)+1; for(i=0;i<times;i++){ int test=oggpack_read24(opb,16); if(test<0 || test>=VI_TIMEB) goto err_out; } } ci->floors=oggpack_read24(opb,6)+1; for(i=0;i<ci->floors;i++){ ci->floor_type[i]=oggpack_read24(opb,16); if(ci->floor_type[i]<0 || ci->floor_type[i]>=VI_FLOORB) goto err_out; ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb); if(!ci->floor_param[i]) goto err_out; } ci->residues=oggpack_read24(opb,6)+1; for(i=0;i<ci->residues;i++){ ci->residue_type[i]=oggpack_read24(opb,16); if(ci->residue_type[i]<0 || ci->residue_type[i]>=VI_RESB) goto err_out; ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb); if(!ci->residue_param[i]) goto err_out; } ci->maps=oggpack_read24(opb,6)+1; for(i=0;i<ci->maps;i++){ ci->map_type[i]=oggpack_read24(opb,16); 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; } ci->modes=oggpack_read24(opb,6)+1; 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_read1(opb); ci->mode_param[i]->windowtype=oggpack_read24(opb,16); ci->mode_param[i]->transformtype=oggpack_read24(opb,16); ci->mode_param[i]->mapping=oggpack_read24(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_read1(opb)!=1) goto err_out; /* top level EOP check */ oggpack_adv(opb,7); // byte alignment return(0); err_out: vorbis_info_clear(vi); return(OV_EBADHEADER); }
static vorbis_info_mapping *mapping0_unpack(vorbis_info *vi,oggpack_buffer *opb) { int i; vorbis_info_mapping0 *info=_ogg_calloc(1,sizeof(*info)); codec_setup_info *ci=vi->codec_setup; if(!info) goto err_out; _ogg_memset(info,0,sizeof(*info)); if(oggpack_read1(opb)) info->submaps=oggpack_read24(opb,4)+1; else info->submaps=1; if(oggpack_read1(opb)){ info->coupling_steps=oggpack_read24(opb,8)+1; info->coupling_mag=_ogg_malloc(sizeof(*info->coupling_mag)*info->coupling_steps); info->coupling_ang=_ogg_malloc(sizeof(*info->coupling_ang)*info->coupling_steps); if(!info->coupling_mag || !info->coupling_ang) goto err_out; for(i=0;i<info->coupling_steps;i++){ int testM=info->coupling_mag[i]=oggpack_read24(opb,ilog(vi->channels)); int testA=info->coupling_ang[i]=oggpack_read24(opb,ilog(vi->channels)); if(testM<0 || testA<0 || testM==testA || testM>=vi->channels || testA>=vi->channels) goto err_out; } } if(oggpack_read24(opb,2)!=0) goto err_out; info->chmuxlist=_ogg_calloc(vi->channels,sizeof(*info->chmuxlist)); if(!info->chmuxlist) goto err_out; if(info->submaps>1){ for(i=0;i<vi->channels;i++){ info->chmuxlist[i]=oggpack_read24(opb,4); if(info->chmuxlist[i]>=info->submaps) goto err_out; } } info->floorsubmap=_ogg_malloc(sizeof(*info->floorsubmap)*info->submaps); info->residuesubmap=_ogg_malloc(sizeof(*info->residuesubmap)*info->submaps); if(!info->floorsubmap || !info->residuesubmap) goto err_out; for(i=0;i<info->submaps;i++){ oggpack_adv(opb,8); info->floorsubmap[i]=oggpack_read24(opb,8); if(info->floorsubmap[i]>=ci->floors) goto err_out; info->residuesubmap[i]=oggpack_read24(opb,8); if(info->residuesubmap[i]>=ci->residues) goto err_out; } info->pcmbundle =_ogg_malloc(sizeof(*info->pcmbundle)*vi->channels); info->nonzero =_ogg_malloc(sizeof(*info->nonzero)*vi->channels); info->floormemo =_ogg_malloc(sizeof(*info->floormemo)*vi->channels); if(!info->pcmbundle || !info->nonzero || !info->floormemo) goto err_out; return info; err_out: mapping0_free_info(info); return(NULL); }
JNIEXPORT void JNICALL Java_org_echocat_jogg_OggPackBufferJNI_adv (JNIEnv *env, jclass thisClass, jlong handle, jint bits) { oggpack_adv((oggpack_buffer*) handle, bits); }