当前位置: 首页>>代码示例>>Java>>正文


Java Utils.u方法代码示例

本文整理汇总了Java中org.jaudiotagger.audio.generic.Utils.u方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.u方法的具体用法?Java Utils.u怎么用?Java Utils.u使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jaudiotagger.audio.generic.Utils的用法示例。


在下文中一共展示了Utils.u方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readChunk

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
 * Reads a chunk and extracts information.
 *
 * @return <code>false</code> if the chunk is structurally
 * invalid, otherwise <code>true</code>
 */
public boolean readChunk() throws IOException
{
    final int numComments = Utils.u(chunkData.getShort());

    //For each comment
    for (int i = 0; i < numComments; i++)
    {
        final long timestamp  = Utils.u(chunkData.getInt());
        final Date jTimestamp = AiffUtil.timestampToDate(timestamp);
        final int marker      = Utils.u(chunkData.getShort());
        final int count       = Utils.u(chunkData.getShort());
        // Append a timestamp to the comment
        final String text = Utils.getString(chunkData, 0, count, StandardCharsets.ISO_8859_1) + " " + AiffUtil.formatDate(jTimestamp);
        if (count % 2 != 0) {
            // if count is odd, text is padded with an extra byte that we need to consume
            chunkData.get();
        }
        aiffHeader.addComment(text);
    }
    return true;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:28,代码来源:CommentsChunk.java

示例2: processData

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
public void processData() throws CannotReadException
{
    //Skip version/other flags
    dataBuffer.position(dataBuffer.position() + OTHER_FLAG_LENGTH);
    dataBuffer.order(ByteOrder.BIG_ENDIAN);

    maxSamplePerFrame   = dataBuffer.getInt();
    unknown1            = Utils.u(dataBuffer.get());
    sampleSize          = Utils.u(dataBuffer.get());
    historyMult         = Utils.u(dataBuffer.get());
    initialHistory      = Utils.u(dataBuffer.get());
    kModifier           = Utils.u(dataBuffer.get());
    channels            = Utils.u(dataBuffer.get());
    unknown2            = dataBuffer.getShort();
    maxCodedFrameSize   = dataBuffer.getInt();
    bitRate             = dataBuffer.getInt();
    sampleRate          = dataBuffer.getInt();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:19,代码来源:Mp4AlacBox.java

示例3: processSectionHeader

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
 * Process header, skipping filler bytes and calculating size
 *
 * @param dataBuffer
 * @return section header
 */
public int processSectionHeader(ByteBuffer dataBuffer)
{
    int datalength;
    byte nextByte = dataBuffer.get();
    if (((nextByte & 0xFF) == FILLER_START) || ((nextByte & 0xFF) == FILLER_OTHER) || ((nextByte & 0xFF) == FILLER_END))
    {
        dataBuffer.get();
        dataBuffer.get();
        datalength = Utils.u(dataBuffer.get());
    }
    else
    {
        datalength = Utils.u(nextByte);
    }
    return datalength;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:Mp4EsdsBox.java

示例4: Mp4MvhdBox

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
 * @param header     header info
 * @param dataBuffer data of box (doesnt include header data)
 */
public Mp4MvhdBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
    this.header = header;
    dataBuffer.order(ByteOrder.BIG_ENDIAN);
    byte version = dataBuffer.get(VERSION_FLAG_POS);

    if (version == LONG_FORMAT)
    {
        timeScale = dataBuffer.getInt(TIMESCALE_LONG_POS);
        timeLength = dataBuffer.getLong(DURATION_LONG_POS);

    }
    else
    {
        timeScale = dataBuffer.getInt(TIMESCALE_SHORT_POS);
        timeLength = Utils.u(dataBuffer.getInt(DURATION_SHORT_POS));
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:23,代码来源:Mp4MvhdBox.java

示例5: Mp4MdhdBox

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
 * @param header     header info
 * @param dataBuffer data of box (doesnt include header data)
 */
public Mp4MdhdBox(Mp4BoxHeader header, ByteBuffer dataBuffer)
{
    this.header = header;
    dataBuffer.order(ByteOrder.BIG_ENDIAN);
    byte version = dataBuffer.get(VERSION_FLAG_POS);

    if (version == LONG_FORMAT)
    {
        this.samplingRate = dataBuffer.getInt(TIMESCALE_LONG_POS);
        timeLength = dataBuffer.getLong(DURATION_LONG_POS);

    }
    else
    {
        this.samplingRate = dataBuffer.getInt(TIMESCALE_SHORT_POS);
        timeLength = Utils.u(dataBuffer.getInt(DURATION_SHORT_POS));

    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:24,代码来源:Mp4MdhdBox.java

示例6: MetadataBlockDataStreamInfo

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
public MetadataBlockDataStreamInfo(MetadataBlockHeader header, FileChannel fc) throws IOException
{
    rawdata = ByteBuffer.allocate(header.getDataLength());
    rawdata.order(ByteOrder.BIG_ENDIAN);
    int bytesRead = fc.read(rawdata);
    if (bytesRead < header.getDataLength())
    {
        throw new IOException("Unable to read required number of bytes, read:" + bytesRead + ":required:" + header.getDataLength());
    }
    rawdata.flip();

    minBlockSize    = Utils.u(rawdata.getShort());
    maxBlockSize    = Utils.u(rawdata.getShort());
    minFrameSize    = readThreeByteInteger(rawdata.get(), rawdata.get(), rawdata.get());
    maxFrameSize    = readThreeByteInteger(rawdata.get(), rawdata.get(), rawdata.get());
    samplingRate    = readSamplingRate();
    noOfChannels    = readNoOfChannels();
    bitsPerSample   = readBitsPerSample();
    noOfSamples     = readTotalNumberOfSamples();
    md5             = readMd5();
    trackLength     = (float) ((double) noOfSamples / samplingRate);
    samplingRatePerChannel = samplingRate / noOfChannels;
    rawdata.rewind();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:25,代码来源:MetadataBlockDataStreamInfo.java

示例7: readTotalNumberOfSamples

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/** Stored in second half of byte 13 plus bytes 14 - 17
 *
 * @return
 */
private int readTotalNumberOfSamples()
{
    int nb = Utils.u(rawdata.get(17));
    nb += Utils.u(rawdata.get(16)) << 8;
    nb += Utils.u(rawdata.get(15)) << 16;
    nb += Utils.u(rawdata.get(14)) << 24;
    nb += (Utils.u(rawdata.get(13)) & 0x0F) << 32;
    return nb;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:14,代码来源:MetadataBlockDataStreamInfo.java

示例8: readChunk

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
@Override
public boolean readChunk() throws IOException
{

    int numChannels         = Utils.u(chunkData.getShort());
    long numSamples         = chunkData.getInt();
    int bitsPerSample       = Utils.u(chunkData.getShort());
    double sampleRate       = AiffUtil.read80BitDouble(chunkData);
    //Compression format, but not necessarily compressed
    String compressionType;
    String compressionName;
    if (aiffHeader.getFileType() == AiffType.AIFC)
    {
        // This is a rather special case, but testing did turn up
        // a file that misbehaved in this way.
        if (chunkData.remaining()==0)
        {
            return false;
        }
        compressionType = Utils.readFourBytesAsChars(chunkData);
        if (compressionType.equals(AiffCompressionType.SOWT.getCode()))
        {
            aiffHeader.setEndian(AiffAudioHeader.Endian.LITTLE_ENDIAN);
        }
        compressionName = Utils.readPascalString(chunkData);
        // Proper handling of compression type should depend
        // on whether raw output is set
        if (compressionType != null)
        {
            //Is it a known compression type
            AiffCompressionType act = AiffCompressionType.getByCode(compressionType);
            if (act != null)
            {
                compressionName = act.getCompression();
                aiffHeader.setLossless(act.isLossless());
                // we assume that the bitrate is not variable, if there is no compression
                if (act == AiffCompressionType.NONE) {
                    aiffHeader.setVariableBitRate(false);
                }
            }
            else
            {
                // We don't know compression type, so we have to assume lossy compression as we know we are using AIFC format
                aiffHeader.setLossless(false);
            }

            if (compressionName.isEmpty())
            {
                aiffHeader.setEncodingType(compressionType);
            }
            else
            {
                aiffHeader.setEncodingType(compressionName);
            }
        }
    }
    //Must be lossless
    else
    {
        aiffHeader.setLossless(true);
        aiffHeader.setEncodingType(AiffCompressionType.NONE.getCompression());
        // regular AIFF has no variable bit rate AFAIK
        aiffHeader.setVariableBitRate(false);
    }

    aiffHeader.setBitsPerSample(bitsPerSample);
    aiffHeader.setSamplingRate((int) sampleRate);
    aiffHeader.setChannelNumber(numChannels);
    aiffHeader.setPreciseLength((numSamples / sampleRate));
    aiffHeader.setNoOfSamples(numSamples);
    return true;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:73,代码来源:CommonChunk.java

示例9: readChunk

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
public boolean readChunk() throws IOException
{
    int subFormatCode = Utils.u(chunkData.getShort());
    wsf = WavSubFormat.getByCode(subFormatCode);
    info.setChannelNumber(Utils.u(chunkData.getShort()));
    info.setSamplingRate(chunkData.getInt());
    info.setByteRate(chunkData.getInt());
    info.setBitRate( info.getByteRate() * Utils.BITS_IN_BYTE_MULTIPLIER / Utils.KILOBYTE_MULTIPLIER); //AvgBytePerSec  converted to kb/sec
    info.setVariableBitRate(false);
    blockAlign      = Utils.u(chunkData.getShort());
    info.setBitsPerSample(Utils.u(chunkData.getShort()));
    if (wsf!=null && wsf == WavSubFormat.FORMAT_EXTENSIBLE)
    {
        int extensibleSize = Utils.u(chunkData.getShort());
        if(extensibleSize == EXTENSIBLE_DATA_SIZE)
        {
            info.setBitsPerSample(Utils.u(chunkData.getShort()));
            //We dont use this currently
            channelMask = chunkData.getInt();

            //If Extensible then the actual formatCode is held here
            wsf = WavSubFormat.getByCode(Utils.u(chunkData.getShort()));
        }
    }
    if(wsf!=null)
    {
        if(info.getBitsPerSample()>0)
        {
            info.setEncodingType(wsf.getDescription() + " " + info.getBitsPerSample() + " bits");
        }
        else
        {
            info.setEncodingType(wsf.getDescription());
        }
    }
    else
    {
        info.setEncodingType("Unknown Sub Format Code:"+ Hex.asHex(subFormatCode));
    }
    return true;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:42,代码来源:WavFormatChunk.java

示例10: readSamplingRate

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
 * Sampling rate is stored over 20 bits bytes 10 and 11 and half of bytes 12 so have to mask third one
 *
 * @return
 */
private int readSamplingRate()
{
    int rate = (Utils.u(rawdata.get(10)) << 12) + (Utils.u(rawdata.get(11)) << 4) + ((Utils.u(rawdata.get(12)) & 0xF0) >>> 4);
    return rate;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:11,代码来源:MetadataBlockDataStreamInfo.java

示例11: readNoOfChannels

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
Stored in 5th to 7th bits of byte 12
 */
private int readNoOfChannels()
{
    return ((Utils.u(rawdata.get(12)) & 0x0E) >>> 1) + 1;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:8,代码来源:MetadataBlockDataStreamInfo.java

示例12: readBitsPerSample

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/** Stored in last bit of byte 12 and first 4 bits of byte 13 */
private int readBitsPerSample()
{
    return ((Utils.u(rawdata.get(12)) & 0x01) << 4) + ((Utils.u(rawdata.get(13)) & 0xF0) >>> 4) + 1;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:6,代码来源:MetadataBlockDataStreamInfo.java

示例13: readThreeByteInteger

import org.jaudiotagger.audio.generic.Utils; //导入方法依赖的package包/类
/**
 * SOme values are stored as 3 byte integrals (instead of the more usual 2 or 4)
 *
 * @param b1
 * @param b2
 * @param b3
 * @return
 */
private int readThreeByteInteger(byte b1, byte b2, byte b3)
{
    int rate = (Utils.u(b1) << 16) + (Utils.u(b2) << 8) + (Utils.u(b3));
    return rate;
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:14,代码来源:MetadataBlockDataStreamInfo.java


注:本文中的org.jaudiotagger.audio.generic.Utils.u方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。