예제 #1
0
        public void TestNoOverlay()
        {
            Frame testFrame = new Frame(new YuvKA.VideoModel.Size(80, 80));

            for (int x = 0; x < testFrame.Size.Width; x++)
            {
                for (int y = 0; y < testFrame.Size.Height; y++)
                {
                    testFrame[x, y] = new Rgb(111, 111, 111);
                }
            }
            Frame[]     input = { testFrame };
            OverlayNode node  = new OverlayNode {
                Type = new NoOverlay()
            };

            node.ProcessCore(input, 0);
            List <Frame> output = new List <Frame>();

            for (int x = 0; x < testFrame.Size.Width; x++)
            {
                for (int y = 0; y < testFrame.Size.Height; y++)
                {
                    Assert.Equal(testFrame[x, y], node.Data[x, y]);
                }
            }
        }
예제 #2
0
        public void ArtifactOverlay()
        {
            Frame testFrame = new Frame(new YuvKA.VideoModel.Size(80, 80));

            for (int x = 0; x < testFrame.Size.Width; x++)
            {
                for (int y = 0; y < testFrame.Size.Height; y++)
                {
                    testFrame[x, y] = new Rgb(111, 111, 111);
                }
            }
            Frame alteredTestFrame = new Frame(testFrame.Size);

            for (int x = 0; x < testFrame.Size.Width; x++)
            {
                for (int y = 0; y < testFrame.Size.Height; y++)
                {
                    alteredTestFrame[x, y] = new Rgb((byte)(x + y), (byte)(x + y), (byte)(x + y));
                }
            }
            Frame[]     input = { alteredTestFrame, testFrame };
            OverlayNode node  = new OverlayNode {
                Type = new ArtifactsOverlay()
            };

            node.ProcessCore(input, 0);
            List <Frame> output = new List <Frame>();

            output.Add(node.Data);
            YuvEncoder.Encode(@"..\..\..\..\output\ArtifactOverlayTest_80x80.yuv", output);
        }
예제 #3
0
        public void TestVecorOverlay()
        {
            Frame testFrame = new Frame(new YuvKA.VideoModel.Size(64, 48));

            for (int x = 0; x < testFrame.Size.Width; x++)
            {
                for (int y = 0; y < testFrame.Size.Height; y++)
                {
                    testFrame[x, y] = new Rgb(111, 111, 111);
                }
            }
            MacroblockDecision[] decisions = new MacroblockDecision[12];
            decisions[0] = new MacroblockDecision {
                Movement = new Vector(0.0, 12.0)
            };
            decisions[1] = new MacroblockDecision {
                Movement = new Vector(12.0, 12.0)
            };
            decisions[2] = new MacroblockDecision {
                Movement = new Vector(12.0, 0.0)
            };
            decisions[3] = new MacroblockDecision {
                Movement = new Vector(12.0, -12.0)
            };
            decisions[4] = new MacroblockDecision {
                Movement = new Vector(3.0, -12.0)
            };
            decisions[5] = new MacroblockDecision {
                Movement = new Vector(-38.0, -15.0)
            };
            decisions[6] = new MacroblockDecision {
                Movement = new Vector(-120.0, 0.0)
            };
            decisions[7] = new MacroblockDecision {
                Movement = new Vector(-20.0, 20.0)
            };
            decisions[8] = new MacroblockDecision {
                Movement = new Vector(4.0, 0.0)
            };
            decisions[9] = new MacroblockDecision {
                Movement = new Vector(0.0, 4.0)
            };
            decisions[10] = new MacroblockDecision {
                Movement = new Vector(4.0, 4.0)
            };
            decisions[11] = new MacroblockDecision {
                Movement = new Vector(-4.0, 0.0)
            };
            Frame[]     input = { new AnnotatedFrame(testFrame, decisions) };
            OverlayNode node  = new OverlayNode {
                Type = new MoveVectorsOverlay()
            };

            node.ProcessCore(input, 0);
            List <Frame> output = new List <Frame>();

            output.Add(node.Data);
            YuvEncoder.Encode(@"..\..\..\..\output\VectorOverlayTest_64x48.yuv", output);
        }
