javazoom.jl.decoder.Header类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中javazoom.jl.decoder.Header类的一些代码示例,展示了Header类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Header类的具体详情如下:
包路径:javazoom.jl.decoder.Header
类名称:Header

Header介绍

[英]Class for extracting information from a frame header.
[中]用于从帧标头提取信息的类。

代码示例

代码示例来源:origin: libgdx/libgdx

public Music (OpenALAudio audio, FileHandle file) {
  super(audio, file);
  if (audio.noDevice) return;
  bitstream = new Bitstream(file.read());
  decoder = new MP3Decoder();
  bufferOverhead = 4096;
  try {
    Header header = bitstream.readFrame();
    if (header == null) throw new GdxRuntimeException("Empty MP3");
    int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
    outputBuffer = new OutputBuffer(channels, false);
    decoder.setOutputBuffer(outputBuffer);
    setup(channels, header.getSampleRate());
  } catch (BitstreamException e) {
    throw new GdxRuntimeException("error while preloading mp3", e);
  }
}

代码示例来源:origin: ddf/Minim

nVersion = m_header.version();
if (nVersion == 2)
  aff_properties.put("mp3.version.mpeg", Float.toString(2.5f));
nLayer = m_header.layer();
aff_properties.put("mp3.version.layer", Integer.toString(nLayer));
nMode = m_header.mode();
aff_properties.put("mp3.mode", new Integer(nMode));
nChannels = nMode == 3 ? 1 : 2;
aff_properties.put("mp3.channels", new Integer(nChannels));
nVBR = m_header.vbr();
af_properties.put("vbr", new Boolean(nVBR));
aff_properties.put("mp3.vbr", new Boolean(nVBR));
aff_properties.put("mp3.vbr.scale", new Integer(m_header.vbr_scale()));
FrameSize = m_header.calculate_framesize();
aff_properties.put("mp3.framesize.bytes", new Integer(FrameSize));
if (FrameSize < 0)
nFrequency = m_header.frequency();
aff_properties.put("mp3.frequency.hz", new Integer(nFrequency));
FrameRate = (float)((1.0 / (m_header.ms_per_frame())) * 1000.0);
aff_properties.put("mp3.framerate.fps", new Float(FrameRate));
if (FrameRate < 0)
  nTotalFrames = m_header.max_number_of_frames(mLength);
  aff_properties.put("mp3.length.frames", new Integer(nTotalFrames));
BitRate = m_header.bitrate();

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

private void initialize (Header header) throws DecoderException {
  // REVIEW: allow customizable scale factor
  float scalefactor = 32700.0f;
  int mode = header.mode();
  header.layer();
  int channels = mode == Header.SINGLE_CHANNEL ? 1 : 2;
  // set up output buffer if not set up by client.
  if (output == null) throw new RuntimeException("Output buffer was not set.");
  filter1 = new SynthesisFilter(0, scalefactor, null);
  // REVIEW: allow mono output for stereo
  if (channels == 2) filter2 = new SynthesisFilter(1, scalefactor, null);
  outputChannels = channels;
  outputFrequency = header.frequency();
  initialized = true;
}

代码示例来源:origin: tulskiy/musique

encDelay = header.getEncDelay();
int encPadding = header.getEncPadding();
int sampleRate = header.frequency();
int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
trackData.setSampleRate(sampleRate);
trackData.setChannels(channels);
oldBitrate = trackData.getBitrate();
samplesPerFrame = (int) (header.ms_per_frame() * header.frequency() / 1000);
audioFormat = new AudioFormat(sampleRate, 16, channels, true, false);
  totalSamples = samplesPerFrame * (header.max_number_of_frames(streamSize) + header.min_number_of_frames(streamSize)) / 2;
  if (encPadding < totalSamples) {
    totalSamples -= encPadding;

代码示例来源:origin: tulskiy/musique

if (header.version() == Header.MPEG1) {
  int channel_bitrate = header.bitrate_index();
  if (header.mode() != Header.SINGLE_CHANNEL)
    if (channel_bitrate == 4)
      channel_bitrate = 1;

代码示例来源:origin: com.googlecode.soundlibs/jlayer

channels    = (header.mode() == Header.SINGLE_CHANNEL) ? 1 : 2;
max_gr      = (header.version() == Header.MPEG1) ? 2 : 1;
sfreq       =  header.sample_frequency() +
      ((header.version() == Header.MPEG1) ? 3 :
      (header.version() == Header.MPEG25_LSF) ? 6 : 0);	// SZD

代码示例来源:origin: pdudits/soundlibs

int mode_ext = header.mode_extension();
int sfb;
int i;
int lines, temp, temp2;
boolean ms_stereo = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x2)!=0));
boolean i_stereo  = ((header.mode() == Header.JOINT_STEREO) && ((mode_ext & 0x1)!=0));
boolean lsf = ((header.version() == Header.MPEG2_LSF || header.version() == Header.MPEG25_LSF ));	// SZD

