Package javazoom.jl.decoder

Examples of javazoom.jl.decoder.Header


        try
        {
            Bitstream m_bitstream = new Bitstream(pis);
            int streamPos = m_bitstream.header_pos();
            aff_properties.put("mp3.header.pos", new Integer(streamPos));
            Header m_header = m_bitstream.readFrame();
            // nVersion = 0 => MPEG2-LSF (Including MPEG2.5), nVersion = 1 => MPEG1
            nVersion = m_header.version();
            if (nVersion == 2) aff_properties.put("mp3.version.mpeg", Float.toString(2.5f));
            else aff_properties.put("mp3.version.mpeg", Integer.toString(2 - nVersion));
            // nLayer = 1,2,3
            nLayer = m_header.layer();
            aff_properties.put("mp3.version.layer", Integer.toString(nLayer));
            nSFIndex = m_header.sample_frequency();
            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) throw new UnsupportedAudioFileException("Invalid FrameSize : " + FrameSize);
            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) throw new UnsupportedAudioFileException("Invalid FrameRate : " + FrameRate);
            // Remove heading tag length from real stream length.
            int tmpLength = mLength;
            if ((streamPos > 0) && (mLength != AudioSystem.NOT_SPECIFIED) && (streamPos < mLength)) tmpLength = tmpLength - streamPos;
            if (mLength != AudioSystem.NOT_SPECIFIED)
            {
                aff_properties.put("mp3.length.bytes", new Integer(mLength));
                nTotalFrames = m_header.max_number_of_frames(tmpLength);
                aff_properties.put("mp3.length.frames", new Integer(nTotalFrames));
            }
            BitRate = m_header.bitrate();
            af_properties.put("bitrate", new Integer(BitRate));
            aff_properties.put("mp3.bitrate.nominal.bps", new Integer(BitRate));
            nHeader = m_header.getSyncHeader();
            encoding = sm_aEncodings[nVersion][nLayer - 1];
            aff_properties.put("mp3.version.encoding", encoding.toString());
            if (mLength != AudioSystem.NOT_SPECIFIED)
            {
                nTotalMS = Math.round(m_header.total_ms(tmpLength));
                aff_properties.put("duration", new Long((long) nTotalMS * 1000L));
            }
            aff_properties.put("mp3.copyright", new Boolean(m_header.copyright()));
            aff_properties.put("mp3.original", new Boolean(m_header.original()));
            aff_properties.put("mp3.crc", new Boolean(m_header.checksums()));
            aff_properties.put("mp3.padding", new Boolean(m_header.padding()));
            InputStream id3v2 = m_bitstream.getRawID3v2();
            if (id3v2 != null)
            {
                aff_properties.put("mp3.id3tag.v2", id3v2);
                parseID3v2Frames(id3v2, aff_properties);
            }
            if (TDebug.TraceAudioFileReader) TDebug.out(m_header.toString());
        }
        catch (Exception e)
        {
            if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream:" + e.getMessage());
            throw new UnsupportedAudioFileException("not a MPEG stream:" + e.getMessage());
View Full Code Here


  {
    if (TDebug.TraceAudioConverter) TDebug.out("execute() : begin");
    try
    {
      // Following line hangs when FrameSize is available in AudioFormat.     
      Header header = null;
      if (m_header == null) header = m_bitstream.readFrame();
      else header = m_header;                       
      if (TDebug.TraceAudioConverter) TDebug.out("execute() : header = "+header);
      if (header == null)
      {
        if (TDebug.TraceAudioConverter)
        {
          TDebug.out("header is null (end of mpeg stream)");
        }
        getCircularBuffer().close();       
        return;
      }      
      currentFrame++;
      currentBitrate = header.bitrate_instant();
      currentFramesize = header.calculate_framesize();
      currentByte = currentByte + currentFramesize;
      currentMicrosecond = (long) (currentFrame* header.ms_per_frame()*1000.0f);
      for (int b=0;b<m_equalizer_values.length;b++)
      {
        m_equalizer.setBand(b,m_equalizer_values[b]);         
      }     
      m_decoder.setEqualizer(m_equalizer);
View Full Code Here

    int bytesReads = 0;
    try
    {
      for (int i=0;i<frames;i++)
      {
        Header header = m_bitstream.readFrame();
        if (header != null)
        {
          int fsize = header.calculate_framesize();         
          bytesReads = bytesReads + fsize;
        }
        m_bitstream.closeFrame();
        framesRead++;
      }
View Full Code Here

  public int getFrameNumber() {
    return maxFramesNumber;
  }
 
  private boolean skipFrame(Bitstream stream) throws BitstreamException {
    Header header = stream.readFrame();
    if (header != null) {
      stream.closeFrame();
      return true;
    } else {
      return false;
View Full Code Here

    {
      AudioDevice out = audio;
      if (out==null)
        return false;

      Header h = bitstream.readFrame()
     
      if (h==null)
        return false;
       
      // sample buffer set when decoder constructed
View Full Code Here

      {
        for (; frame<frameCount; frame++)
        {
          try
          {
            Header header = stream.readFrame();
            if (header==null)
              break;

            progressListener.readFrame(frame, header);

            if (output==null)
            {
              // REVIEW: Incorrect functionality.
              // the decoder should provide decoded
              // frequency and channels output as it may differ from
              // the source (e.g. when downmixing stereo to mono.)
              int channels = (header.mode()==Header.SINGLE_CHANNEL) ? 1 : 2;
              int freq = header.frequency();
              output = new WaveFileObuffer(channels, freq, destName);
              decoder.setOutputBuffer(output);
            }

            Obuffer decoderOutput = decoder.decodeFrame(header, stream);
View Full Code Here

    try
    {
      AudioDevice out = audio;
      if (out == null) return false;

      Header h = bitstream.readFrame();
      if (h == null) return false;

      // sample buffer set when decoder constructed
      SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);
View Full Code Here

   * skips over a single frame
   * @return false  if there are no more frames to decode, true otherwise.
   */
  protected boolean skipFrame() throws JavaLayerException
  {
    Header h = bitstream.readFrame();
    if (h == null) return false;
    bitstream.closeFrame();
    return true;
  }
View Full Code Here

      super(audio, file);
      if (audio.noDevice) return;
      bitstream = new Bitstream(file.read());
      decoder = new MP3Decoder();
      try {
        Header header = bitstream.readFrame();
        if (header == null) throw new GdxRuntimeException("empty ogg");
        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);
      }
    }
View Full Code Here

        }

        int totalLength = 0;
        int minRequiredLength = buffer.length - OutputBuffer.BUFFERSIZE * 2;
        while (totalLength <= minRequiredLength) {
          Header header = bitstream.readFrame();
          if (header == null) break;
          if (setup) {
            int channels = header.mode() == Header.SINGLE_CHANNEL ? 1 : 2;
            outputBuffer = new OutputBuffer(channels, false);
            decoder.setOutputBuffer(outputBuffer);
            setup(channels, header.getSampleRate());
            setup = false;
          }
          try {
            decoder.decodeFrame(header, bitstream);
          } catch (Exception ignored) {
View Full Code Here

TOP

Related Classes of javazoom.jl.decoder.Header

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.