亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? decoder.java

?? java編寫的mp3播放器
?? JAVA
字號:
/*
 * 01/12/99		Initial version.	mdm@techie.com
 *-----------------------------------------------------------------------
 *  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.
 *----------------------------------------------------------------------
 */
 
package javazoom.jl.decoder;

/**
 * The <code>Decoder</code> class encapsulates the details of
 * decoding an MPEG audio frame. 
 * 
 * @author	MDM	
 * @version 0.0.7 12/12/99
 * @since	0.0.5
 */
public class Decoder implements DecoderErrors
{
	static private final Params DEFAULT_PARAMS = new Params();
	
	/**
	 * The Bistream from which the MPEG audio frames are read.
	 */
	//private Bitstream				stream;
	
	/**
	 * The Obuffer instance that will receive the decoded
	 * PCM samples.
	 */
	private Obuffer			output;
		
	/**
	 * Synthesis filter for the left channel.
	 */
	private SynthesisFilter			filter1;
	
	/**
	 * Sythesis filter for the right channel.
	 */
	private SynthesisFilter			filter2;	
			
	/**
	 * The decoder used to decode layer III frames.
	 */
	private LayerIIIDecoder			l3decoder;
	private LayerIIDecoder			l2decoder;
	private LayerIDecoder			l1decoder;
	
	private int						outputFrequency;
	private int						outputChannels;
	
	private Equalizer				equalizer = new Equalizer();
	
	private Params					params;
	
	private boolean					initialized;
		
	
	/**
	 * Creates a new <code>Decoder</code> instance with default 
	 * parameters.
	 */
	
	public Decoder()
	{
		this(null);
	}

	/**
	 * Creates a new <code>Decoder</code> instance with default 
	 * parameters.
	 * 
	 * @param params	The <code>Params</code> instance that describes
	 *					the customizable aspects of the decoder.  
	 */
	public Decoder(Params params0)
	{
		if (params0==null)
			params0 = DEFAULT_PARAMS;
	
		params = params0;
		
		Equalizer eq = params.getInitialEqualizerSettings();
		if (eq!=null)
		{
			equalizer.setFrom(eq);
		}
	}
	
	static public Params getDefaultParams()
	{
		return (Params)DEFAULT_PARAMS.clone();
	}
	
	public void setEqualizer(Equalizer eq)
	{
		if (eq==null)
			eq = Equalizer.PASS_THRU_EQ;
		
		equalizer.setFrom(eq);
		
		float[] factors = equalizer.getBandFactors();

		if (filter1!=null)
			filter1.setEQ(factors);
		
		if (filter2!=null)
			filter2.setEQ(factors);			
	}
	
	/**
	 * Decodes one frame from an MPEG audio bitstream.
	 * 
	 * @param header		The header describing the frame to decode.
	 * @param bitstream		The bistream that provides the bits for te body of the frame. 
	 * 
	 * @return A SampleBuffer containing the decoded samples.
	 */
	public Obuffer decodeFrame(Header header, Bitstream stream)
		throws DecoderException
	{
		if (!initialized)
		{
			initialize(header);
		}
		
		int layer = header.layer();
		
		output.clear_buffer();
		
		FrameDecoder decoder = retrieveDecoder(header, stream, layer);
		
		decoder.decodeFrame();
				
		output.write_buffer(1);
		
		return output;	
	}
	
	/**
	 * Changes the output buffer. This will take effect the next time
	 * decodeFrame() is called. 
	 */
	public void setOutputBuffer(Obuffer out)
	{
		output = out;
	}
	
	/**
	 * Retrieves the sample frequency of the PCM samples output
	 * by this decoder. This typically corresponds to the sample
	 * rate encoded in the MPEG audio stream.
	 * 
	 * @param the sample rate (in Hz) of the samples written to the
	 *		output buffer when decoding. 
	 */
	public int getOutputFrequency()
	{
		return outputFrequency;
	}
	
	/**
	 * Retrieves the number of channels of PCM samples output by
	 * this decoder. This usually corresponds to the number of
	 * channels in the MPEG audio stream, although it may differ.
	 * 
	 * @return The number of output channels in the decoded samples: 1 
	 *		for mono, or 2 for stereo.
	 *		
	 */
	public int getOutputChannels()
	{
		return outputChannels;	
	}
	
	/**
	 * Retrieves the maximum number of samples that will be written to
	 * the output buffer when one frame is decoded. This can be used to
	 * help calculate the size of other buffers whose size is based upon 
	 * the number of samples written to the output buffer. NB: this is
	 * an upper bound and fewer samples may actually be written, depending
	 * upon the sample rate and number of channels.
	 * 
	 * @return The maximum number of samples that are written to the 
	 *		output buffer when decoding a single frame of MPEG audio.
	 */
	public int getOutputBlockSize()
	{
		return Obuffer.OBUFFERSIZE;
	}
	
	
	protected DecoderException newDecoderException(int errorcode)
	{
		return new DecoderException(errorcode, null);
	}
	
	protected DecoderException newDecoderException(int errorcode, Throwable throwable)
	{
		return new DecoderException(errorcode, throwable);
	}
	
