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


Java NIOUtils.read方法代码示例

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


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

示例1: parsePSM

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private PSM parsePSM(ByteBuffer pesBuffer) {
    pesBuffer.getInt();
    short psmLen = pesBuffer.getShort();
    if (psmLen > 1018)
        throw new RuntimeException("Invalid PSM");
    byte b0 = pesBuffer.get();
    byte b1 = pesBuffer.get();
    if ((b1 & 1) != 1)
        throw new RuntimeException("Invalid PSM");
    short psiLen = pesBuffer.getShort();
    ByteBuffer psi = NIOUtils.read(pesBuffer, psiLen & 0xffff);
    short elStreamLen = pesBuffer.getShort();
    parseElStreams(NIOUtils.read(pesBuffer, elStreamLen & 0xffff));
    int crc = pesBuffer.getInt();

    return new PSM();
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:18,代码来源:MPSMediaInfo.java

示例2: read

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void read(ByteBuffer bb) {
    bb.order(ByteOrder.BIG_ENDIAN);
    Map<Integer, ByteBuffer> tags = new HashMap<Integer, ByteBuffer>();
    while (bb.hasRemaining()) {
        int tag = bb.getShort() & 0xffff;
        int size = bb.getShort() & 0xffff;
        ByteBuffer _bb = NIOUtils.read(bb, size);
        switch (tag) {
        case 0x3C0A:
            uid = UL.read(_bb);
            break;
        case 0x0102:
            generationUID = UL.read(_bb);
            break;
        case 0x0101:
            objectClass = UL.read(_bb);
            break;
        default:
            tags.put(tag, _bb);
        }
    }

    if (tags.size() > 0)
        read(tags);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:26,代码来源:MXFInterchangeObject.java

示例3: test

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private boolean test(File coded, File ref) throws IOException {
    MappedH264ES es = new MappedH264ES(NIOUtils.fetchFrom(coded));
    Picture buf = Picture.create(1920, 1088, ColorSpace.YUV420);
    H264Decoder dec = new H264Decoder();
    Packet nextFrame;
    ByteBuffer _yuv = NIOUtils.fetchFrom(ref);
    while ((nextFrame = es.nextFrame()) != null) {
        Picture out = dec.decodeFrame(nextFrame.getData(), buf.getData()).cropped();
        Picture pic = out.createCompatible();
        pic.copyFrom(out);
        int lumaSize = pic.getWidth() * pic.getHeight();
        int crSize = lumaSize >> 2;
        int cbSize = lumaSize >> 2;

        ByteBuffer yuv = NIOUtils.read(_yuv, lumaSize + crSize + cbSize);

        if (!Arrays.equals(getAsIntArray(yuv, lumaSize), pic.getPlaneData(0)))
            return false;
        if (!Arrays.equals(getAsIntArray(yuv, crSize), pic.getPlaneData(1)))
            return false;
        if (!Arrays.equals(getAsIntArray(yuv, cbSize), pic.getPlaneData(2)))
            return false;
    }
    return true;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:26,代码来源:VerifyTool.java

示例4: readPacketData

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
protected ByteBuffer readPacketData(SeekableByteChannel input, ByteBuffer buffer, long offset, int size)
        throws IOException {
    ByteBuffer result = buffer.duplicate();
    synchronized (input) {
        input.position(offset);
        NIOUtils.read(input, result, size);
    }
    result.flip();
    return result;
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:11,代码来源:AbstractMP4DemuxerTrack.java

示例5: parseElStreams

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private void parseElStreams(ByteBuffer buf) {
    while (buf.hasRemaining()) {
        byte streamType = buf.get();
        byte streamId = buf.get();
        short strInfoLen = buf.getShort();
        ByteBuffer strInfo = NIOUtils.read(buf, strInfoLen & 0xffff);
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:9,代码来源:MPSMediaInfo.java

示例6: getData

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
    SeekableByteChannel ch = null;
    try {
        ch = pool.getChannel();
        ch.position(offset);
        ByteBuffer buffer = ByteBuffer.allocate(dataLen);
        NIOUtils.read(ch, buffer);
        buffer.flip();
        return buffer;
    } finally {
        ch.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:15,代码来源:WavTrack.java

示例7: MTSTrackFactory

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public MTSTrackFactory(ByteBuffer index, FilePool fp) throws IOException {
    while (index.remaining() >= 6) {
        int len = index.getInt() - 4;
        ByteBuffer sub = NIOUtils.read(index, len);
        programs.add(new MTSProgram(sub, fp));
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:8,代码来源:MTSTrackFactory.java

示例8: readPes

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
@Override
protected ByteBuffer readPes(SeekableByteChannel ch, long pesPosition, int pesSize, int payloadSize,
        int pesAbsIdx) throws IOException {
    ch.position(pesPosition * 188);
    ByteBuffer buf = NIOUtils.fetchFrom(ch, pesSize * 188);

    // NOW REMOVE THE TS CRAP
    ByteBuffer dst = buf.duplicate();
    while (buf.hasRemaining()) {
        ByteBuffer tsBuf = NIOUtils.read(buf, 188);
        Assert.assertEquals(0x47, tsBuf.get() & 0xff);
        int guidFlags = ((tsBuf.get() & 0xff) << 8) | (tsBuf.get() & 0xff);
        int guid = (int) guidFlags & 0x1fff;
        if (guid == targetGuid) {
            int b0 = tsBuf.get() & 0xff;
            int counter = b0 & 0xf;
            if ((b0 & 0x20) != 0) {
                NIOUtils.skip(tsBuf, tsBuf.get() & 0xff);
            }
            dst.put(tsBuf);
        }
    }
    dst.flip();
    readPESHeader(dst, 0);
    dst.limit(dst.position() + payloadSize);
    return dst;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:28,代码来源:MTSTrackFactory.java

示例9: readFrame

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private Packet readFrame(ByteBuffer buffer, int size, BlockElement block) throws IOException {
    input.position(block.frameOffsets[0]);
    if (NIOUtils.read(input, buffer) < size)
        return null;
    
    buffer.flip();
    
    long timecale = scale != null ? scale.get() : 1L; 
    return new Packet(buffer, 0L, timecale, 0L, pointer, block.keyFrame, new TapeTimecode((short)0, (byte)0, (byte)0, (byte)0, false));
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:11,代码来源:MKVDemuxer.java

示例10: readFrames

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private Packet readFrames(ByteBuffer buffer, int size, int n) throws IOException {
    for (int i = 0; i < n; i++) {
        input.position(sampleOffsets[currentSampleNo + i]);
        if (NIOUtils.read(input, buffer, (int) sampleSizes[currentSampleNo + i]) < sampleSizes[currentSampleNo + i])
            return null;
    }
    
    buffer.flip();
    
    long timecale = scale != null ? scale.get() : 1L; 
    return new Packet(buffer, 0L, timecale, 0L, currentSampleNo, true, new TapeTimecode((short)0, (byte)0, (byte)0, (byte)0, false));
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:13,代码来源:MKVDemuxer.java

示例11: parseDescriptors

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static List<MPEGMediaDescriptor> parseDescriptors(ByteBuffer bb) {
    List<MPEGMediaDescriptor> result = new ArrayList<MPEGMediaDescriptor>();
    while (bb.remaining() >= 2) {
        int tag = bb.get() & 0xff;
        ByteBuffer buf = NIOUtils.read(bb, bb.get() & 0xff);
        if (dMapping[tag] != null)
            try {
                dMapping[tag].newInstance().parse(buf);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
    }
    return result;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:15,代码来源:MPSUtils.java

示例12: readTsFile

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void readTsFile(SeekableByteChannel ch) throws IOException {
    ch.position(0);
    ByteBuffer buf = ByteBuffer.allocate(BUFFER_SIZE);

    for (long pos = ch.position(); ch.read(buf) != -1; pos = ch.position()) {
        buf.flip();
        while (buf.hasRemaining()) {
            ByteBuffer tsBuf = NIOUtils.read(buf, 188);
            pos += 188;
            Assert.assertEquals(0x47, tsBuf.get() & 0xff);
            int guidFlags = ((tsBuf.get() & 0xff) << 8) | (tsBuf.get() & 0xff);
            int guid = (int) guidFlags & 0x1fff;

            int payloadStart = (guidFlags >> 14) & 0x1;
            int b0 = tsBuf.get() & 0xff;
            int counter = b0 & 0xf;
            if ((b0 & 0x20) != 0) {
                NIOUtils.skip(tsBuf, tsBuf.get() & 0xff);
            }
            boolean sectionSyntax = payloadStart == 1 && (getRel(tsBuf, getRel(tsBuf, 0) + 2) & 0x80) == 0x80;
            if (sectionSyntax) {
                NIOUtils.skip(tsBuf, tsBuf.get() & 0xff);
            }
            if (!onPkt(guid, payloadStart == 1, tsBuf, pos - tsBuf.remaining()))
                return;
        }
        buf.flip();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:30,代码来源:MTSUtils.java

示例13: readPacket

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static MTSPacket readPacket(ReadableByteChannel channel) throws IOException {
    ByteBuffer buffer = ByteBuffer.allocate(188);
    if (NIOUtils.read(channel, buffer) != 188)
        return null;
    buffer.flip();
    return parsePacket(buffer);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:8,代码来源:MTSDemuxer.java

示例14: probe

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static int probe(final ByteBuffer b) {
    IntObjectMap<List<ByteBuffer>> streams = new IntObjectMap<List<ByteBuffer>>();
    while (true) {
        try {
            ByteBuffer sub = NIOUtils.read(b, 188);
            if (sub.remaining() < 188)
                break;

            MTSPacket tsPkt = parsePacket(sub);
            if (tsPkt == null)
                break;
            List<ByteBuffer> data = streams.get(tsPkt.pid);
            if (data == null) {
                data = new ArrayList<ByteBuffer>();
                streams.put(tsPkt.pid, data);
            }

            if (tsPkt.payload != null)
                data.add(tsPkt.payload);
        } catch (Throwable t) {
            break;
        }
    }
    int maxScore = 0;
    int[] keys = streams.keys();
    for (int i : keys) {
        int score = MPSDemuxer.probe(NIOUtils.combine(streams.get(i)));
        if (score > maxScore)
            maxScore = score;
    }
    return maxScore;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:33,代码来源:MTSDemuxer.java

示例15: parse

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void parse(ByteBuffer input) {
    data = NIOUtils.read(input, (int) header.getBodySize());
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:4,代码来源:LeafBox.java


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