예제 #4
0
        public void TestOverlayNode()
        {
            OverlayNode node = new OverlayNode();

            Assert.Equal(false, node.InputIsValid);
            NoiseInputNode noise = new NoiseInputNode();

            node.Inputs[0].Source = noise.Outputs[0];
            Assert.Equal(true, node.InputIsValid);
            Frame[] input = { new Frame(new YuvKA.VideoModel.Size(5, 5)) };
            node.Type = new ArtifactsOverlay();
            node.ProcessCore(input, 0);
            node.Type = new BlocksOverlay();
            node.ProcessCore(input, 0);
            node.Type = new MoveVectorsOverlay();
            node.ProcessCore(input, 0);
        }
예제 #5
0
        public void TestGeneralFunctions()
        {
            IOverlayType noOverlay    = new NoOverlay();
            IOverlayType blockOverlay = new BlocksOverlay();

            IoC.GetAllInstances = nope => new List <object> {
                noOverlay, blockOverlay
            };
            IoC.GetInstance = IoCAggregator;
            OverlayNode      node = new OverlayNode();
            OverlayViewModel vm   = new OverlayViewModel(node);

            var inputNodeMock = new Mock <InputNode>(1);

            inputNodeMock.SetupGet(i => i.OutputHasLogfile).Returns(true);
            inputNodeMock.SetupGet(i => i.InputIsValid).Returns(true);

            //Test the available Types
            node.Inputs[0].Source = inputNodeMock.Object.Outputs[0];
            Assert.Equal("No Overlay", vm.TypeTuples.First().Item1);

            //Test altering the chosen Type
            node.Type = blockOverlay;
            Assert.Equal("Macroblock-Overlay", vm.ChosenType.Item1);
            ColorInputNode color = new ColorInputNode();

            color.Size            = new Size(512, 512);
            node.Inputs[0].Source = color.Outputs[0];
            vm.ChosenType         = new System.Tuple <string, IOverlayType>("No Overlay", noOverlay);
            Assert.Equal("No Overlay", vm.ChosenType.Item1);
            //Test "Handling" a message(The result has be inspected manually)
            node.Type = noOverlay;
            Frame[] input = { new Frame(new Size(512, 512)) };
            node.ProcessCore(input, 0);
            vm.Handle(null);

            using (var fileStream = new FileStream(@"..\..\..\..\output\thisIsBlack.png", FileMode.Create)) {
                BitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(vm.RenderedImage));
                encoder.Save(fileStream);
            }
        }
예제 #6
0
		public void TestGeneralFunctions()
		{
			IOverlayType noOverlay = new NoOverlay();
			IOverlayType blockOverlay = new BlocksOverlay();
			IoC.GetAllInstances = nope => new List<object> { noOverlay, blockOverlay };
			IoC.GetInstance = IoCAggregator;
			OverlayNode node = new OverlayNode();
			OverlayViewModel vm = new OverlayViewModel(node);

			var inputNodeMock = new Mock<InputNode>(1);
			inputNodeMock.SetupGet(i => i.OutputHasLogfile).Returns(true);
			inputNodeMock.SetupGet(i => i.InputIsValid).Returns(true);

			//Test the available Types
			node.Inputs[0].Source = inputNodeMock.Object.Outputs[0];
			Assert.Equal("No Overlay", vm.TypeTuples.First().Item1);

			//Test altering the chosen Type
			node.Type = blockOverlay;
			Assert.Equal("Macroblock-Overlay", vm.ChosenType.Item1);
			ColorInputNode color = new ColorInputNode();
			color.Size = new Size(512, 512);
			node.Inputs[0].Source = color.Outputs[0];
			vm.ChosenType = new System.Tuple<string, IOverlayType>("No Overlay", noOverlay);
			Assert.Equal("No Overlay", vm.ChosenType.Item1);
			//Test "Handling" a message(The result has be inspected manually)
			node.Type = noOverlay;
			Frame[] input = { new Frame(new Size(512, 512)) };
			node.ProcessCore(input, 0);
			vm.Handle(null);

			using (var fileStream = new FileStream(@"..\..\..\..\output\thisIsBlack.png", FileMode.Create)) {
				BitmapEncoder encoder = new PngBitmapEncoder();
				encoder.Frames.Add(BitmapFrame.Create(vm.RenderedImage));
				encoder.Save(fileStream);
			}
		}
