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


Java NIOUtils.fetchFrom方法代码示例

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


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

示例1: getTimecodeSample

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private int getTimecodeSample(int sample) throws IOException {
    if (sampleCache != null)
        return sampleCache[sample];
    else {
        synchronized (input) {
            int stscInd, stscSubInd;
            for (stscInd = 0, stscSubInd = sample; stscInd < sampleToChunks.length
                    && stscSubInd >= sampleToChunks[stscInd].getCount(); stscSubInd -= sampleToChunks[stscInd]
                    .getCount(), stscInd++)
                ;
            long offset = chunkOffsets[stscInd]
                    + (Math.min(stscSubInd, sampleToChunks[stscInd].getCount() - 1) << 2);
            if (input.position() != offset)
                input.position(offset);
            ByteBuffer buf = NIOUtils.fetchFrom(input, 4);
            return buf.getInt();
        }
    }
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:20,代码来源:TimecodeMP4DemuxerTrack.java

示例2: cacheSamples

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private void cacheSamples(SampleToChunkEntry[] sampleToChunks, long[] chunkOffsets) throws IOException {
    synchronized (input) {
        int stscInd = 0;
        IntArrayList ss = new IntArrayList();
        for (int chunkNo = 0; chunkNo < chunkOffsets.length; chunkNo++) {
            int nSamples = sampleToChunks[stscInd].getCount();
            if (stscInd < sampleToChunks.length - 1 && chunkNo + 1 >= sampleToChunks[stscInd + 1].getFirst())
                stscInd++;
            long offset = chunkOffsets[chunkNo];
            input.position(offset);
            ByteBuffer buf = NIOUtils.fetchFrom(input, nSamples * 4);
            for (int i = 0; i < nSamples; i++) {
                ss.add(buf.getInt());
            }
        }
        sampleCache = ss.toArray();
    }
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:19,代码来源:TimecodeMP4DemuxerTrack.java

示例3: runJMCompareResults

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private void runJMCompareResults(List<Picture> decodedPics, int seqNo) throws Exception {

        try {
            Process process = Runtime.getRuntime().exec(jm + " -d " + jmconf.getAbsolutePath());
            process.waitFor();

            ByteBuffer yuv = NIOUtils.fetchFrom(decoded);
            for (Picture pic : decodedPics) {
                pic = pic.cropped();
                boolean equals = Arrays.equals(getAsIntArray(yuv, pic.getPlaneWidth(0) * pic.getPlaneHeight(0)),
                        pic.getPlaneData(0));
                equals &= Arrays.equals(getAsIntArray(yuv, pic.getPlaneWidth(1) * pic.getPlaneHeight(1)),
                        pic.getPlaneData(1));
                equals &= Arrays.equals(getAsIntArray(yuv, pic.getPlaneWidth(2) * pic.getPlaneHeight(2)),
                        pic.getPlaneData(2));
                if (!equals)
                    diff(seqNo);
            }
        } catch (Exception e) {
            diff(seqNo);
        }
    }
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:23,代码来源:TestTool.java

示例4: nextFrame

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public Picture nextFrame(int[][] buffer) throws IOException {
    if (invalidFormat != null)
        throw new RuntimeException("Invalid input: " + invalidFormat);
    long pos = is.position();
    ByteBuffer buf = NIOUtils.fetchFrom(is, 2048);
    String frame = readLine(buf);
    if (frame == null || !frame.startsWith("FRAME"))
        return null;

    MappedByteBuffer pix = is.map(MapMode.READ_ONLY, pos + buf.position(), bufSize);
    is.position(pos + buf.position() + bufSize);

    Picture create = Picture.create(width, height, ColorSpace.YUV420);
    copy(pix, create.getPlaneData(0));
    copy(pix, create.getPlaneData(1));
    copy(pix, create.getPlaneData(2));

    return create;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:20,代码来源:Y4MDecoder.java

示例5: readToNextMarker

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public final boolean readToNextMarker(ByteBuffer out) throws IOException {
    if (done)
        return false;
    int n = 1;
    do {
        while (buf.hasRemaining()) {
            if (curMarker >= 0x100 && curMarker <= 0x1ff) {
                if (n == 0) {
                    return true;
                }
                --n;
            }
            out.put((byte) (curMarker >>> 24));
            curMarker = (curMarker << 8) | (buf.get() & 0xff);
        }
        buf = NIOUtils.fetchFrom(channel, fetchSize);
        pos += buf.remaining();
    } while (buf.hasRemaining());
    out.putInt(curMarker);
    done = true;

    return false;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:24,代码来源:SegmentReader.java

示例6: skipToMarker

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public final boolean skipToMarker() throws IOException {
    if (done)
        return false;
    do {
        while (buf.hasRemaining()) {
            curMarker = (curMarker << 8) | (buf.get() & 0xff);
            if (curMarker >= 0x100 && curMarker <= 0x1ff) {
                return true;
            }
        }
        buf = NIOUtils.fetchFrom(channel, fetchSize);
        pos += buf.remaining();
    } while (buf.hasRemaining());
    done = true;

    return false;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:18,代码来源:SegmentReader.java

示例7: read

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public final boolean read(ByteBuffer out, int length) throws IOException {
    if (done)
        return false;
    do {
        while (buf.hasRemaining()) {
            if (length-- == 0)
                return true;
            out.put((byte) (curMarker >>> 24));
            curMarker = (curMarker << 8) | (buf.get() & 0xff);
        }
        buf = NIOUtils.fetchFrom(channel, fetchSize);
        pos += buf.remaining();
    } while (buf.hasRemaining());
    out.putInt(curMarker);
    done = true;

    return false;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:19,代码来源:SegmentReader.java

示例8: main

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    FilePool fp = new FilePool(new File(args[0]), 10);
    MPSTrackFactory factory = new MPSTrackFactory(NIOUtils.fetchFrom(new File(args[1])), fp);
    Stream stream = factory.getVideoStreams().get(0);
    FileChannelWrapper ch = NIOUtils.writableFileChannel(new File(args[2]));

    List<VirtualPacket> pkt = new ArrayList<VirtualPacket>();
    for (int i = 0; i < 2000; i++) {
        pkt.add(stream.nextPacket());
    }

    for (VirtualPacket virtualPacket : pkt) {
        ch.write(virtualPacket.getData());
    }

    ch.close();
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:18,代码来源:MPSTrackFactory.java

示例9: main

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    FilePool fp = new FilePool(new File(args[0]), 10);
    MTSTrackFactory factory = new MTSTrackFactory(NIOUtils.fetchFrom(new File(args[1])), fp);
    Stream stream = factory.getVideoStreams().get(0);
    FileChannelWrapper ch = NIOUtils.writableFileChannel(new File(args[2]));

    List<VirtualPacket> pkt = new ArrayList<VirtualPacket>();
    for (int i = 0; i < 2000; i++) {
        pkt.add(stream.nextPacket());
    }

    for (VirtualPacket virtualPacket : pkt) {
        ch.write(virtualPacket.getData());
    }

    ch.close();
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:18,代码来源:MTSTrackFactory.java

示例10: 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

示例11: parseHeader

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void parseHeader(SeekableByteChannel ff) throws IOException {
    KLV kl;
    header = readHeaderPartition(ff);

    metadata = new ArrayList<MXFMetadata>();

    partitions = new ArrayList<MXFPartition>();
    long nextPartition = ff.size();
    ff.position(header.getPack().getFooterPartition());
    do {
        long thisPartition = ff.position();
        kl = KLV.readKL(ff);
        ByteBuffer fetchFrom = NIOUtils.fetchFrom(ff, (int) kl.len);
        header = MXFPartition.read(kl.key, fetchFrom, ff.position() - kl.offset, nextPartition);

        if (header.getPack().getNbEssenceContainers() > 0)
            partitions.add(0, header);

        metadata.addAll(0, readPartitionMeta(ff, header));

        ff.position(header.getPack().getPrevPartition());
        nextPartition = thisPartition;
    } while (header.getPack().getThisPartition() != 0);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:25,代码来源:MXFDemuxer.java

示例12: getData

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
    SeekableByteChannel ch = null;
    try {
        ch = fp.getChannel();
        ch.position(pkt.getOffset());

        KLV kl = KLV.readKL(ch);
        while (kl != null && !essenceUL.equals(kl.key)) {
            ch.position(ch.position() + kl.len);
            kl = KLV.readKL(ch);
        }

        return kl != null && essenceUL.equals(kl.key) ? NIOUtils.fetchFrom(ch, (int) kl.len) : null;
    } finally {
        NIOUtils.closeQuietly(ch);
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:19,代码来源:MXFVirtualTrack.java

示例13: SegmentReader

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public SegmentReader(ReadableByteChannel channel, int fetchSize) throws IOException {
    this.channel = channel;
    this.fetchSize = fetchSize;
    buf = NIOUtils.fetchFrom(channel, 4);
    pos = buf.remaining();
    curMarker = buf.getInt();
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:8,代码来源:SegmentReader.java

示例14: save

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public boolean save(File f) throws IOException, Exception {
    SeekableByteChannel fi = null;
    try {
        fi = NIOUtils.rwFileChannel(f);
        Atom moov = getMoov(fi);
        Assert.assertNotNull(moov);

        fi.position(moov.getOffset());
        ByteBuffer oldMov = NIOUtils.fetchFrom(fi, (int) moov.getHeader().getSize());
        Header header = Header.read(oldMov);
        MovieBox movBox = (MovieBox) NodeBox.parseBox(oldMov, header, BoxFactory.getDefault());

        apply(movBox);
        
        oldMov.clear();

        try {
            movBox.write(oldMov);
        } catch (Exception e) {
            return false;
        }
        if (oldMov.hasRemaining()) {
            if (oldMov.remaining() < 8)
                return false;
            oldMov.putInt(oldMov.remaining());
            oldMov.put(new byte[] { 'f', 'r', 'e', 'e' });
        }
        oldMov.flip();
        fi.position(moov.getOffset());
        fi.write(oldMov);

        return true;
    } finally {
        if (fi != null)
            fi.close();
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:38,代码来源:InplaceEdit.java

示例15: readPes

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
protected ByteBuffer readPes(SeekableByteChannel ch, long pesPosition, int pesSize, int payloadSize, int pesIdx)
        throws IOException {
    ch.position(pesPosition);
    ByteBuffer pes = NIOUtils.fetchFrom(ch, pesSize);
    readPESHeader(pes, 0);
    return pes;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:8,代码来源:MPSTrackFactory.java


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