代码示例来源:origin: tulskiy/musique

public void decodeFrame() {
  num_subbands = header.number_of_subbands();
  subbands = new Subband[32];
  mode = header.mode();
  createSubbands();
  readAllocation();
  readScaleFactorSelection();
  if ((crc != null) || header.checksum_ok()) {
    readScaleFactors();
    readSampleData();
  }
}

代码示例来源:origin: libetl/soundtransform

throw new JavaLayerException (MP3JLayerConverter.NOT_A_MP3_FILE);
channels = header.mode () == Header.SINGLE_CHANNEL ? MP3JLayerConverter.MONO : MP3JLayerConverter.STEREO;
sampleRate = header.frequency ();
outBuffer = new StreamBuffer (channels, MP3JLayerConverter.BIG_ENDIAN);
formatInfo = new FormatInfo (MP3JLayerConverter.SAMPLE_SIZE, sampleRate);

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

/**
 * Returns total ms.
 * @param streamsize
 * @return total milliseconds
 */
public float total_ms (int streamsize) // E.B
{
  return max_number_of_frames(streamsize) * ms_per_frame();
}

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

/**
 * Returns ms/frame.
 * @return milliseconds per frame
 */
public float ms_per_frame () // E.B
{
  if (h_vbr == true) {
    double tpf = h_vbr_time_per_frame[layer()] / frequency();
    if (h_version == MPEG2_LSF || h_version == MPEG25_LSF) tpf /= 2;
    return (float)(tpf * 1000);
  } else {
    float ms_per_frame_array[][] = { {8.707483f, 8.0f, 12.0f}, {26.12245f, 24.0f, 36.0f}, {26.12245f, 24.0f, 36.0f}};
    return ms_per_frame_array[h_layer - 1][h_sample_frequency];
  }
}

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

protected void readSampleData () {
  boolean read_ready = false;
  boolean write_ready = false;
  int mode = header.mode();
  int i;
  do {
    for (i = 0; i < num_subbands; ++i)
      read_ready = subbands[i].read_sampledata(stream);
    do {
      for (i = 0; i < num_subbands; ++i)
        write_ready = subbands[i].put_next_sample(which_channels, filter1, filter2);
      filter1.calculate_pcm_samples(buffer);
      if (which_channels == OutputChannels.BOTH_CHANNELS && mode != Header.SINGLE_CHANNEL)
        filter2.calculate_pcm_samples(buffer);
    } while (!write_ready);
  } while (!read_ready);
}

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

public void decode () {
  int nSlots = header.slots();
  int flush_main;
  int gr, ch, ss, sb, sb18;
      part2_start = br.hsstell();
      if (header.version() == Header.MPEG1)
        get_scale_factors(ch, gr);
      else

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

/**
 * Return Bitrate.
 * @return bitrate in bps and average bitrate for VBR header
 */
public int bitrate () {
  if (h_vbr == true)
    return (int)(h_vbr_bytes * 8 / (ms_per_frame() * h_vbr_frames)) * 1000;
  else
    return bitrates[h_version][h_layer - 1][h_bitrate_index];
}

代码示例来源:origin: com.threerings/nenya

@Override
public int getFrequency ()
{
  return _header.frequency();
}

代码示例来源:origin: javazoom/jlayer

/**
 * Return Bitrate.
 * @return bitrate in bps
 */
public String bitrate_string()
{
  if (h_vbr == true)
  {
    return Integer.toString(bitrate()/1000)+" kb/s";		
  }
 else return bitrate_str[h_version][h_layer - 1][h_bitrate_index];
}

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

/**
 * 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 OutputBuffer decodeFrame (Header header, Bitstream stream) throws DecoderException {
  if (!initialized) initialize(header);
  int layer = header.layer();
  FrameDecoder decoder = retrieveDecoder(header, stream, layer);
  decoder.decodeFrame();
  return output;
}

代码示例来源:origin: com.badlogicgames.jlayer/jlayer

calculate_framesize();

代码示例来源:origin: com.googlecode.soundlibs/jlayer

if (header.version() == Header.MPEG1)

代码示例来源:origin: tulskiy/musique

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;
}

相关文章