1 // -------------------------------------------------------------------------------------------------------------------- 2 // <copyright file="VideoOptionsTooltipConverter.cs" company="HandBrake Project (http://handbrake.fr)"> 3 // This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. 4 // </copyright> 5 // <summary> 6 // The video options queue tooltip converter. 7 // </summary> 8 // -------------------------------------------------------------------------------------------------------------------- 9 10 namespace HandBrakeWPF.Converters.Video 11 { 12 using System; 13 using System.Globalization; 14 using System.Windows.Data; 15 16 using HandBrakeWPF.Utilities; 17 18 using EncodeTask = HandBrakeWPF.Services.Encode.Model.EncodeTask; 19 using VideoEncoder = HandBrakeWPF.Model.Video.VideoEncoder; 20 using VideoEncodeRateType = HandBrakeWPF.Model.Video.VideoEncodeRateType; 21 22 /// <summary> 23 /// The x 264 queue tooltip converter. 24 /// </summary> 25 public class VideoOptionsTooltipConverter : IValueConverter 26 { 27 /// <summary> 28 /// Converts a value. 29 /// </summary> 30 /// <returns> 31 /// A converted value. If the method returns null, the valid null value is used. 32 /// </returns> 33 /// <param name="value"> 34 /// The value produced by the binding source. 35 /// </param> 36 /// <param name="targetType"> 37 /// The type of the binding target property. 38 /// </param> 39 /// <param name="parameter"> 40 /// The converter parameter to use. 41 /// </param> 42 /// <param name="culture"> 43 /// The culture to use in the converter. 44 /// </param> Convert(object value, Type targetType, object parameter, CultureInfo culture)45 public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 46 { 47 EncodeTask task = value as EncodeTask; 48 if (task != null) 49 { 50 string rfqp = task.VideoEncoder == VideoEncoder.X264 || task.VideoEncoder == VideoEncoder.X264_10 || task.VideoEncoder == VideoEncoder.X265 51 || task.VideoEncoder == VideoEncoder.X265_10 || task.VideoEncoder == VideoEncoder.X265_12 ? "RF" : "QP"; 52 53 if (task.VideoEncoder == VideoEncoder.NvencH264 || task.VideoEncoder == VideoEncoder.NvencH265) 54 { 55 rfqp = "CQ"; 56 } 57 58 if (task.VideoEncoder == VideoEncoder.MFH264 || task.VideoEncoder == VideoEncoder.MFH265) 59 { 60 rfqp = "CQ"; 61 } 62 63 string quality = task.VideoEncodeRateType == VideoEncodeRateType.ConstantQuality ? string.Format("{0} {1}", task.Quality, rfqp) : string.Format("{0} {1}", task.VideoBitrate, " kbps"); 64 string twoPass = null; 65 66 if (task.VideoEncodeRateType == VideoEncodeRateType.AverageBitrate) 67 { 68 twoPass = task.TwoPass ? task.TurboFirstPass ? " (2-Pass with Turbo)" : " (2-Pass)" : string.Empty; 69 } 70 71 return string.Format("{0} - {1}{2}", EnumHelper<VideoEncoder>.GetDisplay(task.VideoEncoder), quality, twoPass); 72 } 73 74 return "Unknown"; 75 } 76 77 /// <summary> 78 /// Converts a value. 79 /// </summary> 80 /// <returns> 81 /// A converted value. If the method returns null, the valid null value is used. 82 /// </returns> 83 /// <param name="value"> 84 /// The value that is produced by the binding target. 85 /// </param> 86 /// <param name="targetType"> 87 /// The type to convert to. 88 /// </param> 89 /// <param name="parameter"> 90 /// The converter parameter to use. 91 /// </param> 92 /// <param name="culture"> 93 /// The culture to use in the converter. 94 /// </param> ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)95 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 96 { 97 throw new NotImplementedException(); 98 } 99 } 100 } 101