示例#1
0
        public void CDRepairDecodeNegativeOffsetErrorsTest()
        {
            var  generator2 = new TestImageGenerator("0 999 9801", seed, 32 * 588 - offset, errors);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;

            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(), encode.CRC, out actualOffset, out hasErrors), "couldn't find offset");
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(-offset, actualOffset, "wrong offset");
            var fix = decode.VerifyParity(encode.AR.GetSyndrome(), encode.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            generator2.Write(fix);
            Assert.AreEqual <uint>(encode.CRC, fix.CRC);

            if (AccurateRipVerify.maxNpar > 8)
            {
                fix = decode.VerifyParity(encode.AR.GetSyndrome(8), encode.CRC, actualOffset);
                Assert.IsTrue(fix.HasErrors, "doesn't have errors");
                Assert.IsTrue(fix.CanRecover, "cannot recover");
                generator2.Write(fix);
                Assert.AreEqual <uint>(encode.CRC, fix.CRC);
            }
        }
示例#2
0
        public void CDRepairEncodeSpeedTest()
        {
            var generator = new TestImageGenerator("0 75000", seed, 0, 0);
            var encode    = generator.CreateCDRepairEncode(stride);

            Assert.AreEqual <string>(Convert.ToBase64String(Convert.FromBase64String(encodeSyndrome1), 0, AccurateRipVerify.maxNpar * 2 * 4),
                                     Convert.ToBase64String(ParityToSyndrome.Syndrome2Bytes(encode.AR.GetSyndrome(AccurateRipVerify.maxNpar, 4))), "syndrome mismatch");
        }
示例#3
0
 public static void MyClassInitialize(TestContext testContext)
 {
     generator               = new TestImageGenerator("0 9801", seed, 32 * 588, 0);
     encode                  = generator.CreateCDRepairEncode(stride);
     encodeSyndrome          = "DP5e7sS+kHjtAEb/o599As2tA3puoW+wuWA5hT1cZxCBRs0bU7Ow3jyLb97/pW1Yjt6H3pph7zKa+hFsT6Wct1r7IciaQ8QUhvzxCof3sJEnJZERL/LnLGrfbjkmdw6wZ0PJjSD5cmwGKFvLpslT/OYwc5M3fbmmFmVDJWRvQdE=";
     encodeSyndromePosOffset = "x5gK5qlKM0HjrEEWOVHQX5VRqD0FtDWGqO/JP2ArcdR0yxE04pdR6B06J3iXbKv9CghrqvNiq+AlMAVWr/pm7bp5s3s+v5Bo3oYpQymmtd0FDKaZ4GQhi9yDu0Vm22j0Cllf5fLPFixhRMCBN/3S3t8IeHtVfmo5Vw0icN7OTHo=";
     encodeSyndromeNegOffset = "wDLTEG5XPVhGlH8fuucGl8St2G/jGLyN3dByVGzOWeZ0CzI1M9jJq4DLj8A3XsMh8u80yvCq36SHXU+iO5cpVcfyiu08pqO1PjPUynqQa/aOcjbFhwjaEZePD42rQCBVdhViBeBEYzMhCTKroorw/Tt0AFC+NlRCMOsUmzSlsRU=";
     encodeSyndrome1         = "YJNmzBE8sVjyo1l59bs/6I+Kqb4PRwEWY34ZHS/yKY5P+AzgGYtQrDplinhvvDKkjMpKOJm6iYplMDQ6OnR0ZwrzJv39czortUxnzOsjIxmzYtdszjDV6jFf/lA8+3lTS2veoTxIJ1a46z9+5hIbAthejftqYB8h9/PAk5PfWDk=";
     encodeParity[8]         = "jvR9QJ1cSWpqbyP0I0tBrBkQRjCDTDDQkttZGj14ROvsXyg+AnnxVKxL7gwLZbrQmTw5ZPps1Q3744g94qaOOQ==";
     encodeParity[16]        = "gwln1GxlYWH/Jn74PreMLv4aFF2glkScSWVFlxMBx94v5D3/3wPx+2guRLquED0s9tOFikPLiSnAv0Xq8aIQ6Q==";
 }
示例#4
0
        public void CDRepairDecodeNegativeOffsetTest()
        {
            var  generator2 = new TestImageGenerator("0 9801", seed, 32 * 588 - offset, 0);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;

            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(), encode.CRC, out actualOffset, out hasErrors));
            Assert.IsFalse(hasErrors, "has errors");
            Assert.AreEqual(-offset, actualOffset, "wrong offset");
        }