예제 #7
0
		public void TestOverlayNode()
		{
			OverlayNode node = new OverlayNode();
			Assert.Equal(false, node.InputIsValid);
			NoiseInputNode noise = new NoiseInputNode();
			node.Inputs[0].Source = noise.Outputs[0];
			Assert.Equal(true, node.InputIsValid);
			Frame[] input = { new Frame(new YuvKA.VideoModel.Size(5, 5)) };
			node.Type = new ArtifactsOverlay();
			node.ProcessCore(input, 0);
			node.Type = new BlocksOverlay();
			node.ProcessCore(input, 0);
			node.Type = new MoveVectorsOverlay();
			node.ProcessCore(input, 0);
		}
예제 #8
0
		public void TestNoOverlay()
		{
			Frame testFrame = new Frame(new YuvKA.VideoModel.Size(80, 80));
			for (int x = 0; x < testFrame.Size.Width; x++) {
				for (int y = 0; y < testFrame.Size.Height; y++) {
					testFrame[x, y] = new Rgb(111, 111, 111);
				}
			}
			Frame[] input = { testFrame };
			OverlayNode node = new OverlayNode { Type = new NoOverlay() };
			node.ProcessCore(input, 0);
			List<Frame> output = new List<Frame>();
			for (int x = 0; x < testFrame.Size.Width; x++) {
				for (int y = 0; y < testFrame.Size.Height; y++) {
					Assert.Equal(testFrame[x, y], node.Data[x, y]);
				}
			}
		}
예제 #9
0
		public void ArtifactOverlay()
		{
			Frame testFrame = new Frame(new YuvKA.VideoModel.Size(80, 80));
			for (int x = 0; x < testFrame.Size.Width; x++) {
				for (int y = 0; y < testFrame.Size.Height; y++) {
					testFrame[x, y] = new Rgb(111, 111, 111);
				}
			}
			Frame alteredTestFrame = new Frame(testFrame.Size);
			for (int x = 0; x < testFrame.Size.Width; x++) {
				for (int y = 0; y < testFrame.Size.Height; y++) {
					alteredTestFrame[x, y] = new Rgb((byte)(x + y), (byte)(x + y), (byte)(x + y));
				}
			}
			Frame[] input = { alteredTestFrame, testFrame };
			OverlayNode node = new OverlayNode { Type = new ArtifactsOverlay() };
			node.ProcessCore(input, 0);
			List<Frame> output = new List<Frame>();
			output.Add(node.Data);
			YuvEncoder.Encode(@"..\..\..\..\output\ArtifactOverlayTest_80x80.yuv", output);
		}
예제 #10
0
		public void TestVecorOverlay()
		{
			Frame testFrame = new Frame(new YuvKA.VideoModel.Size(64, 48));
			for (int x = 0; x < testFrame.Size.Width; x++) {
				for (int y = 0; y < testFrame.Size.Height; y++) {
					testFrame[x, y] = new Rgb(111, 111, 111);
				}
			}
			MacroblockDecision[] decisions = new MacroblockDecision[12];
			decisions[0] = new MacroblockDecision { Movement = new Vector(0.0, 12.0) };
			decisions[1] = new MacroblockDecision { Movement = new Vector(12.0, 12.0) };
			decisions[2] = new MacroblockDecision { Movement = new Vector(12.0, 0.0) };
			decisions[3] = new MacroblockDecision { Movement = new Vector(12.0, -12.0) };
			decisions[4] = new MacroblockDecision { Movement = new Vector(3.0, -12.0) };
			decisions[5] = new MacroblockDecision { Movement = new Vector(-38.0, -15.0) };
			decisions[6] = new MacroblockDecision { Movement = new Vector(-120.0, 0.0) };
			decisions[7] = new MacroblockDecision { Movement = new Vector(-20.0, 20.0) };
			decisions[8] = new MacroblockDecision { Movement = new Vector(4.0, 0.0) };
			decisions[9] = new MacroblockDecision { Movement = new Vector(0.0, 4.0) };
			decisions[10] = new MacroblockDecision { Movement = new Vector(4.0, 4.0) };
			decisions[11] = new MacroblockDecision { Movement = new Vector(-4.0, 0.0) };
			Frame[] input = { new AnnotatedFrame(testFrame, decisions) };
			OverlayNode node = new OverlayNode { Type = new MoveVectorsOverlay() };
			node.ProcessCore(input, 0);
			List<Frame> output = new List<Frame>();
			output.Add(node.Data);
			YuvEncoder.Encode(@"..\..\..\..\output\VectorOverlayTest_64x48.yuv", output);
		}
