Ejemplo n.º 1
0
 public TestImageGenerator(TestImageGenerator copy)
 {
     this.toc             = copy.toc;
     this.seed            = copy.seed;
     this.offset          = copy.offset;
     this.start           = copy.start;
     this.end             = copy.end;
     this.errors          = copy.errors;
     this.maxStrideErrors = copy.maxStrideErrors;
 }
		public TestImageGenerator(TestImageGenerator copy)
		{
			this.toc = copy.toc;
			this.seed = copy.seed;
			this.offset = copy.offset;
			this.start = copy.start;
			this.end = copy.end;
			this.errors = copy.errors;
            this.maxStrideErrors = copy.maxStrideErrors;
		}
		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==";
        }
		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");
            //}

        }
 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");
 }
		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");
		}
        public unsafe void CDRepairSplitSpeedTest()
		{
			var seed = 723722;
			var split = 20 * 588;
            var ar1 = new TestImageGenerator("13 68 99 136", seed, 0, 0, 0, 0, split).CreateCDRepairEncode(stride);
            var ar2 = new TestImageGenerator("13 68 99 136", seed, 0, 0, 0, split, (int)ar1.FinalSampleCount).CreateCDRepairEncode(stride);
			for (int i = 0; i < 20; i++)
				ar1.AR.Combine(ar2.AR, split, (int)ar1.FinalSampleCount);
		}
		public void CDRepairSplitTest()
		{
			var seed = 723722;
            var ar0 = new TestImageGenerator("13 68 99 136", seed, 0, 0).CreateCDRepairEncode(stride);
			var splits = new int[] { 1, 13 * 588 - 1, 13 * 588, 13 * 588 + 1, 30 * 588 - 1, 30 * 588, 30 * 588 + 1, 68 * 588 - 1, 68 * 588, 68 * 588 + 1 };
			foreach (int split in splits)
			{
                var ar1 = new TestImageGenerator("13 68 99 136", seed, 0, 0, 0, 0, split).CreateCDRepairEncode(stride);
                var ar2 = new TestImageGenerator("13 68 99 136", seed, 0, 0, 0, split, (int)ar0.FinalSampleCount).CreateCDRepairEncode(stride);
				ar1.AR.Combine(ar2.AR, split, (int)ar0.FinalSampleCount);
                string message = "split = " + CDImageLayout.TimeToString((uint)split / 588) + "." + (split % 588).ToString();
				Assert.AreEqual(ar0.CRC, ar1.CRC, "CRC was not set correctly, " + message);
                CollectionAssert.AreEqual(ar0.AR.GetSyndrome(), ar1.AR.GetSyndrome(), "Parity was not set correctly, " + message);
			}
		}
 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);
 }
Ejemplo n.º 10
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);
            }
        }
Ejemplo n.º 11
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);
		}
Ejemplo n.º 12
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");
		}
Ejemplo n.º 13
0
        public static AccurateRipVerify CreateAccurateRipVerify(string trackoffsets, int seed, int offset)
        {
            var generator = new TestImageGenerator(trackoffsets, seed, offset, 0, 0);

            return(generator.CreateAccurateRipVerify());
        }
Ejemplo n.º 14
0
		public static AccurateRipVerify CreateAccurateRipVerify(string trackoffsets, int seed, int offset)
		{
			var generator = new TestImageGenerator(trackoffsets, seed, offset, 0, 0);
			return generator.CreateAccurateRipVerify();
		}