mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Move some variables closer to usage
This commit is contained in:
parent
6de95711b4
commit
f411c960c2
@ -553,11 +553,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
try
|
||||
{
|
||||
SubtitleFormat format = null;
|
||||
Encoding encoding;
|
||||
var sub = new Subtitle();
|
||||
var fi = new FileInfo(fileName);
|
||||
if (fi.Length < 1024 * 1024) // max 1 mb
|
||||
{
|
||||
Encoding encoding;
|
||||
format = sub.LoadSubtitle(fileName, out encoding, null);
|
||||
|
||||
if (format == null)
|
||||
|
@ -864,11 +864,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
string fixAction = _language.FixShortDisplayTime;
|
||||
int noOfShortDisplayTimes = 0;
|
||||
bool skip = false;
|
||||
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
Paragraph p = _subtitle.Paragraphs[i];
|
||||
skip = p.StartTime.IsMaxTime || p.EndTime.IsMaxTime;
|
||||
var skip = p.StartTime.IsMaxTime || p.EndTime.IsMaxTime;
|
||||
double displayTime = p.Duration.TotalMilliseconds;
|
||||
if (!skip && displayTime < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
|
||||
{
|
||||
@ -3462,18 +3461,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
public void FixMissingOpenBracket()
|
||||
{
|
||||
string fixAction = _language.FixMissingOpenBracket;
|
||||
int fixCount = 0, openIdx, closeIdx;
|
||||
bool hit = false;
|
||||
int fixCount = 0;
|
||||
for (int i = 0; i < _subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
Paragraph p = _subtitle.Paragraphs[i];
|
||||
|
||||
if (AllowFix(p, fixAction))
|
||||
{
|
||||
hit = false;
|
||||
var hit = false;
|
||||
string oldText = p.Text;
|
||||
openIdx = p.Text.IndexOf('(');
|
||||
closeIdx = p.Text.IndexOf(')');
|
||||
var openIdx = p.Text.IndexOf('(');
|
||||
var closeIdx = p.Text.IndexOf(')');
|
||||
if ((closeIdx > -1 && closeIdx < openIdx) || (closeIdx > -1 && openIdx == -1))
|
||||
{
|
||||
p.Text = FixMissingOpenBracket(p.Text, "(");
|
||||
@ -4829,13 +4827,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
var p = (Paragraph)listViewFixes.SelectedItems[0].Tag;
|
||||
|
||||
int index = -1;
|
||||
foreach (ListViewItem lvi in subtitleListView1.Items)
|
||||
{
|
||||
Paragraph p2 = lvi.Tag as Paragraph;
|
||||
if (p.ID == p2.ID)
|
||||
{
|
||||
index = lvi.Index;
|
||||
var index = lvi.Index;
|
||||
if (index - 1 > 0)
|
||||
subtitleListView1.EnsureVisible(index - 1);
|
||||
if (index + 1 < subtitleListView1.Items.Count)
|
||||
|
@ -633,11 +633,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private string PreTranslate(string s)
|
||||
{
|
||||
Regex reg;
|
||||
|
||||
if ((comboBoxFrom.SelectedItem as ComboBoxItem).Value == "en")
|
||||
{
|
||||
reg = new Regex("\\bI'm ");
|
||||
var reg = new Regex("\\bI'm ");
|
||||
s = reg.Replace(s, "I am ");
|
||||
|
||||
reg = new Regex("\\bI've ");
|
||||
|
@ -730,7 +730,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
Encoding encoding;
|
||||
var sub = new Subtitle();
|
||||
SubtitleFormat format = null;
|
||||
bool done = false;
|
||||
@ -799,6 +798,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var fi = new FileInfo(fileName);
|
||||
if (fi.Length < 10 * 1024 * 1024 && !done) // max 10 mb
|
||||
{
|
||||
Encoding encoding;
|
||||
format = sub.LoadSubtitle(fileName, out encoding, null, true);
|
||||
|
||||
if (format == null || format.GetType() == typeof(Ebu))
|
||||
@ -5275,7 +5275,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
var subtitleToAppend = new Subtitle();
|
||||
Encoding encoding;
|
||||
SubtitleFormat format = null;
|
||||
|
||||
// do not allow blu-ray/vobsub
|
||||
@ -5290,6 +5289,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
Encoding encoding;
|
||||
format = subtitleToAppend.LoadSubtitle(fileName, out encoding, null);
|
||||
if (GetCurrentSubtitleFormat().IsFrameBased)
|
||||
subtitleToAppend.CalculateTimeCodesFromFrameNumbers(CurrentFrameRate);
|
||||
@ -7737,11 +7737,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (newParagraph.Text.StartsWith("<i> "))
|
||||
newParagraph.Text = newParagraph.Text.Remove(3, 1);
|
||||
|
||||
double startFactor = 0;
|
||||
double middle = currentParagraph.StartTime.TotalMilliseconds + (currentParagraph.Duration.TotalMilliseconds / 2);
|
||||
if (!string.IsNullOrWhiteSpace(Utilities.RemoveHtmlTags(oldText)))
|
||||
{
|
||||
startFactor = (double)Utilities.RemoveHtmlTags(currentParagraph.Text).Length / Utilities.RemoveHtmlTags(oldText).Length;
|
||||
var startFactor = (double)Utilities.RemoveHtmlTags(currentParagraph.Text).Length / Utilities.RemoveHtmlTags(oldText).Length;
|
||||
if (startFactor < 0.25)
|
||||
startFactor = 0.25;
|
||||
if (startFactor > 0.75)
|
||||
@ -9084,7 +9083,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
bool isValid;
|
||||
bool isSsa = false;
|
||||
var matroska = new Matroska();
|
||||
SubtitleFormat format;
|
||||
|
||||
if (matroskaSubtitleInfo.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@ -9098,6 +9096,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
List<SubtitleSequence> sub = matroska.GetMatroskaSubtitle(fileName, (int)matroskaSubtitleInfo.TrackNumber, out isValid, MatroskaProgress);
|
||||
if (isValid)
|
||||
{
|
||||
SubtitleFormat format;
|
||||
if (matroskaSubtitleInfo.CodecPrivate.Contains("[script info]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (matroskaSubtitleInfo.CodecPrivate.Contains("[V4 Styles]", StringComparison.OrdinalIgnoreCase))
|
||||
@ -9135,7 +9134,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
bool isValid;
|
||||
bool isSsa = false;
|
||||
var matroska = new Matroska();
|
||||
SubtitleFormat format;
|
||||
|
||||
if (matroskaSubtitleInfo.CodecId.Equals("S_VOBSUB", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
@ -9165,6 +9163,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
ResetSubtitle();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
|
||||
SubtitleFormat format;
|
||||
if (matroskaSubtitleInfo.CodecPrivate.Contains("[script info]", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (matroskaSubtitleInfo.CodecPrivate.Contains("[V4 Styles]", StringComparison.OrdinalIgnoreCase))
|
||||
@ -12705,7 +12704,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName))
|
||||
{
|
||||
Subtitle sub = new Subtitle();
|
||||
Encoding enc;
|
||||
string fileName = openFileDialog1.FileName;
|
||||
|
||||
//TODO: Check for mkv etc
|
||||
@ -12821,6 +12819,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
sub.Renumber(1);
|
||||
if (sub.Paragraphs.Count == 0)
|
||||
{
|
||||
Encoding enc;
|
||||
SubtitleFormat f = sub.LoadSubtitle(fileName, out enc, null);
|
||||
if (f == null)
|
||||
{
|
||||
|
@ -162,11 +162,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
numberOfSplits = 0;
|
||||
string language = Utilities.AutoDetectGoogleLanguage(subtitle);
|
||||
Subtitle splittedSubtitle = new Subtitle();
|
||||
Paragraph p = null;
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
bool added = false;
|
||||
p = subtitle.GetParagraphOrDefault(i);
|
||||
var p = subtitle.GetParagraphOrDefault(i);
|
||||
if (p != null && p.Text != null)
|
||||
{
|
||||
string oldText = Utilities.RemoveHtmlTags(p.Text);
|
||||
@ -213,11 +212,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Paragraph newParagraph2 = new Paragraph(p);
|
||||
newParagraph1.Text = Utilities.AutoBreakLine(arr[0], language);
|
||||
|
||||
double startFactor = 0;
|
||||
double middle = p.StartTime.TotalMilliseconds + (p.Duration.TotalMilliseconds / 2);
|
||||
if (!string.IsNullOrWhiteSpace(Utilities.RemoveHtmlTags(oldText)))
|
||||
{
|
||||
startFactor = (double)Utilities.RemoveHtmlTags(newParagraph1.Text).Length / Utilities.RemoveHtmlTags(oldText).Length;
|
||||
var startFactor = (double)Utilities.RemoveHtmlTags(newParagraph1.Text).Length / Utilities.RemoveHtmlTags(oldText).Length;
|
||||
if (startFactor < 0.25)
|
||||
startFactor = 0.25;
|
||||
if (startFactor > 0.75)
|
||||
|
@ -309,10 +309,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
int startIndex = -1;
|
||||
int endIndex = -1;
|
||||
int minIndex = 0;
|
||||
int maxIndex;
|
||||
List<int> syncIndices = new List<int>();
|
||||
foreach (KeyValuePair<int, TimeSpan> kvp in _syncronizationPoints)
|
||||
syncIndices.Add(kvp.Key);
|
||||
@ -324,9 +322,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
startIndex = endIndex;
|
||||
var startIndex = endIndex;
|
||||
endIndex = syncIndices[i];
|
||||
|
||||
int maxIndex;
|
||||
if (i == syncIndices.Count - 1)
|
||||
maxIndex = _subtitle.Paragraphs.Count;
|
||||
else
|
||||
|
@ -1502,13 +1502,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
// var nbmp = new NikseBitmap(parentBitmap);
|
||||
int w = targetItem.NikseBitmap.Width;
|
||||
int index = 0;
|
||||
foreach (NOcrChar oc in nOcrChars)
|
||||
{
|
||||
if (oc.ExpandCount > 1 && oc.Width > w && targetItem.X + oc.Width < nbmp.Width)
|
||||
{
|
||||
bool ok = true;
|
||||
index = 0;
|
||||
var index = 0;
|
||||
while (index < oc.LinesForeground.Count && ok)
|
||||
{
|
||||
NOcrPoint op = oc.LinesForeground[index];
|
||||
@ -4954,7 +4953,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
List<ImageSplitterItem> lines = NikseBitmapImageSplitter.SplitVertical(bitmap);
|
||||
List<ImageSplitterItem> list = NikseBitmapImageSplitter.SplitBitmapToLetters(lines, p.NumberOfPixelsIsSpace, p.RightToLeft, Configuration.Settings.VobSubOcr.TopToBottom);
|
||||
|
||||
int index;
|
||||
int outerIndex = 0;
|
||||
while (outerIndex < list.Count)
|
||||
{
|
||||
@ -4971,6 +4969,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
int smallestDifference = 10000;
|
||||
int smallestIndex = -1;
|
||||
|
||||
int index;
|
||||
if (smallestDifference > 0)
|
||||
{
|
||||
index = 0;
|
||||
@ -5051,13 +5050,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
CompareMatch match;
|
||||
double differencePercentage = smallestDifference * 100.0 / (item.NikseBitmap.Width * item.NikseBitmap.Height);
|
||||
double maxDiff = (double)p.MaxErrorPercent;
|
||||
if (differencePercentage <= maxDiff && smallestIndex >= 0)
|
||||
{
|
||||
var hit = p.CompareBitmaps[smallestIndex];
|
||||
match = new CompareMatch(hit.Text, hit.Italic, hit.ExpandCount, hit.Name);
|
||||
var match = new CompareMatch(hit.Text, hit.Italic, hit.ExpandCount, hit.Name);
|
||||
matches.Add(new CompareMatch(match.Text, match.Italic, 0, null));
|
||||
if (match.ExpandCount > 0)
|
||||
outerIndex += match.ExpandCount - 1;
|
||||
@ -5128,7 +5126,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
CompareMatch match = null;
|
||||
|
||||
var nbmp = item.NikseBitmap;
|
||||
int index2 = 0;
|
||||
int topMargin = item.Y - item.ParentY;
|
||||
foreach (NOcrChar oc in _nOcrDb.OcrCharacters)
|
||||
{
|
||||
@ -5136,7 +5133,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{ // only very accurate matches
|
||||
|
||||
bool ok = true;
|
||||
index2 = 0;
|
||||
var index2 = 0;
|
||||
while (index2 < oc.LinesForeground.Count && ok)
|
||||
{
|
||||
NOcrPoint op = oc.LinesForeground[index2];
|
||||
|
@ -195,14 +195,13 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
|
||||
cb = new byte[size];
|
||||
cr = new byte[size];
|
||||
|
||||
int[] yCbCr;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
a[i] = alpha[i];
|
||||
r[i] = red[i];
|
||||
g[i] = green[i];
|
||||
b[i] = blue[i];
|
||||
yCbCr = Rgb2YCbCr(r[i] & 0xff, g[i] & 0xff, b[i] & 0xff, useBT601);
|
||||
var yCbCr = Rgb2YCbCr(r[i] & 0xff, g[i] & 0xff, b[i] & 0xff, useBT601);
|
||||
y[i] = (byte)yCbCr[0];
|
||||
cb[i] = (byte)yCbCr[1];
|
||||
cr[i] = (byte)yCbCr[2];
|
||||
|
@ -544,7 +544,6 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
|
||||
|
||||
public static List<PcsData> ParseBluRaySup(Stream ms, StringBuilder log, bool fromMatroskaFile)
|
||||
{
|
||||
SupSegment segment;
|
||||
long position = ms.Position;
|
||||
int segmentCount = 0;
|
||||
var palettes = new Dictionary<int, List<PaletteInfo>>();
|
||||
@ -553,7 +552,6 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
|
||||
PcsData latestPcs = null;
|
||||
int latestCompNum = -1;
|
||||
var pcsList = new List<PcsData>();
|
||||
byte[] buffer;
|
||||
byte[] headerBuffer;
|
||||
if (fromMatroskaFile)
|
||||
headerBuffer = new byte[3];
|
||||
@ -566,6 +564,7 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
|
||||
|
||||
// Read segment header
|
||||
ms.Read(headerBuffer, 0, headerBuffer.Length);
|
||||
SupSegment segment;
|
||||
if (fromMatroskaFile)
|
||||
segment = ParseSegmentHeaderFromMatroska(headerBuffer);
|
||||
else
|
||||
@ -573,7 +572,7 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
|
||||
position += headerBuffer.Length;
|
||||
|
||||
// Read segment data
|
||||
buffer = new byte[segment.Size];
|
||||
var buffer = new byte[segment.Size];
|
||||
ms.Read(buffer, 0, buffer.Length);
|
||||
log.Append(segmentCount + ": ");
|
||||
|
||||
|
@ -113,17 +113,16 @@ namespace Nikse.SubtitleEdit.Logic.BluRaySup
|
||||
private static byte[] EncodeImage(NikseBitmap bm, Dictionary<Color, int> palette)
|
||||
{
|
||||
var bytes = new List<Byte>();
|
||||
byte color = 0;
|
||||
int ofs = 0;
|
||||
int len = 0;
|
||||
for (int y = 0; y < bm.Height; y++)
|
||||
{
|
||||
ofs = y * bm.Width;
|
||||
var ofs = y * bm.Width;
|
||||
//eol = false;
|
||||
int x;
|
||||
int len;
|
||||
for (x = 0; x < bm.Width; x += len, ofs += len)
|
||||
{
|
||||
Color c = bm.GetPixel(x, y);
|
||||
byte color;
|
||||
if (palette.ContainsKey(c))
|
||||
color = (byte)palette[c];
|
||||
else
|
||||
|
@ -28,11 +28,10 @@ namespace Nikse.SubtitleEdit.Logic.Forms
|
||||
int numberOfSplits = 0;
|
||||
Subtitle splittedSubtitle = new Subtitle();
|
||||
string language = Utilities.AutoDetectGoogleLanguage(subtitle);
|
||||
Paragraph p = null;
|
||||
for (int i = 0; i < subtitle.Paragraphs.Count; i++)
|
||||
{
|
||||
bool added = false;
|
||||
p = subtitle.GetParagraphOrDefault(i);
|
||||
var p = subtitle.GetParagraphOrDefault(i);
|
||||
if (p != null && p.Text != null)
|
||||
{
|
||||
string oldText = Utilities.RemoveHtmlTags(p.Text);
|
||||
|
@ -308,11 +308,11 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
// Cell Playback Info Table to retrieve duration
|
||||
_fs.Position = tableStart + programChainAdress + 0xE8;
|
||||
_fs.Position = tableStart + programChainAdress + GetEndian(2);
|
||||
int max = 0;
|
||||
List<int> timeArray = new List<int>();
|
||||
for (int k = 0; k < programChain.NumberOfPGC; k++)
|
||||
{
|
||||
int time = 0;
|
||||
int max;
|
||||
if (k == programChain.NumberOfPGC - 1)
|
||||
max = programChain.NumberOfCells;
|
||||
else
|
||||
|
@ -351,9 +351,6 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
byte[] bufferUnEqual = new byte[Width * Height];
|
||||
int indexBufferEqual = 0;
|
||||
int indexBufferUnEqual = 0;
|
||||
bool indexHalfNibble = false;
|
||||
int lastColor = -1;
|
||||
int count = -1;
|
||||
|
||||
_pixelAddress = -4;
|
||||
for (int y = 0; y < Height; y++)
|
||||
@ -370,9 +367,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
index = indexBufferUnEqual;
|
||||
buffer = bufferUnEqual;
|
||||
}
|
||||
indexHalfNibble = false;
|
||||
lastColor = -1;
|
||||
count = 0;
|
||||
var indexHalfNibble = false;
|
||||
var lastColor = -1;
|
||||
var count = 0;
|
||||
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
@ -730,10 +727,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
bool done = false;
|
||||
int newTop = 0;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
while (!done && y < Height)
|
||||
{
|
||||
x = 0;
|
||||
var x = 0;
|
||||
while (!done && x < Width)
|
||||
{
|
||||
Color c = GetPixel(x, y);
|
||||
@ -770,10 +766,9 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
bool done = false;
|
||||
int newTop = 0;
|
||||
int y = 0;
|
||||
int x = 0;
|
||||
while (!done && y < Height)
|
||||
{
|
||||
x = 0;
|
||||
var x = 0;
|
||||
while (!done && x < Width)
|
||||
{
|
||||
int alpha = GetAlpha(x, y);
|
||||
|
@ -82,7 +82,6 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
{
|
||||
const int NocrMinColor = 300;
|
||||
int topMargin = 1;
|
||||
int index = 0;
|
||||
double widthPercent = nbmp.Height * 100.0 / nbmp.Width;
|
||||
|
||||
foreach (NOcrChar oc in OcrCharacters)
|
||||
@ -91,7 +90,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
{ // only very accurate matches
|
||||
|
||||
bool ok = true;
|
||||
index = 0;
|
||||
var index = 0;
|
||||
while (index < oc.LinesForeground.Count && ok)
|
||||
{
|
||||
NOcrPoint op = oc.LinesForeground[index];
|
||||
|
@ -440,10 +440,10 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
|
||||
public static string GetFormattedText(string text)
|
||||
{
|
||||
text = text.Replace("\\N", Environment.NewLine).Replace("\\n", Environment.NewLine);
|
||||
bool italic = false;
|
||||
|
||||
for (int i = 0; i < 10; i++) // just look ten times...
|
||||
{
|
||||
bool italic;
|
||||
if (text.Contains(@"{\fn"))
|
||||
{
|
||||
int start = text.IndexOf(@"{\fn", StringComparison.Ordinal);
|
||||
@ -923,12 +923,10 @@ Format: Layer, Start, End, Style, Actor, MarginL, MarginR, MarginV, Effect, Text
|
||||
private static string RemoveTag(string s, string tag)
|
||||
{
|
||||
int indexOfTag = s.IndexOf(@"\" + tag, StringComparison.Ordinal);
|
||||
int endIndex1 = int.MaxValue;
|
||||
int endIndex2 = int.MaxValue;
|
||||
if (indexOfTag > 0)
|
||||
{
|
||||
endIndex1 = s.IndexOf('\\', indexOfTag + 1);
|
||||
endIndex2 = s.IndexOf('}', indexOfTag + 1);
|
||||
var endIndex1 = s.IndexOf('\\', indexOfTag + 1);
|
||||
var endIndex2 = s.IndexOf('}', indexOfTag + 1);
|
||||
endIndex1 = Math.Min(endIndex1, endIndex2);
|
||||
if (endIndex1 > 0)
|
||||
s = s.Remove(indexOfTag, endIndex1 - indexOfTag);
|
||||
|
@ -93,7 +93,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p;
|
||||
foreach (string line in lines)
|
||||
{
|
||||
Match m = CsvLine.Match(line);
|
||||
@ -106,7 +105,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
var start = DecodeTimeCode(parts[0]);
|
||||
var end = DecodeTimeCode(parts[1]);
|
||||
string text = ReadText(line.Remove(0, m.Length));
|
||||
p = new Paragraph(start, end, text);
|
||||
var p = new Paragraph(start, end, text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
catch
|
||||
|
@ -62,7 +62,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
//00:03:15:22 00:03:23:10 This is line one.
|
||||
//This is line two.
|
||||
Paragraph p = null;
|
||||
subtitle.Paragraphs.Clear();
|
||||
_errorCount = 0;
|
||||
foreach (string line in lines)
|
||||
@ -79,7 +78,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
string text = line.Remove(0, regexTimeCodes.Match(line).Length - 1).Trim();
|
||||
text = text.Replace("//", Environment.NewLine);
|
||||
p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
|
||||
var p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
}
|
||||
|
@ -92,13 +92,12 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
}
|
||||
|
||||
// seek to text
|
||||
int length = 0;
|
||||
var sb = new StringBuilder();
|
||||
while (i < buffer.Length - 10 && !(buffer[i] == 0xc4 && buffer[i + 1] == 9 && buffer[i + 2] == 0 && buffer[i + 3] == 0x10))
|
||||
{
|
||||
if (buffer[i] == 9 && buffer[i + 1] == 0 && buffer[i + 2] == 0x44)
|
||||
{
|
||||
length = buffer[i - 1];
|
||||
var length = buffer[i - 1];
|
||||
i += 12;
|
||||
for (int j = i; j < i + (length * 4); j += 4)
|
||||
{
|
||||
|
@ -63,7 +63,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
//Var vi bedre end japanerne
|
||||
//eller bare mere heldige? <12:03:29:03> <12:03:35:06>
|
||||
|
||||
Paragraph p = null;
|
||||
subtitle.Paragraphs.Clear();
|
||||
sb = new StringBuilder();
|
||||
foreach (string line in lines)
|
||||
@ -83,7 +82,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
string[] endParts = end.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (startParts.Length == 4 && endParts.Length == 4)
|
||||
{
|
||||
p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), sb.ToString().Trim());
|
||||
var p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), sb.ToString().Trim());
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
sb = new StringBuilder();
|
||||
|
@ -67,7 +67,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
//<Time begin="0:03:24.8" end="0:03:29.4" /><clear/>Man stjæler ikke fra Chavo, nej.
|
||||
Paragraph p = null;
|
||||
subtitle.Paragraphs.Clear();
|
||||
_errorCount = 0;
|
||||
foreach (string line in lines)
|
||||
@ -86,7 +85,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
if (startParts.Length == 4 && endParts.Length == 4)
|
||||
{
|
||||
string text = line.Substring(line.LastIndexOf("/>", StringComparison.Ordinal) + 2);
|
||||
p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
|
||||
var p = new Paragraph(DecodeTimeCode(startParts), DecodeTimeCode(endParts), text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
}
|
||||
}
|
||||
|
@ -366,11 +366,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
settings.OmitXmlDeclaration = omitXmlDeclaration;
|
||||
|
||||
StringWriter textWriter = null;
|
||||
XmlWriter xmlWriter = null;
|
||||
try
|
||||
{
|
||||
textWriter = new StringWriter();
|
||||
xmlWriter = XmlWriter.Create(textWriter, settings);
|
||||
var xmlWriter = XmlWriter.Create(textWriter, settings);
|
||||
xml.Save(xmlWriter);
|
||||
xmlWriter.Flush();
|
||||
return textWriter.ToString().Replace(" encoding=\"utf-16\"", " encoding=\"utf-8\"").Trim();
|
||||
|
@ -139,11 +139,10 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
|
||||
//0001 01:00:15:08 01:00:18:05
|
||||
string[] parts;
|
||||
try
|
||||
{
|
||||
string start = line.Substring(5, 11);
|
||||
parts = start.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var parts = start.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
int startHours = int.Parse(parts[0]);
|
||||
int startMinutes = int.Parse(parts[1]);
|
||||
int startSeconds = int.Parse(parts[2]);
|
||||
|
@ -49,7 +49,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
foreach (string line in lines)
|
||||
{
|
||||
string s = line.Trim();
|
||||
@ -64,7 +63,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
int minutes = int.Parse(arr[1]);
|
||||
int seconds = int.Parse(arr[2]);
|
||||
int frames = int.Parse(arr[3]);
|
||||
p = new Paragraph();
|
||||
var p = new Paragraph();
|
||||
p.StartTime = new TimeCode(hours, minutes, seconds, FramesToMillisecondsMax999(frames));
|
||||
p.Text = s.Remove(0, 10).Trim();
|
||||
subtitle.Paragraphs.Add(p);
|
||||
|
@ -56,7 +56,6 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
|
||||
{
|
||||
_errorCount = 0;
|
||||
Paragraph p = null;
|
||||
subtitle.Paragraphs.Clear();
|
||||
foreach (string line in lines)
|
||||
{
|
||||
@ -64,7 +63,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
|
||||
{
|
||||
int splitter = line.IndexOf(':') + 3;
|
||||
string text = line.Remove(0, splitter);
|
||||
p = new Paragraph(DecodeTimeCode(line.Substring(0, splitter)), new TimeCode(0, 0, 0, 0), text);
|
||||
var p = new Paragraph(DecodeTimeCode(line.Substring(0, splitter)), new TimeCode(0, 0, 0, 0), text);
|
||||
subtitle.Paragraphs.Add(p);
|
||||
text = text.Trim().Trim('–', '.', ';', ':').Trim();
|
||||
if (text.Length > 0 && char.IsDigit(text[0]))
|
||||
|
@ -158,26 +158,18 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
public List<MatroskaTrackInfo> GetTrackInfo()
|
||||
{
|
||||
byte b;
|
||||
bool done;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
bool endOfFile;
|
||||
|
||||
_tracks = new List<MatroskaTrackInfo>();
|
||||
using (_f = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var matroskaId = GetMatroskaId();
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
_f.Seek(dataSize, SeekOrigin.Current);
|
||||
|
||||
done = false;
|
||||
endOfFile = false;
|
||||
var done = false;
|
||||
var endOfFile = false;
|
||||
while (endOfFile == false && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
@ -191,6 +183,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x1549A966) // segment info
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -223,26 +216,18 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
/// <returns>Start time in milliseconds</returns>
|
||||
public Int64 GetTrackStartTime(int trackNumber)
|
||||
{
|
||||
byte b;
|
||||
bool done;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
bool endOfFile;
|
||||
|
||||
_tracks = new List<MatroskaTrackInfo>();
|
||||
using (_f = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var matroskaId = GetMatroskaId();
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
_f.Seek(dataSize, SeekOrigin.Current);
|
||||
|
||||
done = false;
|
||||
endOfFile = false;
|
||||
var done = false;
|
||||
var endOfFile = false;
|
||||
while (endOfFile == false && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
@ -256,6 +241,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x1549A966) // segment info
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -287,27 +273,23 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private Int64 FindTrackStartInCluster(int targetTrackNumber)
|
||||
{
|
||||
byte b;
|
||||
bool done = false;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
long clusterTimeCode = 0;
|
||||
int trackStartTime = -1;
|
||||
|
||||
while (_f.Position < _f.Length && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaClusterId();
|
||||
var matroskaId = GetMatroskaClusterId();
|
||||
|
||||
if (matroskaId == 0)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0xE7) // Timecode
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -428,7 +410,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private long GetMatroskaDataSize(long sizeOfSize, byte firstByte)
|
||||
{
|
||||
byte b4, b5, b6, b7, b8;
|
||||
byte b5, b6, b7, b8;
|
||||
long result = 0;
|
||||
|
||||
if (sizeOfSize == 8)
|
||||
@ -456,7 +438,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
else if (sizeOfSize == 6)
|
||||
{
|
||||
firstByte = (byte)(firstByte & 3); // 00000011
|
||||
b4 = (byte)_f.ReadByte();
|
||||
var b4 = (byte)_f.ReadByte();
|
||||
b5 = (byte)_f.ReadByte();
|
||||
b6 = (byte)_f.ReadByte();
|
||||
b7 = (byte)_f.ReadByte();
|
||||
@ -504,7 +486,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
private long GetMatroskaVariableSizeUnsignedInt(long sizeOfSize)
|
||||
{
|
||||
byte firstByte = (byte)_f.ReadByte();
|
||||
byte b3, b4, b5, b6, b7, b8;
|
||||
byte b4, b5, b6, b7, b8;
|
||||
long result = 0;
|
||||
|
||||
if (sizeOfSize >= 8)
|
||||
@ -513,7 +495,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
}
|
||||
else if (sizeOfSize == 7)
|
||||
{
|
||||
b3 = (byte)_f.ReadByte();
|
||||
var b3 = (byte)_f.ReadByte();
|
||||
b4 = (byte)_f.ReadByte();
|
||||
b5 = (byte)_f.ReadByte();
|
||||
b6 = (byte)_f.ReadByte();
|
||||
@ -702,24 +684,20 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private void AnalyzeMatroskaTrackVideo(long endPosition)
|
||||
{
|
||||
byte b;
|
||||
bool done = false;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
|
||||
while (_f.Position < endPosition && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaTrackVideoId();
|
||||
var matroskaId = GetMatroskaTrackVideoId();
|
||||
if (matroskaId == 0)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0xB0) //// PixelWidth
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -758,13 +736,8 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private void AnalyzeMatroskaTrackEntry()
|
||||
{
|
||||
byte b;
|
||||
bool done = false;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long defaultDuration = 0;
|
||||
long afterPosition;
|
||||
bool isVideo = false;
|
||||
bool isAudio = false;
|
||||
bool isSubtitle = false;
|
||||
@ -779,15 +752,16 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
while (_f.Position < _f.Length && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaTrackEntryId();
|
||||
var matroskaId = GetMatroskaTrackEntryId();
|
||||
if (matroskaId == 0)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x23E383)// Default Duration
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -969,26 +943,22 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private void AnalyzeMatroskaSegmentInformation(long endPosition)
|
||||
{
|
||||
byte b;
|
||||
bool done = false;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
long timeCodeScale = 0;
|
||||
double duration8b = 0;
|
||||
|
||||
while (_f.Position < endPosition && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaSegmentId();
|
||||
var matroskaId = GetMatroskaSegmentId();
|
||||
if (matroskaId == 0)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x2AD7B1)// TimecodeScale - u-integer Timecode scale in nanoseconds (1.000.000 means all timecodes in the segment are expressed in milliseconds).
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -1054,28 +1024,23 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private void AnalyzeMatroskaTracks()
|
||||
{
|
||||
byte b;
|
||||
bool done = false;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
_subtitleList = new List<MatroskaSubtitleInfo>();
|
||||
|
||||
while (_f.Position < _f.Length && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaTracksId();
|
||||
var matroskaId = GetMatroskaTracksId();
|
||||
if (matroskaId == 0)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
if (matroskaId == 0xAE)
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
var afterPosition = _f.Position + dataSize;
|
||||
AnalyzeMatroskaTrackEntry();
|
||||
_f.Seek(afterPosition, SeekOrigin.Begin);
|
||||
}
|
||||
@ -1094,13 +1059,6 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
ref double millisecondDuration,
|
||||
ref string videoCodec)
|
||||
{
|
||||
byte b;
|
||||
bool done;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
bool endOfFile;
|
||||
|
||||
_durationInMilliseconds = 0;
|
||||
|
||||
_f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
@ -1113,14 +1071,14 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
else
|
||||
{
|
||||
isValid = true;
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
_f.Seek(dataSize, SeekOrigin.Current);
|
||||
|
||||
done = false;
|
||||
endOfFile = false;
|
||||
var done = false;
|
||||
var endOfFile = false;
|
||||
while (endOfFile == false && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
@ -1134,6 +1092,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x1549A966) // segment info
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -1219,27 +1178,23 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
private void AnalyzeMatroskaCluster()
|
||||
{
|
||||
byte b;
|
||||
bool done = false;
|
||||
UInt32 matroskaId;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
long clusterTimeCode = 0;
|
||||
long duration = 0;
|
||||
|
||||
while (_f.Position < _f.Length && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaClusterId();
|
||||
var matroskaId = GetMatroskaClusterId();
|
||||
|
||||
if (matroskaId == 0)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0xE7) // Timecode
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -1382,13 +1337,6 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
public List<MatroskaSubtitleInfo> GetMatroskaSubtitleTracks(string fileName, out bool isValid)
|
||||
{
|
||||
byte b;
|
||||
bool done;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
bool endOfFile;
|
||||
|
||||
_f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
var matroskaId = GetMatroskaId();
|
||||
@ -1399,14 +1347,14 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
else
|
||||
{
|
||||
isValid = true;
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
_f.Seek(dataSize, SeekOrigin.Current);
|
||||
|
||||
done = false;
|
||||
endOfFile = false;
|
||||
var done = false;
|
||||
var endOfFile = false;
|
||||
while (endOfFile == false && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
@ -1420,6 +1368,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x1549A966) // segment info
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
@ -1452,12 +1401,6 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
|
||||
public List<SubtitleSequence> GetMatroskaSubtitle(string fileName, int trackNumber, out bool isValid, LoadMatroskaCallback callback)
|
||||
{
|
||||
byte b;
|
||||
bool done;
|
||||
int sizeOfSize;
|
||||
long dataSize;
|
||||
long afterPosition;
|
||||
bool endOfFile;
|
||||
_subtitleRipTrackNumber = trackNumber;
|
||||
|
||||
_f = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
@ -1470,14 +1413,14 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
else
|
||||
{
|
||||
isValid = true;
|
||||
b = (byte)_f.ReadByte();
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
var b = (byte)_f.ReadByte();
|
||||
var sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
var dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
_f.Seek(dataSize, SeekOrigin.Current);
|
||||
|
||||
done = false;
|
||||
endOfFile = false;
|
||||
var done = false;
|
||||
var endOfFile = false;
|
||||
while (endOfFile == false && done == false)
|
||||
{
|
||||
matroskaId = GetMatroskaId();
|
||||
@ -1491,6 +1434,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoFormats
|
||||
sizeOfSize = GetMatroskaVariableIntLength(b);
|
||||
dataSize = GetMatroskaDataSize(sizeOfSize, b);
|
||||
|
||||
long afterPosition;
|
||||
if (matroskaId == 0x1549A966) // segment info
|
||||
{
|
||||
afterPosition = _f.Position + dataSize;
|
||||
|
@ -75,7 +75,6 @@ namespace Nikse.SubtitleEdit.Logic.VobSub
|
||||
ImageDisplayArea = new Rectangle();
|
||||
Bitmap bmp = null;
|
||||
var displayControlSequenceTableAddresses = new List<int>();
|
||||
byte[] imageContrast = null;
|
||||
int imageTopFieldDataAddress = 0;
|
||||
int imageBottomFieldDataAddress = 0;
|
||||
bool bitmapGenerated = false;
|
||||
@ -132,7 +131,7 @@ namespace Nikse.SubtitleEdit.Logic.VobSub
|
||||
case (int)DisplayControlCommand.SetContrast: // 4
|
||||
if (colorLookUpTable != null && fourColors.Count == 4)
|
||||
{
|
||||
imageContrast = new[] { _data[commandIndex + 1], _data[commandIndex + 2] };
|
||||
var imageContrast = new[] { _data[commandIndex + 1], _data[commandIndex + 2] };
|
||||
if (imageContrast[0] + imageContrast[1] > 0)
|
||||
{
|
||||
SetTransparency(fourColors, 3, (imageContrast[0] & 0xF0) >> 4);
|
||||
|
@ -34,8 +34,6 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
int w = bmp.Width;
|
||||
int h = bmp.Height;
|
||||
int v;
|
||||
int len, color;
|
||||
int nibbleOffset = 0;
|
||||
var nibble_end = buf.Length * 2;
|
||||
var x = 0;
|
||||
@ -44,7 +42,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
if (nibbleOffset >= nibble_end)
|
||||
return -1;
|
||||
v = GetNibble(buf, nibbleOffset++);
|
||||
var v = GetNibble(buf, nibbleOffset++);
|
||||
if (v < 0x4)
|
||||
{
|
||||
v = (v << 4) | GetNibble(buf, nibbleOffset++);
|
||||
@ -61,16 +59,18 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
}
|
||||
}
|
||||
len = v >> 2;
|
||||
|
||||
var len = v >> 2;
|
||||
if (len > (w - x))
|
||||
len = (w - x);
|
||||
color = v & 0x03;
|
||||
|
||||
var color = v & 0x03;
|
||||
if (color > 0)
|
||||
{
|
||||
Color c = fourColors[color];
|
||||
bmp.SetPixel(x, y, c, len);
|
||||
}
|
||||
|
||||
x += len;
|
||||
if (x >= w)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user