static int _tarkin_pack_comment(oggpack_buffer *opb,TarkinComment *vc){ char temp[]="libTarkin debugging edition 20011104"; int bytes = strlen(temp); /* preamble */ oggpack_write(opb,0x03,8); _v_writestring(opb,"tarkin", 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); #ifdef DBG_OGG printf("dbg_ogg: Putting out %d comments\n", vc->comments); #endif return(0); }
static int BURGERCALL _vorbis_pack_comment(oggpack_buffer *opb,vorbis_comment *vc){ char temp[]="Xiphophorus libVorbis I 20011231"; 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_comment(oggpack_buffer *opb,vorbis_comment *vc){ int bytes = strlen(ENCODE_VENDOR_STRING); /* preamble */ oggpack_write(opb,0x03,8); _v_writestring(opb,"vorbis", 6); /* vendor */ oggpack_write(opb,bytes,32); _v_writestring(opb,ENCODE_VENDOR_STRING, 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 _commentheader_out(vcedit_state *state, ogg_packet *op) { vorbis_comment *vc = state->vc; char *vendor = state->vendor; oggpack_buffer opb; oggpack_writeinit(&opb); if (state->oggtype == VCEDIT_IS_OGGVORBIS) { /* preamble */ oggpack_write(&opb,0x03,8); _v_writestring(&opb,"vorbis", 6); } /* vendor */ oggpack_write(&opb,strlen(vendor),32); _v_writestring(&opb,vendor, strlen(vendor)); /* 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); 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; if (state->oggtype == VCEDIT_IS_OGGVORBIS) { op->packetno = 1; } oggpack_writeclear(&opb); return 0; }
static int _tarkin_pack_info (oggpack_buffer * opb, TarkinInfo * vi) { /* preamble */ oggpack_write (opb, 0x01, 8); _v_writestring (opb, "tarkin", 6); /* basic information about the stream */ oggpack_write (opb, 0x00, 32); oggpack_write (opb, vi->n_layers, 8); oggpack_write (opb, vi->inter.numerator, 32); oggpack_write (opb, vi->inter.denominator, 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, 1, 1); #ifdef DBG_OGG printf ("dbg_ogg: Putting out info, inter %d/%d, n_layers %d\n", vi->inter.numerator, vi->inter.denominator, vi->n_layers); #endif return (0); }
static int _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi) { codec_setup_info *ci=vi->codec_setup; if(!ci|| ci->blocksizes[0]<64|| ci->blocksizes[1]<ci->blocksizes[0]) { 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,ov_ilog(ci->blocksizes[0]-1),4); oggpack_write(opb,ov_ilog(ci->blocksizes[1]-1),4); 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); }
static bool write_comments (vcedit_state *s, ogg_packet *packet) { oggpack_buffer opb; size_t len; int i; ogg_packet_init (packet, NULL, 0); oggpack_writeinit (&opb); /* preamble */ oggpack_write (&opb, 0x03, 8); _v_writestring (&opb, "vorbis", 6); /* vendor */ len = strlen (s->vendor); oggpack_write (&opb, len, 32); _v_writestring (&opb, s->vendor, len); /* comments */ oggpack_write (&opb, s->vc.comments, 32); for (i = 0; i < s->vc.comments; i++) if (!s->vc.user_comments[i]) oggpack_write (&opb, 0, 32); else { oggpack_write (&opb, s->vc.comment_lengths[i], 32); _v_writestring (&opb, s->vc.user_comments[i], s->vc.comment_lengths[i]); } oggpack_write (&opb, 1, 1); packet->bytes = oggpack_bytes (&opb); packet->packet = _ogg_malloc (packet->bytes); if (!packet->packet) return false; memcpy (packet->packet, opb.buffer, packet->bytes); oggpack_writeclear (&opb); return true; }
static int _commentheader_out(vorbis_comment * vc, char *vendor, ogg_packet * op) { oggpack_buffer opb; oggpack_writeinit(&opb); /* preamble */ oggpack_write(&opb, 0x03, 8); _v_writestring(&opb, "vorbis", 6); /* vendor */ oggpack_write(&opb, strlen(vendor), 32); _v_writestring(&opb, vendor, strlen(vendor)); /* 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); 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; }
static int _tarkin_pack_layer_desc (oggpack_buffer * opb, TarkinInfo * vi) { int i; TarkinVideoLayer *layer; #ifdef DBG_OGG printf ("dbg_ogg: Putting out layers description:\n"); #endif oggpack_write (opb, 0x05, 8); _v_writestring (opb, "tarkin", 6); for (i = 0; i < vi->n_layers; i++) { layer = vi->layer + i; oggpack_write (opb, layer->desc.width, 32); oggpack_write (opb, layer->desc.height, 32); oggpack_write (opb, layer->desc.a_moments, 32); oggpack_write (opb, layer->desc.s_moments, 32); oggpack_write (opb, layer->desc.frames_per_buf, 32); oggpack_write (opb, layer->desc.bitstream_len, 32); oggpack_write (opb, layer->desc.format, 32); #ifdef DBG_OGG printf (" res. %dx%d, format %d, a_m %d, s_m %d, fpb %d\n", layer->desc.width, layer->desc.height, layer->desc.format, layer->desc.a_moments, layer->desc.s_moments, layer->desc.frames_per_buf); #endif } oggpack_write (opb, 1, 1); #ifdef DBG_OGG printf (" wrote %ld bytes.\n", oggpack_bytes (opb)); #endif return (0); }
static int BURGERCALL _vorbis_pack_info(oggpack_buffer *opb,vorbis_info *vi){ codec_setup_info *ci=static_cast<codec_setup_info *>(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); }