	protected FrameDecoder retrieveDecoder(Header header, Bitstream stream, int layer)
		throws DecoderException
	{
		FrameDecoder decoder = null;
		
		// REVIEW: allow channel output selection type
		// (LEFT, RIGHT, BOTH, DOWNMIX)
		switch (layer)
		{
		case 3:
			if (l3decoder==null)
			{
				l3decoder = new LayerIIIDecoder(stream, 
					header, filter1, filter2, 
					output, OutputChannels.BOTH_CHANNELS);
			}						
			
			decoder = l3decoder;
			break;
		case 2:
			if (l2decoder==null)
			{
				l2decoder = new LayerIIDecoder();
				l2decoder.create(stream, 
					header, filter1, filter2, 
					output, OutputChannels.BOTH_CHANNELS);				
			}
			decoder = l2decoder;
			break;
		case 1:
			if (l1decoder==null)
			{
				l1decoder = new LayerIDecoder();
				l1decoder.create(stream, 
					header, filter1, filter2, 
					output, OutputChannels.BOTH_CHANNELS);				
			}
			decoder = l1decoder;
			break;
		}
						
		if (decoder==null)
		{
			throw newDecoderException(UNSUPPORTED_LAYER, null);
		}
		
		return decoder;
	}
	
	private void initialize(Header header)
		throws DecoderException
	{
		
		// REVIEW: allow customizable scale factor
		float scalefactor = 32700.0f;
		
		int mode = header.mode();
		int layer = header.layer();
		int channels = mode==Header.SINGLE_CHANNEL ? 1 : 2;

					
		// set up output buffer if not set up by client.
		if (output==null)
			output = new SampleBuffer(header.frequency(), channels);
		
		float[] factors = equalizer.getBandFactors();
		filter1 = new SynthesisFilter(0, scalefactor, factors);
   		
		// REVIEW: allow mono output for stereo
		if (channels==2) 
			filter2 = new SynthesisFilter(1, scalefactor, factors);

		outputChannels = channels;
		outputFrequency = header.frequency();
		
		initialized = true;
	}
	
	/**
	 * The <code>Params</code> class presents the customizable
	 * aspects of the decoder. 
	 * <p>
	 * Instances of this class are not thread safe. 
	 */
	public static class Params implements Cloneable
	{
		private OutputChannels	outputChannels = OutputChannels.BOTH;
		
		private Equalizer		equalizer = new Equalizer();
		
		public Params()
		{			
		}
		
		public Object clone()
		{
			try
			{
				return super.clone();
			}
			catch (CloneNotSupportedException ex)
			{				
				throw new InternalError(this+": "+ex);
			}
		}
				
		public void setOutputChannels(OutputChannels out)
		{
			if (out==null)
				throw new NullPointerException("out");
			
			outputChannels = out;
		}
		
		public OutputChannels getOutputChannels()
		{
			return outputChannels;
		}
		
