示例#1
0
 private void EnsureInputLoaded()
 {
     if (input == null)
     {
         input = YuvEncoder.Decode(Size.Width, Size.Height, FileName.Path, LogFileName.Path, MotionVectorFileName.Path);
     }
 }
示例#2
0
        public void TestVideoFunctionality()
        {
            int    width                = 352;
            int    height               = 240;
            string videoName            = @"..\..\..\..\resources\americanFootball_352x240_125.yuv";  // be sure to adjust this beforehand
            string logFileName          = @"..\..\..\..\resources\ModeGrid_AmFootball_OUR.dat";
            string motionVectorFileName = @"..\..\..\..\resources\motion_info\motion_info_football_qp20.csv";
            string saveName             = @"..\..\..\..\output\";

            // leave the file extension away
            YuvEncoder.Video video = YuvEncoder.Decode(width, height, videoName, logFileName, motionVectorFileName);
            // Don't expect this to work if the filename doesn't happen to be formatted
            // just the right way
            Assert.Equal(video.FrameCount, int.Parse(videoName.Substring(videoName.Length - 7, 3)));
            // Test video and frame indexer
            Assert.Equal(new Rgb(0, 0, 0), video[0].GetPixelOrBlack(-1, -1));
            // obviously, this is only true if the video is either very large and black or not that large
            Assert.Equal(new Rgb(0, 0, 0), video[0].GetPixelOrBlack(9999999, 9999999));
            Assert.Equal(video[0][0, 0], video[0].GetPixelOrBlack(0, 0));

            Bitmap bmp;

            // I test the first and last three frames
            for (int i = 0; i < 3; i++)
            {
                bmp = FrameToBitmap(video[i]);
                bmp.Save(saveName + i.ToString() + ".png");
            }
            for (int i = video.FrameCount - 4; i < video.FrameCount; i++)
            {
                bmp = FrameToBitmap(video[i]);
                bmp.Save(saveName + i.ToString() + ".png");
            }
        }
示例#3
0
        public void TestYuvEncoder()
        {
            int    width    = 352;
            int    height   = 240;
            string fileName = "..\\..\\..\\..\\resources\\americanFootball_352x240_125.yuv";           // be sure to adjust this beforehand
            string saveName = "..\\..\\..\\..\\output\\yuvencoder-output_352x240_125.yuv";             // warning, depending on the file, this produces a lot of images

            YuvEncoder.Video    video     = new YuvEncoder.Video(new YuvKA.VideoModel.Size(width, height), fileName, null, null);
            IEnumerable <Frame> frameList = Enumerable.Range(0, video.FrameCount).Select(i => video[i]);

            YuvEncoder.Encode(saveName, frameList);
        }
示例#4
0
        public void YuvEncoderSpeedtest()
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            int    width    = 352;
            int    height   = 240;
            string fileName = "..\\..\\..\\..\\resources\\americanFootball_352x240_125.yuv";

            YuvEncoder.Video video = new YuvEncoder.Video(new YuvKA.VideoModel.Size(width, height), fileName, null, null);
            Frame            notLazy;

            for (int i = 0; i < 125; i++)
            {
                notLazy = video[i];
            }
            System.Console.WriteLine(stopWatch.ElapsedMilliseconds + "ms");
        }
示例#5
0
 protected override void OnSizeChanged()
 {
     base.OnSizeChanged();
     input = null;
 }