OSDN Git Service

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