public Calculator(Container container, VideoTrack video, AudioTrack[] audio, ExtraTrack[] extras) { Container = container; VideoTrack = video; AudioTracks = audio; ExtraTracks = extras; QualityCoeffient = 0.75F; }
/// <summary> /// Calculates by the selected method /// </summary> protected void Calculate() { videoSize.ValueChanged -= new EventHandler(value_Changed); bpp.ValueChanged -= new EventHandler(value_Changed); qest.ValueChanged -= new EventHandler(value_Changed); totalSize.ValueChanged -= new EventHandler(value_Changed); try { VideoTrack video = new VideoTrack((long)frames.Value, float.Parse(framerate.Text)); video.FrameSize = new Size((int)width.Value, (int)height.Value); video.VideoCodec = (VideoCodec)videoCodec.SelectedItem; video.HasBframes = bframes.Checked; Calculator data = new Calculator((Container)container.SelectedItem, video, GetAudio().ToArray(), GetExtras().ToArray()); data.QualityCoeffient = (float)complexity.Value / 100F; if (fileSizeRadio.Checked) // get video, bpp, qest { data.TotalBytes = totalSize.SizeLength.Bytes; data.CalcByTotalSize(); } else if (this.bppRadio.Checked) // get video, quest, total { data.BitsPerPixel = (float)bpp.Value; data.CalcByBitsPerPixel(); } else if (this.qEstRadio.Checked) // get video, bpp, total { data.QualityEstimate = (float)qest.Value; data.CalcByQualityEstimate(); } else // given video size, get total, bpp, quest { video.RawBytes = videoSize.SizeLength.Bytes; data.CalcByVideoSize(); } totalSize.SizeLength = data.TotalSizeLength; videoSize.SizeLength = video.SizeLength; bpp.Value = (decimal)data.BitsPerPixel; qest.Value = (decimal)data.QualityEstimate; UpdatePresetLabel(null); SaveSettings(); } catch (Exception ex) { Trace.TraceError(ex.ToString()); if (fileSizeRadio.Checked) { bpp.Value = 0; qest.Value = 0; videoSize.SizeLength = SizeLength.Zero; } else if (this.bppRadio.Checked) { qest.Value = 0; videoSize.SizeLength = SizeLength.Zero; totalSize.SizeLength = SizeLength.Zero; } else if (this.qEstRadio.Checked) { bpp.Value = 0; videoSize.SizeLength = SizeLength.Zero; totalSize.SizeLength = SizeLength.Zero; } else { bpp.Value = 0; qest.Value = 0; totalSize.SizeLength = SizeLength.Zero; } } videoSize.ValueChanged += new EventHandler(value_Changed); bpp.ValueChanged += new EventHandler(value_Changed); qest.ValueChanged += new EventHandler(value_Changed); totalSize.ValueChanged += new EventHandler(value_Changed); }