Ejemplo n.º 1
0
        private void ReadHeader()
        {
            uint code      = 0;
            uint startCode = 0;

            AlignStreamData();

            code = ReadStreamData(22);

            startCode = (uint)(code & ~0x1F);

            if (startCode == 32)
            {
                if (((code & 0x1F) == 0x1F))
                {
                    PictureComplete = true;
                }
                else
                {
                    if (SliceIndex++ == 0)
                    {
                        PictureFormat = (int)ReadStreamData(2);
                        Resolution    = (int)ReadStreamData(3);
                        PictureType   = (int)ReadStreamData(3);
                        QuantizerMode = (int)ReadStreamData(5);
                        FrameIndex    = (int)ReadStreamData(32);

                        switch (PictureFormat)
                        {
                        case (int)PictureFormats.Cif:
                            Width  = CONST_WidthCif << Resolution - 1;
                            Height = CONST_HeightCif << Resolution - 1;
                            break;

                        case (int)PictureFormats.Vga:
                            Width  = CONST_WidthVga << Resolution - 1;
                            Height = CONST_HeightVga << Resolution - 1;
                            break;
                        }

                        //We assume two bytes per pixel (RGB 565)
                        PixelRowSize = Width << 1;

                        SliceCount = Height >> 4;
                        BlockCount = Width >> 4;

                        if (ImageSlice == null)
                        {
                            ImageSlice          = new ImageSlice(BlockCount);
                            PixelData           = new ushort[Width * Height];
                            InternalImageSource = new Bitmap(Width, Height); //new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                            //Rectangle = new Int32Rect(0, 0, Width, Height);
                        }
                        else
                        {
                            if (ImageSlice.MacroBlocks.Count != BlockCount)
                            {
                                ImageSlice          = new ImageSlice(BlockCount);
                                PixelData           = new ushort[Width * Height];
                                InternalImageSource = new Bitmap(Width, Height); //new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                                //Rectangle = new Int32Rect(0, 0, Width, Height);
                            }
                        }
                    }
                    else
                    {
                        QuantizerMode = (int)ReadStreamData(5);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void ReadHeader()
        {
            uint code = 0;
            uint startCode = 0;

            AlignStreamData();

            code = ReadStreamData(22);

            startCode = (uint)(code & ~0x1F);

            if (startCode == 32)
            {
                if (((code & 0x1F) == 0x1F))
                {
                    PictureComplete = true;
                }
                else
                {
                    if (SliceIndex++ == 0)
                    {
                        PictureFormat = (int)ReadStreamData(2);
                        Resolution = (int)ReadStreamData(3);
                        PictureType = (int)ReadStreamData(3);
                        QuantizerMode = (int)ReadStreamData(5);
                        FrameIndex = (int)ReadStreamData(32);

                        switch (PictureFormat)
                        {
                            case (int)PictureFormats.Cif:
                                Width = CONST_WidthCif << Resolution - 1;
                                Height = CONST_HeightCif << Resolution - 1;
                                break;
                            case (int)PictureFormats.Vga:
                                Width = CONST_WidthVga << Resolution - 1;
                                Height = CONST_HeightVga << Resolution - 1;
                                break;
                        }

                        //We assume two bytes per pixel (RGB 565)
                        PixelRowSize = Width << 1;

                        SliceCount = Height >> 4;
                        BlockCount = Width >> 4;

                        if (ImageSlice == null)
                        {
                            ImageSlice = new ImageSlice(BlockCount);
                            PixelData = new ushort[Width * Height];
                            InternalImageSource = new Bitmap(Width, Height); //new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                            //Rectangle = new Int32Rect(0, 0, Width, Height);
                        }
                        else
                        {
                            if (ImageSlice.MacroBlocks.Count != BlockCount)
                            {
                                ImageSlice = new ImageSlice(BlockCount);
                                PixelData = new ushort[Width * Height];
                                InternalImageSource = new Bitmap(Width, Height); //new WriteableBitmap(Width, Height, 96, 96, PixelFormats.Bgr565, null);
                                //Rectangle = new Int32Rect(0, 0, Width, Height);
                            }
                        }
                    }
                    else
                    {
                        QuantizerMode = (int)ReadStreamData(5);
                    }
                }
            }
        }