libjorbis-java-0.0.17.orig/0000775000175000017500000000000011010350672013535 5ustar godgodlibjorbis-java-0.0.17.orig/README0000644000175000017500000001036007362257414014432 0ustar godgod JOrbis a pure Java(TM) Ogg Vorbis decoder by ymnk, JCraft,Inc. http://www.jcraft.com/jorbis/ Last modified: Mon May 7 14:31:03 UTC 2001 Description =========== JOrbis is a pure Java Ogg Vorbis decoder. JOrbis accepts Ogg Vorbis bitstreams and decodes them to raw PCMs. Documentation ============= Read before asking. * README files all over the source tree have info related to the stuff in the directories. Directories & Files in the Source Tree ====================================== * com/ has source trees of JOrbis. * player/ has source and binaries of pure Java Ogg Vorbis player. Copyrights & Disclaimers ======================== JOrbis is copyrighted by JCraft Inc. and is licensed through the GNU Lesser General Public License. Read the COPYING.LIB file for the complete license. Credits ======= All credits goes to authors, Moty,The XIPHOPHORUS Company and contributers of Ogg Vorbis. What is Ogg Vorbis? =================== Here is a quote from README of Ogg Vorbis CODEC from the Developer site for Ogg Vorbis(http://xiph.org/ogg/vorbis/). "Vorbis is a general purpose audio and music encoding format contemporary to MPEG-4's AAC and TwinVQ, the next generation beyond MPEG audio layer 3. Unlike the MPEG sponsored formats (and other proprietary formats such as RealAudio G2 and Windows' flavor of the month), the Vorbis CODEC specification belongs to the public domain. All the technical details are published and documented, and any software entity may make full use of the format without royalty or patent concerns." Why JOrbis? =========== We sympathize the aim of Ogg project. JOrbis is our contribution to the Ogg project in our style. We think the ubiquity of Vorbis decoder will leverage the popularity of Ogg Vorbis. We hope JOrbis will run on any platform, any devices and any web browsers, which support Java and every people will enjoy streamed musics without without royalty or patent concerns. Features ======== * JOrbis is in pure JavaTM. JOrbis will run on JDK1.0.* or higher and may run on J2METM. * JOrbis is under LGPL. Current Status ============== The sound quality of outputs from JOrbis has been improved. If you had tried last version(0.0.1) and been disappointed with its quality, try current version. It will be worth trying. However, in current implementation, the efficiency has not been cared and many CPU resources are required. Much work must be done to solve this problem. How To Try JOrbis ================= A sample program DecodeExample.java has been included in an archive.
If you are on RedHat's GNU/Linux box, just try, $ cat foo.ogg | java com.jcraft.jorbis.DecodeExample | esdcat If outputs are noisy, save outputs in a file then cat it to esdcat. Ogg files are available at http://vorbis.com/listen.html and if you have Ogg Vorbis CODEC from xiph.org, you can make ogg files by your self. How To Play JOrbisPlayer ======================== The Ogg Voribs player, 'JOrbisPlayer', is available at the 'player' directory. It is a pure Java program, but it uses Java Sound APIs. If you have J2SE V.1.3 Java VM, you can enjoy it. *step1: Copy contents in the 'player' directory to some directory, which is accessible via the http server. *step2: Copy some ogg files to that directory. *step3: Change directory to that directory, make 'playlist' file. For example, 'ls *.ogg > playlist' *step4: Open 'JOrbisPlayer.html' file by a web browser via http server. JOrbisPlayer will run on a web browser automatically. 'JOrbisPlayer' also works as an application, so just try 'java JOrbisPlayer' in the 'player' directory. For example, on GNU/Linux, $ cd player $ export CLASSPATH=.:.. $ java JOrbisPlayer foo.ogg bar.ogg http://shomewahre/goo.ogg If you don't have the direct connections to the Internet and you have the http proxy server at 192.168.0.1:80, try as follows, $ java -Dhttp.proxyHost=192.168.0.1 -Dhttp.proxyPort=80 JOrbisPlayer http://shomewahre/goo.ogg In our experiences, if your machine has a Cerelon, you will be able to enjoy JOrbisPlayer. If you have any comments, suggestions and questions, write us at jorbis@jcraft.com libjorbis-java-0.0.17.orig/player/0000755000175000017500000000000011010326151015022 5ustar godgodlibjorbis-java-0.0.17.orig/player/JOrbisPlayer.java0000644000175000017500000006555211010261112020242 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbisPlayer -- pure Java Ogg Vorbis player * * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec and * JOrbisPlayer depends on JOrbis. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import java.util.*; import java.net.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.applet.*; import javax.swing.*; import com.jcraft.jorbis.*; import com.jcraft.jogg.*; import javax.sound.sampled.*; public class JOrbisPlayer extends JApplet implements ActionListener, Runnable{ private static final long serialVersionUID=1L; boolean running_as_applet=true; Thread player=null; InputStream bitStream=null; int udp_port=-1; String udp_baddress=null; static AppletContext acontext=null; static final int BUFSIZE=4096*2; static int convsize=BUFSIZE*2; static byte[] convbuffer=new byte[convsize]; private int RETRY=3; int retry=RETRY; String playlistfile="playlist"; boolean icestats=false; SyncState oy; StreamState os; Page og; Packet op; Info vi; Comment vc; DspState vd; Block vb; byte[] buffer=null; int bytes=0; int format; int rate=0; int channels=0; int left_vol_scale=100; int right_vol_scale=100; SourceDataLine outputLine=null; String current_source=null; int frameSizeInBytes; int bufferLengthInBytes; boolean playonstartup=false; public void init(){ running_as_applet=true; acontext=getAppletContext(); String s=getParameter("jorbis.player.playlist"); playlistfile=s; s=getParameter("jorbis.player.icestats"); if(s!=null&&s.equals("yes")){ icestats=true; } loadPlaylist(); initUI(); if(playlist.size()>0){ s=getParameter("jorbis.player.playonstartup"); if(s!=null&&s.equals("yes")){ playonstartup=true; } } setBackground(Color.lightGray); // setBackground(Color.white); getContentPane().setLayout(new BorderLayout()); getContentPane().add(panel); } public void start(){ super.start(); if(playonstartup){ play_sound(); } } void init_jorbis(){ oy=new SyncState(); os=new StreamState(); og=new Page(); op=new Packet(); vi=new Info(); vc=new Comment(); vd=new DspState(); vb=new Block(vd); buffer=null; bytes=0; oy.init(); } SourceDataLine getOutputLine(int channels, int rate){ if(outputLine==null||this.rate!=rate||this.channels!=channels){ if(outputLine!=null){ outputLine.drain(); outputLine.stop(); outputLine.close(); } init_audio(channels, rate); outputLine.start(); } return outputLine; } void init_audio(int channels, int rate){ try{ //ClassLoader originalClassLoader=null; //try{ // originalClassLoader=Thread.currentThread().getContextClassLoader(); // Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader()); //} //catch(Exception ee){ // System.out.println(ee); //} AudioFormat audioFormat=new AudioFormat((float)rate, 16, channels, true, // PCM_Signed false // littleEndian ); DataLine.Info info=new DataLine.Info(SourceDataLine.class, audioFormat, AudioSystem.NOT_SPECIFIED); if(!AudioSystem.isLineSupported(info)){ //System.out.println("Line " + info + " not supported."); return; } try{ outputLine=(SourceDataLine)AudioSystem.getLine(info); //outputLine.addLineListener(this); outputLine.open(audioFormat); } catch(LineUnavailableException ex){ System.out.println("Unable to open the sourceDataLine: "+ex); return; } catch(IllegalArgumentException ex){ System.out.println("Illegal Argument: "+ex); return; } frameSizeInBytes=audioFormat.getFrameSize(); int bufferLengthInFrames=outputLine.getBufferSize()/frameSizeInBytes/2; bufferLengthInBytes=bufferLengthInFrames*frameSizeInBytes; //if(originalClassLoader!=null) // Thread.currentThread().setContextClassLoader(originalClassLoader); this.rate=rate; this.channels=channels; } catch(Exception ee){ System.out.println(ee); } } private int item2index(String item){ for(int i=0; i=cb.getItemCount()){ current_index=0; } if(cb.getItemCount()<=0) break; } player=null; start_button.setText("start"); } private void play_stream(Thread me){ boolean chained=false; init_jorbis(); retry=RETRY; //System.out.println("play_stream>"); loop: while(true){ int eos=0; int index=oy.buffer(BUFSIZE); buffer=oy.data; try{ bytes=bitStream.read(buffer, index, BUFSIZE); } catch(Exception e){ System.err.println(e); return; } oy.wrote(bytes); if(chained){ // chained=false; // } // else{ // if(oy.pageout(og)!=1){ if(bytes0){ float[][] pcmf=_pcmf[0]; int bout=(samples32767){ val=32767; } if(val<-32768){ val=-32768; } if(val<0) val=val|0x8000; convbuffer[ptr]=(byte)(val); convbuffer[ptr+1]=(byte)(val>>>8); ptr+=2*(vi.channels); } } outputLine.write(convbuffer, 0, 2*vi.channels*bout); vd.synthesis_read(bout); } } } if(og.eos()!=0) eos=1; } } if(eos==0){ index=oy.buffer(BUFSIZE); buffer=oy.data; try{ bytes=bitStream.read(buffer, index, BUFSIZE); } catch(Exception e){ System.err.println(e); return; } if(bytes==-1){ break; } oy.wrote(bytes); if(bytes==0) eos=1; } } os.clear(); vb.clear(); vd.clear(); vi.clear(); } oy.clear(); try{ if(bitStream!=null) bitStream.close(); } catch(Exception e){ } } private void play_udp_stream(Thread me){ init_jorbis(); try{ loop: while(true){ int index=oy.buffer(BUFSIZE); buffer=oy.data; try{ bytes=bitStream.read(buffer, index, BUFSIZE); } catch(Exception e){ System.err.println(e); return; } oy.wrote(bytes); if(oy.pageout(og)!=1){ // if(bytes=0; i--){ if(foo[i]=='/'){ item=item.substring(0, i+1)+"stats.xml"; break; } } System.out.println(item); try{ URL url=null; if(running_as_applet) url=new URL(getCodeBase(), item); else url=new URL(item); BufferedReader stats=new BufferedReader(new InputStreamReader(url .openConnection().getInputStream())); while(true){ String bar=stats.readLine(); if(bar==null) break; System.out.println(bar); } } catch(Exception ee){ //System.err.println(ee); } return; } String command=((JButton)(e.getSource())).getText(); if(command.equals("start")&&player==null){ play_sound(); } else if(player!=null){ stop_sound(); } } public String getTitle(){ return (String)(cb.getSelectedItem()); } public void play_sound(){ if(player!=null) return; player=new Thread(this); start_button.setText("stop"); player.start(); } public void stop_sound(){ if(player==null) return; player=null; start_button.setText("start"); } InputStream selectSource(String item){ if(item.endsWith(".pls")){ item=fetch_pls(item); if(item==null) return null; //System.out.println("fetch: "+item); } else if(item.endsWith(".m3u")){ item=fetch_m3u(item); if(item==null) return null; //System.out.println("fetch: "+item); } if(!item.endsWith(".ogg")){ return null; } InputStream is=null; URLConnection urlc=null; try{ URL url=null; if(running_as_applet) url=new URL(getCodeBase(), item); else url=new URL(item); urlc=url.openConnection(); is=urlc.getInputStream(); current_source=url.getProtocol()+"://"+url.getHost()+":"+url.getPort() +url.getFile(); } catch(Exception ee){ System.err.println(ee); } if(is==null&&!running_as_applet){ try{ is=new FileInputStream(System.getProperty("user.dir") +System.getProperty("file.separator")+item); current_source=null; } catch(Exception ee){ System.err.println(ee); } } if(is==null) return null; System.out.println("Select: "+item); { boolean find=false; for(int i=0; i0){ if((i=inend-instart)inbuffer.length){ n=inbuffer.length; } instart=inend=0; int i; while(true){ recpacket.setData(buf, 0, 1024); socket.receive(recpacket); i=recpacket.getLength(); System.arraycopy(recpacket.getData(), 0, inbuffer, inend, i); if(i==-1){ throw new java.io.IOException(); } inend+=i; break; } } public void close() throws java.io.IOException{ socket.close(); } public int read() throws java.io.IOException{ return 0; } public int read(byte[] array, int begin, int length) throws java.io.IOException{ return getByte(array, begin, length); } } public static void main(String[] arg){ JFrame frame=new JFrame("JOrbisPlayer"); frame.setBackground(Color.lightGray); frame.setBackground(Color.white); frame.getContentPane().setLayout(new BorderLayout()); frame.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); JOrbisPlayer player=new JOrbisPlayer(); player.running_as_applet=false; if(arg.length>0){ for(int i=0; i JOrbisPlayer

