Tabnine Logo
NIOUtils.fetchFrom
Code IndexAdd Tabnine to your IDE (free)

How to use
fetchFrom
method
in
org.jcodec.common.NIOUtils

Best Java code snippets using org.jcodec.common.NIOUtils.fetchFrom (Showing top 16 results out of 315)

origin: us.ihmc/ihmc-video-codecs

public static ByteBuffer fetchFrom(File file) throws IOException {
  return NIOUtils.fetchFrom(file, (int) file.length());
}
origin: us.ihmc/IHMCVideoCodecs

public static ByteBuffer fetchFrom(File file) throws IOException {
  return NIOUtils.fetchFrom(file, (int) file.length());
}
origin: us.ihmc/IHMCVideoCodecs

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);
  }
}
origin: us.ihmc/ihmc-video-codecs

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);
  }
}
origin: us.ihmc/ihmc-video-codecs

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);
}
origin: us.ihmc/IHMCVideoCodecs

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);
}
origin: us.ihmc/IHMCVideoCodecs

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;
}
origin: us.ihmc/ihmc-video-codecs

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();
    }
  }
}
origin: us.ihmc/IHMCVideoCodecs

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();
    }
  }
}
origin: us.ihmc/ihmc-video-codecs

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;
}
origin: us.ihmc/ihmc-video-codecs

public Box parseBox(SeekableByteChannel input) throws IOException {
  input.position(offset + header.headerSize());
  return NodeBox.parseBox(NIOUtils.fetchFrom(input, (int) header.getSize()), header, BoxFactory.getDefault());
}
origin: us.ihmc/IHMCVideoCodecs

public Box parseBox(SeekableByteChannel input) throws IOException {
  input.position(offset + header.headerSize());
  return NodeBox.parseBox(NIOUtils.fetchFrom(input, (int) header.getSize()), header, BoxFactory.getDefault());
}
origin: us.ihmc/IHMCVideoCodecs

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();
  }
}
origin: us.ihmc/ihmc-video-codecs

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();
  }
}
origin: us.ihmc/IHMCVideoCodecs

  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;
  }
}
origin: us.ihmc/ihmc-video-codecs

  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;
  }
}
org.jcodec.commonNIOUtilsfetchFrom

Javadoc

Reads size amount of bytes from ch into a new ByteBuffer allocated from a buffer buf

Popular methods of NIOUtils

  • readableFileChannel
  • closeQuietly
  • writableFileChannel
  • combine
  • copy
  • map
  • read
  • readNullTermString
  • readPascalString
  • readString
  • skip
  • toArray
  • skip,
  • toArray,
  • write,
  • writeLong,
  • writePascalString

Popular in Java

  • Running tasks concurrently on multiple threads
  • putExtra (Intent)
  • scheduleAtFixedRate (Timer)
  • getExternalFilesDir (Context)
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Option (scala)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now