⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mulawcompattest.java

📁 FMJ(freedom media for java)是java视频开发的新选择
💻 JAVA
字号:
package net.sf.fmj.media.codec.audio.ulaw;import javax.media.Buffer;import javax.media.Codec;import javax.media.Format;import javax.media.format.AudioFormat;import junit.framework.TestCase;/** @deprecated not used yet. Requires both FMJ and JMF in classpath. */public class MuLawCompatTest extends TestCase {	public void test1() throws Exception	{		String className = "com.ibm.media.codec.audio.ulaw.JavaEncoder";		String className2 = "net.sf.fmj.media.codec.audio.ulaw.Encoder";				Format f = new AudioFormat(AudioFormat.LINEAR, -1.0, 16, 1, AudioFormat.BIG_ENDIAN, AudioFormat.SIGNED, 16, -1.0, Format.byteArray);				Codec encoder = open(className, f);		Codec encoder2 = open(className2, f);				// signed, big: all values with both bytes negative are wrong.  Half of the values are wrong.		// signed, little: all values where first byte is negative is wrong.  Half are wrong.		// unsigned, big: all values wrong		// unsigned, little: all values wrong.				byte[] data = new byte[2];				int err = 0;		for (int b0 = Byte.MIN_VALUE; b0 <= Byte.MAX_VALUE; ++b0)		{			for (int b1 = Byte.MIN_VALUE; b1 <= Byte.MAX_VALUE; ++b1)			{				data[0] = (byte) b0;				data[1] = (byte) b1;				byte res = encode(data, encoder, f);				byte res2 = encode(data, encoder2, f);				System.out.println("" + b0 + " " + b1 + ": " + res + " " + res2 + " " + (res != res2 ? "************" : ""));				if (res != res2)					++err;				//assertEquals(res, res2);			}		}				System.out.println("Errors: " + err);					}		private Codec open(String className, Format f) throws Exception	{		Codec encoder = (Codec) Class.forName(className).newInstance();		encoder.setInputFormat(f);		encoder.setOutputFormat(encoder.getSupportedOutputFormats(f)[0]);		encoder.open();		return encoder;			}		private byte encode(byte[] data, Codec encoder, Format f)	{		Buffer input = new Buffer();		input.setFormat(f);		input.setData(data);		input.setLength(2);		Buffer output = new Buffer();		output.setData(new byte[1]);		int res = encoder.process(input, output);		assertEquals(res, Codec.BUFFER_PROCESSED_OK);		final byte[] result = (byte[]) output.getData();		final int resultLen = output.getLength();		assertEquals(resultLen, 1);		return result[0];	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -