public static ByteBuffer fetchFrom(File file) throws IOException { return NIOUtils.fetchFrom(file, (int) file.length()); }
public static ByteBuffer fetchFrom(File file) throws IOException { return NIOUtils.fetchFrom(file, (int) file.length()); }
public static ByteBuffer fetchFrom(File file, int length) throws IOException { FileChannel is = null; try { is = new FileInputStream(file).getChannel(); return fetchFrom(is, length); } finally { closeQuietly(is); } }
public static ByteBuffer fetchFrom(File file, int length) throws IOException { FileChannel is = null; try { is = new FileInputStream(file).getChannel(); return fetchFrom(is, length); } finally { closeQuietly(is); } }
public static Atom atom(SeekableByteChannel input) throws IOException { long off = input.position(); Header atom = Header.read(NIOUtils.fetchFrom(input, 16)); return atom == null ? null : new Atom(atom, off); }
public static Atom atom(SeekableByteChannel input) throws IOException { long off = input.position(); Header atom = Header.read(NIOUtils.fetchFrom(input, 16)); return atom == null ? null : new Atom(atom, off); }
public static List<Atom> getRootAtoms(SeekableByteChannel input) throws IOException { input.position(0); List<Atom> result = new ArrayList<Atom>(); long off = 0; Header atom; while (off < input.size()) { input.position(off); atom = Header.read(NIOUtils.fetchFrom(input, 16)); if (atom == null) break; result.add(new Atom(atom, off)); off += atom.getSize(); } return result; }
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(); } } }
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(); } } }
public static List<Atom> getRootAtoms(SeekableByteChannel input) throws IOException { input.position(0); List<Atom> result = new ArrayList<Atom>(); long off = 0; Header atom; while (off < input.size()) { input.position(off); atom = Header.read(NIOUtils.fetchFrom(input, 16)); if (atom == null) break; result.add(new Atom(atom, off)); off += atom.getSize(); } return result; }
public Box parseBox(SeekableByteChannel input) throws IOException { input.position(offset + header.headerSize()); return NodeBox.parseBox(NIOUtils.fetchFrom(input, (int) header.getSize()), header, BoxFactory.getDefault()); }
public Box parseBox(SeekableByteChannel input) throws IOException { input.position(offset + header.headerSize()); return NodeBox.parseBox(NIOUtils.fetchFrom(input, (int) header.getSize()), header, BoxFactory.getDefault()); }
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(); } }
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(); } }
public void write(Chunk chunk) throws IOException { SeekableByteChannel input = getInput(chunk); input.position(chunk.getOffset()); long pos = out.position(); out.write(NIOUtils.fetchFrom(input, (int) chunk.getSize())); offsets[curChunk++] = pos; } }
public void write(Chunk chunk) throws IOException { SeekableByteChannel input = getInput(chunk); input.position(chunk.getOffset()); long pos = out.position(); out.write(NIOUtils.fetchFrom(input, (int) chunk.getSize())); offsets[curChunk++] = pos; } }