예제 #11
0
		public void TestMacroBlockOverlay()
		{
			Frame testFrame = new Frame(new YuvKA.VideoModel.Size(64, 64));
			for (int x = 0; x < testFrame.Size.Width; x++) {
				for (int y = 0; y < testFrame.Size.Height; y++) {
					testFrame[x, y] = new Rgb(111, 111, 111);
				}
			}
			MacroblockDecision[] decisions = new MacroblockDecision[16];
			decisions[0] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.InterSkip };
			decisions[1] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter16x16 };
			decisions[2] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter16x8 };
			decisions[3] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter8x16 };
			decisions[4] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter8x8 };
			decisions[5] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter4x8 };
			decisions[6] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter8x4 };
			decisions[7] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter4x4 };
			decisions[8] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Intra16x16 };
			decisions[9] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Intra8x8 };
			decisions[10] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Intra4x4 };
			decisions[11] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Unknown };
			decisions[12] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Inter8x8OrBelow };
			decisions[13] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.IntraPCM };
			decisions[14] = new MacroblockDecision { PartitioningDecision = null };
			decisions[15] = new MacroblockDecision { PartitioningDecision = MacroblockPartitioning.Unknown };
			Frame[] input = { new AnnotatedFrame(testFrame, decisions) };
			OverlayNode node = new OverlayNode { Type = new BlocksOverlay() };
			node.ProcessCore(input, 0);
			List<Frame> output = new List<Frame>();
			output.Add(node.Data);
			YuvEncoder.Encode(@"..\..\..\..\output\BlockOverlayTest_64x64.yuv", output);
		}
예제 #12
0
        public void TestMacroBlockOverlay()
        {
            Frame testFrame = new Frame(new YuvKA.VideoModel.Size(64, 64));

            for (int x = 0; x < testFrame.Size.Width; x++)
            {
                for (int y = 0; y < testFrame.Size.Height; y++)
                {
                    testFrame[x, y] = new Rgb(111, 111, 111);
                }
            }
            MacroblockDecision[] decisions = new MacroblockDecision[16];
            decisions[0] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.InterSkip
            };
            decisions[1] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter16x16
            };
            decisions[2] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter16x8
            };
            decisions[3] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter8x16
            };
            decisions[4] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter8x8
            };
            decisions[5] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter4x8
            };
            decisions[6] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter8x4
            };
            decisions[7] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter4x4
            };
            decisions[8] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Intra16x16
            };
            decisions[9] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Intra8x8
            };
            decisions[10] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Intra4x4
            };
            decisions[11] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Unknown
            };
            decisions[12] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Inter8x8OrBelow
            };
            decisions[13] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.IntraPCM
            };
            decisions[14] = new MacroblockDecision {
                PartitioningDecision = null
            };
            decisions[15] = new MacroblockDecision {
                PartitioningDecision = MacroblockPartitioning.Unknown
            };
            Frame[]     input = { new AnnotatedFrame(testFrame, decisions) };
            OverlayNode node  = new OverlayNode {
                Type = new BlocksOverlay()
            };

            node.ProcessCore(input, 0);
            List <Frame> output = new List <Frame>();

            output.Add(node.Data);
            YuvEncoder.Encode(@"..\..\..\..\output\BlockOverlayTest_64x64.yuv", output);
        }