< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/UlawCodec.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 28,57 **** import java.io.IOException; import java.util.Objects; import java.util.Vector; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; /** * U-law encodes linear data, and decodes u-law data to linear data. * * @author Kara Kytle */ ! public final class UlawCodec extends SunCodec { /* Tables used for U-law decoding */ private static final byte[] ULAW_TABH = new byte[256]; private static final byte[] ULAW_TABL = new byte[256]; ! private static final AudioFormat.Encoding[] ulawEncodings = {AudioFormat.Encoding.ULAW, ! AudioFormat.Encoding.PCM_SIGNED}; ! ! private static final short seg_end [] = {0xFF, 0x1FF, 0x3FF, ! 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF}; /** * Initializes the decode tables. */ static { --- 28,57 ---- import java.io.IOException; import java.util.Objects; import java.util.Vector; import javax.sound.sampled.AudioFormat; + import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; + import javax.sound.sampled.spi.FormatConversionProvider; /** * U-law encodes linear data, and decodes u-law data to linear data. * * @author Kara Kytle */ ! public final class UlawCodec extends FormatConversionProvider { /* Tables used for U-law decoding */ private static final byte[] ULAW_TABH = new byte[256]; private static final byte[] ULAW_TABL = new byte[256]; ! private static final short seg_end[] = { ! 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF, 0x1FFF, 0x3FFF, 0x7FFF ! }; /** * Initializes the decode tables. */ static {
*** 67,81 **** ULAW_TABL[i] = (byte) (t&0xff); ULAW_TABH[i] = (byte) ((t>>8) & 0xff); } } ! /** ! * Constructs a new ULAW codec object. ! */ ! public UlawCodec() { ! super(ulawEncodings, ulawEncodings); } @Override public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){ if( AudioFormat.Encoding.PCM_SIGNED.equals(sourceFormat.getEncoding()) ) { --- 67,84 ---- ULAW_TABL[i] = (byte) (t&0xff); ULAW_TABH[i] = (byte) ((t>>8) & 0xff); } } ! @Override ! public AudioFormat.Encoding[] getSourceEncodings() { ! return new Encoding[]{Encoding.ULAW, Encoding.PCM_SIGNED}; ! } ! ! @Override ! public AudioFormat.Encoding[] getTargetEncodings() { ! return getSourceEncodings(); } @Override public AudioFormat.Encoding[] getTargetEncodings(AudioFormat sourceFormat){ if( AudioFormat.Encoding.PCM_SIGNED.equals(sourceFormat.getEncoding()) ) {
< prev index next >