{\r
using System;\r
using System.Drawing;\r
+ using System.Globalization;\r
using System.Windows.Forms;\r
\r
/// <summary>\r
}\r
\r
// Quality\r
-\r
if (presetQuery.VideoQuality != -1)\r
{\r
mainWindow.radio_cq.Checked = true;\r
- if (presetQuery.VideoEncoder == "H.264 (x264)")\r
- {\r
- double cqStep = Properties.Settings.Default.x264cqstep;\r
- int value;\r
- double x264Step = cqStep;\r
- double presetValue = presetQuery.VideoQuality;\r
-\r
- double x = 51 / x264Step;\r
-\r
- double calculated = presetValue / x264Step;\r
- calculated = x - calculated;\r
-\r
- int.TryParse(calculated.ToString(), out value);\r
-\r
- // This will sometimes occur when the preset was generated \r
- // with a different granularity, so, round and try again.\r
- if (value == 0)\r
- {\r
- double val = Math.Round(calculated, 0);\r
- int.TryParse(val.ToString(), out value);\r
- }\r
- if (value <= mainWindow.slider_videoQuality.Maximum)\r
- mainWindow.slider_videoQuality.Value = value;\r
- }\r
- else\r
- {\r
- int presetVal;\r
- int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal);\r
- if (presetVal > mainWindow.slider_videoQuality.Minimum)\r
- mainWindow.slider_videoQuality.Value = presetVal;\r
- }\r
+ mainWindow.slider_videoQuality.Value = QualityToSliderValue(presetQuery.VideoEncoder, presetQuery.VideoQuality);\r
}\r
\r
mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
\r
#endregion\r
}\r
+\r
+ /// <summary>\r
+ /// Convert a Quality Value to a position value for the Video Quality slider\r
+ /// </summary>\r
+ /// <param name="videoEncoder">The selected video encoder</param>\r
+ /// <param name="value">The Quality value</param>\r
+ /// <returns>The position on the video quality slider</returns>\r
+ private static int QualityToSliderValue(string videoEncoder, float value)\r
+ {\r
+ int sliderValue = 0;\r
+ switch (videoEncoder)\r
+ {\r
+ case "MPEG-4 (FFmpeg)":\r
+ sliderValue = 32 - (int)value;\r
+ break;\r
+ case "H.264 (x264)":\r
+ double cqStep = Properties.Settings.Default.x264cqstep;\r
+ sliderValue = (int)((51.0 / cqStep) - (value/cqStep));\r
+ break;\r
+ case "VP3 (Theora)":\r
+ sliderValue = (int)value;\r
+ break;\r
+ }\r
+\r
+ return sliderValue;\r
+ }\r
}\r
}
\ No newline at end of file