void vorbis_comment_add_tag(vorbis_comment *vc, constchar *tag, constchar *contents){ /* Length for key and value +2 for = and \0 */ char *comment=_ogg_malloc(strlen(tag)+strlen(contents)+2);
strcpy(comment, tag);
strcat(comment, "=");
strcat(comment, contents);
vorbis_comment_add(vc, comment);
_ogg_free(comment);
}
/* This is more or less the same as strncasecmp - but that doesn't exist
* everywhere, and this is a fairly trivial function, so we include it */ staticint tagcompare(constchar *s1, constchar *s2, int n){ int c=0; while(c < n){ if(_v_toupper(s1[c]) != _v_toupper(s2[c])) return !0;
c++;
} return0;
}
char *vorbis_comment_query(vorbis_comment *vc, constchar *tag, int count){ long i; int found = 0; int taglen = strlen(tag)+1; /* +1 for the = we append */ char *fulltag = _ogg_malloc(taglen+1);
strcpy(fulltag, tag);
strcat(fulltag, "=");
for(i=0;i<vc->comments;i++){ if(!tagcompare(vc->user_comments[i], fulltag, taglen)){ if(count == found) { /* We return a pointer to the data, not a copy */
_ogg_free(fulltag); return vc->user_comments[i] + taglen;
} else {
found++;
}
}
}
_ogg_free(fulltag); return NULL; /* didn't find anything */
}
int vorbis_comment_query_count(vorbis_comment *vc, constchar *tag){ int i,count=0; int taglen = strlen(tag)+1; /* +1 for the = we append */ char *fulltag = _ogg_malloc(taglen+1);
strcpy(fulltag,tag);
strcat(fulltag, "=");
/* blocksize 0 is guaranteed to be short, 1 is guaranteed to be long.
They may be equal, but short will never ge greater than long */ int vorbis_info_blocksize(vorbis_info *vi,int zo){
codec_setup_info *ci = vi->codec_setup; return ci ? ci->blocksizes[zo] : -1;
}
/* used by synthesis, which has a full, alloced vi */ void vorbis_info_init(vorbis_info *vi){
memset(vi,0,sizeof(*vi));
vi->codec_setup=_ogg_calloc(1,sizeof(codec_setup_info));
}
void vorbis_info_clear(vorbis_info *vi){
codec_setup_info *ci=vi->codec_setup; int i;
for(i=0;i<ci->maps;i++) /* unpack does the range checking */ if(ci->map_param[i]) /* this may be cleaning up an aborted unpack,inwhichcasethebelowtype
cannot be trusted */
_mapping_P[ci->map_type[i]]->free_info(ci->map_param[i]);
for(i=0;i<ci->floors;i++) /* unpack does the range checking */ if(ci->floor_param[i]) /* this may be cleaning up an aborted unpack,inwhichcasethebelowtype
cannot be trusted */
_floor_P[ci->floor_type[i]]->free_info(ci->floor_param[i]);
for(i=0;i<ci->residues;i++) /* unpack does the range checking */ if(ci->residue_param[i]) /* this may be cleaning up an aborted unpack,inwhichcasethebelowtype
cannot be trusted */
_residue_P[ci->residue_type[i]]->free_info(ci->residue_param[i]);
for(i=0;i<ci->books;i++){ if(ci->book_param[i]){ /* knows if the book was not alloced */
vorbis_staticbook_destroy(ci->book_param[i]);
} if(ci->fullbooks)
vorbis_book_clear(ci->fullbooks+i);
} if(ci->fullbooks)
_ogg_free(ci->fullbooks);
/* all of the real encoding details are here. The modes, books,
everything */ staticint _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=vi->codec_setup; int i;
if(!op->b_o_s) return(0); /* Not the initial packet */
if(oggpack_read(&opb,8) != 1) return0; /* not an ID header */
memset(buffer,0,6);
_v_readstring(&opb,buffer,6); if(memcmp(buffer,"vorbis",6)) return0; /* not vorbis */
return1;
}
return0;
}
/* The Vorbis header is in three packets; the initial small packet in thefirstpagethatidentifiesbasicparameters,asecondpacket withbitstreamcommentsandathirdpacketthatholdsthe
codebook. */
int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op){
oggpack_buffer opb;
/* 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){ case0x01: /* 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));
case0x03: /* least significant *bit* is read first */ if(vi->rate==0){ /* um... we didn't get the initial header */ return(OV_EBADHEADER);
} if(vc->vendor!=NULL){ /* previously initialized comment header */ return(OV_EBADHEADER);
}
return(_vorbis_unpack_comment(vc,&opb));
case0x05: /* 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);
} if(vi->codec_setup==NULL){ /* improperly initialized vorbis_info */ return(OV_EFAULT);
} if(((codec_setup_info *)vi->codec_setup)->books>0){ /* previously initialized setup header */ 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 **********************************************************/
/* We're not guaranteed a 64 bit unsigned type everywhere, so we
have to put the unsigned granpo in a signed type. */ if(granulepos>=0){ return((double)granulepos/v->vi->rate);
}else{
ogg_int64_t granuleoff=0xffffffff;
granuleoff<<=31;
granuleoff|=0x7ffffffff; return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.