Exemple #1
0
        public SmackerPlayer(Stream smk_stream, int buffered_frames)
        {
            file = SmackerFile.OpenFromStream(smk_stream);
            decoder= file.Decoder;
            this.buffered_frames = buffered_frames;

            waitEvent = new AutoResetEvent (false);
        }
Exemple #2
0
        public static SmackerFile OpenFromStream(Stream s)
        {
            int         i;
            SmackerFile file = new SmackerFile();

            file.Header = ReadHeader(s);

            uint nbFrames = file.Header.NbFrames;

            //The ring frame is not counted!
            if (file.Header.HasRingFrame())
            {
                nbFrames++;
            }

            file.FrameSizes = new UInt32[nbFrames];
            file.FrameTypes = new byte[nbFrames];

            file.IsV4 = (file.Header.Signature != Util.MakeTag('S', 'M', 'K', '2'));

            /* read frame info */

            for (i = 0; i < nbFrames; i++)
            {
                file.FrameSizes[i] = Util.ReadDWord(s);
            }
            for (i = 0; i < nbFrames; i++)
            {
                file.FrameTypes[i] = Util.ReadByte(s);
            }
            //The rest of the header is a bitstream
            BitStream m = new BitStream(s);

            //Read huffman trees

            //MMap
            // System.Console.WriteLine("Mono map tree");
            file.MMap = new BigHuffmanTree();
            file.MMap.BuildTree(m);
            //MClr (color map)
            //  System.Console.WriteLine("Mono Color tree");
            file.MClr = new BigHuffmanTree();
            file.MClr.BuildTree(m);
            //Full (full block stuff)
            // System.Console.WriteLine("Full tree");
            file.Full = new BigHuffmanTree();
            file.Full.BuildTree(m);
            //Type (full block stuff)
            // System.Console.WriteLine("Type descriptor tree");
            file.Type = new BigHuffmanTree();
            file.Type.BuildTree(m);

            //We are ready to decode frames

            file.Stream = s;
            return(file);
        }
Exemple #3
0
 /// <summary>
 /// Creates a new decoder for the specified file
 /// </summary>
 /// <param name="file">the file to create a decoder for</param>
 internal SmackerDecoder(SmackerFile file)
 {
     File = file;
     lastAudioData = new byte[7][];
     lastFrameData = new byte[File.Header.Width * File.Header.Height];
 }
Exemple #4
0
 /// <summary>
 /// Creates a new decoder for the specified file
 /// </summary>
 /// <param name="file">the file to create a decoder for</param>
 internal SmackerDecoder(SmackerFile file)
 {
     File          = file;
     lastAudioData = new byte[7][];
     lastFrameData = new byte[File.Header.Width * File.Header.Height];
 }
Exemple #5
0
        public static SmackerFile OpenFromStream(Stream s)
        {
            int i;
            SmackerFile file = new SmackerFile();

            file.Header = ReadHeader(s);

            uint nbFrames = file.Header.NbFrames;
            //The ring frame is not counted!
            if (file.Header.HasRingFrame()) nbFrames++;

            file.FrameSizes = new UInt32[nbFrames];
            file.FrameTypes = new byte[nbFrames];

            file.IsV4 = (file.Header.Signature != Util.MakeTag('S', 'M', 'K', '2'));

            /* read frame info */

            for (i = 0; i < nbFrames; i++)
            {
                file.FrameSizes[i] = Util.ReadDWord(s);
            }
            for (i = 0; i < nbFrames; i++)
            {
                file.FrameTypes[i] = Util.ReadByte(s);
            }
            //The rest of the header is a bitstream
            BitStream m = new BitStream(s);

            //Read huffman trees

            //MMap 
            // System.Console.WriteLine("Mono map tree");
            file.MMap = new BigHuffmanTree();
            file.MMap.BuildTree(m);
            //MClr (color map)
            //  System.Console.WriteLine("Mono Color tree");
            file.MClr = new BigHuffmanTree();
            file.MClr.BuildTree(m);
            //Full (full block stuff)
            // System.Console.WriteLine("Full tree");
            file.Full = new BigHuffmanTree();
            file.Full.BuildTree(m);
            //Type (full block stuff)
            // System.Console.WriteLine("Type descriptor tree");
            file.Type = new BigHuffmanTree();
            file.Type.BuildTree(m);

            //We are ready to decode frames

            file.Stream = s;
            return file;
        }