Ejemplo n.º 1
0
        public T GetVlc <T>(VlcTable <T> vlcTable)
        {
            Vlc vlc = vlcTable.GetVlc(ShowBits(vlcTable.MaxBits));

            if (vlc == null)
            {
                return(vlcTable.DefaultValue);
            }
            GetBits(vlc.Length);                // Flush the bits
            return(vlcTable[vlc]);
        }
Ejemplo n.º 2
0
        public void TestGetVlc()
        {
            Assert.AreEqual(new Vlc(0x02, 4), _mockTable.GetVlc(0x040), "GetVlc()");

            // Brute-force test
            int numBits = _mockTable.MaxBits;
            for (uint code = 0U; code < (1U << numBits); code++)
            {
                string bitstring = (new Vlc(code, numBits)).ToString();
                Vlc vlc = _mockTable.GetVlc(code);

                if (vlc != null)
                {
                    Assert.IsTrue(bitstring.StartsWith(vlc.ToString()), "GetVlc(), valid code");
                }
                else
                {
                    for (int i = 0; i < MockVlcData.GetLength(0); i++)
                    {
                        Assert.IsFalse(bitstring.StartsWith(MockVlcData[i, 0] as string), "GetVlc(), invalid code");
                    }
                }
            }
        }