summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/Helpers/AdvancedChoicesHelper.cs
blob: 8c521d9e7add27c0b9e8df908bb8d52ba78bba17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="AdvancedChoicesHelper.cs" company="HandBrake Project (http://handbrake.fr)">
//   This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License.
// </copyright>
// <summary>
//   The advanced choices.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace HandBrakeWPF.Helpers
{
    using System.Collections.Generic;
    using System.Globalization;

    using HandBrakeWPF.Model;

    /// <summary>
    /// The advanced choices.
    /// </summary>
    public static class AdvancedChoicesHelper
    {
        #region Constants and Fields

        /// <summary>
        /// The adaptive b frames.
        /// </summary>
        private static List<AdvancedChoice> adaptiveBFrames;

        /// <summary>
        /// The analysis.
        /// </summary>
        private static List<AdvancedChoice> analysis;

        /// <summary>
        /// The b frames.
        /// </summary>
        private static List<AdvancedChoice> bFrames;

        /// <summary>
        /// The deblocking strength.
        /// </summary>
        private static List<AdvancedChoice> deblockingStrength;

        /// <summary>
        /// The deblocking threshold.
        /// </summary>
        private static List<AdvancedChoice> deblockingThreshold;

        /// <summary>
        /// The direct prediction.
        /// </summary>
        private static List<AdvancedChoice> directPrediction;

        /// <summary>
        /// The motion estimation method.
        /// </summary>
        private static List<AdvancedChoice> motionEstimationMethod;

        /// <summary>
        /// The motion estimation range.
        /// </summary>
        private static List<AdvancedChoice> motionEstimationRange;

        /// <summary>
        /// The pyramidal b frames.
        /// </summary>
        private static List<AdvancedChoice> pyramidalBFrames;

        /// <summary>
        /// The reference frames.
        /// </summary>
        private static List<AdvancedChoice> referenceFrames;

        /// <summary>
        /// The subpixel motion estimation.
        /// </summary>
        private static List<AdvancedChoice> subpixelMotionEstimation;

        /// <summary>
        /// The trellis.
        /// </summary>
        private static List<AdvancedChoice> trellis;

        #endregion

        #region Constructors and Destructors

        /// <summary>
        /// Initializes static members of the <see cref="AdvancedChoicesHelper"/> class.
        /// </summary>
        static AdvancedChoicesHelper()
        {
            referenceFrames = CreateNumberList(0, 16, defaultNumber: 3);
            bFrames = CreateNumberList(0, 16, defaultNumber: 3);

            pyramidalBFrames = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "Off", Value = "none" },
                    new AdvancedChoice { Label = "Normal (Default)", IsDefault = true },
                    new AdvancedChoice { Label = "Strict", Value = "strict" }
                };

            adaptiveBFrames = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "Off", Value = "0" },
                    new AdvancedChoice { Label = "Fast (Default)", Value = "1", IsDefault = true },
                    new AdvancedChoice { Label = "Optimal", Value = "2" }
                };

            directPrediction = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "None", Value = "none" },
                    new AdvancedChoice { Label = "Spatial (Default)", Value = "spatial", IsDefault = true },
                    new AdvancedChoice { Label = "Temporal", Value = "temporal" },
                    new AdvancedChoice { Label = "Automatic", Value = "auto" }
                };

            motionEstimationMethod = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "Diamond", Value = "dia" },
                    new AdvancedChoice { Label = "Hexagon (Default)", Value = "hex", IsDefault = true },
                    new AdvancedChoice { Label = "Uneven Multi-Hexagon", Value = "umh" },
                    new AdvancedChoice { Label = "Exhaustive", Value = "esa" },
                    new AdvancedChoice { Label = "Transformed Exhaustive", Value = "tesa" },
                };

            subpixelMotionEstimation = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "0: SAD, no subpel (super fast!)", Value = "0" },
                    new AdvancedChoice { Label = "1: SAD, qpel", Value = "1" },
                    new AdvancedChoice { Label = "2: SATD, qpel", Value = "2" },
                    new AdvancedChoice { Label = "3: SATD, multi-qpel", Value = "3" },
                    new AdvancedChoice { Label = "4: SATD, qpel on all", Value = "4" },
                    new AdvancedChoice { Label = "5: SATD, multi-qpel on all", Value = "5" },
                    new AdvancedChoice { Label = "6: RD in I/P-frames", Value = "6" },
                    new AdvancedChoice { Label = "7: RD in all frames (Default)", Value = "7", IsDefault = true },
                    new AdvancedChoice { Label = "8: RD refine in I/P-frames", Value = "8" },
                    new AdvancedChoice { Label = "9: RD refine in all frames", Value = "9" },
                    new AdvancedChoice { Label = "10: QPRD in all frames", Value = "10" },
                    new AdvancedChoice { Label = "11: No early terminations in analysis", Value = "11" },
                };

            // subpixelMotionEstimation = CreateNumberList(0, 9, defaultNumber: 7);
            motionEstimationRange = CreateNumberList(4, 64, defaultNumber: 16);

            analysis = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "None", Value = "none" },
                    new AdvancedChoice { Label = "Some (Default)", IsDefault = true },
                    new AdvancedChoice { Label = "All", Value = "all" }
                };

            trellis = new List<AdvancedChoice>
                {
                    new AdvancedChoice { Label = "Off", Value = "0" },
                    new AdvancedChoice { Label = "Encode Only (Default)", Value = "1", IsDefault = true },
                    new AdvancedChoice { Label = "Always", Value = "2" }
                };

            deblockingStrength = CreateNumberList(-6, 6, defaultNumber: 0);
            deblockingThreshold = CreateNumberList(-6, 6, defaultNumber: 0);
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets AdaptiveBFrames.
        /// </summary>
        public static List<AdvancedChoice> AdaptiveBFrames
        {
            get
            {
                return adaptiveBFrames;
            }
        }

        /// <summary>
        /// Gets Analysis.
        /// </summary>
        public static List<AdvancedChoice> Analysis
        {
            get
            {
                return analysis;
            }
        }

        /// <summary>
        /// Gets BFrames.
        /// </summary>
        public static List<AdvancedChoice> BFrames
        {
            get
            {
                return bFrames;
            }
        }

        /// <summary>
        /// Gets DeblockingStrength.
        /// </summary>
        public static List<AdvancedChoice> DeblockingStrength
        {
            get
            {
                return deblockingStrength;
            }
        }

        /// <summary>
        /// Gets DeblockingThreshold.
        /// </summary>
        public static List<AdvancedChoice> DeblockingThreshold
        {
            get
            {
                return deblockingThreshold;
            }
        }

        /// <summary>
        /// Gets DirectPrediction.
        /// </summary>
        public static List<AdvancedChoice> DirectPrediction
        {
            get
            {
                return directPrediction;
            }
        }

        /// <summary>
        /// Gets MotionEstimationMethod.
        /// </summary>
        public static List<AdvancedChoice> MotionEstimationMethod
        {
            get
            {
                return motionEstimationMethod;
            }
        }

        /// <summary>
        /// Gets MotionEstimationRange.
        /// </summary>
        public static List<AdvancedChoice> MotionEstimationRange
        {
            get
            {
                return motionEstimationRange;
            }
        }

        /// <summary>
        /// Gets PyramidalBFrames.
        /// </summary>
        public static List<AdvancedChoice> PyramidalBFrames
        {
            get
            {
                return pyramidalBFrames;
            }
        }

        /// <summary>
        /// Gets ReferenceFrames.
        /// </summary>
        public static List<AdvancedChoice> ReferenceFrames
        {
            get
            {
                return referenceFrames;
            }
        }

        /// <summary>
        /// Gets SubpixelMotionEstimation.
        /// </summary>
        public static List<AdvancedChoice> SubpixelMotionEstimation
        {
            get
            {
                return subpixelMotionEstimation;
            }
        }

        /// <summary>
        /// Gets Trellis.
        /// </summary>
        public static List<AdvancedChoice> Trellis
        {
            get
            {
                return trellis;
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// The add range.
        /// </summary>
        /// <param name="list">
        /// The list.
        /// </param>
        /// <param name="lower">
        /// The lower.
        /// </param>
        /// <param name="upper">
        /// The upper.
        /// </param>
        /// <param name="defaultNumber">
        /// The default number.
        /// </param>
        private static void AddRange(List<AdvancedChoice> list, int lower, int upper, int defaultNumber)
        {
            for (int i = lower; i <= upper; i++)
            {
                if (i == defaultNumber)
                {
                    list.Add(
                        new AdvancedChoice
                            {
                                IsDefault = true, 
                                Label = i.ToString() + " (Default)", 
                                Value = i.ToString(CultureInfo.InvariantCulture)
                            });
                }
                else
                {
                    list.Add(
                        new AdvancedChoice { Label = i.ToString(), Value = i.ToString(CultureInfo.InvariantCulture) });
                }
            }
        }

        /// <summary>
        /// The create number list.
        /// </summary>
        /// <param name="lower">
        /// The lower.
        /// </param>
        /// <param name="upper">
        /// The upper.
        /// </param>
        /// <param name="defaultNumber">
        /// The default number.
        /// </param>
        /// <returns>
        /// </returns>
        private static List<AdvancedChoice> CreateNumberList(int lower, int upper, int defaultNumber)
        {
            var list = new List<AdvancedChoice>();
            AddRange(list, lower, upper, defaultNumber);

            return list;
        }

        #endregion
    }
}