#include "misc.h"
#include "os.h"
-#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.0pre"
-#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20100303pre (Everywhere)"
+#define GENERAL_VENDOR_STRING "Xiph.Org libVorbis 1.3.3"
+#define ENCODE_VENDOR_STRING "Xiph.Org libVorbis I 20120203 (Omnipresent)"
/* helpers */
static int ilog2(unsigned int v){
oggpack_buffer opb;
oggpack_writeinit(&opb);
- if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
+ if(_vorbis_pack_comment(&opb,vc)){
+ oggpack_writeclear(&opb);
+ return OV_EIMPL;
+ }
op->packet = _ogg_malloc(oggpack_bytes(&opb));
memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
op->granulepos=0;
op->packetno=1;
+ oggpack_writeclear(&opb);
return 0;
}
}
double vorbis_granule_time(vorbis_dsp_state *v,ogg_int64_t granulepos){
- if(granulepos>=0)
+ if(granulepos == -1) return -1;
+
+ /* 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);
- return(-1);
+ }else{
+ ogg_int64_t granuleoff=0xffffffff;
+ granuleoff<<=31;
+ granuleoff|=0x7ffffffff;
+ return(((double)granulepos+2+granuleoff+granuleoff)/v->vi->rate);
+ }
}
const char *vorbis_version_string(void){