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


Java NIOUtils.skip方法代码示例

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


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

示例1: parse

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
@Override
public void parse(ByteBuffer input) {
    NIOUtils.skip(input, 1);
    profile = input.get() & 0xff;
    profileCompat = input.get() & 0xff;
    level = input.get() & 0xff;
    int flags = input.get() & 0xff;
    nalLengthSize = (flags & 0x03) + 1;

    int nSPS = input.get() & 0x1f; // 3 bits reserved + 5 bits number of
                                   // sps
    for (int i = 0; i < nSPS; i++) {
        int spsSize = input.getShort();
        Assert.assertEquals(0x27, input.get() & 0x3f);
        spsList.add(NIOUtils.read(input, spsSize - 1));
    }

    int nPPS = input.get() & 0xff;
    for (int i = 0; i < nPPS; i++) {
        int ppsSize = input.getShort();
        Assert.assertEquals(0x28, input.get() & 0x3f);
        ppsList.add(NIOUtils.read(input, ppsSize - 1));
    }
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:25,代码来源:AvcCBox.java

示例2: probe

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static int probe(final ByteBuffer b) {
    ByteBuffer fork = b.duplicate();
    int success = 0;
    int total = 0;
    while (fork.remaining() >= 8) {
        long len = fork.getInt() & 0xffffffffL;
        int fcc = fork.getInt();
        int hdrLen = 8;
        if (len == 1) {
            len = fork.getLong();
            hdrLen = 16;
        } else if (len < 8)
            break;
        if (fcc == ftyp && len < 64 || fcc == moov && len < 100 * 1024 * 1024 || fcc == free || fcc == mdat || fcc == wide)
            success++;
        total++;
        if (len >= Integer.MAX_VALUE)
            break;
        NIOUtils.skip(fork, (int) (len - hdrLen));
    }

    return total == 0 ? 0 : success * 100 / total;
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:24,代码来源:MP4Demuxer.java

示例3: parse

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void parse(ByteBuffer input) {
    super.parse(input);
    if (version == 0) {
        created = fromMovTime(input.getInt());
        modified = fromMovTime(input.getInt());
        timescale = input.getInt();
        duration = input.getInt();
    } else if (version == 1) {
        created = fromMovTime((int) input.getLong());
        modified = fromMovTime((int) input.getLong());
        timescale = input.getInt();
        duration = input.getLong();
    } else {
        throw new RuntimeException("Unsupported version");
    }
    rate = readRate(input);
    volume = readVolume(input);
    NIOUtils.skip(input, 10);
    matrix = readMatrix(input);
    NIOUtils.skip(input, 24);
    nextTrackId = input.getInt();
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:23,代码来源:MovieHeaderBox.java

示例4: ConcurrentMovieRange

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public ConcurrentMovieRange(long from, long to) throws IOException {
    if (to < from)
        throw new IllegalArgumentException("from < to");

    this.remaining = to - from + 1;
    this.to = to;

    MovieSegment segment = movie.getPacketAt(from);
    if (segment != null) {

        nextReadAheadNo = segment.getNo();
        scheduleSegmentRetrieve(segment);

        for (int i = 0; i < READ_AHEAD_SEGMENTS; i++)
            tryReadAhead();

        ByteBuffer data = segmentData();
        NIOUtils.skip(data, (int) (from - segment.getPos()));
    }
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:21,代码来源:ConcurrentMovieRangeService.java

示例5: write

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void write(ByteBuffer buf) {
    ByteBuffer dup = buf.duplicate();
    NIOUtils.skip(buf, 8);
    doWrite(buf);

    header.setBodySize(buf.position() - dup.position() - 8);
    Assert.assertEquals(header.headerSize(), 8);
    header.write(dup);
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:10,代码来源:Box.java

示例6: parse

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void parse(ByteBuffer input) {
    super.parse(input);

    NIOUtils.skip(input, 4);
    flags = input.getInt();
    timescale = input.getInt();
    frameDuration = input.getInt();
    numFrames = input.get();
    NIOUtils.skip(input, 1);
}
 
开发者ID:ihmcrobotics,项目名称:ihmc-video-codecs,代码行数:11,代码来源:TimecodeSampleEntry.java

示例7: AvcConfigBox

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public AvcConfigBox(ByteBuffer input) {
	NIOUtils.skip(input, 1); // skip version
	profile = input.get() & 0xff;
	profileCompat = input.get() & 0xff;
	level = input.get() & 0xff;
	int flags = input.get() & 0xff;
	nalLengthSize = (flags & 0x03) + 1;
	int nSPS = input.get() & 0x1f; // 3 bits reserved + 5 bits number of sps
	log.trace("SPS count: {}", nSPS);
	if (nSPS == 1) {
		int spsSize = input.getShort();
		Assert.assertEquals(0x27, input.get() & 0x3f);
		setSps(new byte[spsSize]);
		input.get(getSps());
	} else {
		log.warn("Multiple SPS ignored");
	}
	int nPPS = input.get() & 0xff;
	log.trace("PPS count: {}", nPPS);
	if (nPPS == 1) {
		int ppsSize = input.getShort();
		Assert.assertEquals(0x28, input.get() & 0x3f);
		pps = new byte[ppsSize];
		input.get(pps);
	} else {
		log.warn("Multiple PPS ignored");
	}
}
 
开发者ID:mondain,项目名称:h264app,代码行数:29,代码来源:AvcConfigBox.java

示例8: write

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public void write(ByteBuffer out) {
    ByteBuffer fork = out.duplicate();
    NIOUtils.skip(out, 5);
    doWrite(out);

    int length = out.position() - fork.position() - 5;
    fork.put((byte) tag);
    JCodecUtil.writeBER32(fork, length);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:10,代码来源:Descriptor.java

示例9: encodeSlice

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
protected int encodeSlice(ByteBuffer out, int[][] scaledLuma, int[][] scaledChroma, int[] scan, int sliceMbCount,
        int mbX, int mbY, Picture result, int prevQp, int mbWidth, int mbHeight, boolean unsafe) {

    Picture striped = splitSlice(result, mbX, mbY, sliceMbCount, unsafe);
    dctOnePlane(sliceMbCount << 2, striped.getPlaneData(0));
    dctOnePlane(sliceMbCount << 1, striped.getPlaneData(1));
    dctOnePlane(sliceMbCount << 1, striped.getPlaneData(2));

    int est = (sliceMbCount >> 2) * profile.bitrate;
    int low = est - (est >> 3); // 12% bitrate fluctuation
    int high = est + (est >> 3);

    int qp = prevQp;

    out.put((byte) (6 << 3)); // hdr size
    ByteBuffer fork = out.duplicate();
    NIOUtils.skip(out, 5);
    int rem = out.position();
    int[] sizes = new int[3];
    encodeSliceData(out, scaledLuma[qp - 1], scaledChroma[qp - 1], scan, sliceMbCount, striped, qp, sizes);
    if (bits(sizes) > high && qp < profile.lastQp) {
        do {
            ++qp;
            out.position(rem);
            encodeSliceData(out, scaledLuma[qp - 1], scaledChroma[qp - 1], scan, sliceMbCount, striped, qp, sizes);
        } while (bits(sizes) > high && qp < profile.lastQp);
    } else if (bits(sizes) < low && qp > profile.firstQp) {
        do {
            --qp;
            out.position(rem);
            encodeSliceData(out, scaledLuma[qp - 1], scaledChroma[qp - 1], scan, sliceMbCount, striped, qp, sizes);
        } while (bits(sizes) < low && qp > profile.firstQp);
    }

    fork.put((byte) qp);
    fork.putShort((short) sizes[0]);
    fork.putShort((short) sizes[1]);

    return qp;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:41,代码来源:ProresEncoder.java

示例10: encodePicture

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
protected void encodePicture(ByteBuffer out, int[][] scaledLuma, int[][] scaledChroma, int[] scan, Picture picture) {

        int mbWidth = (picture.getWidth() + 15) >> 4;
        int mbHeight = (picture.getHeight() + 15) >> 4;
        int qp = profile.firstQp;

        int nSlices = calcNSlices(mbWidth, mbHeight);
        writePictureHeader(LOG_DEFAULT_SLICE_MB_WIDTH, nSlices, out);
        ByteBuffer fork = out.duplicate();
        NIOUtils.skip(out, nSlices << 1);

        int i = 0;
        int[] total = new int[nSlices];
        for (int mbY = 0; mbY < mbHeight; mbY++) {
            int mbX = 0;
            int sliceMbCount = DEFAULT_SLICE_MB_WIDTH;
            while (mbX < mbWidth) {
                while (mbWidth - mbX < sliceMbCount)
                    sliceMbCount >>= 1;

                int sliceStart = out.position();
                boolean unsafeBottom = (picture.getHeight() % 16) != 0 && mbY == mbHeight - 1;
                boolean unsafeRight = (picture.getWidth() % 16) != 0 && mbX + sliceMbCount == mbWidth;
                qp = encodeSlice(out, scaledLuma, scaledChroma, scan, sliceMbCount, mbX, mbY, picture, qp, mbWidth,
                        mbHeight, unsafeBottom || unsafeRight);
                fork.putShort((short) (out.position() - sliceStart));
                total[i++] = (short) (out.position() - sliceStart);

                mbX += sliceMbCount;
            }
        }
    }
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:33,代码来源:ProresEncoder.java

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

示例12: read

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
public static DeltaEntries read(ByteBuffer bb) {
    bb.order(ByteOrder.BIG_ENDIAN);
    int n = bb.getInt();
    int len = bb.getInt();
    byte[] posTabIdx = new byte[n];
    byte[] slice = new byte[n];
    int[] elementDelta = new int[n];
    for (int i = 0; i < n; i++) {
        posTabIdx[i] = bb.get();
        slice[i] = bb.get();
        elementDelta[i] = bb.getInt();
        NIOUtils.skip(bb, len - 6);
    }
    return new DeltaEntries(posTabIdx, slice, elementDelta);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:16,代码来源:DeltaEntries.java

示例13: writeHeader1

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private void writeHeader1(ByteBuffer out, int width, int height) {
    NIOUtils.skip(out, 3);

    out.put((byte) 0x9d);
    out.put((byte) 0x01);
    out.put((byte) 0x2a);

    out.putShort((short) width);
    out.putShort((short) height);
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:11,代码来源:VP8Encoder.java

示例14: seekToFrame

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
private void seekToFrame() throws IOException {
    if (seekToFrame == -1)
        return;
    curFrame = seekToFrame;

    long payloadOff = foffs[curFrame];
    long fileOff = 0;

    for (curPesIdx = 0;; curPesIdx++) {
        int payloadSize = payLoadSize(pesTokens[curPesIdx]) * pesRLE[curPesIdx];
        int leadingSize = leadingSize(pesTokens[curPesIdx]) * pesRLE[curPesIdx];
        if (streamId(pesTokens[curPesIdx]) == streamId) {
            if (payloadOff < payloadSize)
                break;
            payloadOff -= payloadSize;
        }
        fileOff += payloadSize + leadingSize;
    }
    curPesSubIdx = payloadOff / payLoadSize(pesTokens[curPesIdx]);
    payloadOff = payloadOff % payLoadSize(pesTokens[curPesIdx]);

    fileOff += curPesSubIdx * (payLoadSize(pesTokens[curPesIdx]) + leadingSize(pesTokens[curPesIdx]));
    fileOff += leadingSize(pesTokens[curPesIdx]);
    source.position(fileOff);
    pesBuf = NIOUtils.fetchFrom(source, payLoadSize(pesTokens[curPesIdx]));
    NIOUtils.skip(pesBuf, (int) payloadOff);

    seekToFrame = -1;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:30,代码来源:MPSRandomAccessDemuxer.java

示例15: getData

import org.jcodec.common.NIOUtils; //导入方法依赖的package包/类
@Override
public ByteBuffer getData() throws IOException {
    ByteBuffer result = ByteBuffer.allocate(dataLen);

    ByteBuffer d0 = pN[0].getData();
    NIOUtils.skip(d0, leading);
    NIOUtils.write(result, d0);
    for (int i = 1; i < pN.length && result.hasRemaining(); i++) {
        ByteBuffer dN = pN[i].getData();
        int toWrite = Math.min(dN.remaining(), result.remaining());
        NIOUtils.write(result, dN, toWrite);
    }
    result.flip();
    return result;
}
 
开发者ID:PenoaksDev,项目名称:OpenSpaceDVR,代码行数:16,代码来源:PCMFlatternTrack.java


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