Exemple #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);

                        if (IsPictureFormatCif(pictureFormat))
                        {
                            width  = widthCif << resolution - 1;
                            height = heightCif << resolution - 1;
                        }
                        else if (IsPictureFormatVGA(pictureFormat))
                        {
                            width  = widthVga << resolution - 1;
                            height = heightVga << resolution - 1;
                        }

                        //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 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 WriteableBitmap(width, height, 96, 96, PixelFormats.Bgr565, null);
                                rectangle           = new Int32Rect(0, 0, width, height);
                            }
                        }
                    }
                    else
                    {
                        quantizerMode = (int)ReadStreamData(5);
                    }
                }
            }
        }
Exemple #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);

                        if (IsPictureFormatCif(pictureFormat))
                        {
                            width = widthCif << resolution - 1;
                            height = heightCif << resolution - 1;
                        }
                        else if (IsPictureFormatVGA(pictureFormat))
                        {
                            width = widthVga << resolution - 1;
                            height = heightVga << resolution - 1;
                        }

                        //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 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 WriteableBitmap(width, height, 96, 96, PixelFormats.Bgr565, null);
                                rectangle = new Int32Rect(0, 0, width, height);
                            }
                        }
                    }
                    else
                    {
                        quantizerMode = (int)ReadStreamData(5);
                    }
                }
            }
        }