Lines Matching defs:opb
209 static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
213 vi->version=oggpack_read(opb,32);
216 vi->channels=oggpack_read(opb,8);
217 vi->rate=oggpack_read(opb,32);
219 vi->bitrate_upper=oggpack_read(opb,32);
220 vi->bitrate_nominal=oggpack_read(opb,32);
221 vi->bitrate_lower=oggpack_read(opb,32);
223 ci->blocksizes[0]=1<<oggpack_read(opb,4);
224 ci->blocksizes[1]=1<<oggpack_read(opb,4);
232 if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
240 static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
242 int vendorlen=oggpack_read(opb,32);
244 if(vendorlen>opb->storage-8)goto err_out;
246 _v_readstring(opb,vc->vendor,vendorlen);
247 i=oggpack_read(opb,32);
249 if(i>((opb->storage-oggpack_bytes(opb))>>2))goto err_out;
255 int len=oggpack_read(opb,32);
257 if(len>opb->storage-oggpack_bytes(opb))goto err_out;
260 _v_readstring(opb,vc->user_comments[i],len);
262 if(oggpack_read(opb,1)!=1)goto err_out; /* EOP check */
272 static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
278 ci->books=oggpack_read(opb,8)+1;
281 ci->book_param[i]=vorbis_staticbook_unpack(opb);
287 int times=oggpack_read(opb,6)+1;
290 int test=oggpack_read(opb,16);
296 ci->floors=oggpack_read(opb,6)+1;
299 ci->floor_type[i]=oggpack_read(opb,16);
301 ci->floor_param[i]=_floor_P[ci->floor_type[i]]->unpack(vi,opb);
306 ci->residues=oggpack_read(opb,6)+1;
309 ci->residue_type[i]=oggpack_read(opb,16);
311 ci->residue_param[i]=_residue_P[ci->residue_type[i]]->unpack(vi,opb);
316 ci->maps=oggpack_read(opb,6)+1;
319 ci->map_type[i]=oggpack_read(opb,16);
321 ci->map_param[i]=_mapping_P[ci->map_type[i]]->unpack(vi,opb);
326 ci->modes=oggpack_read(opb,6)+1;
330 ci->mode_param[i]->blockflag=oggpack_read(opb,1);
331 ci->mode_param[i]->windowtype=oggpack_read(opb,16);
332 ci->mode_param[i]->transformtype=oggpack_read(opb,16);
333 ci->mode_param[i]->mapping=oggpack_read(opb,8);
341 if(oggpack_read(opb,1)!=1)goto err_out; /* top level EOP check */
351 oggpack_buffer opb;
355 oggpack_readinit(&opb,op->packet,op->bytes);
360 if(oggpack_read(&opb,8) != 1)
364 _v_readstring(&opb,buffer,6);
380 oggpack_buffer opb;
383 oggpack_readinit(&opb,op->packet,op->bytes);
389 int packtype=oggpack_read(&opb,8);
391 _v_readstring(&opb,buffer,6);
407 return(_vorbis_unpack_info(vi,&opb));
415 return(_vorbis_unpack_comment(vc,&opb));
423 return(_vorbis_unpack_books(vi,&opb));
437 static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){
442 oggpack_write(opb,0x01,8);
443 _v_writestring(opb,"vorbis", 6);
446 oggpack_write(opb,0x00,32);
447 oggpack_write(opb,vi->channels,8);
448 oggpack_write(opb,vi->rate,32);
450 oggpack_write(opb,vi->bitrate_upper,32);
451 oggpack_write(opb,vi->bitrate_nominal,32);
452 oggpack_write(opb,vi->bitrate_lower,32);
454 oggpack_write(opb,ilog2(ci->blocksizes[0]),4);
455 oggpack_write(opb,ilog2(ci->blocksizes[1]),4);
456 oggpack_write(opb,1,1);
461 static int _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){
465 oggpack_write(opb,0x03,8);
466 _v_writestring(opb,"vorbis", 6);
469 oggpack_write(opb,bytes,32);
470 _v_writestring(opb,ENCODE_VENDOR_STRING, bytes);
474 oggpack_write(opb,vc->comments,32);
479 oggpack_write(opb,vc->comment_lengths[i],32);
480 _v_writestring(opb,vc->user_comments[i], vc->comment_lengths[i]);
482 oggpack_write(opb,0,32);
486 oggpack_write(opb,1,1);
491 static int _vorbis_pack_books(oggpack_buffer *opb,vorbis_info *vi){
496 oggpack_write(opb,0x05,8);
497 _v_writestring(opb,"vorbis", 6);
500 oggpack_write(opb,ci->books-1,8);
502 if(vorbis_staticbook_pack(ci->book_param[i],opb))goto err_out;
505 oggpack_write(opb,0,6);
506 oggpack_write(opb,0,16);
509 oggpack_write(opb,ci->floors-1,6);
511 oggpack_write(opb,ci->floor_type[i],16);
513 _floor_P[ci->floor_type[i]]->pack(ci->floor_param[i],opb);
519 oggpack_write(opb,ci->residues-1,6);
521 oggpack_write(opb,ci->residue_type[i],16);
522 _residue_P[ci->residue_type[i]]->pack(ci->residue_param[i],opb);
526 oggpack_write(opb,ci->maps-1,6);
528 oggpack_write(opb,ci->map_type[i],16);
529 _mapping_P[ci->map_type[i]]->pack(vi,ci->map_param[i],opb);
533 oggpack_write(opb,ci->modes-1,6);
535 oggpack_write(opb,ci->mode_param[i]->blockflag,1);
536 oggpack_write(opb,ci->mode_param[i]->windowtype,16);
537 oggpack_write(opb,ci->mode_param[i]->transformtype,16);
538 oggpack_write(opb,ci->mode_param[i]->mapping,8);
540 oggpack_write(opb,1,1);
550 oggpack_buffer opb;
552 oggpack_writeinit(&opb);
553 if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
555 op->packet = _ogg_malloc(oggpack_bytes(&opb));
556 memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
558 op->bytes=oggpack_bytes(&opb);
574 oggpack_buffer opb;
584 oggpack_writeinit(&opb);
585 if(_vorbis_pack_info(&opb,vi))goto err_out;
589 b->header=_ogg_malloc(oggpack_bytes(&opb));
590 memcpy(b->header,opb.buffer,oggpack_bytes(&opb));
592 op->bytes=oggpack_bytes(&opb);
600 oggpack_reset(&opb);
601 if(_vorbis_pack_comment(&opb,vc))goto err_out;
604 b->header1=_ogg_malloc(oggpack_bytes(&opb));
605 memcpy(b->header1,opb.buffer,oggpack_bytes(&opb));
607 op_comm->bytes=oggpack_bytes(&opb);
615 oggpack_reset(&opb);
616 if(_vorbis_pack_books(&opb,vi))goto err_out;
619 b->header2=_ogg_malloc(oggpack_bytes(&opb));
620 memcpy(b->header2,opb.buffer,oggpack_bytes(&opb));
622 op_code->bytes=oggpack_bytes(&opb);
628 oggpack_writeclear(&opb);
636 oggpack_writeclear(&opb);