Ejemplo n.º 1
0
        /// <summary>
        /// Loads AudioSampleEntry atom from the input bitstream.
        /// </summary>
        /// <param name="bitstream">The input bitstream.</param>
        /// <returns>The number of bytes loaded.</returns>
        public long create_audio_sample_entry_atom(Mp4DataStream bitstream)
        {
            //qtff page 117
#if !SILVERLIGHT
            log.Debug("Audio sample entry");
#endif
            bitstream.SkipBytes(6);
            int dataReferenceIndex = (int)bitstream.ReadBytes(2);
            bitstream.SkipBytes(8);
            channelCount = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Channels: {0}", channelCount));
#endif
            sampleSize = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Sample size (bits): {0}", sampleSize));
#endif
            bitstream.SkipBytes(4);
            timeScale = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Time scale: {0}", timeScale));
#endif
            bitstream.SkipBytes(2);
            _bytesRead += 28;
            Mp4Atom child = Mp4Atom.CreateAtom(bitstream);
            _children.Add(child);
            _bytesRead += child.Size;
            return(_bytesRead);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Loads the composite atom from the input bitstream.
 /// </summary>
 /// <param name="bitstream">The input bitstream.</param>
 /// <returns>The number of bytes loaded.</returns>
 public long create_composite_atom(Mp4DataStream bitstream)
 {
     while (_bytesRead < _size)
     {
         Mp4Atom child = Mp4Atom.CreateAtom(bitstream);
         _children.Add(child);
         _bytesRead += child.Size;
     }
     return(_bytesRead);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Loads MP4VideoSampleEntryAtom atom from the input bitstream.
        /// </summary>
        /// <param name="bitstream">The input bitstream.</param>
        /// <returns>The number of bytes loaded.</returns>
        public long create_video_sample_entry_atom(Mp4DataStream bitstream)
        {
#if !SILVERLIGHT
            log.Debug("Video entry atom contains wxh");
#endif
            bitstream.SkipBytes(6);
            int dataReferenceIndex = (int)bitstream.ReadBytes(2);
            bitstream.SkipBytes(2);
            bitstream.SkipBytes(2);
            bitstream.SkipBytes(12);
            width = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Width: {0}", width));
#endif
            height = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Height: {0}", height));
#endif
            int horizontalRez = (int)bitstream.ReadBytes(4) >> 16;
#if !SILVERLIGHT
            log.Debug(string.Format("H Resolution: {0}", horizontalRez));
#endif
            int verticalRez = (int)bitstream.ReadBytes(4) >> 16;
#if !SILVERLIGHT
            log.Debug(string.Format("V Resolution: {0}", verticalRez));
#endif
            bitstream.SkipBytes(4);
            int frameCount = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Frame to sample count: {0}", frameCount));
#endif
            int stringLen = (int)bitstream.ReadBytes(1);
#if !SILVERLIGHT
            log.Debug(string.Format("String length (cpname): {0}", stringLen));
#endif
            String compressorName = bitstream.ReadString(31);
#if !SILVERLIGHT
            log.Debug(string.Format("Compressor name: {0}", compressorName.Trim()));
#endif
            int depth = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Depth: {0}", depth));
#endif
            bitstream.SkipBytes(2);
            _bytesRead += 78;
#if !SILVERLIGHT
            log.Debug(string.Format("Bytes read: {0}", _bytesRead));
#endif
            Mp4Atom child = Mp4Atom.CreateAtom(bitstream);
            _children.Add(child);
            _bytesRead += child.Size;
            return(_bytesRead);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Loads SampleDescription atom from the input bitstream.
        /// </summary>
        /// <param name="bitstream">The input bitstream.</param>
        /// <returns>The number of bytes loaded.</returns>
        public long create_sample_description_atom(Mp4DataStream bitstream)
        {
            create_full_atom(bitstream);
            entryCount = (int)bitstream.ReadBytes(4);
#if !SILVERLIGHT
            log.Debug(string.Format("stsd entry count: {0}", entryCount));
#endif
            _bytesRead += 4;
            for (int i = 0; i < entryCount; i++)
            {
                Mp4Atom child = Mp4Atom.CreateAtom(bitstream);
                _children.Add(child);
                _bytesRead += child.Size;
            }
            return(_bytesRead);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates the PASP atom or Pixel Aspect Ratio. It is created by Quicktime
        /// when exporting an MP4 file. The atom is required for ipod's and acts as
        /// a container for the avcC atom in these cases.
        /// </summary>
        /// <param name="bitstream">The input bitstream.</param>
        /// <returns>The number of bytes loaded.</returns>
        public long create_pasp_atom(Mp4DataStream bitstream)
        {
#if !SILVERLIGHT
            log.Debug("Pixel aspect ratio");
#endif
            int hSpacing = (int)bitstream.ReadBytes(4);
            int vSpacing = (int)bitstream.ReadBytes(4);
#if !SILVERLIGHT
            log.Debug(string.Format("hSpacing: {0} vSpacing: {1}", hSpacing, vSpacing));
#endif
            _bytesRead += 8;
            Mp4Atom child = Mp4Atom.CreateAtom(bitstream);
            _children.Add(child);
            _bytesRead += child.Size;
            return(_bytesRead);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Loads MP4VisualSampleEntryAtom atom from the input bitstream.
        /// </summary>
        /// <param name="bitstream">The input bitstream.</param>
        /// <returns>The number of bytes loaded.</returns>
        public long create_visual_sample_entry_atom(Mp4DataStream bitstream)
        {
#if !SILVERLIGHT
            log.Debug("Visual entry atom contains wxh");
#endif
            bitstream.SkipBytes(24);
            width = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Width: {0}", width));
#endif
            height = (int)bitstream.ReadBytes(2);
#if !SILVERLIGHT
            log.Debug(string.Format("Height: {0}", height));
#endif
            bitstream.SkipBytes(50);
            _bytesRead += 78;
            Mp4Atom child = Mp4Atom.CreateAtom(bitstream);
            _children.Add(child);
            _bytesRead += child.Size;
            return(_bytesRead);
        }