JOrbisPlayer

</COMMENT> No J2SE plugin support.

  Copyright © 1998-2002 JCraft,Inc. libjorbis-java-0.0.17.orig/ChangeLog0000644000175000017500000000606011010350672015307 0ustar godgod ChangeLog of JOrbis ==================================================================== Last modified: Wed May 7 15:42:40 UTC 2008 Changes since version 0.0.16: - change: refactoring code to improve the performance; suppressing frequent GC in Residue. Changes since version 0.0.15: - feature: added a property 'jorbis.player.playonstartup' to JOrbisPlayer applet to play given stream at the start-up time. Refer to 'play/JOrbisPlayer.html'. Changes since version 0.0.14: - bugfix: case-insensitive matching in Comment was broken. - bugfix: query for the tag "ART" would match the tag "ARTIST". Many thanks to Gregorio Roper at gmx dot li, who pointed out above problem. Changes since version 0.0.13: - added com.jcraft.jogg.Buffer.readB method for Fluendo's theora decoder. - added com.jcraft.jogg.Page.copy method for handling grouped ogg streams. Changes since version 0.0.12: - fixed resorce leaks in com.jcraft.jorbis.VorbisFile class. Changes since version 0.0.11: - updated VorbisFile class for calculating total length in seconds of a Vorbis file. - some improvements on JOrbisPlayer. For example, songs on play-list will be played sequentially. Changes since version 0.0.10: - fixed bugs and incompleteness in the 'residue back-end type 2', which is required for decoding stereo coupling streams generated by RC3 encoder. - fixed minor bugs in JOrbisPlayer. Changes since version 0.0.9: - modified JOrbisPlayer for playing Ogg Vorbis live streams on UDP broadcast packets from JRoar 0.0.2. Changes since version 0.0.8: - improved the performance. In this improvement, the frequency of GC invocations has been suppressed by refraining from object allocations. - modified JOrbisPlayer for accepting *.m3u file. Changes since version 0.0.7: - added a 'simple' comment editor in pure Java. It has been located at 'comment_editor' directory. - improved for decoding Ogg Vorbis streams generated by 1.0 RC2 encoder. - modified JOrbisPlayer for accepting *.pls file. Changes since version 0.0.6: - fixed bugs in playing the chained ogg bit stream. Changes since version 0.0.5: - added the support for odd-sized LSP filters. Now, JOribPlayer can correctly decode/play low bitrate ogg bit streams, which are encoded by Vorbis 1.0beta4. Many thanks to smoerk, who reported me a glitch in playing low bitrate ogg bit streams on previous releases. - tuned up the performance a little bit. Changes since version 0.0.4: - fixed a bug in the LSP conversion routines. Now, JOribPlayer can decode/play 24khz/mono ogg bit streams. - fixed a bug in handling comments. Changes since version 0.0.3: - modified to use the data type 'float' instead of 'double' for handling internal data. - added the LSP conversion routines. - moved chunk of code for handling the ogg bit stream to the 'com.jcraft.jogg' package. Changes since version 0.0.2: - added a pure Java Ogg Vorbis player. Changes since version 0.0.1: - fixed bugs in the synthesis engine. By this bug fix, the sound quality of output from JOrbis has been improved. libjorbis-java-0.0.17.orig/comment_editor/0000755000175000017500000000000010241137603016545 5ustar godgodlibjorbis-java-0.0.17.orig/comment_editor/README0000644000175000017500000000074707362001511017433 0ustar godgodJOrbisComment is a simple comment editor for Ogg Vorbis. This program is just provided here for setting an example, how to use JOrbis for editing comments. The following command will generate new Ogg Vorbis file 'bar.ogg' from 'foo.ogg' and 'bar.ogg' will include comments from 'foo.ogg' and new two comments; TITLE, ARTIST. $ java -classpath .. -DJOrbis.comment.0=TITLE=sometitle \ -DJOrbis.comment.1=ARTIST=somename \ JOrbisComment foo.ogg bar.ogg libjorbis-java-0.0.17.orig/comment_editor/JOrbisComment.java0000644000175000017500000003042110136064777022141 0ustar godgod/* JOrbisComment -- pure Java Ogg Vorbis Comment Editor * * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec and * JOrbisPlayer depends on JOrbis. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ import java.io.*; import java.util.*; import com.jcraft.jogg.*; import com.jcraft.jorbis.*; class JOrbisComment { State state=null; public static void main(String[] arg){ String input=arg[0]; String output=(arg.length>1?arg[1]:null); InputStream in=null; try{ in=new FileInputStream(input); } catch(Exception e){ System.out.println(e); } State foo=new State(); JOrbisComment jorbiscomment=new JOrbisComment(foo); jorbiscomment.read(in); System.out.println(foo.vc); if(output==null) return; Properties props=System.getProperties(); int i=0; String comment=null; while(true){ try{ comment=(String)props.get("JOrbis.comment."+new Integer(i)); foo.vc.add(comment); i++; } catch(Exception e){ break; } } // foo.vc.add("TEST=TESTTEST"); // foo.vc.add_tag("TITLE", "demodemo"); System.out.println(foo.vc); //System.out.println(foo.vc.query("TEST")); //System.out.println(foo.vc.query("TITLE")); //System.out.println(foo.vc.query("ARTIST")); try{ OutputStream out=new FileOutputStream(output); jorbiscomment.write(out); out.close(); } catch(Exception e){ e.printStackTrace(); System.out.println(e); } } private static int CHUNKSIZE=4096; JOrbisComment(State state){ super(); this.state=state; } void read(InputStream in){ state.in=in; Page og=new Page(); int index; byte[] buffer; int bytes=0; state.oy=new SyncState(); state.oy.init(); index=state.oy.buffer(CHUNKSIZE); buffer=state.oy.data; try{ bytes=state.in.read(buffer, index, CHUNKSIZE); } catch(Exception e){ System.err.println(e); return; } state.oy.wrote(bytes); if(state.oy.pageout(og)!=1){ if(bytesop.granulepos){ granpos=op.granulepos; streamout.packetin(op); needflush=1; } else{ streamout.packetin(op); needout=1; } } //System.out.println("#3"); } //System.out.println("%3"); streamout.e_o_s=1; while(streamout.flush(ogout)!=0){ try{ out.write(ogout.header_base,ogout.header,ogout.header_len); out.flush(); } catch(Exception e){ e.printStackTrace(); //goto cleanup; return -1; } try{ out.write(ogout.body_base,ogout.body,ogout.body_len); out.flush(); } catch(Exception e){ e.printStackTrace(); //System.out.println("ogout.body_base.length="+ogout.body_base.length+ // ", ogout.body="+ogout.body+ // ", ogout.body_len="+ogout.body_len); //goto cleanup; return -1; } } //System.out.println("%4"); state.vi.clear(); //System.out.println("%3 eosin="+eosin); //System.out.println("%5"); eosin=0; /* clear it, because not all paths to here do */ while(eosin==0){ /* We reached eos, not eof */ /* We copy the rest of the stream (other logical streams) * through, a page at a time. */ while(true){ result=state.oy.pageout(ogout); //System.out.println(" result4="+result); if(result==0) break; if(result<0){ System.out.println("Corrupt or missing data, continuing..."); } else{ /* Don't bother going through the rest, we can just * write the page out now */ try{ out.write(ogout.header_base,ogout.header,ogout.header_len); out.flush(); } catch(Exception e){ //goto cleanup; return -1; } try{ out.write(ogout.body_base,ogout.body,ogout.body_len); out.flush(); } catch(Exception e){ //goto cleanup; return -1; } } } index=state.oy.buffer(CHUNKSIZE); buffer=state.oy.data; try{ bytes=state.in.read(buffer, index, CHUNKSIZE); } catch(Exception e){ System.err.println(e); return -1; } //System.out.println("bytes="+bytes); state.oy.wrote(bytes); if(bytes == 0 || bytes==-1) { eosin = 1; break; } } /* cleanup: ogg_stream_clear(&streamout); ogg_packet_clear(&header_comments); free(state->mainbuf); free(state->bookbuf); jorbiscomment_clear_internals(state); if(!eosin) { state->lasterror = "Error writing stream to output. " "Output stream may be corrupted or truncated."; return -1; } return 0; } */ return 0; } } class State{ private static int CHUNKSIZE=4096; SyncState oy; StreamState os; Comment vc; Info vi; InputStream in; int serial; byte[] mainbuf; byte[] bookbuf; int mainlen; int booklen; String lasterror; int prevW; int blocksize(Packet p){ int _this = vi.blocksize(p); int ret = (_this + prevW)/4; if(prevW==0){ prevW=_this; return 0; } prevW = _this; return ret; } Page og=new Page(); int fetch_next_packet(Packet p){ int result; byte[] buffer; int index; int bytes; result = os.packetout(p); if(result > 0){ return 1; } while(oy.pageout(og) <= 0){ index=oy.buffer(CHUNKSIZE); buffer=oy.data; try{ bytes=in.read(buffer, index, CHUNKSIZE); } catch(Exception e){ System.err.println(e); return 0; } if(bytes>0) oy.wrote(bytes); if(bytes==0 || bytes==-1) { return 0; } } os.pagein(og); return fetch_next_packet(p); } } libjorbis-java-0.0.17.orig/COPYING.LIB0000644000175000017500000006364407362001511015210 0ustar godgod GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. ^L Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. ^L GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. ^L Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. ^L 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. ^L 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. ^L 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. ^L 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS ^L How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libjorbis-java-0.0.17.orig/com/0000755000175000017500000000000010241131175014311 5ustar godgodlibjorbis-java-0.0.17.orig/com/jcraft/0000755000175000017500000000000007362001510015561 5ustar godgodlibjorbis-java-0.0.17.orig/com/jcraft/jorbis/0000755000175000017500000000000011010326376017056 5ustar godgodlibjorbis-java-0.0.17.orig/com/jcraft/jorbis/FuncMapping.java0000644000175000017500000000275311010261401022122 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; abstract class FuncMapping{ public static FuncMapping[] mapping_P= {new Mapping0()}; abstract void pack(Info info, Object imap, Buffer buffer); abstract Object unpack(Info info, Buffer buffer); abstract Object look(DspState vd, InfoMode vm, Object m); abstract void free_info(Object imap); abstract void free_look(Object imap); abstract int inverse(Block vd, Object lm); } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/FuncTime.java0000644000175000017500000000273311010261406021430 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; abstract class FuncTime{ public static FuncTime[] time_P= {new Time0()}; abstract void pack(Object i, Buffer opb); abstract Object unpack(Info vi, Buffer opb); abstract Object look(DspState vd, InfoMode vm, Object i); abstract void free_info(Object i); abstract void free_look(Object i); abstract int inverse(Block vb, Object i, float[] in, float[] out); } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Time0.java0000644000175000017500000000267311010261460020677 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; class Time0 extends FuncTime{ void pack(Object i, Buffer opb){ } Object unpack(Info vi, Buffer opb){ return ""; } Object look(DspState vd, InfoMode mi, Object i){ return ""; } void free_info(Object i){ } void free_look(Object i){ } int inverse(Block vb, Object i, float[] in, float[] out){ return 0; } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/DecodeExample.java0000644000175000017500000002565011010261350022416 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; // Takes a vorbis bitstream from stdin and writes raw stereo PCM to // stdout. Decodes simple and chained OggVorbis files from beginning // to end. Vorbisfile.a is somewhat more complex than the code below. class DecodeExample{ static int convsize=4096*2; static byte[] convbuffer=new byte[convsize]; // take 8k out of the data segment, not the stack public static void main(String[] arg){ java.io.InputStream input=System.in; if(arg.length>0){ try{ input=new java.io.FileInputStream(arg[0]); } catch(Exception e){ System.err.println(e); } } SyncState oy=new SyncState(); // sync and verify incoming physical bitstream StreamState os=new StreamState(); // take physical pages, weld into a logical stream of packets Page og=new Page(); // one Ogg bitstream page. Vorbis packets are inside Packet op=new Packet(); // one raw packet of data for decode Info vi=new Info(); // struct that stores all the static vorbis bitstream settings Comment vc=new Comment(); // struct that stores all the bitstream user comments DspState vd=new DspState(); // central working state for the packet->PCM decoder Block vb=new Block(vd); // local working space for packet->PCM decode byte[] buffer; int bytes=0; // Decode setup oy.init(); // Now we can read pages while(true){ // we repeat if the bitstream is chained int eos=0; // grab some data at the head of the stream. We want the first page // (which is guaranteed to be small and only contain the Vorbis // stream initial header) We need the first page to get the stream // serialno. // submit a 4k block to libvorbis' Ogg layer int index=oy.buffer(4096); buffer=oy.data; try{ bytes=input.read(buffer, index, 4096); } catch(Exception e){ System.err.println(e); System.exit(-1); } oy.wrote(bytes); // Get the first page. if(oy.pageout(og)!=1){ // have we simply run out of data? If so, we're done. if(bytes<4096) break; // error case. Must not be Vorbis data System.err.println("Input does not appear to be an Ogg bitstream."); System.exit(1); } // Get the serial number and set up the rest of decode. // serialno first; use it to set up a logical stream os.init(og.serialno()); // extract the initial header from the first page and verify that the // Ogg bitstream is in fact Vorbis data // I handle the initial header first instead of just having the code // read all three Vorbis headers at once because reading the initial // header is an easy way to identify a Vorbis bitstream and it's // useful to see that functionality seperated out. vi.init(); vc.init(); if(os.pagein(og)<0){ // error; stream version mismatch perhaps System.err.println("Error reading first page of Ogg bitstream data."); System.exit(1); } if(os.packetout(op)!=1){ // no page? must not be vorbis System.err.println("Error reading initial header packet."); System.exit(1); } if(vi.synthesis_headerin(vc, op)<0){ // error case; not a vorbis header System.err .println("This Ogg bitstream does not contain Vorbis audio data."); System.exit(1); } // At this point, we're sure we're Vorbis. We've set up the logical // (Ogg) bitstream decoder. Get the comment and codebook headers and // set up the Vorbis decoder // The next two packets in order are the comment and codebook headers. // They're likely large and may span multiple pages. Thus we reead // and submit data until we get our two pacakets, watching that no // pages are missing. If a page is missing, error out; losing a // header page is the only place where missing data is fatal. */ int i=0; while(i<2){ while(i<2){ int result=oy.pageout(og); if(result==0) break; // Need more data // Don't complain about missing or corrupt data yet. We'll // catch it at the packet output phase if(result==1){ os.pagein(og); // we can ignore any errors here // as they'll also become apparent // at packetout while(i<2){ result=os.packetout(op); if(result==0) break; if(result==-1){ // Uh oh; data at some point was corrupted or missing! // We can't tolerate that in a header. Die. System.err.println("Corrupt secondary header. Exiting."); System.exit(1); } vi.synthesis_headerin(vc, op); i++; } } } // no harm in not checking before adding more index=oy.buffer(4096); buffer=oy.data; try{ bytes=input.read(buffer, index, 4096); } catch(Exception e){ System.err.println(e); System.exit(1); } if(bytes==0&&i<2){ System.err.println("End of file before finding all Vorbis headers!"); System.exit(1); } oy.wrote(bytes); } // Throw the comments plus a few lines about the bitstream we're // decoding { byte[][] ptr=vc.user_comments; for(int j=0; jPCM decoder. vd.synthesis_init(vi); // central decode state vb.init(vd); // local state for most of the decode // so multiple block decodes can // proceed in parallel. We could init // multiple vorbis_block structures // for vd here float[][][] _pcm=new float[1][][]; int[] _index=new int[vi.channels]; // The rest is just a straight decode loop until end of stream while(eos==0){ while(eos==0){ int result=oy.pageout(og); if(result==0) break; // need more data if(result==-1){ // missing or corrupt data at this page position System.err .println("Corrupt or missing data in bitstream; continuing..."); } else{ os.pagein(og); // can safely ignore errors at // this point while(true){ result=os.packetout(op); if(result==0) break; // need more data if(result==-1){ // missing or corrupt data at this page position // no reason to complain; already complained above } else{ // we have a packet. Decode it int samples; if(vb.synthesis(op)==0){ // test for success! vd.synthesis_blockin(vb); } // **pcm is a multichannel float vector. In stereo, for // example, pcm[0] is left, and pcm[1] is right. samples is // the size of each channel. Convert the float values // (-1.<=range<=1.) to whatever PCM format and write it out while((samples=vd.synthesis_pcmout(_pcm, _index))>0){ float[][] pcm=_pcm[0]; int bout=(samples32767){ val=32767; } if(val<-32768){ val=-32768; } if(val<0) val=val|0x8000; convbuffer[ptr]=(byte)(val); convbuffer[ptr+1]=(byte)(val>>>8); ptr+=2*(vi.channels); } } System.out.write(convbuffer, 0, 2*vi.channels*bout); // tell libvorbis how // many samples we // actually consumed vd.synthesis_read(bout); } } } if(og.eos()!=0) eos=1; } } if(eos==0){ index=oy.buffer(4096); buffer=oy.data; try{ bytes=input.read(buffer, index, 4096); } catch(Exception e){ System.err.println(e); System.exit(1); } oy.wrote(bytes); if(bytes==0) eos=1; } } // clean up this logical bitstream; before exit we see if we're // followed by another [chained] os.clear(); // ogg_page and ogg_packet structs always point to storage in // libvorbis. They're never freed or manipulated directly vb.clear(); vd.clear(); vi.clear(); // must be called last } // OK, clean up the framer oy.clear(); System.err.println("Done."); } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Mdct.java0000644000175000017500000001236211010261435020606 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class Mdct{ int n; int log2n; float[] trig; int[] bitrev; float scale; void init(int n){ bitrev=new int[n/4]; trig=new float[n+n/4]; log2n=(int)Math.rint(Math.log(n)/Math.log(2)); this.n=n; int AE=0; int AO=1; int BE=AE+n/2; int BO=BE+1; int CE=BE+n/2; int CO=CE+1; // trig lookups... for(int i=0; i>>j!=0; j++) if(((msb>>>j)&i)!=0) acc|=1<>>1; int n4=n>>>2; int n8=n>>>3; // rotate + step 1 { int inO=1; int xO=0; int A=n2; int i; for(i=0; i>>(i+2); int k1=1<<(i+3); int wbase=n2-2; A=0; float[] temp; for(int r=0; r<(k0>>>2); r++){ int w1=wbase; w2=w1-(k0>>1); float AEv=trig[A], wA; float AOv=trig[A+1], wB; wbase-=2; k0++; for(int s=0; s<(2< * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; class CodeBook{ int dim; // codebook dimensions (elements per vector) int entries; // codebook entries StaticCodeBook c=new StaticCodeBook(); float[] valuelist; // list of dim*entries actual entry values int[] codelist; // list of bitstream codewords for each entry DecodeAux decode_tree; // returns the number of bits int encode(int a, Buffer b){ b.write(codelist[a], c.lengthlist[a]); return (c.lengthlist[a]); } // One the encode side, our vector writers are each designed for a // specific purpose, and the encoder is not flexible without modification: // // The LSP vector coder uses a single stage nearest-match with no // interleave, so no step and no error return. This is specced by floor0 // and doesn't change. // // Residue0 encoding interleaves, uses multiple stages, and each stage // peels of a specific amount of resolution from a lattice (thus we want // to match by threshhold, not nearest match). Residue doesn't *have* to // be encoded that way, but to change it, one will need to add more // infrastructure on the encode side (decode side is specced and simpler) // floor0 LSP (single stage, non interleaved, nearest match) // returns entry number and *modifies a* to the quantization value int errorv(float[] a){ int best=best(a, 1); for(int k=0; k8){ for(i=0; i declarative (set the value) // stage==1 -> additive // stage==2 -> multiplicitive // returns the entry number or -1 on eof int decode(Buffer b){ int ptr=0; DecodeAux t=decode_tree; int lok=b.look(t.tabn); if(lok>=0){ ptr=t.tab[lok]; b.adv(t.tabl[lok]); if(ptr<=0){ return -ptr; } } do{ switch(b.read1()){ case 0: ptr=t.ptr0[ptr]; break; case 1: ptr=t.ptr1[ptr]; break; case -1: default: return (-1); } } while(ptr>0); return (-ptr); } // returns the entry number or -1 on eof int decodevs(float[] a, int index, Buffer b, int step, int addmul){ int entry=decode(b); if(entry==-1) return (-1); switch(addmul){ case -1: for(int i=0, o=0; ibook_param)free(vi->book_param); book_param=null; for(int i=0; i=VI_TIMEB){ clear(); return (-1); } time_param[i]=FuncTime.time_P[time_type[i]].unpack(this, opb); if(time_param[i]==null){ clear(); return (-1); } } // floor backend settings floors=opb.read(6)+1; if(floor_type==null||floor_type.length!=floors) floor_type=new int[floors]; if(floor_param==null||floor_param.length!=floors) floor_param=new Object[floors]; for(int i=0; i=VI_FLOORB){ clear(); return (-1); } floor_param[i]=FuncFloor.floor_P[floor_type[i]].unpack(this, opb); if(floor_param[i]==null){ clear(); return (-1); } } // residue backend settings residues=opb.read(6)+1; if(residue_type==null||residue_type.length!=residues) residue_type=new int[residues]; if(residue_param==null||residue_param.length!=residues) residue_param=new Object[residues]; for(int i=0; i=VI_RESB){ clear(); return (-1); } residue_param[i]=FuncResidue.residue_P[residue_type[i]].unpack(this, opb); if(residue_param[i]==null){ clear(); return (-1); } } // map backend settings maps=opb.read(6)+1; if(map_type==null||map_type.length!=maps) map_type=new int[maps]; if(map_param==null||map_param.length!=maps) map_param=new Object[maps]; for(int i=0; i=VI_MAPB){ clear(); return (-1); } map_param[i]=FuncMapping.mapping_P[map_type[i]].unpack(this, opb); if(map_param[i]==null){ clear(); return (-1); } } // mode settings modes=opb.read(6)+1; if(mode_param==null||mode_param.length!=modes) mode_param=new InfoMode[modes]; for(int i=0; i=VI_WINDOWB) ||(mode_param[i].transformtype>=VI_WINDOWB) ||(mode_param[i].mapping>=maps)){ clear(); return (-1); } } if(opb.read(1)!=1){ clear(); return (-1); } return (0); } // The Vorbis header is in three packets; the initial small packet in // the first page that identifies basic parameters, a second packet // with bitstream comments and a third packet that holds the // codebook. public int synthesis_headerin(Comment vc, Packet op){ Buffer opb=new Buffer(); if(op!=null){ opb.readinit(op.packet_base, op.packet, op.bytes); // Which of the three types of header is this? // Also verify header-ness, vorbis { byte[] buffer=new byte[6]; int packtype=opb.read(8); opb.read(buffer, 6); if(buffer[0]!='v'||buffer[1]!='o'||buffer[2]!='r'||buffer[3]!='b' ||buffer[4]!='i'||buffer[5]!='s'){ // not a vorbis header return (-1); } switch(packtype){ case 0x01: // least significant *bit* is read first if(op.b_o_s==0){ // Not the initial packet return (-1); } if(rate!=0){ // previously initialized info header return (-1); } return (unpack_info(opb)); case 0x03: // least significant *bit* is read first if(rate==0){ // um... we didn't get the initial header return (-1); } return (vc.unpack(opb)); case 0x05: // least significant *bit* is read first if(rate==0||vc.vendor==null){ // um... we didn;t get the initial header or comments yet return (-1); } return (unpack_books(opb)); default: // Not a valid vorbis header type //return(-1); break; } } } return (-1); } // pack side int pack_info(Buffer opb){ // preamble opb.write(0x01, 8); opb.write(_vorbis); // basic information about the stream opb.write(0x00, 32); opb.write(channels, 8); opb.write(rate, 32); opb.write(bitrate_upper, 32); opb.write(bitrate_nominal, 32); opb.write(bitrate_lower, 32); opb.write(Util.ilog2(blocksizes[0]), 4); opb.write(Util.ilog2(blocksizes[1]), 4); opb.write(1, 1); return (0); } int pack_books(Buffer opb){ opb.write(0x05, 8); opb.write(_vorbis); // books opb.write(books-1, 8); for(int i=0; i1){ modebits++; v>>>=1; } /* read our mode and pre/post windowsize */ mode=opb.read(modebits); } if(mode==-1) return (OV_EBADPACKET); return (blocksizes[mode_param[mode].blockflag]); } public String toString(){ return "version:"+new Integer(version)+", channels:"+new Integer(channels) +", rate:"+new Integer(rate)+", bitrate:"+new Integer(bitrate_upper) +","+new Integer(bitrate_nominal)+","+new Integer(bitrate_lower); } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/PsyLook.java0000644000175000017500000000241111010261442021307 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class PsyLook{ int n; PsyInfo vi; float[][][] tonecurves; float[][] peakatt; float[][][] noisecurves; float[] ath; int[] octave; void init(PsyInfo vi, int n, int rate){ } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/FuncResidue.java0000644000175000017500000000303411010261404022123 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; abstract class FuncResidue{ public static FuncResidue[] residue_P= {new Residue0(), new Residue1(), new Residue2()}; abstract void pack(Object vr, Buffer opb); abstract Object unpack(Info vi, Buffer opb); abstract Object look(DspState vd, InfoMode vm, Object vr); abstract void free_info(Object i); abstract void free_look(Object i); abstract int inverse(Block vb, Object vl, float[][] in, int[] nonzero, int ch); } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/ChainingExample.java0000644000175000017500000000444011010261335022750 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class ChainingExample{ public static void main(String[] arg){ VorbisFile ov=null; try{ if(arg.length>0){ ov=new VorbisFile(arg[0]); } else{ ov=new VorbisFile(System.in, null, -1); } } catch(Exception e){ System.err.println(e); return; } 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{ System.out.println("Standard input was not seekable."); System.out.println("First logical bitstream information:\n"); } for(int i=0; i * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class Residue2 extends Residue0{ int inverse(Block vb, Object vl, float[][] in, int[] nonzero, int ch){ int i=0; for(i=0; i * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; abstract class FuncFloor{ public static FuncFloor[] floor_P= {new Floor0(), new Floor1()}; abstract void pack(Object i, Buffer opb); abstract Object unpack(Info vi, Buffer opb); abstract Object look(DspState vd, InfoMode mi, Object i); abstract void free_info(Object i); abstract void free_look(Object i); abstract void free_state(Object vs); abstract int forward(Block vb, Object i, float[] in, float[] out, Object vs); abstract Object inverse1(Block vb, Object i, Object memo); abstract int inverse2(Block vb, Object i, Object memo, float[] out); } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Comment.java0000644000175000017500000001344311010261344021321 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; // the comments are not part of vorbis_info so that vorbis_info can be // static storage public class Comment{ private static byte[] _vorbis="vorbis".getBytes(); private static byte[] _vendor="Xiphophorus libVorbis I 20000508".getBytes(); private static final int OV_EIMPL=-130; // unlimited user comment fields. public byte[][] user_comments; public int[] comment_lengths; public int comments; public byte[] vendor; public void init(){ user_comments=null; comments=0; vendor=null; } public void add(String comment){ add(comment.getBytes()); } private void add(byte[] comment){ byte[][] foo=new byte[comments+2][]; if(user_comments!=null){ System.arraycopy(user_comments, 0, foo, 0, comments); } user_comments=foo; int[] goo=new int[comments+2]; if(comment_lengths!=null){ System.arraycopy(comment_lengths, 0, goo, 0, comments); } comment_lengths=goo; byte[] bar=new byte[comment.length+1]; System.arraycopy(comment, 0, bar, 0, comment.length); user_comments[comments]=bar; comment_lengths[comments]=comment.length; comments++; user_comments[comments]=null; } public void add_tag(String tag, String contents){ if(contents==null) contents=""; add(tag+"="+contents); } static boolean tagcompare(byte[] s1, byte[] s2, int n){ int c=0; byte u1, u2; while(c=u1&&u1>='A') u1=(byte)(u1-'A'+'a'); if('Z'>=u2&&u2>='A') u2=(byte)(u2-'A'+'a'); if(u1!=u2){ return false; } c++; } return true; } public String query(String tag){ return query(tag, 0); } public String query(String tag, int count){ int foo=query(tag.getBytes(), count); if(foo==-1) return null; byte[] comment=user_comments[foo]; for(int i=0; i * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; // psychoacoustic setup class PsyInfo{ int athp; int decayp; int smoothp; int noisefitp; int noisefit_subblock; float noisefit_threshdB; float ath_att; int tonemaskp; float[] toneatt_125Hz=new float[5]; float[] toneatt_250Hz=new float[5]; float[] toneatt_500Hz=new float[5]; float[] toneatt_1000Hz=new float[5]; float[] toneatt_2000Hz=new float[5]; float[] toneatt_4000Hz=new float[5]; float[] toneatt_8000Hz=new float[5]; int peakattp; float[] peakatt_125Hz=new float[5]; float[] peakatt_250Hz=new float[5]; float[] peakatt_500Hz=new float[5]; float[] peakatt_1000Hz=new float[5]; float[] peakatt_2000Hz=new float[5]; float[] peakatt_4000Hz=new float[5]; float[] peakatt_8000Hz=new float[5]; int noisemaskp; float[] noiseatt_125Hz=new float[5]; float[] noiseatt_250Hz=new float[5]; float[] noiseatt_500Hz=new float[5]; float[] noiseatt_1000Hz=new float[5]; float[] noiseatt_2000Hz=new float[5]; float[] noiseatt_4000Hz=new float[5]; float[] noiseatt_8000Hz=new float[5]; float max_curve_dB; float attack_coeff; float decay_coeff; void free(){ } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Lsp.java0000644000175000017500000000562111010261427020456 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; /* function: LSP (also called LSF) conversion routines The LSP generation code is taken (with minimal modification) from "On the Computation of the LSP Frequencies" by Joseph Rothweiler , available at: http://www2.xtdl.com/~rothwlr/lsfpaper/lsfpage.html ********************************************************************/ class Lsp{ static final float M_PI=(float)(3.1415926539); static void lsp_to_curve(float[] curve, int[] map, int n, int ln, float[] lsp, int m, float amp, float ampoffset){ int i; float wdel=M_PI/ln; for(i=0; i=0x7f800000||(ix==0)){ // 0,inf,nan } else{ if(ix<0x00800000){ // subnormal q*=3.3554432000e+07; // 0x4c000000 hx=Float.floatToIntBits(q); ix=0x7fffffff&hx; qexp=-25; } qexp+=((ix>>>23)-126); hx=(hx&0x807fffff)|0x3f000000; q=Float.intBitsToFloat(hx); } q=Lookup.fromdBlook(amp*Lookup.invsqlook(q)*Lookup.invsq2explook(qexp+m) -ampoffset); do{ curve[i++]*=q; } while(i * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class InfoMode{ int blockflag; int windowtype; int transformtype; int mapping; } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Lookup.java0000644000175000017500000001737511010261422021175 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class Lookup{ static final int COS_LOOKUP_SZ=128; static final float[] COS_LOOKUP= {+1.0000000000000f, +0.9996988186962f, +0.9987954562052f, +0.9972904566787f, +0.9951847266722f, +0.9924795345987f, +0.9891765099648f, +0.9852776423889f, +0.9807852804032f, +0.9757021300385f, +0.9700312531945f, +0.9637760657954f, +0.9569403357322f, +0.9495281805930f, +0.9415440651830f, +0.9329927988347f, +0.9238795325113f, +0.9142097557035f, +0.9039892931234f, +0.8932243011955f, +0.8819212643484f, +0.8700869911087f, +0.8577286100003f, +0.8448535652497f, +0.8314696123025f, +0.8175848131516f, +0.8032075314806f, +0.7883464276266f, +0.7730104533627f, +0.7572088465065f, +0.7409511253550f, +0.7242470829515f, +0.7071067811865f, +0.6895405447371f, +0.6715589548470f, +0.6531728429538f, +0.6343932841636f, +0.6152315905806f, +0.5956993044924f, +0.5758081914178f, +0.5555702330196f, +0.5349976198871f, +0.5141027441932f, +0.4928981922298f, +0.4713967368260f, +0.4496113296546f, +0.4275550934303f, +0.4052413140050f, +0.3826834323651f, +0.3598950365350f, +0.3368898533922f, +0.3136817403989f, +0.2902846772545f, +0.2667127574749f, +0.2429801799033f, +0.2191012401569f, +0.1950903220161f, +0.1709618887603f, +0.1467304744554f, +0.1224106751992f, +0.0980171403296f, +0.0735645635997f, +0.0490676743274f, +0.0245412285229f, +0.0000000000000f, -0.0245412285229f, -0.0490676743274f, -0.0735645635997f, -0.0980171403296f, -0.1224106751992f, -0.1467304744554f, -0.1709618887603f, -0.1950903220161f, -0.2191012401569f, -0.2429801799033f, -0.2667127574749f, -0.2902846772545f, -0.3136817403989f, -0.3368898533922f, -0.3598950365350f, -0.3826834323651f, -0.4052413140050f, -0.4275550934303f, -0.4496113296546f, -0.4713967368260f, -0.4928981922298f, -0.5141027441932f, -0.5349976198871f, -0.5555702330196f, -0.5758081914178f, -0.5956993044924f, -0.6152315905806f, -0.6343932841636f, -0.6531728429538f, -0.6715589548470f, -0.6895405447371f, -0.7071067811865f, -0.7242470829515f, -0.7409511253550f, -0.7572088465065f, -0.7730104533627f, -0.7883464276266f, -0.8032075314806f, -0.8175848131516f, -0.8314696123025f, -0.8448535652497f, -0.8577286100003f, -0.8700869911087f, -0.8819212643484f, -0.8932243011955f, -0.9039892931234f, -0.9142097557035f, -0.9238795325113f, -0.9329927988347f, -0.9415440651830f, -0.9495281805930f, -0.9569403357322f, -0.9637760657954f, -0.9700312531945f, -0.9757021300385f, -0.9807852804032f, -0.9852776423889f, -0.9891765099648f, -0.9924795345987f, -0.9951847266722f, -0.9972904566787f, -0.9987954562052f, -0.9996988186962f, -1.0000000000000f,}; /* interpolated lookup based cos function, domain 0 to PI only */ static float coslook(float a){ double d=a*(.31830989*(float)COS_LOOKUP_SZ); int i=(int)d; return COS_LOOKUP[i]+((float)(d-i))*(COS_LOOKUP[i+1]-COS_LOOKUP[i]); } static final int INVSQ_LOOKUP_SZ=32; static final float[] INVSQ_LOOKUP= {1.414213562373f, 1.392621247646f, 1.371988681140f, 1.352246807566f, 1.333333333333f, 1.315191898443f, 1.297771369046f, 1.281025230441f, 1.264911064067f, 1.249390095109f, 1.234426799697f, 1.219988562661f, 1.206045378311f, 1.192569588000f, 1.179535649239f, 1.166919931983f, 1.154700538379f, 1.142857142857f, 1.131370849898f, 1.120224067222f, 1.109400392450f, 1.098884511590f, 1.088662107904f, 1.078719779941f, 1.069044967650f, 1.059625885652f, 1.050451462878f, 1.041511287847f, 1.032795558989f, 1.024295039463f, 1.016001016002f, 1.007905261358f, 1.000000000000f,}; /* interpolated 1./sqrt(p) where .5 <= p < 1. */ static float invsqlook(float a){ double d=a*(2.f*(float)INVSQ_LOOKUP_SZ)-(float)INVSQ_LOOKUP_SZ; int i=(int)d; return INVSQ_LOOKUP[i]+((float)(d-i))*(INVSQ_LOOKUP[i+1]-INVSQ_LOOKUP[i]); } static final int INVSQ2EXP_LOOKUP_MIN=-32; static final int INVSQ2EXP_LOOKUP_MAX=32; static final float[] INVSQ2EXP_LOOKUP= {65536.f, 46340.95001f, 32768.f, 23170.47501f, 16384.f, 11585.2375f, 8192.f, 5792.618751f, 4096.f, 2896.309376f, 2048.f, 1448.154688f, 1024.f, 724.0773439f, 512.f, 362.038672f, 256.f, 181.019336f, 128.f, 90.50966799f, 64.f, 45.254834f, 32.f, 22.627417f, 16.f, 11.3137085f, 8.f, 5.656854249f, 4.f, 2.828427125f, 2.f, 1.414213562f, 1.f, 0.7071067812f, 0.5f, 0.3535533906f, 0.25f, 0.1767766953f, 0.125f, 0.08838834765f, 0.0625f, 0.04419417382f, 0.03125f, 0.02209708691f, 0.015625f, 0.01104854346f, 0.0078125f, 0.005524271728f, 0.00390625f, 0.002762135864f, 0.001953125f, 0.001381067932f, 0.0009765625f, 0.000690533966f, 0.00048828125f, 0.000345266983f, 0.000244140625f, 0.0001726334915f, 0.0001220703125f, 8.631674575e-05f, 6.103515625e-05f, 4.315837288e-05f, 3.051757812e-05f, 2.157918644e-05f, 1.525878906e-05f,}; /* interpolated 1./sqrt(p) where .5 <= p < 1. */ static float invsq2explook(int a){ return INVSQ2EXP_LOOKUP[a-INVSQ2EXP_LOOKUP_MIN]; } static final int FROMdB_LOOKUP_SZ=35; static final int FROMdB2_LOOKUP_SZ=32; static final int FROMdB_SHIFT=5; static final int FROMdB2_SHIFT=3; static final int FROMdB2_MASK=31; static final float[] FROMdB_LOOKUP= {1.f, 0.6309573445f, 0.3981071706f, 0.2511886432f, 0.1584893192f, 0.1f, 0.06309573445f, 0.03981071706f, 0.02511886432f, 0.01584893192f, 0.01f, 0.006309573445f, 0.003981071706f, 0.002511886432f, 0.001584893192f, 0.001f, 0.0006309573445f, 0.0003981071706f, 0.0002511886432f, 0.0001584893192f, 0.0001f, 6.309573445e-05f, 3.981071706e-05f, 2.511886432e-05f, 1.584893192e-05f, 1e-05f, 6.309573445e-06f, 3.981071706e-06f, 2.511886432e-06f, 1.584893192e-06f, 1e-06f, 6.309573445e-07f, 3.981071706e-07f, 2.511886432e-07f, 1.584893192e-07f,}; static final float[] FROMdB2_LOOKUP= {0.9928302478f, 0.9786445908f, 0.9646616199f, 0.9508784391f, 0.9372921937f, 0.92390007f, 0.9106992942f, 0.8976871324f, 0.8848608897f, 0.8722179097f, 0.8597555737f, 0.8474713009f, 0.835362547f, 0.8234268041f, 0.8116616003f, 0.8000644989f, 0.7886330981f, 0.7773650302f, 0.7662579617f, 0.755309592f, 0.7445176537f, 0.7338799116f, 0.7233941627f, 0.7130582353f, 0.7028699885f, 0.6928273125f, 0.6829281272f, 0.6731703824f, 0.6635520573f, 0.6540711597f, 0.6447257262f, 0.6355138211f,}; /* interpolated lookup based fromdB function, domain -140dB to 0dB only */ static float fromdBlook(float a){ int i=(int)(a*((float)(-(1<=(FROMdB_LOOKUP_SZ<>>FROMdB_SHIFT]*FROMdB2_LOOKUP[i&FROMdB2_MASK]); } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Floor1.java0000644000175000017500000004372611010261373021072 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; class Floor1 extends FuncFloor{ static final int floor1_rangedb=140; static final int VIF_POSIT=63; void pack(Object i, Buffer opb){ InfoFloor1 info=(InfoFloor1)i; int count=0; int rangebits; int maxposit=info.postlist[1]; int maxclass=-1; /* save out partitions */ opb.write(info.partitions, 5); /* only 0 to 31 legal */ for(int j=0; j=vi.books){ info.free(); return (null); } for(int k=0; k<(1<=vi.books){ info.free(); return (null); } } } /* read the post list */ info.mult=opb.read(2)+1; /* only 1,2,3,4 legal now */ rangebits=opb.read(4); for(int j=0, k=0; j=(1<info.postlist[sortpointer[k]]){ foo=sortpointer[k]; sortpointer[k]=sortpointer[j]; sortpointer[j]=foo; } } } /* points from sort order back to range number */ for(int j=0; j<_n; j++){ look.forward_index[j]=sortpointer[j]; } /* points from range order to sorted position */ for(int j=0; j<_n; j++){ look.reverse_index[look.forward_index[j]]=j; } /* we actually need the post values too */ for(int j=0; j<_n; j++){ look.sorted_index[j]=info.postlist[look.forward_index[j]]; } /* quantize values to multiplier spec */ switch(info.mult){ case 1: /* 1024 -> 256 */ look.quant_q=256; break; case 2: /* 1024 -> 128 */ look.quant_q=128; break; case 3: /* 1024 -> 86 */ look.quant_q=86; break; case 4: /* 1024 -> 64 */ look.quant_q=64; break; default: look.quant_q=-1; } /* discover our neighbors for decode where we don't use fit flags (that would push the neighbors outward) */ for(int j=0; j<_n-2; j++){ int lo=0; int hi=1; int lx=0; int hx=look.n; int currentx=info.postlist[j+2]; for(int k=0; klx&&xcurrentx){ hi=k; hx=x; } } look.loneighbor[j]=lo; look.hineighbor[j]=hi; } return look; } void free_info(Object i){ } void free_look(Object i){ } void free_state(Object vs){ } int forward(Block vb, Object i, float[] in, float[] out, Object vs){ return 0; } Object inverse1(Block vb, Object ii, Object memo){ LookFloor1 look=(LookFloor1)ii; InfoFloor1 info=look.vi; CodeBook[] books=vb.vd.fullbooks; /* unpack wrapped/predicted values from stream */ if(vb.opb.read(1)==1){ int[] fit_value=null; if(memo instanceof int[]){ fit_value=(int[])memo; } if(fit_value==null||fit_value.length>>=csubbits; if(book>=0){ if((fit_value[j+k]=books[book].decode(vb.opb))==-1){ return (null); } } else{ fit_value[j+k]=0; } } j+=cdim; } /* unwrap positive values and reconsitute via linear interpolation */ for(int i=2; i=room){ if(hiroom>loroom){ val=val-loroom; } else{ val=-1-(val-hiroom); } } else{ if((val&1)!=0){ val=-((val+1)>>>1); } else{ val>>=1; } } fit_value[i]=val+predicted; fit_value[look.loneighbor[i-2]]&=0x7fff; fit_value[look.hineighbor[i-2]]&=0x7fff; } else{ fit_value[i]=predicted|0x8000; } } return (fit_value); } return (null); } private static int render_point(int x0, int x1, int y0, int y1, int x){ y0&=0x7fff; /* mask off flag */ y1&=0x7fff; { int dy=y1-y0; int adx=x1-x0; int ady=Math.abs(dy); int err=ady*(x-x0); int off=(int)(err/adx); if(dy<0) return (y0-off); return (y0+off); } } int inverse2(Block vb, Object i, Object memo, float[] out){ LookFloor1 look=(LookFloor1)i; InfoFloor1 info=look.vi; int n=vb.vd.vi.blocksizes[vb.mode]/2; if(memo!=null){ /* render the lines */ int[] fit_value=(int[])memo; int hx=0; int lx=0; int ly=fit_value[0]*info.mult; for(int j=1; j=adx){ err-=adx; y+=sy; } else{ y+=base; } d[x]*=FLOOR_fromdB_LOOKUP[y]; } } class InfoFloor1{ static final int VIF_POSIT=63; static final int VIF_CLASS=16; static final int VIF_PARTS=31; int partitions; /* 0 to 31 */ int[] partitionclass=new int[VIF_PARTS]; /* 0 to 15 */ int[] class_dim=new int[VIF_CLASS]; /* 1 to 8 */ int[] class_subs=new int[VIF_CLASS]; /* 0,1,2,3 (bits: 1< * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; public class Block{ ///necessary stream state for linking to the framing abstraction float[][] pcm=new float[0][]; // this is a pointer into local storage Buffer opb=new Buffer(); int lW; int W; int nW; int pcmend; int mode; int eofflag; long granulepos; long sequence; DspState vd; // For read-only access of configuration // bitmetrics for the frame int glue_bits; int time_bits; int floor_bits; int res_bits; public Block(DspState vd){ this.vd=vd; if(vd.analysisp!=0){ opb.writeinit(); } } public void init(DspState vd){ this.vd=vd; } public int clear(){ if(vd!=null){ if(vd.analysisp!=0){ opb.writeclear(); } } return (0); } public int synthesis(Packet op){ Info vi=vd.vi; // first things first. Make sure decode is ready opb.readinit(op.packet_base, op.packet, op.bytes); // Check the packet type if(opb.read(1)!=0){ // Oops. This is not an audio data packet return (-1); } // read our mode and pre/post windowsize int _mode=opb.read(vd.modebits); if(_mode==-1) return (-1); mode=_mode; W=vi.mode_param[mode].blockflag; if(W!=0){ lW=opb.read(1); nW=opb.read(1); if(nW==-1) return (-1); } else{ lW=0; nW=0; } // more setup granulepos=op.granulepos; sequence=op.packetno-3; // first block is third packet eofflag=op.e_o_s; // alloc pcm passback storage pcmend=vi.blocksizes[W]; if(pcm.length * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; import java.io.InputStream; import java.io.IOException; public class VorbisFile{ static final int CHUNKSIZE=8500; static final int SEEK_SET=0; static final int SEEK_CUR=1; static final int SEEK_END=2; static final int OV_FALSE=-1; static final int OV_EOF=-2; static final int OV_HOLE=-3; static final int OV_EREAD=-128; static final int OV_EFAULT=-129; static final int OV_EIMPL=-130; static final int OV_EINVAL=-131; static final int OV_ENOTVORBIS=-132; static final int OV_EBADHEADER=-133; static final int OV_EVERSION=-134; static final int OV_ENOTAUDIO=-135; static final int OV_EBADPACKET=-136; static final int OV_EBADLINK=-137; static final int OV_ENOSEEK=-138; InputStream datasource; boolean seekable=false; long offset; long end; SyncState oy=new SyncState(); int links; long[] offsets; long[] dataoffsets; int[] serialnos; long[] pcmlengths; Info[] vi; Comment[] vc; // Decoding working state local storage long pcm_offset; boolean decode_ready=false; int current_serialno; int current_link; float bittrack; float samptrack; StreamState os=new StreamState(); // take physical pages, weld into a logical // stream of packets DspState vd=new DspState(); // central working state for // the packet->PCM decoder Block vb=new Block(vd); // local working space for packet->PCM decode //ov_callbacks callbacks; public VorbisFile(String file) throws JOrbisException{ super(); InputStream is=null; try{ is=new SeekableInputStream(file); int ret=open(is, null, 0); if(ret==-1){ throw new JOrbisException("VorbisFile: open return -1"); } } catch(Exception e){ throw new JOrbisException("VorbisFile: "+e.toString()); } finally{ if(is!=null){ try{ is.close(); } catch(IOException e){ e.printStackTrace(); } } } } public VorbisFile(InputStream is, byte[] initial, int ibytes) throws JOrbisException{ super(); int ret=open(is, initial, ibytes); if(ret==-1){ } } private int get_data(){ int index=oy.buffer(CHUNKSIZE); byte[] buffer=oy.data; int bytes=0; try{ bytes=datasource.read(buffer, index, CHUNKSIZE); } catch(Exception e){ return OV_EREAD; } oy.wrote(bytes); if(bytes==-1){ bytes=0; } return bytes; } private void seek_helper(long offst){ fseek(datasource, offst, SEEK_SET); this.offset=offst; oy.reset(); } private int get_next_page(Page page, long boundary){ if(boundary>0) boundary+=offset; while(true){ int more; if(boundary>0&&offset>=boundary) return OV_FALSE; more=oy.pageseek(page); if(more<0){ offset-=more; } else{ if(more==0){ if(boundary==0) return OV_FALSE; int ret=get_data(); if(ret==0) return OV_EOF; if(ret<0) return OV_EREAD; } else{ int ret=(int)offset; //!!! offset+=more; return ret; } } } } private int get_prev_page(Page page) throws JOrbisException{ long begin=offset; //!!! int ret; int offst=-1; while(offst==-1){ begin-=CHUNKSIZE; if(begin<0) begin=0; seek_helper(begin); while(offset=0) next=ret; } else{ searched=ret+page.header_len+page.body_len; } } seek_helper(next); ret=get_next_page(page, -1); if(ret==OV_EREAD) return OV_EREAD; if(searched>=end||ret==-1){ links=m+1; offsets=new long[m+2]; offsets[m+1]=searched; } else{ ret=bisect_forward_serialno(next, offset, end, page.serialno(), m+1); if(ret==OV_EREAD) return OV_EREAD; } offsets[m]=begin; return 0; } // uses the local ogg_stream storage in vf; this is important for // non-streaming input sources int fetch_headers(Info vi, Comment vc, int[] serialno, Page og_ptr){ Page og=new Page(); Packet op=new Packet(); int ret; if(og_ptr==null){ ret=get_next_page(og, CHUNKSIZE); if(ret==OV_EREAD) return OV_EREAD; if(ret<0) return OV_ENOTVORBIS; og_ptr=og; } if(serialno!=null) serialno[0]=og_ptr.serialno(); os.init(og_ptr.serialno()); // extract the initial header from the first page and verify that the // Ogg bitstream is in fact Vorbis data vi.init(); vc.init(); int i=0; while(i<3){ os.pagein(og_ptr); while(i<3){ int result=os.packetout(op); if(result==0) break; if(result==-1){ vi.clear(); vc.clear(); os.clear(); return -1; } if(vi.synthesis_headerin(vc, op)!=0){ vi.clear(); vc.clear(); os.clear(); return -1; } i++; } if(i<3) if(get_next_page(og_ptr, 1)<0){ vi.clear(); vc.clear(); os.clear(); return -1; } } return 0; } // last step of the OggVorbis_File initialization; get all the // vorbis_info structs and PCM positions. Only called by the seekable // initialization (local stream storage is hacked slightly; pay // attention to how that's done) void prefetch_all_headers(Info first_i, Comment first_c, int dataoffset) throws JOrbisException{ Page og=new Page(); int ret; vi=new Info[links]; vc=new Comment[links]; dataoffsets=new long[links]; pcmlengths=new long[links]; serialnos=new int[links]; for(int i=0; i0){ // got a packet. process it granulepos=op.granulepos; if(vb.synthesis(op)==0){ // lazy check for lazy // header handling. The // header packets aren't // audio, so if/when we // submit them, // vorbis_synthesis will // reject them // suck in the synthesis data and track bitrate { int oldsamples=vd.synthesis_pcmout(null, null); vd.synthesis_blockin(vb); samptrack+=vd.synthesis_pcmout(null, null)-oldsamples; bittrack+=op.bytes*8; } // update the pcm offset. if(granulepos!=-1&&op.e_o_s==0){ int link=(seekable ? current_link : 0); int samples; // this packet has a pcm_offset on it (the last packet // completed on a page carries the offset) After processing // (above), we know the pcm position of the *last* sample // ready to be returned. Find the offset of the *first* // // As an aside, this trick is inaccurate if we begin // reading anew right at the last page; the end-of-stream // granulepos declares the last frame in the stream, and the // last packet of the last page may be a partial frame. // So, we need a previous granulepos from an in-sequence page // to have a reference point. Thus the !op.e_o_s clause above samples=vd.synthesis_pcmout(null, null); granulepos-=samples; for(int i=0; i=links) return (-1); if(!seekable&&i!=0) return (bitrate(0)); if(i<0){ long bits=0; for(int j=0; j0){ return vi[i].bitrate_nominal; } else{ if(vi[i].bitrate_upper>0){ if(vi[i].bitrate_lower>0){ return (vi[i].bitrate_upper+vi[i].bitrate_lower)/2; } else{ return vi[i].bitrate_upper; } } return (-1); } } } } // returns the actual bitrate since last call. returns -1 if no // additional data to offer since last call (or at beginning of stream) public int bitrate_instant(){ int _link=(seekable ? current_link : 0); if(samptrack==0) return (-1); int ret=(int)(bittrack/samptrack*vi[_link].rate+.5); bittrack=0.f; samptrack=0.f; return (ret); } public int serialnumber(int i){ if(i>=links) return (-1); if(!seekable&&i>=0) return (serialnumber(-1)); if(i<0){ return (current_serialno); } else{ return (serialnos[i]); } } // returns: total raw (compressed) length of content if i==-1 // raw (compressed) length of that logical bitstream for i==0 to n // -1 if the stream is not seekable (we can't know the length) public long raw_total(int i){ if(!seekable||i>=links) return (-1); if(i<0){ long acc=0; // bug? for(int j=0; j=links) return (-1); if(i<0){ long acc=0; for(int j=0; j=links) return (-1); if(i<0){ float acc=0; for(int j=0; joffsets[links]){ //goto seek_error; pcm_offset=-1; decode_clear(); return -1; } // clear out decoding machine state pcm_offset=-1; decode_clear(); // seek seek_helper(pos); // we need to make sure the pcm_offset is set. We use the // _fetch_packet helper to process one packet with readp set, then // call it until it returns '0' with readp not set (the last packet // from a page has the 'granulepos' field set, and that's how the // helper updates the offset switch(process_packet(1)){ case 0: // oh, eof. There are no packets remaining. Set the pcm offset to // the end of file pcm_offset=pcm_total(-1); return (0); case -1: // error! missing data or invalid bitstream structure //goto seek_error; pcm_offset=-1; decode_clear(); return -1; default: // all OK break; } while(true){ switch(process_packet(0)){ case 0: // the offset is set. If it's a bogus bitstream with no offset // information, it's not but that's not our fault. We still run // gracefully, we're just missing the offset return (0); case -1: // error! missing data or invalid bitstream structure //goto seek_error; pcm_offset=-1; decode_clear(); return -1; default: // continue processing packets break; } } // seek_error: // dump the machine so we're in a known state //pcm_offset=-1; //decode_clear(); //return -1; } // seek to a sample offset relative to the decompressed pcm stream // returns zero on success, nonzero on failure public int pcm_seek(long pos){ int link=-1; long total=pcm_total(-1); if(!seekable) return (-1); // don't dump machine if we can't seek if(pos<0||pos>total){ //goto seek_error; pcm_offset=-1; decode_clear(); return -1; } // which bitstream section does this pcm offset occur in? for(link=links-1; link>=0; link--){ total-=pcmlengths[link]; if(pos>=total) break; } // search within the logical bitstream for the page with the highest // pcm_pos preceeding (or equal to) pos. There is a danger here; // missing pages or incorrect frame number information in the // bitstream could make our task impossible. Account for that (it // would be an error condition) { long target=pos-total; long end=offsets[link+1]; long begin=offsets[link]; int best=(int)begin; Page og=new Page(); while(begin=pos){ //goto seek_error; pcm_offset=-1; decode_clear(); return -1; } if(pos>pcm_total(-1)){ //goto seek_error; pcm_offset=-1; decode_clear(); return -1; } // discard samples until we reach the desired position. Crossing a // logical bitstream boundary with abandon is OK. while(pcm_offsettarget) samples=target; vd.synthesis_read(samples); pcm_offset+=samples; if(samplestime_total){ //goto seek_error; pcm_offset=-1; decode_clear(); return -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(seconds>=time_total) break; } // enough information to convert time offset to pcm offset { long target=(long)(pcm_total+(seconds-time_total)*vi[link].rate); return (pcm_seek(target)); } //seek_error: // dump machine so we're in a known state //pcm_offset=-1; //decode_clear(); //return -1; } // tell the current stream offset cursor. Note that seek followed by // tell will likely not give the set offset due to caching public long raw_tell(){ return (offset); } // return PCM offset (sample) of next PCM sample to be read public long pcm_tell(){ return (pcm_offset); } // return time offset (seconds) of next PCM sample to be read 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); } // link: -1) return the vorbis_info struct for the bitstream section // currently being decoded // 0-n) to request information for a specific bitstream section // // In the case of a non-seekable bitstream, any call returns the // current bitstream. NULL in the case that the machine is not // initialized public Info getInfo(int link){ if(seekable){ if(link<0){ if(decode_ready){ return vi[current_link]; } else{ return null; } } else{ if(link>=links){ return null; } else{ return vi[link]; } } } else{ if(decode_ready){ return vi[0]; } else{ return null; } } } public Comment getComment(int link){ if(seekable){ if(link<0){ if(decode_ready){ return vc[current_link]; } else{ return null; } } else{ if(link>=links){ return null; } else{ return vc[link]; } } } else{ if(decode_ready){ return vc[0]; } else{ return null; } } } int host_is_big_endian(){ return 1; // short pattern = 0xbabe; // unsigned char *bytewise = (unsigned char *)&pattern; // if (bytewise[0] == 0xba) return 1; // assert(bytewise[0] == 0xbe); // return 0; } // up to this point, everything could more or less hide the multiple // logical bitstream nature of chaining from the toplevel application // if the toplevel application didn't particularly care. However, at // the point that we actually read audio back, the multiple-section // nature must surface: Multiple bitstream sections do not necessarily // have to have the same number of channels or sampling rate. // // read returns the sequential logical bitstream number currently // being decoded along with the PCM data in order that the toplevel // application can take action on channel/sample rate changes. This // number will be incremented even for streamed (non-seekable) streams // (for seekable streams, it represents the actual logical bitstream // index within the physical bitstream. Note that the accessor // functions above are aware of this dichotomy). // // input values: buffer) a buffer to hold packed PCM data for return // length) the byte length requested to be placed into buffer // bigendianp) should the data be packed LSB first (0) or // MSB first (1) // word) word size for output. currently 1 (byte) or // 2 (16 bit short) // // return values: -1) error/hole in data // 0) EOF // n) number of bytes of PCM actually returned. The // below works on a packet-by-packet basis, so the // return length is not related to the 'length' passed // in, just guaranteed to fit. // // *section) set to the logical bitstream number int read(byte[] buffer, int length, int bigendianp, int word, int sgned, int[] bitstream){ int host_endian=host_is_big_endian(); int index=0; while(true){ if(decode_ready){ 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){ // yay! proceed to pack data into the byte buffer int channels=getInfo(-1).channels; int bytespersample=word*channels; if(samples>length/bytespersample) samples=length/bytespersample; // a tight loop to pack each size { int val; if(word==1){ int off=(sgned!=0 ? 0 : 128); for(int j=0; j127) val=127; else if(val<-128) val=-128; buffer[index++]=(byte)(val+off); } } } else{ int off=(sgned!=0 ? 0 : 32768); if(host_endian==bigendianp){ if(sgned!=0){ for(int i=0; i32767) val=32767; else if(val<-32768) val=-32768; buffer[dest]=(byte)(val>>>8); buffer[dest+1]=(byte)(val); dest+=channels*2; } } } else{ for(int i=0; i32767) val=32767; else if(val<-32768) val=-32768; buffer[dest]=(byte)((val+off)>>>8); buffer[dest+1]=(byte)(val+off); dest+=channels*2; } } } } else if(bigendianp!=0){ for(int j=0; j32767) val=32767; else if(val<-32768) val=-32768; val+=off; buffer[index++]=(byte)(val>>>8); buffer[index++]=(byte)val; } } } else{ //int val; for(int j=0; j32767) val=32767; else if(val<-32768) val=-32768; val+=off; buffer[index++]=(byte)val; buffer[index++]=(byte)(val>>>8); } } } } } vd.synthesis_read(samples); pcm_offset+=samples; if(bitstream!=null) bitstream[0]=current_link; return (samples*bytespersample); } } // suck in another packet switch(process_packet(1)){ case 0: return (0); case -1: return -1; default: break; } } } public Info[] getInfo(){ return vi; } public Comment[] getComment(){ return vc; } public void close() throws java.io.IOException{ datasource.close(); } class SeekableInputStream extends InputStream{ java.io.RandomAccessFile raf=null; final String mode="r"; SeekableInputStream(String file) throws java.io.IOException{ raf=new java.io.RandomAccessFile(file, mode); } public int read() throws java.io.IOException{ return raf.read(); } public int read(byte[] buf) throws java.io.IOException{ return raf.read(buf); } public int read(byte[] buf, int s, int len) throws java.io.IOException{ return raf.read(buf, s, len); } public long skip(long n) throws java.io.IOException{ return (long)(raf.skipBytes((int)n)); } public long getLength() throws java.io.IOException{ return raf.length(); } public long tell() throws java.io.IOException{ return raf.getFilePointer(); } public int available() throws java.io.IOException{ return (raf.length()==raf.getFilePointer()) ? 0 : 1; } public void close() throws java.io.IOException{ raf.close(); } public synchronized void mark(int m){ } public synchronized void reset() throws java.io.IOException{ } public boolean markSupported(){ return false; } public void seek(long pos) throws java.io.IOException{ raf.seek(pos); } } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Mapping0.java0000644000175000017500000002353011010261432021366 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; class Mapping0 extends FuncMapping{ static int seq=0; void free_info(Object imap){ }; void free_look(Object imap){ } Object look(DspState vd, InfoMode vm, Object m){ //System.err.println("Mapping0.look"); Info vi=vd.vi; LookMapping0 look=new LookMapping0(); InfoMapping0 info=look.map=(InfoMapping0)m; look.mode=vm; look.time_look=new Object[info.submaps]; look.floor_look=new Object[info.submaps]; look.residue_look=new Object[info.submaps]; look.time_func=new FuncTime[info.submaps]; look.floor_func=new FuncFloor[info.submaps]; look.residue_func=new FuncResidue[info.submaps]; for(int i=0; i1){ opb.write(1, 1); opb.write(info.submaps-1, 4); } else{ opb.write(0, 1); } if(info.coupling_steps>0){ opb.write(1, 1); opb.write(info.coupling_steps-1, 8); for(int i=0; i1){ for(int i=0; i=vi.channels ||testA>=vi.channels){ //goto err_out; info.free(); return (null); } } } if(opb.read(2)>0){ /* 2,3:reserved */ info.free(); return (null); } if(info.submaps>1){ for(int i=0; i=info.submaps){ info.free(); return (null); } } } for(int i=0; i=vi.times){ info.free(); return (null); } info.floorsubmap[i]=opb.read(8); if(info.floorsubmap[i]>=vi.floors){ info.free(); return (null); } info.residuesubmap[i]=opb.read(8); if(info.residuesubmap[i]>=vi.residues){ info.free(); return (null); } } return info; } float[][] pcmbundle=null; int[] zerobundle=null; int[] nonzero=null; Object[] floormemo=null; synchronized int inverse(Block vb, Object l){ DspState vd=vb.vd; Info vi=vd.vi; LookMapping0 look=(LookMapping0)l; InfoMapping0 info=look.map; InfoMode mode=look.mode; int n=vb.pcmend=vi.blocksizes[vb.W]; float[] window=vd.window[vb.W][vb.lW][vb.nW][mode.windowtype]; if(pcmbundle==null||pcmbundle.length=0; i--){ float[] pcmM=vb.pcm[info.coupling_mag[i]]; float[] pcmA=vb.pcm[info.coupling_ang[i]]; for(int j=0; j0){ if(ang>0){ pcmM[j]=mag; pcmA[j]=mag-ang; } else{ pcmA[j]=mag; pcmM[j]=mag+ang; } } else{ if(ang>0){ pcmM[j]=mag; pcmA[j]=mag+ang; } else{ pcmA[j]=mag; pcmM[j]=mag-ang; } } } } // /* compute and apply spectral envelope */ for(int i=0; i * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; public class JOrbisException extends Exception{ private static final long serialVersionUID=1L; public JOrbisException(){ super(); } public JOrbisException(String s){ super("JOrbis: "+s); } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Floor0.java0000644000175000017500000002067711010261370021066 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; class Floor0 extends FuncFloor{ void pack(Object i, Buffer opb){ InfoFloor0 info=(InfoFloor0)i; opb.write(info.order, 8); opb.write(info.rate, 16); opb.write(info.barkmap, 16); opb.write(info.ampbits, 6); opb.write(info.ampdB, 8); opb.write(info.numbooks-1, 4); for(int j=0; j=vi.books){ return (null); } } return (info); } Object look(DspState vd, InfoMode mi, Object i){ float scale; Info vi=vd.vi; InfoFloor0 info=(InfoFloor0)i; LookFloor0 look=new LookFloor0(); look.m=info.order; look.n=vi.blocksizes[mi.blockflag]/2; look.ln=info.barkmap; look.vi=info; look.lpclook.init(look.ln, look.m); // we choose a scaling constant so that: scale=look.ln/toBARK((float)(info.rate/2.)); // the mapping from a linear scale to a smaller bark scale is // straightforward. We do *not* make sure that the linear mapping // does not skip bark-scale bins; the decoder simply skips them and // the encoder may do what it wishes in filling them. They're // necessary in some mapping combinations to keep the scale spacing // accurate look.linearmap=new int[look.n]; for(int j=0; j=look.ln) val=look.ln; // guard against the approximation look.linearmap[j]=val; } return look; } static float toBARK(float f){ return (float)(13.1*Math.atan(.00074*(f))+2.24*Math.atan((f)*(f)*1.85e-8)+1e-4*(f)); } Object state(Object i){ EchstateFloor0 state=new EchstateFloor0(); InfoFloor0 info=(InfoFloor0)i; // a safe size if usually too big (dim==1) state.codewords=new int[info.order]; state.curve=new float[info.barkmap]; state.frameno=-1; return (state); } void free_info(Object i){ } void free_look(Object i){ } void free_state(Object vs){ } int forward(Block vb, Object i, float[] in, float[] out, Object vs){ return 0; } float[] lsp=null; int inverse(Block vb, Object i, float[] out){ //System.err.println("Floor0.inverse "+i.getClass()+"]"); LookFloor0 look=(LookFloor0)i; InfoFloor0 info=look.vi; int ampraw=vb.opb.read(info.ampbits); if(ampraw>0){ // also handles the -1 out of data case int maxval=(1<0){ // also handles the -1 out of data case int maxval=(1<m+1 must be less than l->ln, but guard in case we get a bad stream float[] lcurve=new float[Math.max(l.ln*2, l.m*2+2)]; if(amp==0){ for(int j=0; j * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class Drft{ int n; float[] trigcache; int[] splitcache; void backward(float[] data){ if(n==1) return; drftb1(n, data, trigcache, trigcache, n, splitcache); } void init(int n){ this.n=n; trigcache=new float[3*n]; splitcache=new int[32]; fdrffti(n, trigcache, splitcache); } void clear(){ if(trigcache!=null) trigcache=null; if(splitcache!=null) splitcache=null; } static int[] ntryh= {4, 2, 3, 5}; static float tpi=6.28318530717958647692528676655900577f; static float hsqt2=.70710678118654752440084436210485f; static float taui=.86602540378443864676372317075293618f; static float taur=-.5f; static float sqrt2=1.4142135623730950488016887242097f; static void drfti1(int n, float[] wa, int index, int[] ifac){ float arg, argh, argld, fi; int ntry=0, i, j=-1; int k1, l1, l2, ib; int ld, ii, ip, is, nq, nr; int ido, ipm, nfm1; int nl=n; int nf=0; int state=101; loop: while(true){ switch(state){ case 101: j++; if(j<4) ntry=ntryh[j]; else ntry+=2; case 104: nq=nl/ntry; nr=nl-ntry*nq; if(nr!=0){ state=101; break; } nf++; ifac[nf+1]=ntry; nl=nq; if(ntry!=2){ state=107; break; } if(nf==1){ state=107; break; } for(i=1; i>1; ipp2=ip; idp2=ido; nbd=(ido-1)>>1; t0=l1*ido; t10=ip*ido; int state=100; loop: while(true){ switch(state){ case 101: if(ido==1){ state=119; break; } for(ik=0; ikl1){ for(j=1; j>>1; ipp2=ip; ipph=(ip+1)>>>1; if(idol1){ state=139; break; } is=-ido-1; t1=0; for(j=1; j>>=1; } return (ret); } static int ilog2(int v){ int ret=0; while(v>1){ ret++; v>>>=1; } return (ret); } static int icount(int v){ int ret=0; while(v!=0){ ret+=(v&1); v>>>=1; } return (ret); } } libjorbis-java-0.0.17.orig/com/jcraft/jorbis/Residue1.java0000644000175000017500000000261511010261450021375 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; class Residue1 extends Residue0{ int inverse(Block vb, Object vl, float[][] in, int[] nonzero, int ch){ int used=0; for(int i=0; i * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jorbis; import com.jcraft.jogg.*; class StaticCodeBook{ int dim; // codebook dimensions (elements per vector) int entries; // codebook entries int[] lengthlist; // codeword lengths in bits // mapping int maptype; // 0=none // 1=implicitly populated values from map column // 2=listed arbitrary values // The below does a linear, single monotonic sequence mapping. int q_min; // packed 32 bit float; quant value 0 maps to minval int q_delta; // packed 32 bit float; val 1 - val 0 == delta int q_quant; // bits: 0 < quant <= 16 int q_sequencep; // bitflag // additional information for log (dB) mapping; the linear mapping // is assumed to actually be values in dB. encodebias is used to // assign an error weight to 0 dB. We have two additional flags: // zeroflag indicates if entry zero is to represent -Inf dB; negflag // indicates if we're to represent negative linear values in a // mirror of the positive mapping. int[] quantlist; // map == 1: (int)(entries/dim) element column map // map == 2: list of dim*entries quantized entry vals StaticCodeBook(){ } int pack(Buffer opb){ int i; boolean ordered=false; opb.write(0x564342, 24); opb.write(dim, 16); opb.write(entries, 24); // pack the codewords. There are two packings; length ordered and // length random. Decide between the two now. for(i=1; i_last){ for(int j=_last; j<_this; j++){ opb.write(i-count, Util.ilog(entries-count)); count=i; } } } opb.write(i-count, Util.ilog(entries-count)); } else{ // length random. Again, we don't code the codeword itself, just // the length. This time, though, we have to encode each length opb.write(0, 1); // unordered // algortihmic mapping has use for 'unused entries', which we tag // here. The algorithmic mapping happens as usual, but the unused // entry has no codeword. for(i=0; ientries/c->dim) quantized values for // building a full value list algorithmically (square lattice) quantvals=maptype1_quantvals(); break; case 2: // every value (c->entries*c->dim total) specified explicitly quantvals=entries*dim; break; } // quantized values for(i=0; ibim <= b->entries // treat the above as an initial guess while(true){ int acc=1; int acc1=1; for(int i=0; ientries){ return (vals); } else{ if(acc>entries){ vals--; } else{ vals++; } } } } void clear(){ } // unpack the quantized list of values for encode/decode // we need to deal with two map types: in map type 1, the values are // generated algorithmically (each column of the vector counts through // the values in the quant vector). in map type 2, all the values came // in in an explicit list. Both value lists must be unpacked float[] unquantize(){ if(maptype==1||maptype==2){ int quantvals; float mindel=float32_unpack(q_min); float delta=float32_unpack(q_delta); float[] r=new float[entries*dim]; // maptype 1 and 2 both use a quantized value vector, but // different sizes switch(maptype){ case 1: // most of the time, entries%dimensions == 0, but we need to be // well defined. We define that the possible vales at each // scalar is values == entries/dim. If entries%dim != 0, we'll // have 'too few' values (values*dim "+val+" | ");} val=Math.abs(val)*delta+mindel+last; if(q_sequencep!=0) last=val; r[j*dim+k]=val; //if((j*dim+k)==0){System.err.println(" $ r[0] -> "+r[0]+" | ");} } } //System.err.println("\nr[0]="+r[0]); } return (r); } return (null); } // 32 bit float (not IEEE; nonnormalized mantissa + // biased exponent) : neeeeeee eeemmmmm mmmmmmmm mmmmmmmm // Why not IEEE? It's just not that important here. static final int VQ_FEXP=10; static final int VQ_FMAN=21; static final int VQ_FEXP_BIAS=768; // bias toward values smaller than 1. // doesn't currently guard under/overflow static long float32_pack(float val){ int sign=0; int exp; int mant; if(val<0){ sign=0x80000000; val=-val; } exp=(int)Math.floor(Math.log(val)/Math.log(2)); mant=(int)Math.rint(Math.pow(val, (VQ_FMAN-1)-exp)); exp=(exp+VQ_FEXP_BIAS)<>>VQ_FMAN; if((val&0x80000000)!=0) mant=-mant; return (ldexp(mant, ((int)exp)-(VQ_FMAN-1)-VQ_FEXP_BIAS)); } static float ldexp(float foo, int e){ return (float)(foo*Math.pow(2, e)); } } libjorbis-java-0.0.17.orig/com/jcraft/jogg/0000755000175000017500000000000011010340473016506 5ustar godgodlibjorbis-java-0.0.17.orig/com/jcraft/jogg/SyncState.java0000644000175000017500000001612611010261516021274 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jogg; // DECODING PRIMITIVES: packet streaming layer // This has two layers to place more of the multi-serialno and paging // control in the application's hands. First, we expose a data buffer // using ogg_decode_buffer(). The app either copies into the // buffer, or passes it directly to read(), etc. We then call // ogg_decode_wrote() to tell how many bytes we just added. // // Pages are returned (pointers into the buffer in ogg_sync_state) // by ogg_decode_stream(). The page is then submitted to // ogg_decode_page() along with the appropriate // ogg_stream_state* (ie, matching serialno). We then get raw // packets out calling ogg_stream_packet() with a // ogg_stream_state. See the 'frame-prog.txt' docs for details and // example code. public class SyncState{ public byte[] data; int storage; int fill; int returned; int unsynced; int headerbytes; int bodybytes; public int clear(){ data=null; return (0); } public int buffer(int size){ // first, clear out any space that has been previously returned if(returned!=0){ fill-=returned; if(fill>0){ System.arraycopy(data, returned, data, 0, fill); } returned=0; } if(size>storage-fill){ // We need to extend the internal buffer int newsize=size+fill+4096; // an extra page to be nice if(data!=null){ byte[] foo=new byte[newsize]; System.arraycopy(data, 0, foo, 0, data.length); data=foo; } else{ data=new byte[newsize]; } storage=newsize; } return (fill); } public int wrote(int bytes){ if(fill+bytes>storage) return (-1); fill+=bytes; return (0); } // sync the stream. This is meant to be useful for finding page // boundaries. // // return values for this: // -n) skipped n bytes // 0) page not ready; more data (no bytes skipped) // n) page synced at current location; page length n bytes private Page pageseek=new Page(); private byte[] chksum=new byte[4]; public int pageseek(Page og){ int page=returned; int next; int bytes=fill-returned; if(headerbytes==0){ int _headerbytes, i; if(bytes<27) return (0); // not enough for a header /* verify capture pattern */ if(data[page]!='O'||data[page+1]!='g'||data[page+2]!='g' ||data[page+3]!='S'){ headerbytes=0; bodybytes=0; // search for possible capture next=0; for(int ii=0; iibytes) return (0); // The whole test page is buffered. Verify the checksum synchronized(chksum){ // Grab the checksum bytes, set the header field to zero System.arraycopy(data, page+22, chksum, 0, 4); data[page+22]=0; data[page+23]=0; data[page+24]=0; data[page+25]=0; // set up a temp page struct and recompute the checksum Page log=pageseek; log.header_base=data; log.header=page; log.header_len=headerbytes; log.body_base=data; log.body=page+headerbytes; log.body_len=bodybytes; log.checksum(); // Compare if(chksum[0]!=data[page+22]||chksum[1]!=data[page+23] ||chksum[2]!=data[page+24]||chksum[3]!=data[page+25]){ // D'oh. Mismatch! Corrupt page (or miscapture and not a page at all) // replace the computed checksum with the one actually read in System.arraycopy(chksum, 0, data, page+22, 4); // Bad checksum. Lose sync */ headerbytes=0; bodybytes=0; // search for possible capture next=0; for(int ii=0; ii0){ // have a page return (1); } if(ret==0){ // need more data return (0); } // head did not start a synced page... skipped some bytes if(unsynced==0){ unsynced=1; return (-1); } // loop. keep looking } } // clear things to an initial state. Good to call, eg, before seeking public int reset(){ fill=0; returned=0; unsynced=0; headerbytes=0; bodybytes=0; return (0); } public void init(){ } public int getDataOffset(){ return returned; } public int getBufferOffset(){ return fill; } } libjorbis-java-0.0.17.orig/com/jcraft/jogg/StreamState.java0000644000175000017500000003321311010261513021604 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jogg; public class StreamState{ byte[] body_data; /* bytes from packet bodies */ int body_storage; /* storage elements allocated */ int body_fill; /* elements stored; fill mark */ private int body_returned; /* elements of fill returned */ int[] lacing_vals; /* The values that will go to the segment table */ long[] granule_vals; /* pcm_pos values for headers. Not compact this way, but it is simple coupled to the lacing fifo */ int lacing_storage; int lacing_fill; int lacing_packet; int lacing_returned; byte[] header=new byte[282]; /* working space for header encode */ int header_fill; public int e_o_s; /* set when we have buffered the last packet in the logical bitstream */ int b_o_s; /* set after we've written the initial page of a logical bitstream */ int serialno; int pageno; long packetno; /* sequence number for decode; the framing knows where there's a hole in the data, but we need coupling so that the codec (which is in a seperate abstraction layer) also knows about the gap */ long granulepos; public StreamState(){ init(); } StreamState(int serialno){ this(); init(serialno); } void init(){ body_storage=16*1024; body_data=new byte[body_storage]; lacing_storage=1024; lacing_vals=new int[lacing_storage]; granule_vals=new long[lacing_storage]; } public void init(int serialno){ if(body_data==null){ init(); } else{ for(int i=0; i0) return (-1); lacing_expand(segments+1); // are we in sequence? if(_pageno!=pageno){ int i; // unroll previous partial packet (if any) for(i=lacing_packet; i0) lacing_vals[lacing_fill-1]|=0x200; } pageno=_pageno+1; return (0); } /* This will flush remaining packets into a page (returning nonzero), even if there is not enough data to trigger a flush normally (undersized page). If there are no packets or partial packets to flush, ogg_stream_flush returns 0. Note that ogg_stream_flush will try to flush a normal sized page like ogg_stream_pageout; a call to ogg_stream_flush does not gurantee that all packets have flushed. Only a return value of 0 from ogg_stream_flush indicates all packet data is flushed into pages. ogg_stream_page will flush the last page in a stream even if it's undersized; you almost certainly want to use ogg_stream_pageout (and *not* ogg_stream_flush) unless you need to flush an undersized page in the middle of a stream for some reason. */ public int flush(Page og){ int i; int vals=0; int maxvals=(lacing_fill>255 ? 255 : lacing_fill); int bytes=0; int acc=0; long granule_pos=granule_vals[0]; if(maxvals==0) return (0); /* construct a page */ /* decide how many segments to include */ /* If this is the initial header case, the first page must only include the initial header packet */ if(b_o_s==0){ /* 'initial header page' case */ granule_pos=0; for(vals=0; vals4096) break; acc+=(lacing_vals[vals]&0x0ff); granule_pos=granule_vals[vals]; } } /* construct the header in temp storage */ System.arraycopy("OggS".getBytes(), 0, header, 0, 4); /* stream structure version */ header[4]=0x00; /* continued packet flag? */ header[5]=0x00; if((lacing_vals[0]&0x100)==0) header[5]|=0x01; /* first page flag? */ if(b_o_s==0) header[5]|=0x02; /* last page flag? */ if(e_o_s!=0&&lacing_fill==vals) header[5]|=0x04; b_o_s=1; /* 64 bits of PCM position */ for(i=6; i<14; i++){ header[i]=(byte)granule_pos; granule_pos>>>=8; } /* 32 bits of stream serial number */ { int _serialno=serialno; for(i=14; i<18; i++){ header[i]=(byte)_serialno; _serialno>>>=8; } } /* 32 bits of page counter (we have both counter and page header because this val can roll over) */ if(pageno==-1) pageno=0; /* because someone called stream_reset; this would be a strange thing to do in an encode stream, but it has plausible uses */ { int _pageno=pageno++; for(i=18; i<22; i++){ header[i]=(byte)_pageno; _pageno>>>=8; } } /* zero for computation; filled in later */ header[22]=0; header[23]=0; header[24]=0; header[25]=0; /* segment table */ header[26]=(byte)vals; for(i=0; i4096|| /* 'page nominal size' case */ lacing_fill>=255|| /* 'segment table full' case */ (lacing_fill!=0&&b_o_s==0)){ /* 'initial header page' case */ return flush(og); } return 0; } public int eof(){ return e_o_s; } public int reset(){ body_fill=0; body_returned=0; lacing_fill=0; lacing_packet=0; lacing_returned=0; header_fill=0; e_o_s=0; b_o_s=0; pageno=-1; packetno=0; granulepos=0; return (0); } } libjorbis-java-0.0.17.orig/com/jcraft/jogg/Page.java0000644000175000017500000000736711010261504020237 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jogg; public class Page{ private static int[] crc_lookup=new int[256]; static{ for(int i=0; i>>24)&0xff)^(header_base[header+i]&0xff)]; } for(int i=0; i>>24)&0xff)^(body_base[body+i]&0xff)]; } header_base[header+22]=(byte)crc_reg; header_base[header+23]=(byte)(crc_reg>>>8); header_base[header+24]=(byte)(crc_reg>>>16); header_base[header+25]=(byte)(crc_reg>>>24); } public Page copy(){ return copy(new Page()); } public Page copy(Page p){ byte[] tmp=new byte[header_len]; System.arraycopy(header_base, header, tmp, 0, header_len); p.header_len=header_len; p.header_base=tmp; p.header=0; tmp=new byte[body_len]; System.arraycopy(body_base, body, tmp, 0, body_len); p.body_len=body_len; p.body_base=tmp; p.body=0; return p; } } libjorbis-java-0.0.17.orig/com/jcraft/jogg/Packet.java0000644000175000017500000000273711010261500020562 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jogg; public class Packet{ public byte[] packet_base; public int packet; public int bytes; public int b_o_s; public int e_o_s; public long granulepos; /** * sequence number for decode; the framing * knows where there's a hole in the data, * but we need coupling so that the codec * (which is in a seperate abstraction * layer) also knows about the gap */ public long packetno; } libjorbis-java-0.0.17.orig/com/jcraft/jogg/Buffer.java0000644000175000017500000001431111010261475020566 0ustar godgod/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */ /* JOrbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * * Many thanks to * Monty and * The XIPHOPHORUS Company http://www.xiph.org/ . * JOrbis has been based on their awesome works, Vorbis codec. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package com.jcraft.jogg; public class Buffer{ private static final int BUFFER_INCREMENT=256; private static final int[] mask= {0x00000000, 0x00000001, 0x00000003, 0x00000007, 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f, 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff, 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff, 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff, 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff, 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff, 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff, 0xffffffff}; int ptr=0; byte[] buffer=null; int endbit=0; int endbyte=0; int storage=0; public void writeinit(){ buffer=new byte[BUFFER_INCREMENT]; ptr=0; buffer[0]=(byte)'\0'; storage=BUFFER_INCREMENT; } public void write(byte[] s){ for(int i=0; i=storage){ byte[] foo=new byte[storage+BUFFER_INCREMENT]; System.arraycopy(buffer, 0, foo, 0, storage); buffer=foo; storage+=BUFFER_INCREMENT; } value&=mask[bits]; bits+=endbit; buffer[ptr]|=(byte)(value<=8){ buffer[ptr+1]=(byte)(value>>>(8-endbit)); if(bits>=16){ buffer[ptr+2]=(byte)(value>>>(16-endbit)); if(bits>=24){ buffer[ptr+3]=(byte)(value>>>(24-endbit)); if(bits>=32){ if(endbit>0) buffer[ptr+4]=(byte)(value>>>(32-endbit)); else buffer[ptr+4]=0; } } } } endbyte+=bits/8; ptr+=bits/8; endbit=bits&7; } public int look(int bits){ int ret; int m=mask[bits]; bits+=endbit; if(endbyte+4>=storage){ if(endbyte+(bits-1)/8>=storage) return (-1); } ret=((buffer[ptr])&0xff)>>>endbit; if(bits>8){ ret|=((buffer[ptr+1])&0xff)<<(8-endbit); if(bits>16){ ret|=((buffer[ptr+2])&0xff)<<(16-endbit); if(bits>24){ ret|=((buffer[ptr+3])&0xff)<<(24-endbit); if(bits>32&&endbit!=0){ ret|=((buffer[ptr+4])&0xff)<<(32-endbit); } } } } return (m&ret); } public int look1(){ if(endbyte>=storage) return (-1); return ((buffer[ptr]>>endbit)&1); } public void adv(int bits){ bits+=endbit; ptr+=bits/8; endbyte+=bits/8; endbit=bits&7; } public void adv1(){ ++endbit; if(endbit>7){ endbit=0; ptr++; endbyte++; } } public int read(int bits){ int ret; int m=mask[bits]; bits+=endbit; if(endbyte+4>=storage){ ret=-1; if(endbyte+(bits-1)/8>=storage){ ptr+=bits/8; endbyte+=bits/8; endbit=bits&7; return (ret); } } ret=((buffer[ptr])&0xff)>>>endbit; if(bits>8){ ret|=((buffer[ptr+1])&0xff)<<(8-endbit); if(bits>16){ ret|=((buffer[ptr+2])&0xff)<<(16-endbit); if(bits>24){ ret|=((buffer[ptr+3])&0xff)<<(24-endbit); if(bits>32&&endbit!=0){ ret|=((buffer[ptr+4])&0xff)<<(32-endbit); } } } } ret&=m; ptr+=bits/8; endbyte+=bits/8; endbit=bits&7; return (ret); } public int readB(int bits){ int ret; int m=32-bits; bits+=endbit; if(endbyte+4>=storage){ /* not the main path */ ret=-1; if(endbyte*8+bits>storage*8){ ptr+=bits/8; endbyte+=bits/8; endbit=bits&7; return (ret); } } ret=(buffer[ptr]&0xff)<<(24+endbit); if(bits>8){ ret|=(buffer[ptr+1]&0xff)<<(16+endbit); if(bits>16){ ret|=(buffer[ptr+2]&0xff)<<(8+endbit); if(bits>24){ ret|=(buffer[ptr+3]&0xff)<<(endbit); if(bits>32&&(endbit!=0)) ret|=(buffer[ptr+4]&0xff)>>(8-endbit); } } } ret=(ret>>>(m>>1))>>>((m+1)>>1); ptr+=bits/8; endbyte+=bits/8; endbit=bits&7; return (ret); } public int read1(){ int ret; if(endbyte>=storage){ ret=-1; endbit++; if(endbit>7){ endbit=0; ptr++; endbyte++; } return (ret); } ret=(buffer[ptr]>>endbit)&1; endbit++; if(endbit>7){ endbit=0; ptr++; endbyte++; } return (ret); } public int bytes(){ return (endbyte+(endbit+7)/8); } public int bits(){ return (endbyte*8+endbit); } public byte[] buffer(){ return (buffer); } public static int ilog(int v){ int ret=0; while(v>0){ ret++; v>>>=1; } return (ret); } public static void report(String in){ System.err.println(in); System.exit(1); } }