Package davaguine.jmac.tools

Examples of davaguine.jmac.tools.JMACException


            header.nAPEFrameDataBytesHigh = reader.readUnsignedInt();
            header.nTerminatingDataBytes = reader.readUnsignedInt();
            file.readFully(header.cFileMD5);
            return header;
        } catch (EOFException e) {
            throw new JMACException("Unsupported Format");
        }
    }
View Full Code Here


            String data = null;
            try {
                // parse out the information
                data = new String(pData, "US-ASCII");
            } catch (java.io.UnsupportedEncodingException e) {
                throw new JMACException("Unsupported encoding", e);
            }

            int pHeader = data.indexOf(APE_LINK_HEADER);
            int pImageFile = data.indexOf(APE_LINK_IMAGE_FILE_TAG);
            int pStartBlock = data.indexOf(APE_LINK_START_BLOCK_TAG);
View Full Code Here

    public void Analyze(APEFileInfo pInfo) throws IOException {
        // find the descriptor
        pInfo.nJunkHeaderBytes = FindDescriptor(true);
        if (pInfo.nJunkHeaderBytes < 0)
            throw new JMACException("Unsupported Format");

        // read the first 8 bytes of the descriptor (ID and version)
        m_pIO.mark(10);
        final ByteArrayReader reader = new ByteArrayReader(m_pIO, 8);
        if (!reader.readString(4, "US-ASCII").equals("MAC "))
            throw new JMACException("Unsupported Format");

        int version = reader.readUnsignedShort();

        m_pIO.reset();
View Full Code Here

            m_APEFileInfo.spSeekByteTable[i] = m_pIO.readIntBack();

        // get the wave header
        if ((APEHeader.nFormatFlags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER) <= 0) {
            if (m_APEFileInfo.nWAVHeaderBytes > Integer.MAX_VALUE)
                throw new JMACException("The HeaderBytes Parameter Is Too Big");
            m_APEFileInfo.spWaveHeaderData = new byte[m_APEFileInfo.nWAVHeaderBytes];
            try {
                m_pIO.readFully(m_APEFileInfo.spWaveHeaderData);
            } catch (EOFException e) {
                throw new JMACException("Can't Read Wave Header Data");
            }
        }
    }
