Exemplo n.º 1
0
        private void Fill()
        {
            ReadOnlySpan <byte> buffer      = _buffer.AsSpan();
            ReadOnlySpan <byte> bufferStart = buffer;
            ulong value     = Value;
            int   count     = Count;
            ulong bytesLeft = (ulong)buffer.Length;
            ulong bitsLeft  = bytesLeft * 8;
            int   shift     = BdValueSize - 8 - (count + 8);

            if (bitsLeft > BdValueSize)
            {
                int   bits = (shift & unchecked ((int)0xfffffff8)) + 8;
                ulong nv;
                ulong bigEndianValues = BinaryPrimitives.ReadUInt64BigEndian(buffer);
                nv     = bigEndianValues >> (BdValueSize - bits);
                count += bits;
                buffer = buffer.Slice(bits >> 3);
                value  = Value | (nv << (shift & 0x7));
            }
            else
            {
                int bitsOver = shift + 8 - (int)bitsLeft;
                int loopEnd  = 0;
                if (bitsOver >= 0)
                {
                    count  += LotsOfBits;
                    loopEnd = bitsOver;
                }

                if (bitsOver < 0 || bitsLeft != 0)
                {
                    while (shift >= loopEnd)
                    {
                        count += 8;
                        value |= (ulong)buffer[0] << shift;
                        buffer = buffer.Slice(1);
                        shift -= 8;
                    }
                }
            }

            // NOTE: Variable 'buffer' may not relate to '_buffer' after decryption,
            // so we increase '_buffer' by the amount that 'buffer' moved, rather than
            // assign 'buffer' to '_buffer'.
            _buffer = _buffer.Slice(bufferStart.Length - buffer.Length);
            Value   = value;
            Count   = count;
        }
Exemplo n.º 2
0
        internal void InitMacroBlockD(ref MacroBlockD xd, ArrayPtr <int> dqcoeff)
        {
            int i;

            for (i = 0; i < Constants.MaxMbPlane; ++i)
            {
                xd.Plane[i].DqCoeff = dqcoeff;
                xd.AboveContext[i]  = AboveContext.Slice(i * 2 * TileInfo.MiColsAlignedToSb(MiCols));

                if (i == 0)
                {
                    MemoryUtil.Copy(ref xd.Plane[i].SegDequant, ref YDequant);
                }
                else
                {
                    MemoryUtil.Copy(ref xd.Plane[i].SegDequant, ref UvDequant);
                }
                xd.Fc = new Ptr <Vp9EntropyProbs>(ref Fc.Value);
            }

            xd.AboveSegContext = AboveSegContext;
            xd.MiStride        = MiStride;
            xd.ErrorInfo       = new Ptr <InternalErrorInfo>(ref Error);

            SetPartitionProbs(ref xd);
        }
Exemplo n.º 3
0
        private static void SetupPredPlanes(
            ref Buf2D dst,
            ArrayPtr <byte> src,
            int stride,
            int miRow,
            int miCol,
            Ptr <ScaleFactors> scale,
            int subsamplingX,
            int subsamplingY)
        {
            int x = (Constants.MiSize * miCol) >> subsamplingX;
            int y = (Constants.MiSize * miRow) >> subsamplingY;

            dst.Buf    = src.Slice(ScaledBufferOffset(x, y, stride, scale));
            dst.Stride = stride;
        }
Exemplo n.º 4
0
 private unsafe void DecSetupMi()
 {
     Mi            = Mip.Slice(MiStride + 1);
     MiGridVisible = MiGridBase.Slice(MiStride + 1);
     MemoryUtil.Fill(MiGridBase.ToPointer(), Ptr <ModeInfo> .Null, MiStride * (MiRows + 1));
 }