예제 #1
0
        public void Init()
        {
            this.WidthInBlocks = (int)MathF.Ceiling(
                MathF.Ceiling(this.Frame.SamplesPerLine / 8F) * this.HorizontalSamplingFactor / this.Frame.MaxHorizontalFactor);

            this.HeightInBlocks = (int)MathF.Ceiling(
                MathF.Ceiling(this.Frame.Scanlines / 8F) * this.VerticalSamplingFactor / this.Frame.MaxVerticalFactor);

            int blocksPerLineForMcu   = this.Frame.McusPerLine * this.HorizontalSamplingFactor;
            int blocksPerColumnForMcu = this.Frame.McusPerColumn * this.VerticalSamplingFactor;

            this.SizeInBlocks = new Size(blocksPerLineForMcu, blocksPerColumnForMcu);

            JpegComponent c0 = this.Frame.Components[0];

            this.SubSamplingDivisors = c0.SamplingFactors.DivideBy(this.SamplingFactors);

            if (this.SubSamplingDivisors.Width == 0 || this.SubSamplingDivisors.Height == 0)
            {
                JpegThrowHelper.ThrowBadSampling();
            }

            int totalNumberOfBlocks = blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
            int width  = this.WidthInBlocks + 1;
            int height = totalNumberOfBlocks / width;

            var buf = MemoryGroup <Block8x8> .Allocate(width *height, height);

            this.SpectralBlocks = new Buffer2D <Block8x8>(buf, width, height);
        }
예제 #2
0
        /// <summary>
        /// Allocates the frame component blocks.
        /// </summary>
        public void InitComponents()
        {
            this.McusPerLine   = (int)MathF.Ceiling(this.SamplesPerLine / 8F / this.MaxHorizontalFactor);
            this.McusPerColumn = (int)MathF.Ceiling(this.Scanlines / 8F / this.MaxVerticalFactor);

            for (int i = 0; i < this.ComponentCount; i++)
            {
                JpegComponent component = this.Components[i];
                component.Init();
            }
        }