View Full Code Here

    protected void AnalyzeOld(APEFileInfo m_APEFileInfo) throws IOException {
        APEHeaderOld header = APEHeaderOld.read(m_pIO);

        // fail on 0 length APE files (catches non-finalized APE files)
        if (header.nTotalFrames == 0)
            throw new JMACException("Unsupported Format");

        int nPeakLevel = -1;
        if ((header.nFormatFlags & MAC_FORMAT_FLAG_HAS_PEAK_LEVEL) > 0)
            nPeakLevel = m_pIO.readIntBack();

        if ((header.nFormatFlags & MAC_FORMAT_FLAG_HAS_SEEK_ELEMENTS) > 0)
            m_APEFileInfo.nSeekTableElements = m_pIO.readIntBack();
        else
            m_APEFileInfo.nSeekTableElements = (int) header.nTotalFrames;

        // fill the APE info structure
        m_APEFileInfo.nVersion = header.nVersion;
        m_APEFileInfo.nCompressionLevel = header.nCompressionLevel;
        m_APEFileInfo.nFormatFlags = header.nFormatFlags;
        m_APEFileInfo.nTotalFrames = (int) header.nTotalFrames;
        m_APEFileInfo.nFinalFrameBlocks = (int) header.nFinalFrameBlocks;
        m_APEFileInfo.nBlocksPerFrame = ((header.nVersion >= 3900) || ((header.nVersion >= 3800) && (header.nCompressionLevel == CompressionLevel.COMPRESSION_LEVEL_EXTRA_HIGH))) ? 73728 : 9216;
        if (header.nVersion >= 3950)
            m_APEFileInfo.nBlocksPerFrame = 73728 * 4;
        m_APEFileInfo.nChannels = header.nChannels;
        m_APEFileInfo.nSampleRate = (int) header.nSampleRate;
        m_APEFileInfo.nBitsPerSample = (m_APEFileInfo.nFormatFlags & MAC_FORMAT_FLAG_8_BIT) > 0 ? 8 : ((m_APEFileInfo.nFormatFlags & MAC_FORMAT_FLAG_24_BIT) > 0 ? 24 : 16);
        m_APEFileInfo.nBytesPerSample = m_APEFileInfo.nBitsPerSample / 8;
        m_APEFileInfo.nBlockAlign = m_APEFileInfo.nBytesPerSample * m_APEFileInfo.nChannels;
        m_APEFileInfo.nTotalBlocks = (int) ((header.nTotalFrames == 0) ? 0 : ((header.nTotalFrames - 1) * m_APEFileInfo.nBlocksPerFrame) + header.nFinalFrameBlocks);
        m_APEFileInfo.nWAVHeaderBytes = (int) ((header.nFormatFlags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER) > 0 ? WaveHeader.WAVE_HEADER_BYTES : header.nHeaderBytes);
        m_APEFileInfo.nWAVTerminatingBytes = (int) header.nTerminatingBytes;
        m_APEFileInfo.nWAVDataBytes = m_APEFileInfo.nTotalBlocks * m_APEFileInfo.nBlockAlign;
        m_APEFileInfo.nWAVTotalBytes = m_APEFileInfo.nWAVDataBytes + m_APEFileInfo.nWAVHeaderBytes + m_APEFileInfo.nWAVTerminatingBytes;
        m_APEFileInfo.nAPETotalBytes = m_pIO.isLocal() ? (int) m_pIO.length() : -1;
        m_APEFileInfo.nLengthMS = (int) ((m_APEFileInfo.nTotalBlocks * 1000L) / m_APEFileInfo.nSampleRate);
        m_APEFileInfo.nAverageBitrate = (int) ((m_APEFileInfo.nLengthMS <= 0) ? 0 : ((m_APEFileInfo.nAPETotalBytes * 8L) / m_APEFileInfo.nLengthMS));
        m_APEFileInfo.nDecompressedBitrate = (m_APEFileInfo.nBlockAlign * m_APEFileInfo.nSampleRate * 8) / 1000;
        m_APEFileInfo.nPeakLevel = nPeakLevel;

        // get the wave header
        if ((header.nFormatFlags & MAC_FORMAT_FLAG_CREATE_WAV_HEADER) <= 0) {
            if (header.nHeaderBytes > Integer.MAX_VALUE)
                throw new JMACException("The HeaderBytes Parameter Is Too Big");
            m_APEFileInfo.spWaveHeaderData = new byte[(int) header.nHeaderBytes];
            try {
                m_pIO.readFully(m_APEFileInfo.spWaveHeaderData);
            } catch (EOFException e) {
                throw new JMACException("Can't Read Wave Header Data");
            }
        }

        // get the seek tables (really no reason to get the whole thing if there's extra)
        m_APEFileInfo.spSeekByteTable = new int[m_APEFileInfo.nSeekTableElements];
        for (int i = 0; i < m_APEFileInfo.nSeekTableElements; i++)
            m_APEFileInfo.spSeekByteTable[i] = m_pIO.readIntBack();

        if (header.nVersion <= 3800) {
            m_APEFileInfo.spSeekBitTable = new byte[m_APEFileInfo.nSeekTableElements];
            try {
                m_pIO.readFully(m_APEFileInfo.spSeekBitTable);
            } catch (EOFException e) {
                throw new JMACException("Can't Read Seek Bit Table");
            }
        }
    }
View Full Code Here

        return genres[genre];
    }

    public final static String genreString(int genre) {
        if (genre != GENRE_UNDEFINED && (genre < 0 || genre >= genres.length))
            throw new JMACException("Wrong Genre");
        return genres[genre];
    }
View Full Code Here

        return genres.length;
    }

    public ID3Genre(final int genre) {
        if (genre != GENRE_UNDEFINED && (genre < 0 || genre >= genres.length))
            throw new JMACException("Wrong Genre");
        this.genre = genre;
    }
View Full Code Here

            header.nBitsPerSample = reader.readUnsignedShort();
            header.nChannels = reader.readUnsignedShort();
            header.nSampleRate = reader.readUnsignedInt();
            return header;
        } catch (EOFException e) {
            throw new JMACException("Unsupported Format");
        }
    }
View Full Code Here

        //initialize the bit array
        m_pUnBitArray = UnBitArrayBase.CreateUnBitArray(pAPEDecompress, pAPEDecompress.getApeInfoFileVersion());

        if (pAPEDecompress.getApeInfoFileVersion() >= 3930)
            throw new JMACException("Wrong Version");

        m_pAntiPredictorX = AntiPredictor.CreateAntiPredictor(pAPEDecompress.getApeInfoCompressionLevel(), pAPEDecompress.getApeInfoFileVersion());
        m_pAntiPredictorY = AntiPredictor.CreateAntiPredictor(pAPEDecompress.getApeInfoCompressionLevel(), pAPEDecompress.getApeInfoFileVersion());

        m_pDataX = new int[pAPEDecompress.getApeInfoBlocksPerFrame() + 16];
View Full Code Here

        if (m_bInitialized)
            Uninitialize();

        if (pAPEDecompress == null) {
            Uninitialize();
            throw new JMACException("Error Initializing UnMAC");
        }

        //set the member pointer to the IAPEDecompress class
        m_pAPEDecompress = pAPEDecompress;
View Full Code Here

TOP

Related Classes of davaguine.jmac.tools.JMACException

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.