/// <summary> /// Compress MPEG function. /// Simply performs JPEG on the first. /// Calculates MVs /// Converts MVs to bytes /// Appends length of MVs + MVs /// onto the already compressed data. /// Writes to file. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void compressToolStripMenuItem1_Click(object sender, EventArgs e) { Thread procesThread = new Thread(new DctImageProcessor(MPEGData[0]).Process); await Task.Run(() => { MVs = ExaustiveSearch.Search(MPEGData[0], MPEGData[1]); }); procesThread.Start(); List <Tuple <Point, Point> > filteredMVs = MVs.Where(mV => mV.Item1 != mV.Item2).ToList(); byte[] data = ObjectConverter.ObjectToByteArray(filteredMVs); byte[] MVsize = System.BitConverter.GetBytes(data.Length); procesThread.Join(); sbyte[] encoded = MPEGData[0].EncodedBytes; IEnumerable <byte> output = data.Concat(encoded.Select(s => (byte)s)); output = MVsize.Concat(output); data = output.ToArray(); File.WriteAllBytes("./MPEGoutput.rippeg", data); }
private void MVToolStripMenuItem_Click(object sender, EventArgs e) { MVs = ExaustiveSearch.Search(MPEGData[0], MPEGData[1]); }