public static Packet createPacketWithData(Packet other, ByteBuffer data) { return new Packet(data, other.pts, other.timescale, other.duration, other.frameNo, other.frameType, other.tapeTimecode, other.displayOrder); }
public static Packet createPacket(ByteBuffer data, long pts, int timescale, long duration, long frameNo, FrameType frameType, TapeTimecode tapeTimecode) { return new Packet(data, pts, timescale, duration, frameNo, frameType, tapeTimecode, 0); }
public void addTimecode(Packet packet) throws IOException { if (packet.isKeyFrame()) processGop(); gop.add(new Packet(packet, (ByteBuffer) null)); }
private Packet loadFrame() throws IOException { if (frameNo > maxFrames) { return null; } File file = null; do { String name = String.format(namePattern, frameNo); // In case the name doesn't contain placeholders, to prevent infinitely // looping around the same file. if (name.equals(prevName)) { return null; } prevName = name; file = new File(name); if (file.exists() || frameNo > 0) break; frameNo++; } while (frameNo < 2); if (file == null || !file.exists()) return null; Packet ret = new Packet(NIOUtils.fetchFromFile(file), frameNo, VIDEO_FPS, 1, frameNo, FrameType.KEY, null, frameNo); ++frameNo; return ret; }
public void addTimecode(Packet packet) throws IOException { if (packet.isKeyFrame()) processGop(); gop.add(new Packet(packet, (ByteBuffer) null)); }
@Override public Packet nextFrame() throws IOException { if (eof) return null; if (!validHeader(runningFour)) { eof = skipJunk(); } int frameSize = calcFrameSize(runningFour); ByteBuffer frame = ByteBuffer.allocate(frameSize); eof = readFrame(frame); frame.flip(); Packet pkt = new Packet(frame, frameNo * 1152, sampleRate, 1152, frameNo, FrameType.KEY, null, 0); ++frameNo; return pkt; }
@Override public Packet nextFrame() throws IOException { if (invalidFormat != null) throw new RuntimeException("Invalid input: " + invalidFormat); ByteBuffer buf = NIOUtils.fetchFromChannel(is, 2048); String frame = readLine(buf); if (frame == null || !frame.startsWith("FRAME")) return null; is.setPosition(is.position() - buf.remaining()); ByteBuffer pix = NIOUtils.fetchFromChannel(is, bufSize); Packet packet = new Packet(pix, frameNum * fps.getDen(), fps.getNum(), fps.getDen(), frameNum, FrameType.KEY, null, frameNum); ++frameNum; return packet; }
private Packet detectPoc(ByteBuffer result, NALUnit nu, SliceHeader sh) { int maxFrameNum = 1 << (sh.sps.log2MaxFrameNumMinus4 + 4); if (detectGap(sh, maxFrameNum)) { issueNonExistingPic(sh, maxFrameNum); } int absFrameNum = updateFrameNumber(sh.frameNum, maxFrameNum, detectMMCO5(sh.refPicMarkingNonIDR)); int poc = 0; if (nu.type == NALUnitType.NON_IDR_SLICE) { poc = calcPoc(absFrameNum, nu, sh); } return new Packet(result, absFrameNum, 1, 1, frameNo++, nu.type == NALUnitType.IDR_SLICE ? FrameType.KEY : FrameType.INTER, null, poc); }
byte[] b = new byte[size]; raf.readFully(b); return new Packet(ByteBuffer.wrap(b), 0, 25, 1, 0, FrameType.KEY, null, 0); case FOURCC_ICCP: case FOURCC_ANIM: