Beispiel #1
0
        private static void IncMvComponent(int v, ref Vp9BackwardUpdates counts, int comp, int incr, int usehp)
        {
            int s, z, c, o = 0, d, e, f;

            Debug.Assert(v != 0); /* Should not be zero */
            s = v < 0 ? 1 : 0;
            counts.Sign[comp][s] += (uint)incr;
            z = (s != 0 ? -v : v) - 1; /* Magnitude - 1 */

            c = (int)GetMvClass(z, new Ptr <int>(ref o));
            counts.Classes[comp][c] += (uint)incr;

            d = (o >> 3);     /* Int mv data */
            f = (o >> 1) & 3; /* Fractional pel mv data */
            e = (o & 1);      /* High precision mv data */

            if (c == (int)MvClassType.MvClass0)
            {
                counts.Class0[comp][d]      += (uint)incr;
                counts.Class0Fp[comp][d][f] += (uint)incr;
                counts.Class0Hp[comp][e]    += (uint)(usehp * incr);
            }
            else
            {
                int i;
                int b = c + Constants.Class0Bits - 1;  // Number of bits
                for (i = 0; i < b; ++i)
                {
                    counts.Bits[comp][i][((d >> i) & 1)] += (uint)incr;
                }

                counts.Fp[comp][f] += (uint)incr;
                counts.Hp[comp][e] += (uint)(usehp * incr);
            }
        }
Beispiel #2
0
        private static Span <uint> GetTxCounts(ref Vp9BackwardUpdates counts, TxSize maxTxSize, int ctx)
        {
            switch (maxTxSize)
            {
            case TxSize.Tx8x8: return(counts.Tx8x8[ctx].ToSpan());

            case TxSize.Tx16x16: return(counts.Tx16x16[ctx].ToSpan());

            case TxSize.Tx32x32: return(counts.Tx32x32[ctx].ToSpan());

            default: Debug.Assert(false, "Invalid maxTxSize."); return(Span <uint> .Empty);
            }
        }
Beispiel #3
0
        public BackwardUpdates(ref Vp9BackwardUpdates counts)
        {
            InterModeCounts = new Array7 <Array3 <Array2 <uint> > >();

            for (int i = 0; i < 7; i++)
            {
                InterModeCounts[i][0][0] = counts.InterMode[i][2];
                InterModeCounts[i][0][1] = counts.InterMode[i][0] + counts.InterMode[i][1] + counts.InterMode[i][3];
                InterModeCounts[i][1][0] = counts.InterMode[i][0];
                InterModeCounts[i][1][1] = counts.InterMode[i][1] + counts.InterMode[i][3];
                InterModeCounts[i][2][0] = counts.InterMode[i][1];
                InterModeCounts[i][2][1] = counts.InterMode[i][3];
            }

            YModeCounts            = counts.YMode;
            UvModeCounts           = counts.UvMode;
            PartitionCounts        = counts.Partition;
            SwitchableInterpsCount = counts.SwitchableInterp;
            IntraInterCount        = counts.IntraInter;
            CompInterCount         = counts.CompInter;
            SingleRefCount         = counts.SingleRef;
            CompRefCount           = counts.CompRef;
            Tx32x32     = counts.Tx32x32;
            Tx16x16     = counts.Tx16x16;
            Tx8x8       = counts.Tx8x8;
            MbSkipCount = counts.Skip;
            Joints      = counts.Joints;
            Sign        = counts.Sign;
            Classes     = counts.Classes;
            Class0      = counts.Class0;
            Bits        = counts.Bits;
            Class0Fp    = counts.Class0Fp;
            Fp          = counts.Fp;
            Class0Hp    = counts.Class0Hp;
            Hp          = counts.Hp;
            CoefCounts  = counts.Coef;
            EobCounts   = counts.EobBranch;
        }
Beispiel #4
0
        private static void WriteBackwardUpdates(MemoryManager gmm, uint offset, ref Vp9BackwardUpdates counts)
        {
            using var backwardUpdatesRegion = gmm.GetWritableRegion(ExtendOffset(offset), Unsafe.SizeOf <BackwardUpdates>());

            ref var backwardUpdates = ref MemoryMarshal.Cast <byte, BackwardUpdates>(backwardUpdatesRegion.Memory.Span)[0];