		/**
		 * Retrieves the equalizer settings that the decoder's equalizer
		 * will be initialized from.
		 * <p>
		 * The <code>Equalizer</code> instance returned 
		 * cannot be changed in real time to affect the 
		 * decoder output as it is used only to initialize the decoders
		 * EQ settings. To affect the decoder's output in realtime,
		 * use the Equalizer returned from the getEqualizer() method on
		 * the decoder. 
		 * 
		 * @return	The <code>Equalizer</code> used to initialize the
		 *			EQ settings of the decoder. 
		 */
		public Equalizer getInitialEqualizerSettings()
		{
			return equalizer;	
		}
				
	};
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲日穴在线视频| 亚洲va欧美va人人爽午夜| 国产精品久久一卡二卡| 成人免费在线视频观看| 亚洲va在线va天堂| 成人丝袜高跟foot| 久久精品视频免费| 亚洲欧美激情视频在线观看一区二区三区 | 懂色av一区二区三区免费观看 | 中文字幕一区二区5566日韩| 一区二区三区色| 国产在线视频精品一区| 色成年激情久久综合| 精品理论电影在线| 亚洲最大色网站| 国产成人av电影| 欧美色综合天天久久综合精品| 精品国产免费久久 | 不卡视频免费播放| 这里只有精品视频在线观看| 国产亚洲精品中文字幕| 日韩国产成人精品| 91浏览器打开| 亚洲国产精品av| 国内精品国产成人国产三级粉色| 欧美亚洲愉拍一区二区| 1区2区3区欧美| 国产乱码精品一区二区三区五月婷| 欧美色综合久久| 一区二区在线观看免费 | 日本欧美肥老太交大片| 欧美丝袜第三区| 亚洲另类一区二区| 成人app在线| 久久嫩草精品久久久久| 激情小说亚洲一区| 在线综合亚洲欧美在线视频| 亚洲国产成人高清精品| 在线一区二区三区四区五区| 欧美成人精品福利| 裸体在线国模精品偷拍| 91精品欧美一区二区三区综合在| 一区二区三区高清在线| 99re这里只有精品视频首页| 欧美激情一区二区三区四区| 国产成人在线网站| 国产亚洲精品福利| 欧美aaaaa成人免费观看视频| 欧美日韩久久久久久| 午夜久久久影院| 欧美高清你懂得| 婷婷综合五月天| 欧美一区二区三区人| 国产麻豆欧美日韩一区| 亚洲视频一二三区| 欧美日韩美女一区二区| 国内精品自线一区二区三区视频| 亚洲欧美自拍偷拍色图| 欧美福利视频一区| 国产91丝袜在线播放0| 一区二区三区高清不卡| 精品国产1区二区| 91精品欧美一区二区三区综合在| 久久99精品久久久久久久久久久久| 久久精品免费在线观看| 欧美图片一区二区三区| 国产精品资源在线看| 亚洲人成网站精品片在线观看| 91精品欧美久久久久久动漫| kk眼镜猥琐国模调教系列一区二区 | 日韩一二三区视频| 成人av在线网| 久久99最新地址| 亚洲综合色噜噜狠狠| 欧美成人高清电影在线| 欧美曰成人黄网| 成人一区二区三区中文字幕| 亚洲国产成人91porn| 国产精品成人午夜| 精品99一区二区| 欧美午夜寂寞影院| 99热99精品| 国产精品99久久不卡二区| 亚洲成a天堂v人片| 亚洲欧美视频在线观看视频| 精品美女一区二区| 91麻豆精品91久久久久同性| 99国产精品国产精品久久| 国产一二三精品| 美国三级日本三级久久99 | 欧美日韩精品专区| 一本大道av伊人久久综合| 国产露脸91国语对白| 色综合中文字幕国产 | 青青青伊人色综合久久| 亚洲精品综合在线| 国产精品久久久久9999吃药| 精品日韩欧美在线| 欧美精三区欧美精三区| 99re这里只有精品6| 成人免费视频一区| 国产激情一区二区三区四区| 久久疯狂做爰流白浆xx| 美女精品一区二区| 蜜桃视频第一区免费观看| 蜜臀久久99精品久久久画质超高清 | 国产欧美精品在线观看| 久久女同精品一区二区| 国产色婷婷亚洲99精品小说| 精品少妇一区二区三区| 精品久久久影院| 精品少妇一区二区三区在线视频| 欧美一二三区精品| 日韩丝袜美女视频| 精品国产一区二区三区久久久蜜月| 日韩欧美色电影| 制服丝袜中文字幕亚洲| 日韩一二三四区| 26uuu精品一区二区在线观看| xvideos.蜜桃一区二区| 久久久久久久免费视频了| 中文字幕乱码亚洲精品一区| 国产精品久久二区二区| 亚洲欧美日韩人成在线播放| 亚洲一区二区三区不卡国产欧美 | 狠狠网亚洲精品| 成人激情免费网站| 日本电影欧美片| 欧美一区二区三区四区五区| 欧美一区二区三区性视频| 精品国一区二区三区| 国产精品午夜在线| 亚洲国产成人精品视频| 91蜜桃视频在线| 欧美视频一区在线观看| 91精品免费在线观看| 久久无码av三级| 国产精品麻豆久久久| 亚洲精品国产高清久久伦理二区| 樱花草国产18久久久久| 美女网站视频久久| 国产99一区视频免费| 91在线精品一区二区三区| 欧美日韩不卡在线| 国产人妖乱国产精品人妖| 亚洲精品高清视频在线观看| 日韩av高清在线观看| 国产不卡视频在线观看| 欧美无砖砖区免费| 久久精品亚洲精品国产欧美 | 在线综合亚洲欧美在线视频 | 国产亚洲欧美日韩在线一区| 亚洲色图19p| 麻豆freexxxx性91精品| 97se亚洲国产综合自在线 | 在线观看精品一区| 久久婷婷成人综合色| 亚洲韩国一区二区三区| 粉嫩一区二区三区性色av| 欧美精品自拍偷拍动漫精品| 国产精品久久久久久久久久久免费看 | 欧美精品在线观看播放| 国产精品素人一区二区| 美女免费视频一区| 欧美性感一类影片在线播放| 国产欧美va欧美不卡在线| 日韩黄色免费网站| 91在线精品一区二区| 久久久亚洲高清| 蜜乳av一区二区三区| 欧美四级电影在线观看| 一区视频在线播放| 国产一区二区三区电影在线观看| 欧美三级三级三级爽爽爽| 亚洲欧美自拍偷拍色图| 国产69精品久久99不卡| 精品国产三级电影在线观看| 亚洲国产精品一区二区久久恐怖片| 波多野结衣一区二区三区 | 日韩一级精品视频在线观看| 亚洲精品国久久99热| 成人动漫av在线| 国产三级精品在线| 久久99日本精品| 777欧美精品| 亚洲成人动漫在线观看| 色av成人天堂桃色av| 亚洲日韩欧美一区二区在线| 欧美日韩大陆在线| 亚洲精品视频在线| av电影一区二区| 中文字幕不卡的av| 丰满岳乱妇一区二区三区| 欧美激情综合五月色丁香| 国产成人精品亚洲日本在线桃色| 久久综合视频网| 国产福利一区在线观看| 欧美国产亚洲另类动漫| youjizz国产精品| 综合亚洲深深色噜噜狠狠网站|