X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FFunctions%2FQueryParser.cs;h=a4bd1c1e544ee86d718f9443c377eb64da7b3bd1;hb=d49d3923cd466f1010f0097c9819f2d836aec01c;hp=1b81331e09b26155677fcd32e25735b4792dedce;hpb=aff96d7a4e884187b39c33f6e8ed86bab4a3cdd0;p=handbrake-jp%2Fhandbrake-jp-git.git
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs
index 1b81331e..a4bd1c1e 100644
--- a/win/C#/Functions/QueryParser.cs
+++ b/win/C#/Functions/QueryParser.cs
@@ -38,6 +38,19 @@ namespace Handbrake.Functions
}
}
+ private string q_format;
+ ///
+ /// Returns a String
+ /// Full path of the destination.
+ ///
+ public string Format
+ {
+ get
+ {
+ return this.q_format;
+ }
+ }
+
private int q_dvdTitle;
///
/// Returns an Integer
@@ -51,16 +64,29 @@ namespace Handbrake.Functions
}
}
- private string q_dvdChapters;
+ private int q_chaptersStart;
///
- /// Returns an String
+ /// Returns an Int
/// DVD Chapter number or chapter range.
///
- public string DVDChapters
+ public int DVDChapterStart
{
get
{
- return this.q_dvdChapters;
+ return this.q_chaptersStart;
+ }
+ }
+
+ private int q_chaptersFinish;
+ ///
+ /// Returns an Int
+ /// DVD Chapter number or chapter range.
+ ///
+ public int DVDChapterFinish
+ {
+ get
+ {
+ return this.q_chaptersFinish;
}
}
@@ -92,7 +118,7 @@ namespace Handbrake.Functions
private int q_videoWidth;
///
- /// Returns an Integer
+ /// Returns an Int
/// The selected Width for the encoding.
///
public int Width
@@ -105,7 +131,7 @@ namespace Handbrake.Functions
private int q_videoHeight;
///
- /// Returns an Integer
+ /// Returns an Int
/// The selected Height for the encoding.
///
public int Height
@@ -129,6 +155,58 @@ namespace Handbrake.Functions
}
}
+ private string q_croptop;
+ ///
+ /// Returns an String
+ /// Cropping values.
+ ///
+ public string CropTop
+ {
+ get
+ {
+ return this.q_croptop;
+ }
+ }
+
+ private string q_cropbottom;
+ ///
+ /// Returns an String
+ /// Cropping values.
+ ///
+ public string CropBottom
+ {
+ get
+ {
+ return this.q_cropbottom;
+ }
+ }
+
+ private string q_cropLeft;
+ ///
+ /// Returns an String
+ /// Cropping values.
+ ///
+ public string CropLeft
+ {
+ get
+ {
+ return this.q_cropLeft;
+ }
+ }
+
+ private string q_cropRight;
+ ///
+ /// Returns an String
+ /// Cropping values.
+ ///
+ public string CropRight
+ {
+ get
+ {
+ return this.q_cropRight;
+ }
+ }
+
private Boolean q_detelecine;
///
/// Returns a boolean to indicate wither DeTelecine is on or off
@@ -398,11 +476,14 @@ namespace Handbrake.Functions
{
QueryParser thisQuery = new QueryParser();
+ #region reg exp
//Source
Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9:\\\s\.]+)(?:\"")");
Match source = r1.Match(input.Replace('"', '\"'));
Match title = Regex.Match(input, @"-t ([0-9]*)");
Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
+ Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
+ //-f mp4
//Destination
Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9:\\\s\.]+)(?:\"")");
@@ -413,11 +494,11 @@ namespace Handbrake.Functions
Match audioEncoder = Regex.Match(input, @"-E ([a-zA-Z0-9]*)");
//Picture Settings Tab
- Match deinterlace = Regex.Match(input, @"--deinterlace=([0-9:-]*)"); // DOES NOT WORK. Needs Fixed
- Match denoise = Regex.Match(input, @"--denoise=([0-9:]*)");
+ Match deinterlace = Regex.Match(input, @"--deinterlace=([a-z]*)");
+ Match denoise = Regex.Match(input, @"--denoise=([a-z]*)");
Match deblock = Regex.Match(input, @"--deblock");
Match detelecine = Regex.Match(input, @"--detelecine");
- Match anamorphic = Regex.Match(input, @"-p");
+ Match anamorphic = Regex.Match(input, @"-p ");
Match chapterMarkers = Regex.Match(input, @"-m");
Match crop = Regex.Match(input, @"--crop ([0-9]):([0-9]):([0-9]):([0-9])");
@@ -436,7 +517,7 @@ namespace Handbrake.Functions
Match subtitles = Regex.Match(input, @"-s ([0-9]*)");
Match audioBitrate = Regex.Match(input, @"-B ([0-9]*)");
Match audioSampleRate = Regex.Match(input, @"-R ([0-9.]*)");
- Match audioChannelsMix = Regex.Match(input, @"-6 ([a-zA-Z0-9]*)");
+ Match audioChannelsMix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)"); // 1 -6 dpl2 // Broken
Match audioChannel = Regex.Match(input, @"-a ([0-9]*)");
//H264 Tab
@@ -444,60 +525,265 @@ namespace Handbrake.Functions
//Program Options
Match verbose = Regex.Match(input, @"-v");
-
-
- // ### NOTES ###
- // May be an idea to add additional options such as CPU etc later.
+ #endregion
try
{
- //Source
- thisQuery.q_source = source.ToString();
- if (title.ToString() != "")
+ //
+ // Source
+ //
+ #region Source Tab
+
+ thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");
+ if (title.Success != false)
+ {
thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
- thisQuery.q_dvdChapters = chapters.ToString();
-
- //Destination
- thisQuery.q_destination = destination.ToString();
- thisQuery.q_videoEncoder = videoEncoder.ToString();
- thisQuery.q_audioEncoder = audioEncoder.ToString();
- if (width.ToString() != "")
+ }
+
+ if (chapters.Success != false)
+ {
+ string[] actTitles = new string[2];
+ actTitles = chapters.ToString().Replace("-c ", "").Split('-');
+ thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
+ thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
+ }
+
+ if (format.Success != false)
+ {
+
+ thisQuery.q_format = format.ToString().Replace("-f ", "");
+ }
+ #endregion
+
+ //
+ // Destination
+ //
+ #region Destination
+ thisQuery.q_destination = destination.ToString().Replace("-o ","").Replace("\"", "");
+
+ string videoEncoderConvertion;
+ string audioEncoderConvertion;
+
+ videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
+ switch (videoEncoderConvertion)
+ {
+ case "ffmpeg":
+ videoEncoderConvertion = "Mpeg 4";
+ break;
+ case "xvid":
+ videoEncoderConvertion = "Xvid";
+ break;
+ case "x264":
+ videoEncoderConvertion = "H.264";
+ break;
+ case "x264b13":
+ videoEncoderConvertion = "H.264 Baseline 1.3";
+ break;
+ case "x264b30":
+ videoEncoderConvertion = "H.264 (iPod)";
+ break;
+ default:
+ videoEncoderConvertion = "Mpeg 4";
+ break;
+ }
+ thisQuery.q_videoEncoder = videoEncoderConvertion;
+
+ audioEncoderConvertion = audioEncoder.ToString().Replace("-E ", "");
+ switch (audioEncoderConvertion)
+ {
+ case "faac":
+ audioEncoderConvertion = "AAC";
+ break;
+ case "lame":
+ audioEncoderConvertion = "MP3";
+ break;
+ case "vorbis":
+ audioEncoderConvertion = "Vorbis";
+ break;
+ case "ac3":
+ audioEncoderConvertion = "AC3";
+ break;
+ default:
+ audioEncoderConvertion = "AAC";
+ break;
+ }
+ thisQuery.q_audioEncoder =audioEncoderConvertion;
+
+
+ if (width.Success != false)
+ {
thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
- if (height.ToString() != "")
+ }
+ if (height.Success != false)
+ {
thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
+ }
+ #endregion
+ //
//Picture Settings Tab
- thisQuery.q_cropValues = crop.ToString();
- thisQuery.q_detelecine = detelecine.Success;
- thisQuery.q_deBlock = deblock.Success;
- thisQuery.q_deinterlace = deinterlace.ToString();
- thisQuery.q_denoise = denoise.ToString();
- thisQuery.q_anamorphic = anamorphic.Success;
- thisQuery.q_chapterMarkers = chapterMarkers.Success;
-
+ //
+ #region Picture Tab
+ if (crop.Success != false)
+ {
+ thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
+ string[] actCropValues = new string[3];
+ actCropValues = thisQuery.q_cropValues.Split(':');
+ thisQuery.q_croptop = actCropValues[0];
+ thisQuery.q_cropbottom = actCropValues[1];
+ thisQuery.q_cropLeft = actCropValues[2];
+ thisQuery.q_cropRight = actCropValues[3];
+ }
+
+ thisQuery.q_detelecine = detelecine.Success;
+ thisQuery.q_deBlock = deblock.Success;
+
+ thisQuery.q_deinterlace = "None";
+ if (deinterlace.Success != false)
+ {
+ switch (deinterlace.ToString().Replace("--deinterlace=", ""))
+ {
+ case "fast":
+ thisQuery.q_deinterlace = "Original (Fast)";
+ break;
+ case "slow":
+ thisQuery.q_deinterlace = "yadif (Slow)";
+ break;
+ case "slower":
+ thisQuery.q_deinterlace = "yadif + mcdeint (Slower)";
+ break;
+ case "slowest":
+ thisQuery.q_deinterlace = "yadif + mcdeint (Slowest)";
+ break;
+ default:
+ thisQuery.q_deinterlace = "None";
+ break;
+ }
+ }
+
+ thisQuery.q_denoise = "None";
+ if (denoise.Success != false)
+ {
+ switch (denoise.ToString().Replace("--denoise=", ""))
+ {
+ case "weak":
+ thisQuery.q_denoise = "Weak";
+ break;
+ case "medium":
+ thisQuery.q_denoise = "Medium";
+ break;
+ case "strong":
+ thisQuery.q_denoise = "Strong";
+ break;
+ default:
+ thisQuery.q_denoise = "None";
+ break;
+ }
+
+ }
+ thisQuery.q_anamorphic = anamorphic.Success;
+ thisQuery.q_chapterMarkers = chapterMarkers.Success;
+ #endregion
+
+ //
//Video Settings Tab
+ //
+ #region Video
thisQuery.q_grayscale = grayscale.Success;
thisQuery.q_twoPass = twoPass.Success;
thisQuery.q_turboFirst = turboFirstPass.Success;
thisQuery.q_largeMp4 = largerMp4.Success;
- thisQuery.q_videoFramerate = videoFramerate.ToString();
- thisQuery.q_avgBitrate = videoBitrate.ToString();
- thisQuery.q_videoTargetSize = videoFilesize.ToString();
- if (videoQuality.ToString() != "")
- thisQuery.q_videoQuality = int.Parse(videoQuality.ToString());
+ if (videoFramerate.Success != false)
+ {
+ thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");
+ }
+ if (videoBitrate.Success != false)
+ {
+ thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
+ }
+ if (videoFilesize.Success != false)
+ {
+ thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
+ }
+
+ double qConvert = 0;
+ if (videoQuality.Success != false)
+ {
+ qConvert = double.Parse(videoQuality.ToString().Replace("-q ", "")) * 100;
+ qConvert = System.Math.Ceiling(qConvert);
+ thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
+ }
thisQuery.q_crf = CRF.Success;
+ #endregion
+ //
//Audio Settings Tab
- thisQuery.q_audioBitrate = audioBitrate.ToString();
- thisQuery.q_audioSamplerate = audioSampleRate.ToString();
- thisQuery.q_audioTrack1 = audioChannel.ToString();
- thisQuery.q_audioTrackMix = audioChannelsMix.ToString();
- thisQuery.q_subtitles = subtitles.ToString();
-
+ //
+ #region Audio
+ if (audioBitrate.Success != false)
+ {
+ thisQuery.q_audioBitrate = audioBitrate.ToString().Replace("-B ", "");
+ }
+ if (audioSampleRate.Success != false)
+ {
+ thisQuery.q_audioSamplerate = audioSampleRate.ToString().Replace("-R ", "");
+ }
+ if (audioChannel.Success != false)
+ {
+ thisQuery.q_audioTrack1 = audioChannel.ToString().Replace("-a ", "");
+ }
+ else
+ {
+ thisQuery.q_audioTrack1 = "Automatic";
+ }
+
+ thisQuery.q_audioTrackMix = "Automatic";
+ if (audioChannelsMix.Success != false)
+ {
+ switch (audioChannelsMix.ToString().Replace("-6 ", "").Replace(" ",""))
+ {
+ case "mono":
+ thisQuery.q_audioTrackMix = "Mono";
+ break;
+ case "stereo":
+ thisQuery.q_audioTrackMix = "Stereo";
+ break;
+ case "dpl1":
+ thisQuery.q_audioTrackMix = "Dolby Surround";
+ break;
+ case "dpl2":
+ thisQuery.q_audioTrackMix = "Dolby Pro Logic II";
+ break;
+ case "6ch":
+ thisQuery.q_audioTrackMix = "6 Channel Discrete";
+ break;
+ default:
+ thisQuery.q_audioTrackMix = "Automatic";
+ break;
+ }
+
+ }
+ if (subtitles.Success != false)
+ {
+ thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
+ }
+ else
+ {
+ thisQuery.q_subtitles = "None";
+ }
+ #endregion
+
+ //
//H264 Tab
- thisQuery.q_h264 = x264.ToString();
+ //
+ if (x264.Success != false)
+ {
+ thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
+ }
+ //
//Progam Options
+ //
thisQuery.q_verbose = verbose.Success;
}
catch (Exception exc)
@@ -508,4 +794,4 @@ namespace Handbrake.Functions
return thisQuery;
}
}
-}
+}
\ No newline at end of file