Пример #1
0
        void ReadAudioChunk(BitStream bs, int channel)
        {
            uint frameAudioLength        = 0;
            uint audioDecompressedLength = 0;

            bool compressed = ((audioFlags[channel] & (int)ARFlags.Compressed) == (int)ARFlags.Compressed);
            bool is16       = ((audioFlags[channel] & (int)ARFlags.Is16Bit) == (int)ARFlags.Is16Bit);
            bool stereo     = ((audioFlags[channel] & (int)ARFlags.Stereo) == (int)ARFlags.Stereo);

            bs.AssertAtByteBoundary();

            bs.DebugFirst();

            Console.WriteLine("reading audio chunk length");
            frameAudioLength = bs.ReadDWord();
            Console.WriteLine("audio chunk length = {0}", frameAudioLength);

            if (compressed)
            {
                audioDecompressedLength = bs.ReadDWord();
                Console.WriteLine("decompressed audio length = {0}", audioDecompressedLength);


                byte[] streamBuf = new byte[frameAudioLength];
                bs.Read(streamBuf, 0, streamBuf.Length);

                audioOut[channel] = new byte[audioDecompressedLength];

                if (is16)
                {
                    if (stereo)
                    {
                        Decompress16Stereo(new BitStream(streamBuf), new MemoryStream(audioOut[channel]));
                    }
                    else
                    {
                        Decompress16Mono(new BitStream(streamBuf), new MemoryStream(audioOut[channel]));
                    }
                }
                else
                if (stereo)
                {
                    Decompress8Stereo(new BitStream(streamBuf), new MemoryStream(audioOut[channel]));
                }
                else
                {
                    Decompress8Mono(new BitStream(streamBuf), new MemoryStream(audioOut[channel]));
                }
            }
            else
            {
                audioOut[channel] = new byte[frameAudioLength];
                bs.Read(audioOut[channel], 0, (int)frameAudioLength);
            }
        }
Пример #2
0
		void ReadAudioChunk (BitStream bs, int channel)
		{
			uint frameAudioLength = 0;
			uint audioDecompressedLength = 0;

			bool compressed = ((audioFlags[channel] & (int)ARFlags.Compressed) == (int)ARFlags.Compressed);
			bool is16 = ((audioFlags[channel] & (int)ARFlags.Is16Bit) == (int)ARFlags.Is16Bit);
			bool stereo = ((audioFlags[channel] & (int)ARFlags.Stereo) == (int)ARFlags.Stereo);

			bs.AssertAtByteBoundary ();

			bs.DebugFirst ();

			Console.WriteLine ("reading audio chunk length");
			frameAudioLength = bs.ReadDWord ();
			Console.WriteLine ("audio chunk length = {0}", frameAudioLength);

			if (compressed) {
				audioDecompressedLength = bs.ReadDWord ();
				Console.WriteLine ("decompressed audio length = {0}", audioDecompressedLength);


				byte[] streamBuf = new byte[frameAudioLength];
				bs.Read (streamBuf, 0, streamBuf.Length);

				audioOut[channel] = new byte[audioDecompressedLength];

				if (is16)
					if (stereo)
						Decompress16Stereo (new BitStream (streamBuf), new MemoryStream (audioOut[channel]));
					else
						Decompress16Mono (new BitStream (streamBuf), new MemoryStream (audioOut[channel]));
				else
					if (stereo)
						Decompress8Stereo (new BitStream (streamBuf), new MemoryStream (audioOut[channel]));
					else
						Decompress8Mono (new BitStream (streamBuf), new MemoryStream (audioOut[channel]));
			}
			else {
				audioOut[channel] = new byte[frameAudioLength];
				bs.Read (audioOut[channel], 0, (int)frameAudioLength);
			}
		}
