OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / HandBrake.ApplicationServices / Utilities / QueryParserUtility.cs
1 /*  QueryParser.cs $\r
2     This file is part of the HandBrake source code.\r
3     Homepage: <http://handbrake.fr>.\r
4     It may be used under the terms of the GNU General Public License. */\r
5 \r
6 namespace HandBrake.ApplicationServices.Utilities\r
7 {\r
8     using System;\r
9     using System.Collections;\r
10     using System.Globalization;\r
11     using System.Text.RegularExpressions;\r
12 \r
13     using HandBrake.ApplicationServices.Functions;\r
14     using HandBrake.ApplicationServices.Model.Encoding;\r
15 \r
16     /// <summary>\r
17     /// Parse a CLI Query\r
18     /// </summary>\r
19     public class QueryParserUtility\r
20     {\r
21         /// <summary>\r
22         /// The Culture\r
23         /// </summary>\r
24         private static readonly CultureInfo Culture = new CultureInfo("en-US", false);\r
25 \r
26         #region Varibles\r
27 \r
28         #region Source Title / Chapters\r
29         /// <summary>\r
30         /// Gets or sets Title.\r
31         /// </summary>\r
32         public int Title { get; set; }\r
33 \r
34         /// <summary>\r
35         /// Gets or sets ChapterStart.\r
36         /// </summary>\r
37         public int ChapterStart { get; set; }\r
38 \r
39         /// <summary>\r
40         /// Gets or sets ChapterFinish.\r
41         /// </summary>\r
42         public int ChapterFinish { get; set; }\r
43         #endregion\r
44 \r
45         #region Output Settings\r
46         /// <summary>\r
47         /// Gets or sets the file Format. e.g mkv or mp4\r
48         /// </summary>\r
49         public string Format { get; set; }\r
50 \r
51         /// <summary>\r
52         /// Gets or sets a value indicating whether LargeMP4 support is enabled.\r
53         /// This is the 64bit MP4 file that allows >4GB files\r
54         /// </summary>\r
55         public bool LargeMP4 { get; set; }\r
56 \r
57         /// <summary>\r
58         /// Gets or sets a value indicating whether IpodAtom is inserted\r
59         /// </summary>\r
60         public bool IpodAtom { get; set; }\r
61 \r
62         /// <summary>\r
63         /// Gets or sets a value indicating whether OptimizeMP4 is enabed for web streaming\r
64         /// </summary>\r
65         public bool OptimizeMP4 { get; set; }\r
66         #endregion\r
67 \r
68         #region Picture Settings\r
69 \r
70         /// <summary>\r
71         /// Gets or sets Width.\r
72         /// </summary>\r
73         public int Width { get; set; }\r
74 \r
75         /// <summary>\r
76         /// Gets or sets Height.\r
77         /// </summary>\r
78         public int Height { get; set; }\r
79 \r
80         /// <summary>\r
81         /// Gets or sets MaxWidth.\r
82         /// </summary>\r
83         public int MaxWidth { get; set; }\r
84 \r
85         /// <summary>\r
86         /// Gets or sets MaxHeight.\r
87         /// </summary>\r
88         public int MaxHeight { get; set; }\r
89 \r
90         /// <summary>\r
91         /// Gets or sets CropValues.\r
92         /// </summary>\r
93         public string CropValues { get; set; }\r
94 \r
95         /// <summary>\r
96         /// Gets or sets CropTop.\r
97         /// </summary>\r
98         public string CropTop { get; set; }\r
99 \r
100         /// <summary>\r
101         /// Gets or sets CropBottom.\r
102         /// </summary>\r
103         public string CropBottom { get; set; }\r
104 \r
105         /// <summary>\r
106         /// Gets or sets CropLeft.\r
107         /// </summary>\r
108         public string CropLeft { get; set; }\r
109 \r
110         /// <summary>\r
111         /// Gets or sets CropRight.\r
112         /// </summary>\r
113         public string CropRight { get; set; }\r
114 \r
115         /// <summary>\r
116         /// Gets or sets AnamorphicMode.\r
117         /// </summary>\r
118         public int AnamorphicMode { get; set; }\r
119 \r
120         /// <summary>\r
121         /// Gets or sets a value indicating whether KeepDisplayAsect.\r
122         /// </summary>\r
123         public bool KeepDisplayAsect { get; set; }\r
124 \r
125         /// <summary>\r
126         /// Gets or sets DisplayWidthValue.\r
127         /// </summary>\r
128         public double DisplayWidthValue { get; set; }\r
129 \r
130         /// <summary>\r
131         /// Gets or sets PixelAspectWidth.\r
132         /// </summary>\r
133         public int PixelAspectWidth { get; set; }\r
134 \r
135         /// <summary>\r
136         /// Gets or sets PixelAspectHeight.\r
137         /// </summary>\r
138         public int PixelAspectHeight { get; set; }\r
139 \r
140         /// <summary>\r
141         /// Gets or sets AnamorphicModulus.\r
142         /// </summary>\r
143         public int AnamorphicModulus { get; set; }\r
144         #endregion\r
145 \r
146         #region Video Filters\r
147 \r
148         /// <summary>\r
149         /// Gets or sets DeTelecine.\r
150         /// </summary>\r
151         public string DeTelecine { get; set; }\r
152 \r
153         /// <summary>\r
154         /// Gets or sets DeBlock.\r
155         /// </summary>\r
156         public int DeBlock { get; set; }\r
157 \r
158         /// <summary>\r
159         /// Gets or sets DeInterlace.\r
160         /// </summary>\r
161         public string DeInterlace { get; set; }\r
162 \r
163         /// <summary>\r
164         /// Gets or sets DeNoise.\r
165         /// </summary>\r
166         public string DeNoise { get; set; }\r
167 \r
168         /// <summary>\r
169         /// Gets or sets Decomb.\r
170         /// </summary>\r
171         public string Decomb { get; set; }\r
172         #endregion\r
173 \r
174         #region Video Settings\r
175         /// <summary>\r
176         /// Gets or sets VideoEncoder.\r
177         /// </summary>\r
178         public string VideoEncoder { get; set; }\r
179 \r
180         /// <summary>\r
181         /// Gets or sets a value indicating whether Grayscale.\r
182         /// </summary>\r
183         public bool Grayscale { get; set; }\r
184 \r
185         /// <summary>\r
186         /// Gets or sets a value indicating whether TwoPass.\r
187         /// </summary>\r
188         public bool TwoPass { get; set; }\r
189 \r
190         /// <summary>\r
191         /// Gets or sets a value indicating whether TurboFirstPass.\r
192         /// </summary>\r
193         public bool TurboFirstPass { get; set; }\r
194 \r
195         /// <summary>\r
196         /// Gets or sets VideoFramerate.\r
197         /// </summary>\r
198         public string VideoFramerate { get; set; }\r
199 \r
200         /// <summary>\r
201         /// Gets or sets a value indicating whether Pfr.\r
202         /// </summary>\r
203         public bool Pfr { get; set; }\r
204 \r
205         /// <summary>\r
206         /// Gets or sets AverageVideoBitrate.\r
207         /// </summary>\r
208         public string AverageVideoBitrate { get; set; }\r
209 \r
210         /// <summary>\r
211         /// Gets or sets VideoTargetSize.\r
212         /// </summary>\r
213         public string VideoTargetSize { get; set; }\r
214 \r
215         /// <summary>\r
216         /// Gets or sets VideoQuality.\r
217         /// </summary>\r
218         public float VideoQuality { get; set; }\r
219         #endregion\r
220 \r
221         #region Audio Settings\r
222 \r
223         /// <summary>\r
224         /// Gets or sets AudioInformation.\r
225         /// </summary>\r
226         public ArrayList AudioInformation { get; set; }\r
227 \r
228         /// <summary>\r
229         /// Gets or sets Subtitles.\r
230         /// </summary>\r
231         public string Subtitles { get; set; }\r
232 \r
233         /// <summary>\r
234         /// Gets or sets a value indicating whether ForcedSubtitles.\r
235         /// </summary>\r
236         public bool ForcedSubtitles { get; set; }\r
237         #endregion\r
238 \r
239         #region Other\r
240         /// <summary>\r
241         /// Gets or sets a value indicating whether ChapterMarkers.\r
242         /// </summary>\r
243         public bool ChapterMarkers { get; set; }\r
244 \r
245         /// <summary>\r
246         /// Gets or sets H264Query.\r
247         /// </summary>\r
248         public string H264Query { get; set; }\r
249 \r
250         /// <summary>\r
251         /// Gets or sets a value indicating whether Verbose.\r
252         /// </summary>\r
253         public bool Verbose { get; set; }\r
254         #endregion\r
255 \r
256         #region Preset Information\r
257 \r
258         /// <summary>\r
259         /// Gets or sets PresetBuildNumber.\r
260         /// </summary>\r
261         public int PresetBuildNumber { get; set; }\r
262 \r
263         /// <summary>\r
264         /// Gets or sets PresetDescription.\r
265         /// </summary>\r
266         public string PresetDescription { get; set; }\r
267 \r
268         /// <summary>\r
269         /// Gets or sets PresetName.\r
270         /// </summary>\r
271         public string PresetName { get; set; }\r
272 \r
273         /// <summary>\r
274         /// Gets or sets Type.\r
275         /// </summary>\r
276         public string Type { get; set; }\r
277 \r
278         /// <summary>\r
279         /// Gets or sets a value indicating whether UsesMaxPictureSettings.\r
280         /// </summary>\r
281         public bool UsesMaxPictureSettings { get; set; }\r
282 \r
283         /// <summary>\r
284         /// Gets or sets a value indicating whether UsesPictureFilters.\r
285         /// </summary>\r
286         public bool UsesPictureFilters { get; set; }\r
287 \r
288         /// <summary>\r
289         /// Gets or sets a value indicating whether UsesPictureSettings.\r
290         /// </summary>\r
291         public bool UsesPictureSettings { get; set; }\r
292         #endregion\r
293 \r
294         #endregion\r
295 \r
296         /// <summary>\r
297         /// Takes in a query which can be in any order and parses it. \r
298         /// All varibles are then set so they can be used elsewhere.\r
299         /// </summary>\r
300         /// <param name="input">A ClI Query</param>\r
301         /// <returns>A Parsed Query</returns>\r
302         public static QueryParserUtility Parse(string input)\r
303         {\r
304             var thisQuery = new QueryParserUtility();\r
305 \r
306             #region Regular Expressions\r
307 \r
308             // Source\r
309             Match title = Regex.Match(input, @"-t ([0-9]*)");\r
310             Match chapters = Regex.Match(input, @"-c ([0-9-]*)");\r
311 \r
312             // Output Settings\r
313             Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
314             Match grayscale = Regex.Match(input, @" -g");\r
315             Match largerMp4 = Regex.Match(input, @" -4");\r
316             Match ipodAtom = Regex.Match(input, @" -I");\r
317 \r
318             // Picture Settings Tab\r
319             Match width = Regex.Match(input, @"-w ([0-9]*)");\r
320             Match height = Regex.Match(input, @"-l ([0-9]*)");\r
321             Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");\r
322             Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");\r
323             Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");\r
324 \r
325             Match looseAnamorphic = Regex.Match(input, @"--loose-anamorphic");\r
326             Match strictAnamorphic = Regex.Match(input, @"--strict-anamorphic");\r
327             Match customAnamorphic = Regex.Match(input, @"--custom-anamorphic");\r
328 \r
329             Match keepDisplayAsect = Regex.Match(input, @"--keep-display-aspect");\r
330             Match displayWidth = Regex.Match(input, @"--display-width ([0-9]*)");\r
331             Match pixelAspect = Regex.Match(input, @"--pixel-aspect ([0-9]*):([0-9]*)");\r
332             Match modulus = Regex.Match(input, @"--modulus ([0-9]*)");\r
333 \r
334             // Picture Settings - Filters\r
335             Match decomb = Regex.Match(input, @" --decomb");\r
336             Match decombValue = Regex.Match(input, @" --decomb=\""([a-zA-Z0-9.:]*)\""");\r
337             Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z0-9.:]*)\""");\r
338             Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z0-9.:]*)\""");\r
339             Match deblock = Regex.Match(input, @"--deblock=([0-9:]*)");\r
340             Match detelecine = Regex.Match(input, @"--detelecine");\r
341             Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\""");\r
342 \r
343             // Video Settings Tab\r
344             Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
345             Match videoFramerate = Regex.Match(input, @"-r ([0-9.]*)");\r
346             Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");\r
347             Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");\r
348             Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");\r
349             Match twoPass = Regex.Match(input, @" -2");\r
350             Match turboFirstPass = Regex.Match(input, @" -T");\r
351             Match optimizeMP4 = Regex.Match(input, @" -O");\r
352             Match pfr = Regex.Match(input, @" --pfr");\r
353 \r
354             // Audio Settings Tab\r
355             Match noAudio = Regex.Match(input, @"-a none");\r
356             Match audioTracks = Regex.Match(input, @"-a ([0-9,]*)");\r
357             Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]*)");\r
358             Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,:]*)");\r
359             Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]*)"); // Auto = a-z\r
360             Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z\r
361             Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)");\r
362 \r
363             Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");\r
364             Match subScan = Regex.Match(input, @" -U");\r
365             Match forcedSubtitles = Regex.Match(input, @" -F");\r
366 \r
367             // Chapters Tab\r
368             Match chapterMarkers = Regex.Match(input, @" -m");\r
369             Match chapterMarkersFileMode = Regex.Match(input, @"--markers");\r
370 \r
371             // H264 Tab\r
372             Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");\r
373 \r
374             // Program Options\r
375             Match verbose = Regex.Match(input, @" -v");\r
376 \r
377             #endregion\r
378 \r
379             #region Set Varibles\r
380 \r
381             try\r
382             {\r
383                 #region Source Tab\r
384 \r
385                 if (title.Success)\r
386                     thisQuery.Title = int.Parse(title.ToString().Replace("-t ", string.Empty));\r
387 \r
388                 if (chapters.Success)\r
389                 {\r
390                     string[] actTitles = chapters.ToString().Replace("-c ", string.Empty).Split('-');\r
391                     thisQuery.ChapterStart = int.Parse(actTitles[0]);\r
392                     if (actTitles.Length > 1)\r
393                     {\r
394                         thisQuery.ChapterFinish = int.Parse(actTitles[1]);\r
395                     }\r
396 \r
397                     if ((thisQuery.ChapterStart == 1) && (thisQuery.ChapterFinish == 0))\r
398                         thisQuery.ChapterFinish = thisQuery.ChapterStart;\r
399                 }\r
400 \r
401                 #endregion\r
402 \r
403                 #region Output Settings\r
404 \r
405                 if (format.Success)\r
406                     thisQuery.Format = format.ToString().Replace("-f ", string.Empty);\r
407                 thisQuery.LargeMP4 = largerMp4.Success;\r
408                 thisQuery.IpodAtom = ipodAtom.Success;\r
409                 thisQuery.OptimizeMP4 = optimizeMP4.Success;\r
410 \r
411                 #endregion\r
412 \r
413                 #region Picture Tab\r
414 \r
415                 if (width.Success)\r
416                     thisQuery.Width = int.Parse(width.Groups[0].Value.Replace("-w ", string.Empty));\r
417 \r
418                 if (height.Success)\r
419                     thisQuery.Height = int.Parse(height.Groups[0].Value.Replace("-l ", string.Empty));\r
420 \r
421                 if (maxWidth.Success)\r
422                     thisQuery.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", string.Empty));\r
423 \r
424                 if (maxHeight.Success)\r
425                     thisQuery.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", string.Empty));\r
426 \r
427                 if (crop.Success)\r
428                 {\r
429                     thisQuery.CropValues = crop.ToString().Replace("--crop ", string.Empty);\r
430                     string[] actCropValues = thisQuery.CropValues.Split(':');\r
431                     thisQuery.CropTop = actCropValues[0];\r
432                     thisQuery.CropBottom = actCropValues[1];\r
433                     thisQuery.CropLeft = actCropValues[2];\r
434                     thisQuery.CropRight = actCropValues[3];\r
435                 }\r
436 \r
437                 if (strictAnamorphic.Success)\r
438                     thisQuery.AnamorphicMode = 1;\r
439                 else if (looseAnamorphic.Success)\r
440                     thisQuery.AnamorphicMode = 2;\r
441                 else if (customAnamorphic.Success)\r
442                     thisQuery.AnamorphicMode = 3;\r
443                 else\r
444                     thisQuery.AnamorphicMode = 0;\r
445 \r
446                 thisQuery.KeepDisplayAsect = keepDisplayAsect.Success;\r
447 \r
448                 if (displayWidth.Success)\r
449                     thisQuery.DisplayWidthValue =\r
450                         double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", string.Empty));\r
451 \r
452                 if (pixelAspect.Success)\r
453                     thisQuery.PixelAspectWidth = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", string.Empty));\r
454 \r
455                 if (pixelAspect.Success && pixelAspect.Groups.Count >= 3)\r
456                     thisQuery.PixelAspectHeight = int.Parse(pixelAspect.Groups[2].Value.Replace("--pixel-aspect ", string.Empty));\r
457 \r
458                 if (modulus.Success)\r
459                     thisQuery.AnamorphicModulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", string.Empty));\r
460 \r
461                 #endregion\r
462 \r
463                 #region Filters\r
464 \r
465                 thisQuery.Decomb = "Off";\r
466                 if (decomb.Success)\r
467                 {\r
468                     thisQuery.Decomb = "Default";\r
469                     if (decombValue.Success)\r
470                         thisQuery.Decomb = decombValue.ToString().Replace("--decomb=", string.Empty).Replace("\"", string.Empty);\r
471                 }\r
472 \r
473                 thisQuery.DeInterlace = "Off";\r
474                 if (deinterlace.Success)\r
475                 {\r
476                     thisQuery.DeInterlace = deinterlace.ToString().Replace("--deinterlace=", string.Empty).Replace("\"", string.Empty);\r
477                     thisQuery.DeInterlace =\r
478                         thisQuery.DeInterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");\r
479                     thisQuery.DeInterlace = thisQuery.DeInterlace.Replace("slowest", "Slowest");\r
480                 }\r
481 \r
482                 thisQuery.DeNoise = "Off";\r
483                 if (denoise.Success)\r
484                 {\r
485                     thisQuery.DeNoise = denoise.ToString().Replace("--denoise=", string.Empty).Replace("\"", string.Empty);\r
486                     thisQuery.DeNoise =\r
487                         thisQuery.DeNoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");\r
488                 }\r
489 \r
490                 string deblockValue = string.Empty;\r
491                 thisQuery.DeBlock = 0;\r
492                 if (deblock.Success)\r
493                     deblockValue = deblock.ToString().Replace("--deblock=", string.Empty);\r
494 \r
495                 int dval = 0;\r
496                 if (deblockValue != string.Empty)\r
497                     int.TryParse(deblockValue, out dval);\r
498                 thisQuery.DeBlock = dval;\r
499 \r
500                 thisQuery.DeTelecine = "Off";\r
501                 if (detelecine.Success)\r
502                 {\r
503                     thisQuery.DeTelecine = "Default";\r
504                     if (detelecineValue.Success)\r
505                         thisQuery.DeTelecine = detelecineValue.ToString().Replace("--detelecine=", string.Empty).Replace("\"", string.Empty);\r
506                 }\r
507 \r
508                 #endregion\r
509 \r
510                 #region Video Settings Tab\r
511 \r
512                 string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", string.Empty);\r
513                 switch (videoEncoderConvertion)\r
514                 {\r
515                     case "ffmpeg":\r
516                         videoEncoderConvertion = "MPEG-4 (FFmpeg)";\r
517                         break;\r
518                     case "x264":\r
519                         videoEncoderConvertion = "H.264 (x264)";\r
520                         break;\r
521                     case "theora":\r
522                         videoEncoderConvertion = "VP3 (Theora)";\r
523                         break;\r
524                     default:\r
525                         videoEncoderConvertion = "MPEG-4 (FFmpeg)";\r
526                         break;\r
527                 }\r
528                 thisQuery.VideoEncoder = videoEncoderConvertion;\r
529                 thisQuery.VideoFramerate = videoFramerate.Success\r
530                                                ? videoFramerate.ToString().Replace("-r ", string.Empty)\r
531                                                : "Same as source";\r
532 \r
533                 thisQuery.Pfr = pfr.Success;\r
534                 thisQuery.Grayscale = grayscale.Success;\r
535                 thisQuery.TwoPass = twoPass.Success;\r
536                 thisQuery.TurboFirstPass = turboFirstPass.Success;\r
537 \r
538                 if (videoBitrate.Success)\r
539                     thisQuery.AverageVideoBitrate = videoBitrate.ToString().Replace("-b ", string.Empty);\r
540                 if (videoFilesize.Success)\r
541                     thisQuery.VideoTargetSize = videoFilesize.ToString().Replace("-S ", string.Empty);\r
542 \r
543                 if (videoQuality.Success)\r
544                 {\r
545                     float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", string.Empty), Culture);\r
546                     thisQuery.VideoQuality = qConvert;\r
547                 }\r
548                 else\r
549                     thisQuery.VideoQuality = -1;\r
550 \r
551                 #endregion\r
552 \r
553                 #region Audio Tab\r
554 \r
555                 // Find out how many tracks we need to add by checking how many encoders or audio tracks are selected.\r
556                 int encoderCount = 0;\r
557                 if (audioEncoders.Success)\r
558                 {\r
559                     string[] audioDataCounters = audioEncoders.ToString().Replace("-E ", string.Empty).Split(',');\r
560                     encoderCount = audioDataCounters.Length;\r
561                 }\r
562 \r
563                 // Get the data from the regular expression results\r
564                 string[] trackData = null;\r
565                 string[] trackMixes = null;\r
566                 string[] trackEncoders = null;\r
567                 string[] trackBitrates = null;\r
568                 string[] trackSamplerates = null;\r
569                 string[] trackDRCvalues = null;\r
570 \r
571                 if (audioTracks.Success)\r
572                     trackData = audioTracks.ToString().Replace("-a ", string.Empty).Split(',');\r
573                 if (audioTrackMixes.Success)\r
574                     trackMixes = audioTrackMixes.ToString().Replace("-6 ", string.Empty).Split(',');\r
575                 if (audioEncoders.Success)\r
576                     trackEncoders = audioEncoders.ToString().Replace("-E ", string.Empty).Split(',');\r
577                 if (audioBitrates.Success)\r
578                     trackBitrates = audioBitrates.ToString().Replace("-B ", string.Empty).Split(',');\r
579                 if (audioSampleRates.Success)\r
580                     trackSamplerates = audioSampleRates.ToString().Replace("-R ", string.Empty).Split(',');\r
581                 if (drcValues.Success)\r
582                     trackDRCvalues = drcValues.ToString().Replace("-D ", string.Empty).Split(',');\r
583 \r
584                 // Create new Audio Track Classes and store them in the ArrayList\r
585                 ArrayList allAudioTrackInfo = new ArrayList();\r
586                 for (int x = 0; x < encoderCount; x++)\r
587                 {\r
588                     AudioTrack track = new AudioTrack();\r
589                     if (trackData != null)\r
590                         if (trackData.Length >= (x + 1)) // Audio Track\r
591                             track.Track = trackData[x].Trim();\r
592 \r
593                     if (trackMixes != null)\r
594                         if (trackMixes.Length >= (x + 1)) // Audio Mix\r
595                             track.MixDown = Converters.GetMixDown(trackMixes[x].Trim());\r
596 \r
597                     if (trackEncoders != null)\r
598                         if (trackEncoders.Length >= (x + 1)) // Audio Mix\r
599                             track.Encoder = Converters.GetAudioEncoder(trackEncoders[x].Trim());\r
600 \r
601                     if (trackBitrates != null)\r
602                         if (trackBitrates.Length >= (x + 1)) // Audio Encoder\r
603                             track.Bitrate = trackBitrates[x].Trim() == "auto" ? "Auto" : trackBitrates[x].Trim();\r
604 \r
605                     if (trackSamplerates != null)\r
606                         if (trackSamplerates.Length >= (x + 1)) // Audio SampleRate\r
607                             track.SampleRate = trackSamplerates[x].Trim() == "0" ? "Auto" : trackSamplerates[x].Trim();\r
608 \r
609                     if (trackDRCvalues != null)\r
610                         if (trackDRCvalues.Length >= (x + 1)) // Audio DRC Values\r
611                             track.DRC = trackDRCvalues[x].Trim();\r
612 \r
613                     allAudioTrackInfo.Add(track);\r
614                 }\r
615                 thisQuery.AudioInformation = allAudioTrackInfo;\r
616 \r
617                 // Subtitle Stuff\r
618                 if (subtitles.Success)\r
619                     thisQuery.Subtitles = subtitles.ToString().Replace("-s ", string.Empty);\r
620                 else\r
621                     thisQuery.Subtitles = subScan.Success ? "Autoselect" : "None";\r
622 \r
623                 thisQuery.ForcedSubtitles = forcedSubtitles.Success;\r
624 \r
625                 #endregion\r
626 \r
627                 #region Chapters Tab\r
628 \r
629                 if (chapterMarkersFileMode.Success || chapterMarkers.Success)\r
630                     thisQuery.ChapterMarkers = true;\r
631 \r
632                 #endregion\r
633 \r
634                 #region H.264 and other\r
635 \r
636                 if (x264.Success)\r
637                     thisQuery.H264Query = x264.ToString().Replace("-x ", string.Empty);\r
638 \r
639                 thisQuery.Verbose = verbose.Success;\r
640 \r
641                 #endregion\r
642             }\r
643             catch (Exception exc)\r
644             {\r
645                 throw new Exception("An error has occured in the QueryParser Utility.", exc);\r
646             }\r
647 \r
648             #endregion\r
649 \r
650             return thisQuery;\r
651         }\r
652     }\r
653 }