Class QTReader

All Implemented Interfaces:
Closeable, AutoCloseable, ICompressedTileReader, IFormatHandler, IFormatReader, IMetadataConfigurable, IPyramidHandler

public class QTReader extends FormatReader
QTReader is the file format reader for QuickTime movie files. It does not require any external libraries to be installed. Video codecs currently supported: raw, rle, jpeg, mjpb, rpza. Additional video codecs will be added as time permits.
Author:
Melissa Linkert melissa at glencoesoftware.com
  • Field Details

    • CONTAINER_TYPES

      private static final String[] CONTAINER_TYPES
      List of identifiers for each container atom.
    • pixelOffset

      private long pixelOffset
      Offset to start of pixel data.
    • pixelBytes

      private long pixelBytes
      Total number of bytes of pixel data.
    • bitsPerPixel

      private int bitsPerPixel
      Pixel depth.
    • rawSize

      private int rawSize
      Raw plane size, in bytes.
    • offsets

      private Vector<Integer> offsets
      Offsets to each plane's pixel data.
    • prevPixels

      private byte[] prevPixels
      Pixel data for the previous image plane.
    • prevPlane

      private int prevPlane
      Previous plane number.
    • canUsePrevious

      private boolean canUsePrevious
      Flag indicating whether we can safely use prevPixels.
    • codec

      private String codec
      Video codec used by this movie.
    • altCodec

      private String altCodec
      Some movies use two video codecs -- this is the second codec.
    • altPlanes

      private int altPlanes
      Number of frames that use the alternate codec.
    • scale

      private int scale
      Amount to subtract from each offset.
    • chunkSizes

      private Vector<Integer> chunkSizes
      Number of bytes in each plane.
    • interlaced

      private boolean interlaced
      Set to true if the scanlines in a plane are interlaced (mjpb only).
    • separatedFork

      private boolean separatedFork
      Flag indicating whether the resource and data fork are separated.
    • forkFile

      private String forkFile
    • flip

      private boolean flip
  • Constructor Details

    • QTReader

      public QTReader()
      Constructs a new QuickTime reader.
  • Method Details

    • isThisType

      public boolean isThisType(loci.common.RandomAccessInputStream stream) throws IOException
      Description copied from interface: IFormatReader
      Checks if the given stream is a valid stream for this file format. The number of bytes read is format-dependent.
      Specified by:
      isThisType in interface IFormatReader
      Overrides:
      isThisType in class FormatReader
      Parameters:
      stream - A RandomAccessInputStream representing the file to check. The first byte in the stream is assumed to be the first byte in the file.
      Returns:
      true if the file represented by the stream can be read by this reader; false otherwise.
      Throws:
      IOException
    • getSeriesUsedFiles

      public String[] getSeriesUsedFiles(boolean noPixels)
      Description copied from interface: IFormatReader
      Returns an array of filenames needed to open the current series. If the 'noPixels' flag is set, then only files that do not contain pixel data will be returned. The first element in the array is expected to be the path passed to IFormatHandler.setId(String), if appropriate based upon 'noPixels'. The remaining elements are expected to be in a consistent order; if a directory listing is necessary to build the list then it should be sorted first.
      Specified by:
      getSeriesUsedFiles in interface IFormatReader
      Overrides:
      getSeriesUsedFiles in class FormatReader
    • openBytes

      public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException
      Description copied from interface: IFormatReader
      Obtains a sub-image of the specified image plane into a pre-allocated byte array.
      Specified by:
      openBytes in interface IFormatReader
      Specified by:
      openBytes in class FormatReader
      Parameters:
      no - the plane index within the current series.
      buf - a pre-allocated buffer.
      x - X coordinate of the upper-left corner of the sub-image
      y - Y coordinate of the upper-left corner of the sub-image
      w - width of the sub-image
      h - height of the sub-image
      Returns:
      the pre-allocated buffer buf for convenience.
      Throws:
      FormatException - if there was a problem parsing the metadata of the file.
      IOException - if there was a problem reading the file.
      See Also:
    • close

      public void close(boolean fileOnly) throws IOException
      Description copied from interface: IFormatReader
      Closes the currently open file. If the flag is set, this is all that happens; if unset, it is equivalent to calling Closeable.close().
      Specified by:
      close in interface IFormatReader
      Overrides:
      close in class FormatReader
      Throws:
      IOException
    • initFile

      protected void initFile(String id) throws FormatException, IOException
      Description copied from class: FormatReader
      Initializes the given file (parsing header information, etc.). Most subclasses should override this method to perform initialization operations such as parsing metadata.
      Overrides:
      initFile in class FormatReader
      Throws:
      FormatException - if a parsing error occurs processing the file.
      IOException - if an I/O error occurs processing the file
    • parse

      private void parse(int depth, long offset, long length) throws FormatException, IOException
      Parse all of the atoms in the file.
      Throws:
      FormatException
      IOException
    • isContainer

      private boolean isContainer(String type)
      Checks if the given String is a container atom type.
    • print

      private void print(int depth, long size, String type)
      Debugging method; prints information on an atom.
    • uncompress

      private byte[] uncompress(byte[] pixs, String code) throws FormatException, IOException
      Uncompresses an image plane according to the the codec identifier.
      Throws:
      FormatException
      IOException
    • stripHeader

      private void stripHeader() throws IOException
      Cut off header bytes from a resource fork file.
      Throws:
      IOException