Пример #3
0
		void ReadVideoChunk (BitStream bs)
		{
			int current_block_x = 0, current_block_y = 0;
			int block_rez_x = (int)PaddedWidth / 4;
			int block_rez_y = (int)PaddedHeight / 4;

			Console.WriteLine ("reading video chunk");
			bs.DebugFirst ();

			while (true) {
				ushort type_descriptor = 0;
				if (type_Tree != null)
					type_descriptor = (ushort)type_Tree.Decode (bs);
				BlockType type = (BlockType)(type_descriptor & 0x3);
				uint chain_length = block_chain_size_table [(type_descriptor & 0xfc) >> 2];

				Console.WriteLine ("rendering {0} blocks of type {1}", chain_length, type);

				for (int i = 0; i < chain_length; i ++) {
					switch (type) {
					case BlockType.Mono:
						ushort pixel = (ushort) mclr_Tree.Decode (bs);
						byte color1 = (byte)((pixel >> 8) & 0xff);
						byte color0 = (byte)(pixel & 0xff);
						ushort map = (ushort) mmap_Tree.Decode (bs);
						int mask = 1;
						int bx, by;
						bx = current_block_x * 4;
						by = current_block_y * 4;
						for (int bi = 0; bi < 16;) {
							if ((map & mask) == 0)
								frameData[by * PaddedWidth + bx] = color0;
							else
								frameData[by * PaddedWidth + bx] = color1;
							mask <<= 1;
							bx ++;
							bi++;
							if ((bi % 4) == 0) {
								bx = current_block_x * 4;
								by ++;
							}
						}
						break;
					case BlockType.Full:
						break;
					case BlockType.Void:
						break;
					case BlockType.Solid:
						break;
					}
					current_block_x ++;
					if (current_block_x == block_rez_x) {
						current_block_x = 0;
						current_block_y ++;
						if (current_block_y == block_rez_y)
							return;
					}
				}
			}
		}
Пример #4
0
        void ReadVideoChunk(BitStream bs)
        {
            int current_block_x = 0, current_block_y = 0;
            int block_rez_x = (int)PaddedWidth / 4;
            int block_rez_y = (int)PaddedHeight / 4;

            Console.WriteLine("reading video chunk");
            bs.DebugFirst();

            while (true)
            {
                ushort type_descriptor = 0;
                if (type_Tree != null)
                {
                    type_descriptor = (ushort)type_Tree.Decode(bs);
                }
                BlockType type         = (BlockType)(type_descriptor & 0x3);
                uint      chain_length = block_chain_size_table [(type_descriptor & 0xfc) >> 2];

                Console.WriteLine("rendering {0} blocks of type {1}", chain_length, type);

                for (int i = 0; i < chain_length; i++)
                {
                    switch (type)
                    {
                    case BlockType.Mono:
                        ushort pixel = (ushort)mclr_Tree.Decode(bs);
                        byte   color1 = (byte)((pixel >> 8) & 0xff);
                        byte   color0 = (byte)(pixel & 0xff);
                        ushort map = (ushort)mmap_Tree.Decode(bs);
                        int    mask = 1;
                        int    bx, by;
                        bx = current_block_x * 4;
                        by = current_block_y * 4;
                        for (int bi = 0; bi < 16;)
                        {
                            if ((map & mask) == 0)
                            {
                                frameData[by * PaddedWidth + bx] = color0;
                            }
                            else
                            {
                                frameData[by * PaddedWidth + bx] = color1;
                            }
                            mask <<= 1;
                            bx++;
                            bi++;
                            if ((bi % 4) == 0)
                            {
                                bx = current_block_x * 4;
                                by++;
                            }
                        }
                        break;

                    case BlockType.Full:
                        break;

                    case BlockType.Void:
                        break;

                    case BlockType.Solid:
                        break;
                    }
                    current_block_x++;
                    if (current_block_x == block_rez_x)
                    {
                        current_block_x = 0;
                        current_block_y++;
                        if (current_block_y == block_rez_y)
                        {
                            return;
                        }
                    }
                }
            }
        }