java.lang.Object
org.monte.media.quicktime.QuickTimeDeserializer
QuickTimeDeserializer. This is an internal class of
QuickTimeInputStream.- Author:
- Werner Randelshofer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidParses a QuickTime file.protected voidparseDataReference(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The data reference ("dref"-Atom).protected voidparseEditList(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Track t) The edit list ("elst"-Atom).protected voidparseFileType(QTFFImageInputStream in, long remainingSize, QuickTimeMeta m) The file type ("ftyp"-atom).protected voidparseHandlerReference(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Track t, QuickTimeMeta.Media m) Handler Reference Atom ("hdlr"-Atom).protected voidparseMediaHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The media header (mdhd-Atom).protected voidparseMovieHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta m) The movie header ("mvhd"-atom).protected voidparseRecursively(QTFFImageInputStream in, long remainingSize, QuickTimeMeta m) Parses a QuickTime file.protected voidparseSampleSize(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The Sample Size atom ("stsz"-Atom in a media information section).protected voidparseSampleToChunk(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The Sample-to-Chunk atom ("stsc"-Atom in a media information section).protected voidparseSoundMediaHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The sound media header ("smhd"-Atom).protected voidparseSoundSampleDescription(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The sound sample description ("stsd"-Atom in a sound track).protected voidparseSyncSample(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The Sync Sample atom ("stss"-Atom in a media information section).protected voidparseTimeToSample(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The Time-to-Sample atom ("stts"-Atom in a media information section).protected voidparseTrackHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Track t) The track header ("tkhd"-atom).protected voidparseVideoMediaHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The video media header ("vmhd"-Atom).protected voidparseVideoSampleDescription(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) The video sample description ("stsd"-Atom in a video track).read(ImageInputStream iin)
-
Constructor Details
-
QuickTimeDeserializer
public QuickTimeDeserializer()
-
-
Method Details
-
read
- Throws:
IOException
-
read
- Throws:
IOException
-
parse
Parses a QuickTime file. This method invokes other parse methods for individual data structures in the file.- Throws:
IOException
-
parseRecursively
protected void parseRecursively(QTFFImageInputStream in, long remainingSize, QuickTimeMeta m) throws IOException Parses a QuickTime file. This method invokes other parse methods for individual data structures in the file.struct atom { uint32 size; type type; // exists only if size >= 8 byte[size-8] body; // exists only if size > 8 }- Throws:
IOException
-
parseFileType
protected void parseFileType(QTFFImageInputStream in, long remainingSize, QuickTimeMeta m) throws IOException The file type ("ftyp"-atom).typedef struct { magic brand; bcd4 versionYear; bcd2 versionMonth; bcd2 versionMinor; magic[] compatibleBrands; } ftypAtom;- Throws:
IOException
-
parseMovieHeader
protected void parseMovieHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta m) throws IOException The movie header ("mvhd"-atom).
typedef struct { byte version; byte[3] flags; mactimestamp creationTime; mactimestamp modificationTime; uint timeScale; uint duration; fixed16d16 preferredRate; fixed8d8 preferredVolume; byte[10] reserved; fixed16d16 matrixA; fixed16d16 matrixB; fixed2d30 matrixU; fixed16d16 matrixC; fixed16d16 matrixD; fixed2d30 matrixV; fixed16d16 matrixX; fixed16d16 matrixY; fixed2d30 matrixW; uint previewTime; uint previewDuration; uint posterTime; uint selectionTime; uint selectionDuration; uint currentTime; uint nextTrackId; } movieHeaderAtom;- Throws:
IOException
-
parseTrackHeader
protected void parseTrackHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Track t) throws IOException The track header ("tkhd"-atom).
Enumeration for track header flags set { TrackEnable = 0x1, // enabled track TrackInMovie = 0x2, // track in playback TrackInPreview = 0x4, // track in preview TrackInPoster = 0x8 // track in poster } TrackHeaderFlags; typedef struct { byte version; byte flag0; byte flag1; byte set TrackHeaderFlags flag2; mactimestamp creationTime; mactimestamp modificationTime; int trackId; byte[4] reserved; int duration; byte[8] reserved; short layer; short alternateGroup; fixed8d8 volume; byte[2] reserved; fixed16d16 matrixA; fixed16d16 matrixB; fixed2d30 matrixU; fixed16d16 matrixC; fixed16d16 matrixD; fixed2d30 matrixV; fixed16d16 matrixY; fixed2d30 matrixW; fixed16d16 trackWidth; fixed16d16 trackHeight; trackHeaderAtom;- Throws:
IOException
-
parseEditList
protected void parseEditList(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Track t) throws IOException The edit list ("elst"-Atom).typedef struct { byte version; byte[3] flags; uint numberOfEntries; editListTable editListTable[numberOfEntries]; } editListAtom; typedef struct { int trackDuration; int mediaTime; fixed16d16 mediaRate; } editListTable;- Throws:
IOException
-
parseMediaHeader
protected void parseMediaHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The media header (mdhd-Atom).typedef struct { byte version; byte[3] flags; mactimestamp creationTime; mactimestamp modificationTime; int timeScale; int duration; short language; short quality; } mediaHeaderAtom;- Throws:
IOException
-
parseHandlerReference
protected void parseHandlerReference(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Track t, QuickTimeMeta.Media m) throws IOException Handler Reference Atom ("hdlr"-Atom).typedef struct { byte version; byte[3] flags; magic componentType; magic componentSubtype; magic componentManufacturer; int componentFlags; int componentFlagsMask; pstring componentName; ubyte[] extraData; } handlerReferenceAtom;- Throws:
IOException
-
parseSoundMediaHeader
protected void parseSoundMediaHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The sound media header ("smhd"-Atom).typedef struct { ubyte version; // A 1-byte specification of the version of this sound media information header atom. byte[3] flags; // A 3-byte space for sound media information flags. Set this field to 0. fixed8d8 balance; // A 16-bit integer that specifies the sound balance of this // sound media. Sound balance is the setting that controls // the mix of sound between the two speakers of a computer. // This field is normally set to 0. // Balance values are represented as 16-bit, fixed-point // numbers that range from -1.0 to +1.0. The high-order 8 // bits contain the integer portion of the value; the // low-order 8 bits contain the fractional part. Negative // values weight the balance toward the left speaker; // positive values emphasize the right channel. Setting the // balance to 0 corresponds to a neutral setting. short reserved; // Reserved for use by Apple. Set this field to 0. } soundMediaInformationHeaderAtom;- Throws:
IOException
-
parseVideoMediaHeader
protected void parseVideoMediaHeader(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The video media header ("vmhd"-Atom).set { videoFlagNoLeanAhead=1 // I am not shure if this is the correct value for this flag } vmhdFlags; enum { Copy = 0x0, DitherCopy = 0x40, Blend = 0x20, // uses opcolor Transparent = 0x24, // uses opcolor StraightAlpha = 0x100, PremulWhiteAlpha = 0x101, PremulBlackAlpha = 0x102, StraightAlphaBlend = 0x104, // uses opclor Composition = 0x103 } GraphicsModes; typedef struct { byte version; byte flag1; byte flag2; byte set vmhdFlags flag3; short enum GraphicsModes graphicsMode; ushort[3] opcolor; } videoMediaInformationHeaderAtom;- Throws:
IOException
-
parseDataReference
protected void parseDataReference(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The data reference ("dref"-Atom).set { dataRefSelfReference=1 // I am not shure if this is the correct value for this flag } drefEntryFlags; typedef struct { uint size; magic type; byte version; ubyte flag1; ubyte flag2; ubyte set drefEntryFlags flag3; ubyte[size - 12] data; } dataReferenceEntry; typedef struct { ubyte version; ubyte[3] flags; int numberOfEntries; dataReferenceEntry dataReference[numberOfEntries]; } dataReferenceAtom;- Throws:
IOException
-
parseSoundSampleDescription
protected void parseSoundSampleDescription(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The sound sample description ("stsd"-Atom in a sound track).enum { version0 = 0, // compressionId must be 0 for version 0 sound sample description. uncompressedAudio = -1, compressedAudio = -2, } soundSampleCompressionId; typedef struct { ushort version; // A 16-bit integer that holds the sample description // version (currently 0 or 1). ushort revisionLevel;// A 16-bit integer that must be set to 0. uint vendor; // A 32-bit integer that must be set to 0. ushort numberOfChannels; // A 16-bit integer that indicates the number of sound // channels used by the sound sample. Set to 1 for // monaural sounds, 2 for stereo sounds. // Higher numbers of channels are not supported. ushort sampleSize; // A 16-bit integer that specifies the number of bits in // each uncompressed sound sample. Allowable values are // 8 or 16. Formats using more than 16 bits per sample // set this field to 16 and use sound description // version 1. short enum soundSampleCompressionId compressionId;// A 16-bit integer that must be set to 0 for version 0 // sound descriptions. This may be set to –2 for some // version 1 sound descriptions; see “Redefined Sample // Tables” (page 115). ushort packetSize; // A 16-bit integer that must be set to 0. fixed16d16 sampleRate;// A 32-bit unsigned fixed-point number (16.16) that // indicates the rate at which the sound samples were // obtained. The integer portion of this number should // match the media’s time scale. Many older version 0 // files have values of 22254.5454 or 11127.2727, but // most files have integer values, such as 44100. Sample // rates greater than 2^16 are not supported. soundSampleDescriptionV1[version] v1; // Additional fields for version 1 soundSampleDescriptionExtension[] extendedData; } soundSampleDescription; typedef struct { int size; // A 32-bit integer indicating the number of bytes in the sample description. magic type; // A 32-bit integer indicating the format of the stored data. // This depends on the media type, but is usually either the // compression format or the media type. byte[6] reserved; // six bytes that must be zero short dataReferenceIndex; // A 16-bit integer that contains the index of the data reference to use to retrieve data associated with samples that use this sample description. Data references are stored in data reference atoms. soundSampleDescription data; } soundSampleDescriptionEntry; typedef struct { uint samplesPerPacket; // This field is only present if version == 1. // A 32-bit integer. // The number of uncompressed frames generated by a // compressed frame (an uncompressed frame is one sample // from each channel). This is also the frame duration, // expressed in the media’s timescale, where the // timescale is equal to the sample rate. For // uncompressed formats, this field is always 1. uint bytesPerPacket; // This field is only present if version == 1. // A 32-bit integer. // For uncompressed audio, the number of bytes in a // sample for a single channel. This replaces the older // sampleSize field, which is set to 16. // This value is calculated by dividing the frame size // by the number of channels. The same calculation is // performed to calculate the value of this field for // compressed audio, but the result of the calculation // is not generally meaningful for compressed audio. uint bytesPerFrame; // This field is only present if version == 1. // A 32-bit integer. // The number of bytes in a frame: for uncompressed // audio, an uncompressed frame; for compressed audio, a // compressed frame. This can be calculated by // multiplying the bytes per packet field by the number // of channels. uint bytesPerSample; // This field is only present if version == 1. // A 32-bit integer. // The size of an uncompressed sample in bytes. This is // set to 1 for 8-bit audio, 2 for all other cases, even // if the sample size is greater than 2 bytes. } soundSampleDescriptionV1; typedef struct { uint dataSize; magic type; ubyte[dataSize - 8] data; } soundSampleDescriptionExtension; typedef struct { byte version; // A 1-byte specification of the version of this sample description atom. byte[3] flags; // A 3-byte space for sample description flags. Set this field to 0. int numberOfEntries; // A 32-bit integer containing the number of sample descriptions that follow. soundSampleDescriptionEntry sampleDescriptionTable[numberOfEntries]; } soundSampleDescriptionAtom;- Throws:
IOException
-
parseVideoSampleDescription
protected void parseVideoSampleDescription(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The video sample description ("stsd"-Atom in a video track).typedef struct { byte version; byte[3] flags; int numberOfEntries; videoSampleDescriptionEntry sampleDescriptionTable[numberOfEntries]; } videoSampleDescriptionAtom; typedef struct { int size; magic type; byte[6] reserved; // six bytes that must be zero short dataReferenceIndex; // A 16-bit integer that contains the index of the data reference to use to retrieve data associated with samples that use this sample description. Data references are stored in data reference atoms. videoSampleDescription data; } videoSampleDescriptionEntry; typedef struct { ushort version; // A 16-bit integer indicating the version number of the // compressed data. This is set to 0, unless a // compressor has changed its data format. ushort revisionLevel;// A 16-bit integer that must be set to 0. magic vendor; // A 32-bit integer that specifies the developer of the // compressor that generated the compressed data. Often // this field contains 'appl' to indicate Apple // Computer, Inc. uint temporalQuality;// A 32-bit integer containing a value from 0 to 1023 // indicating the degree of temporal compression. uint spatialQuality; // A 32-bit integer containing a value from 0 to 1024 // indicating the degree of spatial compression. ushort width; // A 16-bit integer that specifies the width of the // source image in pixels. ushort height; // A 16-bit integer that specifies the height of the // source image in pixels. fixed16d16 horizontalResolution; // A 32-bit fixed-point number containing the horizontal // resolution of the image in pixels per inch. fixed16d16 verticalResolution; // A 32-bit fixed-point number containing the vertical // resolution of the image in pixels per inch. uint dataSize; // A 32-bit integer that must be set to 0. ushort frameCount; // A 16-bit integer that indicates how many frames of // compressed data are stored in each sample. Usually // set to 1. pstring32 compressorName;// A 32-byte Pascal string containing the name of the // compressor that created the image, such as "jpeg". ushort depth; // A 16-bit integer that indicates the pixel depth of // the compressed image. Values of 1, 2, 4, 8 ,16, 24, // and 32 indicate the depth of color images. The value // 32 should be used only if the image contains an alpha // channel. Values of 34, 36, and 40 indicate 2-, 4-, // and 8-bit grayscale, respectively, for grayscale // images. ushort colorTableId; // A 16-bit integer that identifies which color table to // use. If this field is set to –1, the default color // table should be used for the specified depth. For all // depths below 16 bits per pixel, this indicates a // standard Macintosh color table for the specified // depth. Depths of 16, 24, and 32 have no color table. // If the color table ID is set to 0, a color table is // contained within the sample description itself. The // color table immediately follows the color table ID // field in the sample description. See “Color Table // Atoms” (page 41) for a complete description of a color table. videoSampleDescriptionExtension[] extendedData; } videoSampleDescription; typedef struct { uint dataSize; magic type; ubyte[dataSize - 8] data; } videoSampleDescriptionExtension; typedef struct { byte version; // A 1-byte specification of the version of this sample description atom. byte[3] flags; // A 3-byte space for sample description flags. Set this field to 0. int numberOfEntries; // A 32-bit integer containing the number of sample descriptions that follow. soundSampleDescriptionEntry sampleDescriptionTable[numberOfEntries]; } soundSampleDescriptionAtom;- Throws:
IOException
-
parseTimeToSample
protected void parseTimeToSample(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The Time-to-Sample atom ("stts"-Atom in a media information section). Time-to-sample atoms store duration information for the samples in a media, providing a mapping from a time in a media to the corresponding data sample.typedef struct { byte version; byte[3] flags; int numberOfEntries; timeToSampleTable timeToSampleTable[numberOfEntries]; } timeToSampleAtom; typedef struct { int sampleCount; int sampleDuration; } timeToSampleTable;Note: this method adds
Sampleobjects to theMedia.sampleslist.- Parameters:
in-remainingSize-m-- Throws:
IOException
-
parseSampleToChunk
protected void parseSampleToChunk(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The Sample-to-Chunk atom ("stsc"-Atom in a media information section). As samples are added to a media, they are collected into chunks that allow optimized data access. A chunk may contain one or more samples. Chunks in a media may have different sizes, and the samples within a chunk may have different sizes.typedef struct { byte version; byte[3] flags; int numberOfEntries; sampleToChunkTable sampleToChunkTable[numberOfEntries]; } sampleToChunkAtom; typedef struct { int firstChunk; int samplesPerChunk; int sampleDescription; } sampleToChunkTable;- Parameters:
in-remainingSize-m-- Throws:
IOException
-
parseSyncSample
protected void parseSyncSample(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The Sync Sample atom ("stss"-Atom in a media information section). The sync sample atom identifies the key frames in the media. In a media that contains compressed data, key frames define starting points for portions of a temporally compressed sequence. The key frame is self-contained - that is, it is independent of preceding frames. Subsequent frames may depend on the key frame.typedef struct { byte version; byte[3] flags; int numberOfEntries; syncSampleTable syncSampleTable[numberOfEntries]; } syncSampleAtom; typedef struct { int number; } syncSampleTable;- Parameters:
in-remainingSize-m-- Throws:
IOException
-
parseSampleSize
protected void parseSampleSize(QTFFImageInputStream in, long remainingSize, QuickTimeMeta.Media m) throws IOException The Sample Size atom ("stsz"-Atom in a media information section). Sample size atoms identify the size of each sample in the media.typedef struct { byte version; byte[3] flags; int sampleSize; int numberOfEntries; sampleSizeTable sampleSizeTable[numberOfEntries]; } sampleSizeAtom; typedef struct { int size; } sampleSizeTable;- Parameters:
in-remainingSize-m-- Throws:
IOException
-