OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / QueryParser.cs
1 /*  QueryParser.cs $\r
2         \r
3            This file is part of the HandBrake source code.\r
4            Homepage: <http://handbrake.m0k.org/>.\r
5            It may be used under the terms of the GNU General Public License. */\r
6 \r
7 using System;\r
8 using System.Collections.Generic;\r
9 using System.Text;\r
10 using System.Text.RegularExpressions;\r
11 using System.Windows.Forms;\r
12 \r
13 namespace Handbrake.Functions\r
14 {\r
15     class QueryParser\r
16     {\r
17 \r
18         // All the Main Window GUI options\r
19         #region Varibles\r
20 \r
21         #region Source\r
22         private string q_source;\r
23         /// <summary>\r
24         /// Returns a String \r
25         /// Full path of the source.\r
26         /// </summary>\r
27         public string Source\r
28         {\r
29             get\r
30             {\r
31                 return this.q_source;\r
32             }\r
33         }\r
34         private int q_dvdTitle;\r
35         /// <summary>\r
36         /// Returns an Integer\r
37         /// DVD Title number.\r
38         /// </summary>\r
39         public int DVDTitle\r
40         {\r
41             get\r
42             {\r
43                 return this.q_dvdTitle;\r
44             }\r
45         }\r
46 \r
47         private int q_chaptersStart;\r
48         /// <summary>\r
49         /// Returns an Int\r
50         /// DVD Chapter number or chapter range.\r
51         /// </summary>\r
52         public int DVDChapterStart\r
53         {\r
54             get\r
55             {\r
56                 return this.q_chaptersStart;\r
57             }\r
58         }\r
59 \r
60         private int q_chaptersFinish;\r
61         /// <summary>\r
62         /// Returns an Int\r
63         /// DVD Chapter number or chapter range.\r
64         /// </summary>\r
65         public int DVDChapterFinish\r
66         {\r
67             get\r
68             {\r
69                 return this.q_chaptersFinish;\r
70             }\r
71         }\r
72 #endregion\r
73 \r
74         #region Destination\r
75 \r
76         private string q_destination;\r
77         /// <summary>\r
78         /// Returns a String \r
79         /// Full path of the destination.\r
80         /// </summary>\r
81         public string Destination\r
82         {\r
83             get\r
84             {\r
85                 return this.q_destination;\r
86             }\r
87         }\r
88 \r
89         private string q_format;\r
90         /// <summary>\r
91         /// Returns a String \r
92         /// Full path of the destination.\r
93         /// </summary>\r
94         public string Format\r
95         {\r
96             get\r
97             {\r
98                 return this.q_format;\r
99             }\r
100         }\r
101 \r
102         private string q_videoEncoder;\r
103         /// <summary>\r
104         /// Returns an String\r
105         /// The Video Encoder used.\r
106         /// </summary>\r
107         public string VideoEncoder\r
108         {\r
109             get\r
110             {\r
111                 return this.q_videoEncoder;\r
112             }\r
113         }\r
114 \r
115         private string q_audioEncoder;\r
116         /// <summary>\r
117         /// Returns an String\r
118         /// The Audio Encoder used.\r
119         /// </summary>\r
120         public string AudioEncoder\r
121         {\r
122             get\r
123             {\r
124                 return this.q_audioEncoder;\r
125             }\r
126         }\r
127 #endregion\r
128 \r
129         #region Picture Settings\r
130         private int q_videoWidth;\r
131         /// <summary>\r
132         /// Returns an Int\r
133         /// The selected Width for the encoding.\r
134         /// </summary>\r
135         public int Width\r
136         {\r
137             get\r
138             {\r
139                 return this.q_videoWidth;\r
140             }\r
141         }\r
142 \r
143         private int q_videoHeight;\r
144         /// <summary>\r
145         /// Returns an Int\r
146         /// The selected Height for the encoding.\r
147         /// </summary>\r
148         public int Height\r
149         {\r
150             get\r
151             {\r
152                 return this.q_videoHeight;\r
153             }\r
154         }\r
155 \r
156         private string q_cropValues;\r
157         /// <summary>\r
158         /// Returns an String\r
159         /// Cropping values.\r
160         /// </summary>\r
161         public string CropValues\r
162         {\r
163             get\r
164             {\r
165                 return this.q_cropValues;\r
166             }\r
167         }\r
168 \r
169         private string q_croptop;\r
170         /// <summary>\r
171         /// Returns an String\r
172         /// Cropping values.\r
173         /// </summary>\r
174         public string CropTop\r
175         {\r
176             get\r
177             {\r
178                 return this.q_croptop;\r
179             }\r
180         }\r
181 \r
182         private string q_cropbottom;\r
183         /// <summary>\r
184         /// Returns an String\r
185         /// Cropping values.\r
186         /// </summary>\r
187         public string CropBottom\r
188         {\r
189             get\r
190             {\r
191                 return this.q_cropbottom;\r
192             }\r
193         }\r
194 \r
195         private string q_cropLeft;\r
196         /// <summary>\r
197         /// Returns an String\r
198         /// Cropping values.\r
199         /// </summary>\r
200         public string CropLeft\r
201         {\r
202             get\r
203             {\r
204                 return this.q_cropLeft;\r
205             }\r
206         }\r
207 \r
208         private string q_cropRight;\r
209         /// <summary>\r
210         /// Returns an String\r
211         /// Cropping values.\r
212         /// </summary>\r
213         public string CropRight\r
214         {\r
215             get\r
216             {\r
217                 return this.q_cropRight;\r
218             }\r
219         }\r
220 \r
221         private Boolean q_detelecine;\r
222         /// <summary>\r
223         /// Returns a boolean to indicate wither DeTelecine is on or off\r
224         /// </summary>\r
225         public Boolean DeTelecine\r
226         {\r
227             get\r
228             {\r
229                 return this.q_detelecine;\r
230             }\r
231         }\r
232 \r
233         private Boolean q_vfr;\r
234         /// <summary>\r
235         /// Returns a boolean to indicate wither DeTelecine is on or off\r
236         /// </summary>\r
237         public Boolean VFR\r
238         {\r
239             get\r
240             {\r
241                 return this.q_vfr;\r
242             }\r
243         }\r
244 \r
245         private Boolean q_deBlock;\r
246         /// <summary>\r
247         /// Returns a boolean to indicate wither DeBlock is on or off.\r
248         /// </summary>\r
249         public Boolean DeBlock\r
250         {\r
251             get\r
252             {\r
253                 return this.q_deBlock;\r
254             }\r
255         }\r
256 \r
257         private string q_deinterlace;\r
258         /// <summary>\r
259         /// Returns a string with the De-Interlace option used.\r
260         /// </summary>\r
261         public string DeInterlace\r
262         {\r
263             get\r
264             {\r
265                 return this.q_deinterlace;\r
266             }\r
267         }\r
268 \r
269         private string q_denoise;\r
270         /// <summary>\r
271         /// Returns a string with the DeNoise option used.\r
272         /// </summary>\r
273         public string DeNoise\r
274         {\r
275             get\r
276             {\r
277                 return this.q_denoise;\r
278             }\r
279         }\r
280 \r
281         private Boolean q_anamorphic;\r
282         /// <summary>\r
283         /// Returns a boolean to indicate wither Anamorphic is on or off.\r
284         /// </summary>\r
285         public Boolean Anamorphic\r
286         {\r
287             get\r
288             {\r
289                 return this.q_anamorphic;\r
290             }\r
291         }\r
292 \r
293         private Boolean q_looseAnamorphic;\r
294         /// <summary>\r
295         /// Returns a boolean to indicate wither Anamorphic is on or off.\r
296         /// </summary>\r
297         public Boolean LooseAnamorphic\r
298         {\r
299             get\r
300             {\r
301                 return this.q_looseAnamorphic;\r
302             }\r
303         }\r
304 \r
305         private Boolean q_chapterMarkers;\r
306         /// <summary>\r
307         /// Returns a boolean to indicate wither Chapter Markers is on or off.\r
308         /// </summary>\r
309         public Boolean ChapterMarkers\r
310         {\r
311             get\r
312             {\r
313                 return this.q_chapterMarkers;\r
314             }\r
315         }\r
316         #endregion\r
317 \r
318         #region Video Settings\r
319         private Boolean q_grayscale;\r
320         /// <summary>\r
321         /// Returns a boolean to indicate wither Grayscale is on or off.\r
322         /// </summary>\r
323         public Boolean Grayscale\r
324         {\r
325             get\r
326             {\r
327                 return this.q_grayscale;\r
328             }\r
329         }\r
330 \r
331         private Boolean q_twoPass;\r
332         /// <summary>\r
333         /// Returns a boolean to indicate wither Two Pass Encoding is on or off.\r
334         /// </summary>\r
335         public Boolean TwoPass\r
336         {\r
337             get\r
338             {\r
339                 return this.q_twoPass;\r
340             }\r
341         }\r
342 \r
343         private Boolean q_turboFirst;\r
344         /// <summary>\r
345         /// Returns a boolean to indicate wither Chapter Markers is on or off.\r
346         /// </summary>\r
347         public Boolean TurboFirstPass\r
348         {\r
349             get\r
350             {\r
351                 return this.q_turboFirst;\r
352             }\r
353         }\r
354 \r
355         private Boolean q_largeMp4;\r
356         /// <summary>\r
357         /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
358         /// </summary>\r
359         public Boolean LargeMP4\r
360         {\r
361             get\r
362             {\r
363                 return this.q_largeMp4;\r
364             }\r
365         }\r
366 \r
367         private Boolean q_ipodAtom;\r
368         /// <summary>\r
369         /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
370         /// </summary>\r
371         public Boolean IpodAtom\r
372         {\r
373             get\r
374             {\r
375                 return this.q_ipodAtom;\r
376             }\r
377         }\r
378 \r
379         private Boolean q_optimizeMp4;\r
380         /// <summary>\r
381         /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
382         /// </summary>\r
383         public Boolean OptimizeMP4\r
384         {\r
385             get\r
386             {\r
387                 return this.q_optimizeMp4;\r
388             }\r
389         }\r
390 \r
391         private string q_videoFramerate;\r
392         /// <summary>\r
393         /// Returns a string with the video Framerate\r
394         /// </summary>\r
395         public string VideoFramerate\r
396         {\r
397             get\r
398             {\r
399                 return this.q_videoFramerate;\r
400             }\r
401         }\r
402 \r
403         private string q_avgBitrate;\r
404         /// <summary>\r
405         /// Returns a string with the average video bitrate\r
406         /// </summary>\r
407         public string AverageVideoBitrate\r
408         {\r
409             get\r
410             {\r
411                 return this.q_avgBitrate;\r
412             }\r
413         }\r
414 \r
415         private string q_videoTargetSize;\r
416         /// <summary>\r
417         /// Returns a string with the video target size\r
418         /// </summary>\r
419         public string VideoTargetSize\r
420         {\r
421             get\r
422             {\r
423                 return this.q_videoTargetSize;\r
424             }\r
425         }\r
426 \r
427         private int q_videoQuality;\r
428         /// <summary>\r
429         /// Returns a int with the video quality value\r
430         /// </summary>\r
431         public int VideoQuality\r
432         {\r
433             get\r
434             {\r
435                 return this.q_videoQuality;\r
436             }\r
437         }\r
438 \r
439         #endregion\r
440 \r
441         #region Audio Settings\r
442         private string q_audioBitrate;\r
443         /// <summary>\r
444         /// Returns a string with the audio bitrate\r
445         /// </summary>\r
446         public string AudioBitrate\r
447         {\r
448             get\r
449             {\r
450                 return this.q_audioBitrate;\r
451             }\r
452         }\r
453 \r
454         private string q_audioSamplerate;\r
455         /// <summary>\r
456         /// Returns a string with the audio sample rate\r
457         /// </summary>\r
458         public string AudioSampleBitrate\r
459         {\r
460             get\r
461             {\r
462                 return this.q_audioSamplerate;\r
463             }\r
464         }\r
465 \r
466         private string q_audioTrack1;\r
467         /// <summary>\r
468         /// Returns a string with the First selected Audio track\r
469         /// </summary>\r
470         public string AudioTrack1\r
471         {\r
472             get\r
473             {\r
474                 return this.q_audioTrack1;\r
475             }\r
476         }\r
477 \r
478         private string q_audioTrack2;\r
479         /// <summary>\r
480         /// Returns a string with the First selected Audio track\r
481         /// </summary>\r
482         public string AudioTrack2\r
483         {\r
484             get\r
485             {\r
486                 return this.q_audioTrack2;\r
487             }\r
488         }\r
489 \r
490         private string q_audioTrackMix;\r
491         /// <summary>\r
492         /// Returns a string with the First selected Audio track Mix\r
493         /// </summary>\r
494         public string AudioTrackMix\r
495         {\r
496             get\r
497             {\r
498                 return this.q_audioTrackMix;\r
499             }\r
500         }\r
501 \r
502         private double q_drc;\r
503         /// <summary>\r
504         /// Returns a string with the selected subtitle track\r
505         /// </summary>\r
506         public double DRC\r
507         {\r
508             get\r
509             {\r
510                 return this.q_drc;\r
511             }\r
512         }\r
513 \r
514 \r
515         private string q_subtitles;\r
516         /// <summary>\r
517         /// Returns a string with the selected subtitle track\r
518         /// </summary>\r
519         public string Subtitles\r
520         {\r
521             get\r
522             {\r
523                 return this.q_subtitles;\r
524             }\r
525         }\r
526 \r
527         private Boolean q_forcedSubs;\r
528         /// <summary>\r
529         /// Returns a string with the selected subtitle track\r
530         /// </summary>\r
531         public Boolean ForcedSubtitles\r
532         {\r
533             get\r
534             {\r
535                 return this.q_forcedSubs;\r
536             }\r
537         }\r
538 \r
539         #endregion\r
540 \r
541         #region Other\r
542         private string q_h264;\r
543         /// <summary>\r
544         /// Returns a string with the Advanced H264 query string\r
545         /// </summary>\r
546         public string H264Query\r
547         {\r
548             get\r
549             {\r
550                 return this.q_h264;\r
551             }\r
552         }\r
553         private Boolean q_verbose;\r
554         /// <summary>\r
555         /// Returns a string with the Advanced H264 query string\r
556         /// </summary>\r
557         public Boolean Verbose\r
558         {\r
559             get\r
560             {\r
561                 return this.q_verbose;\r
562             }\r
563         }\r
564         #endregion\r
565 \r
566         #endregion\r
567 \r
568         // Takes in a query which can be in any order and parses it. All varibles are then set so they can be used elsewhere.\r
569         public static QueryParser Parse(String input)\r
570         {\r
571             QueryParser thisQuery = new QueryParser();\r
572 \r
573             #region reg exp\r
574             //Source\r
575             Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9:\\\s\.]+)(?:\"")");\r
576             Match source = r1.Match(input.Replace('"', '\"'));\r
577             Match title = Regex.Match(input, @"-t ([0-9]*)");\r
578             Match chapters = Regex.Match(input, @"-c ([0-9-]*)");\r
579             Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
580 \r
581             //Destination\r
582             Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9:\\\s\.]+)(?:\"")");\r
583             Match destination = r2.Match(input.Replace('"', '\"'));\r
584             Match width = Regex.Match(input, @"-w ([0-9]*)");\r
585             Match height = Regex.Match(input, @"-l ([0-9]*)");\r
586             Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
587             Match audioEncoder = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");\r
588 \r
589             //Picture Settings Tab\r
590             Match deinterlace = Regex.Match(input, @"--deinterlace=([a-z]*)");\r
591             Match denoise = Regex.Match(input, @"--denoise=([a-z]*)");\r
592             Match deblock = Regex.Match(input, @"--deblock");\r
593             Match detelecine = Regex.Match(input, @"--detelecine");\r
594             Match anamorphic = Regex.Match(input, @"-p ");\r
595             Match chapterMarkers = Regex.Match(input, @"-m");\r
596             Match crop = Regex.Match(input, @"--crop ([0-9]):([0-9]):([0-9]):([0-9])");\r
597             Match vfr = Regex.Match(input, @"-V");\r
598             Match lanamorphic = Regex.Match(input, @"-P");\r
599 \r
600             //Video Settings Tab\r
601             Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");\r
602             Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");\r
603             Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");\r
604             Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");\r
605             Match twoPass = Regex.Match(input, @"-2");\r
606             Match turboFirstPass = Regex.Match(input, @"-T");\r
607             Match grayscale = Regex.Match(input, @"-g");\r
608             Match largerMp4 = Regex.Match(input, @"-4");\r
609             Match ipodAtom = Regex.Match(input, @"-I");\r
610             Match optimizeMP4 = Regex.Match(input, @"-O");\r
611 \r
612             //Audio Settings Tab\r
613             Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");\r
614             Match subScan = Regex.Match(input, @"-U");\r
615             Match audioBitrate = Regex.Match(input, @"-B ([0-9]*)");\r
616             Match audioSampleRate = Regex.Match(input, @"-R ([0-9.]*)");\r
617             Match audioChannelsMix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");  // 1 -6 dpl2 // Broken\r
618             Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");\r
619             Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");\r
620             Match forcedSubtitles = Regex.Match(input, @"-F");\r
621             Match drc = Regex.Match(input, @"-D ([0-9.]*)");\r
622 \r
623             //H264 Tab\r
624             Match x264 = Regex.Match(input, @"-x ([,a-zA-Z0-9=:-]*)");\r
625 \r
626             //Program Options\r
627             Match verbose = Regex.Match(input, @"-v");\r
628             #endregion\r
629 \r
630             try\r
631             {\r
632                 //\r
633                 // Source\r
634                 //\r
635                 #region Source Tab\r
636 \r
637                 thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");\r
638                 if (title.Success != false)\r
639                     thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
640 \r
641                 if (chapters.Success != false)\r
642                 {\r
643                     string[] actTitles = new string[2];\r
644                     actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
645                     thisQuery.q_chaptersStart = int.Parse(actTitles[0]);\r
646                     if (actTitles.Length > 1)\r
647                     {\r
648                         thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);\r
649                     }\r
650 \r
651                     if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))\r
652                         thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;\r
653                 }\r
654 \r
655                 if (format.Success != false)\r
656                     thisQuery.q_format = format.ToString().Replace("-f ", "");\r
657 \r
658                 #endregion\r
659 \r
660                 //\r
661                 // Destination\r
662                 //\r
663                 #region Destination\r
664                 thisQuery.q_destination = destination.ToString().Replace("-o ", "").Replace("\"", "");\r
665 \r
666                 string videoEncoderConvertion;\r
667                 string audioEncoderConvertion;\r
668 \r
669                 videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
670                 switch (videoEncoderConvertion)\r
671                 {\r
672                     case "ffmpeg":\r
673                         videoEncoderConvertion = "Mpeg 4";\r
674                         break;\r
675                     case "xvid":\r
676                         videoEncoderConvertion = "Xvid";\r
677                         break;\r
678                     case "x264":\r
679                         videoEncoderConvertion = "H.264";\r
680                         break;\r
681                     case "x264b13":\r
682                         videoEncoderConvertion = "H.264 Baseline 1.3";\r
683                         break;\r
684                     case "x264b30":\r
685                         videoEncoderConvertion = "H.264 (iPod)";\r
686                         break;\r
687                     default:\r
688                         videoEncoderConvertion = "Mpeg 4";\r
689                         break;\r
690                 }\r
691                 thisQuery.q_videoEncoder = videoEncoderConvertion;\r
692 \r
693                 audioEncoderConvertion = audioEncoder.ToString().Replace("-E ", "");\r
694                 switch (audioEncoderConvertion)\r
695                 {\r
696                     case "faac":\r
697                         audioEncoderConvertion = "AAC";\r
698                         break;\r
699                     case "lame":\r
700                         audioEncoderConvertion = "MP3";\r
701                         break;\r
702                     case "vorbis":\r
703                         audioEncoderConvertion = "Vorbis";\r
704                         break;\r
705                     case "ac3":\r
706                         audioEncoderConvertion = "AC3";\r
707                         break;\r
708                     case "aac+ac3":\r
709                         audioEncoderConvertion = "AAC + AC3";\r
710                         break;\r
711                     default:\r
712                         audioEncoderConvertion = "AAC";\r
713                         break;\r
714                 }\r
715                 thisQuery.q_audioEncoder = audioEncoderConvertion;\r
716 \r
717 \r
718                 if (width.Success != false)\r
719                     thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));\r
720 \r
721                 if (height.Success != false)\r
722                     thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));\r
723 \r
724                 #endregion\r
725 \r
726                 //\r
727                 //Picture Settings Tab\r
728                 //\r
729                 #region Picture Tab\r
730                 if (crop.Success != false)\r
731                 {\r
732                     thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");\r
733                     string[] actCropValues = new string[3];\r
734                     actCropValues = thisQuery.q_cropValues.Split(':');\r
735                     thisQuery.q_croptop = actCropValues[0];\r
736                     thisQuery.q_cropbottom = actCropValues[1];\r
737                     thisQuery.q_cropLeft = actCropValues[2];\r
738                     thisQuery.q_cropRight = actCropValues[3];\r
739                 }\r
740 \r
741                 thisQuery.q_detelecine = detelecine.Success;\r
742                 thisQuery.q_deBlock = deblock.Success;\r
743 \r
744                 thisQuery.q_deinterlace = "None";\r
745                 if (deinterlace.Success != false)\r
746                 {\r
747                     switch (deinterlace.ToString().Replace("--deinterlace=", ""))\r
748                     {\r
749                         case "fast":\r
750                             thisQuery.q_deinterlace = "Fast";\r
751                             break;\r
752                         case "slow":\r
753                             thisQuery.q_deinterlace = "Slow";\r
754                             break;\r
755                         case "slower":\r
756                             thisQuery.q_deinterlace = "Slower";\r
757                             break;\r
758                         case "slowest":\r
759                             thisQuery.q_deinterlace = "Slowest";\r
760                             break;\r
761                         default:\r
762                             thisQuery.q_deinterlace = "None";\r
763                             break;\r
764                     }\r
765                 }\r
766 \r
767                 thisQuery.q_denoise = "None";\r
768                 if (denoise.Success != false)\r
769                 {\r
770                     switch (denoise.ToString().Replace("--denoise=", ""))\r
771                     {\r
772                         case "weak":\r
773                             thisQuery.q_denoise = "Weak";\r
774                             break;\r
775                         case "medium":\r
776                             thisQuery.q_denoise = "Medium";\r
777                             break;\r
778                         case "strong":\r
779                             thisQuery.q_denoise = "Strong";\r
780                             break;\r
781                         default:\r
782                             thisQuery.q_denoise = "None";\r
783                             break;\r
784                     }\r
785 \r
786                 }\r
787                 thisQuery.q_anamorphic = anamorphic.Success;\r
788                 thisQuery.q_chapterMarkers = chapterMarkers.Success;\r
789                 thisQuery.q_vfr = vfr.Success;\r
790                 thisQuery.q_looseAnamorphic = lanamorphic.Success;\r
791 \r
792                 #endregion\r
793 \r
794                 //\r
795                 //Video Settings Tab\r
796                 //\r
797                 #region Video\r
798                 thisQuery.q_grayscale = grayscale.Success;\r
799                 thisQuery.q_twoPass = twoPass.Success;\r
800                 thisQuery.q_turboFirst = turboFirstPass.Success;\r
801                 thisQuery.q_largeMp4 = largerMp4.Success;\r
802                 if (videoFramerate.Success != false)\r
803                     thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");\r
804                 else\r
805                     thisQuery.q_videoFramerate = "Automatic";\r
806 \r
807                 if (videoBitrate.Success != false)\r
808                     thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");\r
809                 if (videoFilesize.Success != false)\r
810                     thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");\r
811 \r
812                 double qConvert = 0;\r
813                 if (videoQuality.Success != false)\r
814                 {\r
815                     qConvert = double.Parse(videoQuality.ToString().Replace("-q ", "")) * 100;\r
816                     qConvert = System.Math.Ceiling(qConvert);\r
817                     thisQuery.q_videoQuality = int.Parse(qConvert.ToString());\r
818                 }\r
819                 thisQuery.q_ipodAtom = ipodAtom.Success;\r
820                 thisQuery.q_optimizeMp4 = optimizeMP4.Success;\r
821 \r
822                 #endregion\r
823 \r
824                 //\r
825                 //Audio Settings Tab\r
826                 //\r
827                 #region Audio\r
828                 if (audioBitrate.Success != false)\r
829                     thisQuery.q_audioBitrate = audioBitrate.ToString().Replace("-B ", "");\r
830 \r
831                 if (audioSampleRate.Success != false)\r
832                     thisQuery.q_audioSamplerate = audioSampleRate.ToString().Replace("-R ", "");\r
833 \r
834                 if (audioTrack1.Success != false)\r
835                     thisQuery.q_audioTrack1 = audioTrack1.ToString().Replace("-a ", "");\r
836                 else\r
837                     thisQuery.q_audioTrack1 = "Automatic";\r
838 \r
839                 if (audioTrack2.Success != false)\r
840                 {\r
841                     string[] audioChan = audioTrack2.ToString().Split(',');\r
842                     thisQuery.q_audioTrack2 = audioChan[1];\r
843                 }\r
844                 else\r
845                     thisQuery.q_audioTrack2 = "None";\r
846 \r
847                 thisQuery.q_audioTrackMix = "Automatic";\r
848                 if (audioChannelsMix.Success != false)\r
849                 {\r
850                     switch (audioChannelsMix.ToString().Replace("-6 ", "").Replace(" ", ""))\r
851                     {\r
852                         case "mono":\r
853                             thisQuery.q_audioTrackMix = "Mono";\r
854                             break;\r
855                         case "stereo":\r
856                             thisQuery.q_audioTrackMix = "Stereo";\r
857                             break;\r
858                         case "dpl1":\r
859                             thisQuery.q_audioTrackMix = "Dolby Surround";\r
860                             break;\r
861                         case "dpl2":\r
862                             thisQuery.q_audioTrackMix = "Dolby Pro Logic II";\r
863                             break;\r
864                         case "6ch":\r
865                             thisQuery.q_audioTrackMix = "6 Channel Discrete";\r
866                             break;\r
867                         default:\r
868                             thisQuery.q_audioTrackMix = "Automatic";\r
869                             break;\r
870                     }\r
871 \r
872                 }\r
873                 if (subtitles.Success != false)\r
874                     thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");\r
875                 else\r
876                 {\r
877                     if (subScan.Success)\r
878                         thisQuery.q_subtitles = "Autoselect";\r
879                     else\r
880                         thisQuery.q_subtitles = "None";\r
881                 }\r
882 \r
883                 if (drc.Success != false)\r
884                 {\r
885                     string value = drc.ToString().Replace("-D ", "");\r
886                     float drcValue = float.Parse(value);\r
887                     drcValue = drcValue * 10;\r
888                     thisQuery.q_drc = drcValue;\r
889                 }\r
890                 else\r
891                 {\r
892                     thisQuery.q_drc = 0;\r
893                 }\r
894 \r
895                 thisQuery.q_forcedSubs = forcedSubtitles.Success;\r
896 \r
897                 #endregion\r
898 \r
899                 //\r
900                 //H264 tab and other \r
901                 //\r
902                 #region h264 and other\r
903                 //\r
904                 //H264 Tab\r
905                 //\r
906                 if (x264.Success != false)\r
907                 {\r
908                     thisQuery.q_h264 = x264.ToString().Replace("-x ", "");\r
909                 }\r
910 \r
911                 //\r
912                 //Progam Options\r
913                 //\r
914                 thisQuery.q_verbose = verbose.Success;\r
915                 #endregion\r
916             }\r
917             catch (Exception exc)\r
918             {\r
919                 MessageBox.Show("An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
920             }\r
921 \r
922             return thisQuery;\r
923         }\r
924     }\r
925 }