ov = new VorbisFile(arg[0]); } else { ov = new VorbisFile(System.in, null, -1); if (ov.seekable()) { System.out.println("Input bitstream contained " + ov.streams() + " logical bitstream section(s)."); System.out.println("Total bitstream playing time: " + ov.time_total(-1) + " seconds\n"); } else { for (int i = 0; i < ov.streams(); i++) { Info vi = ov.getInfo(i); System.out.println("\tlogical bitstream section " + (i + 1) + " information:"); System.out.println("\t\t" + vi.rate + "Hz " + vi.channels + " channels bitrate " + (ov.bitrate(i) / 1000) + "kbps serial number=" + ov.serialnumber(i)); System.out.print("\t\tcompressed length: " + ov.raw_total(i) + " bytes "); System.out.println(" play time: " + ov.time_total(i) + "s"); Comment vc = ov.getComment(i); System.out.println(vc);
long pcm_total=pcm_total(-1); float time_total=time_total(-1); decode_clear(); return -1; time_total-=time_total(link); if(seconds>=time_total) break; return (pcm_seek(target));
private void seek_helper(long offst){ fseek(datasource, offst, SEEK_SET); this.offset=offst; oy.reset(); }
public float time_tell(){ // translate time to PCM position and call pcm_seek int link=-1; long pcm_total=0; float time_total=0.f; if(seekable){ pcm_total=pcm_total(-1); time_total=time_total(-1); // which bitstream section does this time offset occur in? for(link=links-1; link>=0; link--){ pcm_total-=pcmlengths[link]; time_total-=time_total(link); if(pcm_offset>=pcm_total) break; } } return ((float)time_total+(float)(pcm_offset-pcm_total)/vi[link].rate); }
decode_clear(); return -1; decode_clear(); seek_helper(pos); switch(process_packet(1)){ case 0: pcm_offset=pcm_total(-1); return (0); case -1: decode_clear(); return -1; default: switch(process_packet(0)){ case 0: decode_clear(); return -1; default:
public int pcm_seek(long pos){ int link=-1; long total=pcm_total(-1); decode_clear(); return -1; seek_helper(bisect); ret=get_next_page(og, end-bisect); if(raw_seek(best)!=0){ decode_clear(); return -1; decode_clear(); return -1; if(pos>pcm_total(-1)){ decode_clear(); return -1; int target=(int)(pos-pcm_offset); float[][][] _pcm=new float[1][][]; int[] _index=new int[getInfo(-1).channels]; int samples=vd.synthesis_pcmout(_pcm, _index); if(process_packet(1)==0){ pcm_offset=pcm_total(-1); // eof
ret=fetch_headers(initial_i, initial_c, foo, null); serialno=foo[0]; dataoffset=(int)offset; //!! fseek(datasource, 0, SEEK_END); offset=ftell(datasource); end=offset; end=get_prev_page(og); if(bisect_forward_serialno(0, 0, end+1, serialno, 0)<0){ clear(); return OV_EREAD; if(bisect_forward_serialno(0, end, end+1, serialno, 0)<0){ clear(); return OV_EREAD; prefetch_all_headers(initial_i, initial_c, dataoffset); return 0;
if(get_next_page(og, -1)<0) return (0); // eof. leave unitialized decode_clear(); int ret=fetch_headers(vi[0], vc[0], foo, og); current_serialno=foo[0]; if(ret!=0) i=0; make_decode_ready();
int open_callbacks(InputStream is, byte[] initial, int ibytes//, callbacks callbacks ) throws JOrbisException { int ret; datasource = is; oy.init(); // perhaps some data was previously read into a buffer for testing // against other stream types. Allow initialization from this // previously read data (as we may be reading from a non-seekable // stream) if (initial != null) { int index = oy.buffer(ibytes); System.arraycopy(initial, 0, oy.data, index, ibytes); oy.wrote(ibytes); } // can we seek? Stevens suggests the seek test was portable if (is instanceof SeekableInputStream) { ret = open_seekable(); } else { ret = open_nonseekable(); } if (ret != 0) { datasource = null; clear(); } return ret; }
seek_helper(bisect); ret = get_next_page(page, -1); if (ret == OV_EREAD) return OV_EREAD; seek_helper(next); ret = get_next_page(page, -1); if (ret == OV_EREAD) return OV_EREAD; offsets[m + 1] = searched; } else { ret = bisect_forward_serialno(next, offset, end, page.serialno(), m + 1); if (ret == OV_EREAD) return OV_EREAD;
seek_helper(offsets[i]); //!!! vi[i]=new Info(); vc[i]=new Comment(); if(fetch_headers(vi[i], vc[i], null, null)==-1){ dataoffsets[i]=-1; seek_helper(end); ret=get_prev_page(og); if(ret==-1){
int read(byte[] buffer, int length, int bigendianp, int word, int sgned, int[] bitstream){ int host_endian=host_is_big_endian(); int index=0; float[][] pcm; float[][][] _pcm=new float[1][][]; int[] _index=new int[getInfo(-1).channels]; int samples=vd.synthesis_pcmout(_pcm, _index); pcm=_pcm[0]; if(samples!=0){ int channels=getInfo(-1).channels; int bytespersample=word*channels; if(samples>length/bytespersample) switch(process_packet(1)){ case 0: return (0);
return (-1); if (!seekable && i != 0) return (bitrate(0)); if (i < 0) { long bits = 0; bits += (offsets[j + 1] - dataoffsets[j]) * 8; return ((int) Math.rint(bits / time_total(-1))); } else { if (seekable) { return ((int) Math.rint((offsets[i + 1] - dataoffsets[i]) * 8 / time_total(i))); } else {
int open_nonseekable(){ // we cannot seek. Set up a 'single' (current) logical bitstream entry links=1; vi=new Info[links]; vi[0]=new Info(); // ?? vc=new Comment[links]; vc[0]=new Comment(); // ?? bug? // Try to fetch the headers, maintaining all the storage int[] foo=new int[1]; if(fetch_headers(vi[0], vc[0], foo, null)==-1) return (-1); current_serialno=foo[0]; make_decode_ready(); return 0; }
/** * Return the AudioFileFormat from the given file. */ public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) TDebug.out("getAudioFileFormat(File file)"); InputStream inputStream = null; try { inputStream = new BufferedInputStream(new FileInputStream(file)); inputStream.mark(MARK_LIMIT); AudioFileFormat aff = getAudioFileFormat(inputStream); inputStream.reset(); // Get Vorbis file info such as length in seconds. VorbisFile vf = new VorbisFile(file.getAbsolutePath()); return getAudioFileFormat(inputStream,(int) file.length(), (int) Math.round((vf.time_total(-1))*1000)); } catch (JOrbisException e) { throw new IOException(e.getMessage()); } finally { if (inputStream != null) inputStream.close(); } }
public float time_total(int i) { if (!seekable || i >= links) return (-1); if (i < 0) { float acc = 0; for (int j = 0; j < links; j++) { acc += time_total(j); } return (acc); } else { return ((float) (pcmlengths[i]) / vi[i].rate); } }
if (trackData.isFile()) { logger.fine("Opening file: " + trackData.getFile()); vorbisFile = new VorbisFile(trackData.getFile().getAbsolutePath()); streaming = false; oldBitrate = trackData.getBitrate(); vorbisFile = new VorbisFile(bis, null, 0); streaming = true; reloadComments(track); trackData.setCodec("OGG Vorbis Stream"); Info info = vorbisFile.getInfo()[0]; trackData.setSampleRate(info.rate); trackData.setChannels(info.channels);
float[][] pcm; float[][][] _pcm = new float[1][][]; int[] _index = new int[getInfo(-1).channels]; int samples = vd.synthesis_pcmout(_pcm, _index); pcm = _pcm[0]; if (samples != 0) { int channels = getInfo(-1).channels; int bytespersample = 2 * channels; if (samples > length / bytespersample) switch (process_packet(1)) { case 0: return (0);
public void seekSample(long sample) { vorbisFile.pcm_seek(sample); }
public int pcm_seek(long pos) { int link = -1; long total = pcm_total(-1); decode_clear(); return -1; seek_helper(bisect); ret = get_next_page(og, end - bisect); if (raw_seek(best) != 0) { decode_clear(); return -1; decode_clear(); return -1; if (pos > pcm_total(-1)) { decode_clear(); return -1; int target = (int) (pos - pcm_offset); float[][][] _pcm = new float[1][][]; int[] _index = new int[getInfo(-1).channels]; int samples = vd.synthesis_pcmout(_pcm, _index); if (process_packet(1) == 0) { pcm_offset = pcm_total(-1); // eof