示例#5
0
        public void CDRepairDecodeOriginalTest()
        {
            var  decode = generator.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;

            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(), encode.CRC, out actualOffset, out hasErrors));
            Assert.IsFalse(hasErrors, "has errors");
            Assert.AreEqual(0, actualOffset, "wrong offset");
            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(8), encode.CRC, out actualOffset, out hasErrors));
            Assert.IsFalse(hasErrors, "has errors");
            Assert.AreEqual(0, actualOffset, "wrong offset");
        }
示例#6
0
        public void CDRepairDecodeModifiedWithPregapTest()
        {
            var  generator2 = new TestImageGenerator("32 9833", seed, offset, errors);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;

            Assert.IsTrue(decode.FindOffset(encode.AR.GetSyndrome(), encode.CRC, out actualOffset, out hasErrors));
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(offset, actualOffset, "wrong offset");
            CDRepairFix fix = decode.VerifyParity(encode.AR.GetSyndrome(), encode.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            generator2.Write(fix);
            Assert.AreEqual <uint>(encode.CRC, fix.CRC);
        }
示例#7
0
        public void CDRepairVerifyParityLongTest()
        {
            var  generator1 = new TestImageGenerator("0 655000", seed);
            var  encode1    = generator1.CreateCDRepairEncode(stride);
            var  generator2 = new TestImageGenerator("0 655000", seed, 0, stride / 2 * 3, 7);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;
            var  syndrome = encode1.AR.GetSyndrome();

            Assert.IsTrue(decode.FindOffset(syndrome, encode1.CRC, out actualOffset, out hasErrors));
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(0, actualOffset, "wrong offset");
            CDRepairFix fix = decode.VerifyParity(syndrome, encode1.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
        }
示例#8
0
        public void CDRepairDecodePositiveOffsetErrorsTest()
        {
            var  generator2 = new TestImageGenerator("0 9801", seed, 32 * 588 + offset, errors);
            var  decode     = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;
            var  syn = encode.AR.GetSyndrome();

            Assert.IsTrue(decode.FindOffset(syn, encode.CRC, out actualOffset, out hasErrors));
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(offset, actualOffset, "wrong offset");
            CDRepairFix fix = decode.VerifyParity(syn, encode.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            generator2.Write(fix);
            Assert.AreEqual <uint>(encode.CRC, fix.CRC);
        }
示例#9
0
        public void CDRepairVerifyParitySpeedTest()
        {
            var generator1 = new TestImageGenerator("0 98011", seed, 32 * 588);
            var encode1    = generator1.CreateCDRepairEncode(stride);
            var generator2 = new TestImageGenerator("0 98011", seed, 32 * 588, stride / 2 * 3, 7);
            //var generator2 = new TestImageGenerator("0 98011", seed, 32 * 588, stride, 7);
            var  decode = generator2.CreateCDRepairEncode(stride);
            int  actualOffset;
            bool hasErrors;
            var  syndrome = encode1.AR.GetSyndrome();

            Assert.IsTrue(decode.FindOffset(syndrome, encode1.CRC, out actualOffset, out hasErrors));
            Assert.IsTrue(hasErrors, "doesn't have errors");
            Assert.AreEqual(0, actualOffset, "wrong offset");
            for (int t = 0; t < 100; t++)
            {
                decode.VerifyParity(syndrome, encode1.CRC, actualOffset);
            }
            CDRepairFix fix = decode.VerifyParity(syndrome, encode1.CRC, actualOffset);

            Assert.IsTrue(fix.HasErrors, "doesn't have errors");
            Assert.IsTrue(fix.CanRecover, "cannot recover");
            //generator2.Write(fix);
            //Assert.AreEqual<uint>(encode1.CRC, fix.CRC);


            //var encodeTable = Galois16.instance.makeEncodeTable(16);
            //using (StreamWriter sr = new StreamWriter(@"D:\Work\cuetoolsnet\CUETools\x64\Release\ddd"))
            //{
            //    for (int i = 0; i < encodeTable.GetLength(0) * encodeTable.GetLength(1) * encodeTable.GetLength(2); i++)
            //    {
            //        if ((i % 16) == 0)
            //            sr.WriteLine();
            //        sr.Write(string.Format("0x{0:X4}, ", pte[i]));
            //    }
            //    sr.Close();
            //    throw new Exception("aa");
            //}
        }