|
| 1 | +using System; |
| 2 | +using System.Collections.Generic; |
| 3 | +using System.Linq; |
| 4 | +using System.Text; |
| 5 | + |
| 6 | +namespace VidCoder.ViewModel |
| 7 | +{ |
| 8 | + public class AdvancedChoice |
| 9 | + { |
| 10 | + /// <summary> |
| 11 | + /// Gets or sets a value indicating whether the given choice is default. |
| 12 | + /// </summary> |
| 13 | + public bool IsDefault { get; set; } |
| 14 | + |
| 15 | + /// <summary> |
| 16 | + /// Gets or sets the UI label for the choice. |
| 17 | + /// </summary> |
| 18 | + public string Label { get; set; } |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// Gets or sets the value on the options string for the choice. |
| 22 | + /// </summary> |
| 23 | + public string Value { get; set; } |
| 24 | + } |
| 25 | + |
| 26 | + public static class AdvancedChoices |
| 27 | + { |
| 28 | + private static List<AdvancedChoice> referenceFrames; |
| 29 | + private static List<AdvancedChoice> bFrames; |
| 30 | + private static List<AdvancedChoice> adaptiveBFrames; |
| 31 | + private static List<AdvancedChoice> directPrediction; |
| 32 | + private static List<AdvancedChoice> motionEstimationMethod; |
| 33 | + private static List<AdvancedChoice> subpixelMotionEstimation; |
| 34 | + private static List<AdvancedChoice> motionEstimationRange; |
| 35 | + private static List<AdvancedChoice> analysis; |
| 36 | + private static List<AdvancedChoice> trellis; |
| 37 | + private static List<AdvancedChoice> deblockingStrength; |
| 38 | + private static List<AdvancedChoice> deblockingThreshold; |
| 39 | + |
| 40 | + static AdvancedChoices() |
| 41 | + { |
| 42 | + referenceFrames = CreateNumberList(0, 16, defaultNumber: 3); |
| 43 | + bFrames = CreateNumberList(0, 16, defaultNumber: 3); |
| 44 | + |
| 45 | + adaptiveBFrames = new List<AdvancedChoice> |
| 46 | + { |
| 47 | + new AdvancedChoice { Label = "Off", Value = "0" }, |
| 48 | + new AdvancedChoice { Label = "Fast (Default)", Value = "1", IsDefault = true }, |
| 49 | + new AdvancedChoice { Label = "Optimal", Value = "2" } |
| 50 | + }; |
| 51 | + |
| 52 | + directPrediction = new List<AdvancedChoice> |
| 53 | + { |
| 54 | + new AdvancedChoice { Label = "None", Value = "none" }, |
| 55 | + new AdvancedChoice { Label = "Spatial (Default)", Value = "spatial", IsDefault = true }, |
| 56 | + new AdvancedChoice { Label = "Temporal", Value = "temporal" }, |
| 57 | + new AdvancedChoice { Label = "Automatic", Value = "auto" } |
| 58 | + }; |
| 59 | + |
| 60 | + motionEstimationMethod = new List<AdvancedChoice> |
| 61 | + { |
| 62 | + new AdvancedChoice { Label = "Diamond", Value = "dia" }, |
| 63 | + new AdvancedChoice { Label = "Hexagon (Default)", Value = "hex", IsDefault = true }, |
| 64 | + new AdvancedChoice { Label = "Uneven Multi-Hexagon", Value = "umh" }, |
| 65 | + new AdvancedChoice { Label = "Exhaustive", Value = "esa" }, |
| 66 | + new AdvancedChoice { Label = "Transformed Exhaustive", Value = "tesa" }, |
| 67 | + }; |
| 68 | + |
| 69 | + subpixelMotionEstimation = CreateNumberList(0, 9, defaultNumber: 7); |
| 70 | + motionEstimationRange = CreateNumberList(4, 64, defaultNumber: 16); |
| 71 | + |
| 72 | + analysis = new List<AdvancedChoice> |
| 73 | + { |
| 74 | + new AdvancedChoice { Label = "None", Value = "none" }, |
| 75 | + new AdvancedChoice { Label = "Some (Default)", IsDefault = true }, |
| 76 | + new AdvancedChoice { Label = "All", Value = "all" } |
| 77 | + }; |
| 78 | + |
| 79 | + trellis = CreateNumberList(0, 2, defaultNumber: 1); |
| 80 | + deblockingStrength = CreateNumberList(-6, 6, defaultNumber: 0); |
| 81 | + deblockingThreshold = CreateNumberList(-6, 6, defaultNumber: 0); |
| 82 | + } |
| 83 | + |
| 84 | + #region Properties |
| 85 | + public static List<AdvancedChoice> ReferenceFrames |
| 86 | + { |
| 87 | + get |
| 88 | + { |
| 89 | + return referenceFrames; |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + public static List<AdvancedChoice> BFrames |
| 94 | + { |
| 95 | + get |
| 96 | + { |
| 97 | + return bFrames; |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + public static List<AdvancedChoice> AdaptiveBFrames |
| 102 | + { |
| 103 | + get |
| 104 | + { |
| 105 | + return adaptiveBFrames; |
| 106 | + } |
| 107 | + } |
| 108 | + |
| 109 | + public static List<AdvancedChoice> DirectPrediction |
| 110 | + { |
| 111 | + get |
| 112 | + { |
| 113 | + return directPrediction; |
| 114 | + } |
| 115 | + } |
| 116 | + |
| 117 | + public static List<AdvancedChoice> MotionEstimationMethod |
| 118 | + { |
| 119 | + get |
| 120 | + { |
| 121 | + return motionEstimationMethod; |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + public static List<AdvancedChoice> SubpixelMotionEstimation |
| 126 | + { |
| 127 | + get |
| 128 | + { |
| 129 | + return subpixelMotionEstimation; |
| 130 | + } |
| 131 | + } |
| 132 | + |
| 133 | + public static List<AdvancedChoice> MotionEstimationRange |
| 134 | + { |
| 135 | + get |
| 136 | + { |
| 137 | + return motionEstimationRange; |
| 138 | + } |
| 139 | + } |
| 140 | + |
| 141 | + public static List<AdvancedChoice> Analysis |
| 142 | + { |
| 143 | + get |
| 144 | + { |
| 145 | + return analysis; |
| 146 | + } |
| 147 | + } |
| 148 | + |
| 149 | + public static List<AdvancedChoice> Trellis |
| 150 | + { |
| 151 | + get |
| 152 | + { |
| 153 | + return trellis; |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + public static List<AdvancedChoice> DeblockingStrength |
| 158 | + { |
| 159 | + get |
| 160 | + { |
| 161 | + return deblockingStrength; |
| 162 | + } |
| 163 | + } |
| 164 | + |
| 165 | + public static List<AdvancedChoice> DeblockingThreshold |
| 166 | + { |
| 167 | + get |
| 168 | + { |
| 169 | + return deblockingThreshold; |
| 170 | + } |
| 171 | + } |
| 172 | + #endregion |
| 173 | + |
| 174 | + private static List<AdvancedChoice> CreateNumberList(int lower, int upper, int defaultNumber) |
| 175 | + { |
| 176 | + var list = new List<AdvancedChoice>(); |
| 177 | + AddRange(list, lower, upper, defaultNumber); |
| 178 | + |
| 179 | + return list; |
| 180 | + } |
| 181 | + |
| 182 | + private static void AddRange(List<AdvancedChoice> list, int lower, int upper, int defaultNumber) |
| 183 | + { |
| 184 | + for (int i = lower; i <= upper; i++) |
| 185 | + { |
| 186 | + if (i == defaultNumber) |
| 187 | + { |
| 188 | + list.Add(new AdvancedChoice |
| 189 | + { |
| 190 | + IsDefault = true, |
| 191 | + Label = i.ToString() + " (Default)", |
| 192 | + Value = i.ToString() |
| 193 | + }); |
| 194 | + } |
| 195 | + else |
| 196 | + { |
| 197 | + list.Add(new AdvancedChoice |
| 198 | + { |
| 199 | + Label = i.ToString(), |
| 200 | + Value = i.ToString() |
| 201 | + }); |
| 202 | + } |
| 203 | + } |
| 204 | + } |
| 205 | + } |
| 206 | +} |
0 commit comments