src/share/classes/com/sun/media/sound/AiffFileReader.java

Print this page


   1 /*
   2  * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 389         }
 390         dos.writeShort(exponent);
 391         dos.writeInt( ((int) highMantissa) << 16);
 392         dos.writeInt(0); // low Mantissa
 393     }
 394 
 395 
 396     /**
 397      * read_ieee_extended
 398      * Extended precision IEEE floating-point conversion routine.
 399      * @argument DataInputStream
 400      * @return double
 401      * @exception IOException
 402      */
 403     private double read_ieee_extended(DataInputStream dis) throws IOException {
 404 
 405         double f = 0;
 406         int expon = 0;
 407         long hiMant = 0, loMant = 0;
 408         long t1, t2;
 409         double HUGE = ((double)3.40282346638528860e+38);
 410 
 411 
 412         expon = dis.readUnsignedShort();
 413 
 414         t1 = (long)dis.readUnsignedShort();
 415         t2 = (long)dis.readUnsignedShort();
 416         hiMant = t1 << 16 | t2;
 417 
 418         t1 = (long)dis.readUnsignedShort();
 419         t2 = (long)dis.readUnsignedShort();
 420         loMant = t1 << 16 | t2;
 421 
 422         if (expon == 0 && hiMant == 0 && loMant == 0) {
 423             f = 0;
 424         } else {
 425             if (expon == 0x7FFF)
 426                 f = HUGE;
 427             else {
 428                 expon -= 16383;
 429                 expon -= 31;
   1 /*
   2  * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 389         }
 390         dos.writeShort(exponent);
 391         dos.writeInt( ((int) highMantissa) << 16);
 392         dos.writeInt(0); // low Mantissa
 393     }
 394 
 395 
 396     /**
 397      * read_ieee_extended
 398      * Extended precision IEEE floating-point conversion routine.
 399      * @argument DataInputStream
 400      * @return double
 401      * @exception IOException
 402      */
 403     private double read_ieee_extended(DataInputStream dis) throws IOException {
 404 
 405         double f = 0;
 406         int expon = 0;
 407         long hiMant = 0, loMant = 0;
 408         long t1, t2;
 409         double HUGE = 3.40282346638528860e+38;
 410 
 411 
 412         expon = dis.readUnsignedShort();
 413 
 414         t1 = (long)dis.readUnsignedShort();
 415         t2 = (long)dis.readUnsignedShort();
 416         hiMant = t1 << 16 | t2;
 417 
 418         t1 = (long)dis.readUnsignedShort();
 419         t2 = (long)dis.readUnsignedShort();
 420         loMant = t1 << 16 | t2;
 421 
 422         if (expon == 0 && hiMant == 0 && loMant == 0) {
 423             f = 0;
 424         } else {
 425             if (expon == 0x7FFF)
 426                 f = HUGE;
 427             else {
 428                 expon -= 16383;
 429                 expon -= 31;