Refactor - fix minor issues from codacy

This commit is contained in:
Nikolaj Olsson 2019-01-20 14:53:58 +01:00
parent ae7cb6a911
commit 8c4e3e06cf
25 changed files with 22 additions and 301 deletions

View File

@ -111,7 +111,6 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
var bytes = new List<byte>(); var bytes = new List<byte>();
for (int y = 0; y < bm.Height; y++) for (int y = 0; y < bm.Height; y++)
{ {
//eol = false;
int x; int x;
int len; int len;
for (x = 0; x < bm.Width; x += len) for (x = 0; x < bm.Width; x += len)
@ -185,7 +184,7 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
} }
} }
} }
if (/*!eol &&*/ x == bm.Width) if (x == bm.Width)
{ {
bytes.Add(0); // rle id bytes.Add(0); // rle id
bytes.Add(0); bytes.Add(0);
@ -562,7 +561,7 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
} }
packetHeader[10] = 0x15; // ID packetHeader[10] = 0x15; // ID
timestamp = 0; //dts + imageDecodeTime; timestamp = 0;
ToolBox.SetDWord(packetHeader, 2, timestamp); // PTS ToolBox.SetDWord(packetHeader, 2, timestamp); // PTS
ToolBox.SetDWord(packetHeader, 6, dts); // DTS ToolBox.SetDWord(packetHeader, 6, dts); // DTS
ToolBox.SetWord(packetHeader, 11, headerOdsFirst.Length + bufSize); // size ToolBox.SetWord(packetHeader, 11, headerOdsFirst.Length + bufSize); // size
@ -627,7 +626,7 @@ namespace Nikse.SubtitleEdit.Core.BluRaySup
// write PCS end // write PCS end
packetHeader[10] = 0x16; // ID packetHeader[10] = 0x16; // ID
ToolBox.SetDWord(packetHeader, 2, pic.EndTimeForWrite); // PTS ToolBox.SetDWord(packetHeader, 2, pic.EndTimeForWrite); // PTS
dts = pic.EndTimeForWrite - 90; //dts = pic.StartTimeForWrite - 1; dts = pic.EndTimeForWrite - 90;
ToolBox.SetDWord(packetHeader, 6, dts); // DTS ToolBox.SetDWord(packetHeader, 6, dts); // DTS
ToolBox.SetWord(packetHeader, 11, headerPcsEnd.Length); // size ToolBox.SetWord(packetHeader, 11, headerPcsEnd.Length); // size
for (int i = 0; i < packetHeader.Length; i++) for (int i = 0; i < packetHeader.Length; i++)

View File

@ -70,24 +70,6 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats
public int cFrames; public int cFrames;
} }
//internal struct TIMECODEDATA
//{
// private TIMECODE time;
// public int dwSMPTEflags;
// public int dwUser;
//}
//internal struct WAVEFORMATEX
//{
// public short wFormatTag;
// public short nChannels;
// public int nSamplesPerSec;
// public int nAvgBytesPerSec;
// public short nBlockAlign;
// public short wBitsPerSample;
// public short cbSize;
//}
internal static class AviRiffData internal static class AviRiffData
{ {
#region AVI constants #region AVI constants
@ -117,18 +99,12 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats
// AVI stream FourCC codes // AVI stream FourCC codes
public static readonly int streamtypeVIDEO = RiffParser.ToFourCc("vids"); public static readonly int streamtypeVIDEO = RiffParser.ToFourCc("vids");
public static readonly int streamtypeAUDIO = RiffParser.ToFourCc("auds"); public static readonly int streamtypeAUDIO = RiffParser.ToFourCc("auds");
//public static readonly int streamtypeMIDI = RiffParser.ToFourCC("mids");
//public static readonly int streamtypeTEXT = RiffParser.ToFourCC("txts");
// AVI section FourCC codes // AVI section FourCC codes
public static readonly int ckidAVIHeaderList = RiffParser.ToFourCc("hdrl"); public static readonly int ckidAVIHeaderList = RiffParser.ToFourCc("hdrl");
public static readonly int ckidMainAVIHeader = RiffParser.ToFourCc("avih"); public static readonly int ckidMainAVIHeader = RiffParser.ToFourCc("avih");
//public static readonly int ckidODML = RiffParser.ToFourCC("odml");
//public static readonly int ckidAVIExtHeader = RiffParser.ToFourCC("dmlh");
public static readonly int ckidAVIStreamList = RiffParser.ToFourCc("strl"); public static readonly int ckidAVIStreamList = RiffParser.ToFourCc("strl");
public static readonly int ckidAVIStreamHeader = RiffParser.ToFourCc("strh"); public static readonly int ckidAVIStreamHeader = RiffParser.ToFourCc("strh");
//public static readonly int ckidStreamFormat = RiffParser.ToFourCC("strf");
//public static readonly int ckidAVIOldIndex = RiffParser.ToFourCC("idx1");
public static readonly int ckidINFOList = RiffParser.ToFourCc("INFO"); public static readonly int ckidINFOList = RiffParser.ToFourCc("INFO");
public static readonly int ckidAVIISFT = RiffParser.ToFourCc("ISFT"); public static readonly int ckidAVIISFT = RiffParser.ToFourCc("ISFT");
public const int ckidMP3 = 0x0055; public const int ckidMP3 = 0x0055;

View File

@ -41,8 +41,6 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats.Mp4.Boxes
Width = (uint)GetWord(76 + addToIndex64Bit); // skip decimals Width = (uint)GetWord(76 + addToIndex64Bit); // skip decimals
Height = (uint)GetWord(80 + addToIndex64Bit); // skip decimals Height = (uint)GetWord(80 + addToIndex64Bit); // skip decimals
//System.Windows.Forms.MessageBox.Show("Width: " + GetWord(76 + addToIndex64Bit).ToString() + "." + GetWord(78 + addToIndex64Bit).ToString());
//System.Windows.Forms.MessageBox.Show("Height: " + GetWord(80 + addToIndex64Bit).ToString() + "." + GetWord(82 + addToIndex64Bit).ToString());
} }
} }
} }

View File

@ -163,8 +163,6 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats
_shortName = fi.Name; _shortName = fi.Name;
_fileSize = fi.Length; _fileSize = fi.Length;
//Console.WriteLine(ShortName + " is a valid file.");
// Read the RIFF header // Read the RIFF header
_stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); _stream = new FileStream(_fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
int fourCc; int fourCc;
@ -187,9 +185,6 @@ namespace Nikse.SubtitleEdit.Core.ContainerFormats
} }
// Good header. Check size // Good header. Check size
//Console.WriteLine(ShortName + " has a valid type \"" + riff + "\"");
//Console.WriteLine(ShortName + " has a specific type of \"" + FromFourCC(fileType) + "\"");
_dataSize = datasize; _dataSize = datasize;
if (_fileSize < _dataSize + TwoDWordSize) if (_fileSize < _dataSize + TwoDWordSize)
{ {

View File

@ -310,7 +310,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
else if (ch == 'ı' && TextField.Substring(index).StartsWith("ı̂")) // extended unicode char - rewritten as simple 'î' - looks the same as "î" but it's not...) else if (ch == 'ı' && TextField.Substring(index).StartsWith("ı̂")) // extended unicode char - rewritten as simple 'î' - looks the same as "î" but it's not...)
{ {
sbTwoChar.Append(encoding.GetString(new byte[] { 0xc3, 0x69 })); // Ãi - simple î sbTwoChar.Append(encoding.GetString(new byte[] { 0xc3, 0x69 })); // Ãi - simple î
// sbTwoChar.Append(encoding.GetString(new byte[] { 0xc3, 0xf5 }));
skipNext = true; skipNext = true;
} }
else if ("ÀÈÌÒÙàèìòù".Contains(ch)) else if ("ÀÈÌÒÙàèìòù".Contains(ch))

View File

@ -11,7 +11,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
/// </summary> /// </summary>
public class F4Text : SubtitleFormat public class F4Text : SubtitleFormat
{ {
private static readonly Regex regexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d-\d$", RegexOptions.Compiled); private static readonly Regex RegexTimeCodes = new Regex(@"^\d\d:\d\d:\d\d-\d$", RegexOptions.Compiled);
public override string Extension => ".txt"; public override string Extension => ".txt";
@ -30,15 +30,10 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public static string ToF4Text(Subtitle subtitle) public static string ToF4Text(Subtitle subtitle)
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
//double lastEndTimeMilliseconds = -1;
const string writeFormat = "{0}{1}"; const string writeFormat = "{0}{1}";
foreach (Paragraph p in subtitle.Paragraphs) foreach (Paragraph p in subtitle.Paragraphs)
{ {
// if (p.StartTime.TotalMilliseconds == lastEndTimeMilliseconds)
sb.AppendFormat(writeFormat, HtmlUtil.RemoveHtmlTags(p.Text, true), EncodeTimeCode(p.EndTime)); sb.AppendFormat(writeFormat, HtmlUtil.RemoveHtmlTags(p.Text, true), EncodeTimeCode(p.EndTime));
//else
// sb.Append(string.Format("{0}{1}{2}", EncodeTimeCode(p.StartTime), HtmlUtil.RemoveHtmlTags(p.Text), EncodeTimeCode(p.EndTime)));
//lastEndTimeMilliseconds = p.EndTime.TotalMilliseconds;
} }
return sb.ToString().Trim(); return sb.ToString().Trim();
} }
@ -79,7 +74,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
var currentText = new StringBuilder(); var currentText = new StringBuilder();
foreach (string line in arr) foreach (string line in arr)
{ {
if (regexTimeCodes.IsMatch(line)) if (RegexTimeCodes.IsMatch(line))
{ {
if (p == null) if (p == null)
{ {
@ -110,8 +105,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{ {
if (p == null && subtitle.Paragraphs.Count > 0) if (p == null && subtitle.Paragraphs.Count > 0)
{ {
p = new Paragraph(); p = new Paragraph { StartTime = { TotalMilliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds } };
p.StartTime.TotalMilliseconds = subtitle.Paragraphs[subtitle.Paragraphs.Count - 1].EndTime.TotalMilliseconds;
} }
currentText.AppendLine(line.Trim()); currentText.AppendLine(line.Trim());
} }

View File

@ -207,7 +207,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
startIndex += tag.Length + 2; startIndex += tag.Length + 2;
string res = s.Substring(startIndex).TrimStart().TrimStart(':').TrimStart(); //.TrimStart('[').TrimStart(); string res = s.Substring(startIndex).TrimStart().TrimStart(':').TrimStart();
int tagLevel = 1; int tagLevel = 1;
int oldStart = 0; int oldStart = 0;
if (oldStart < res.Length && res[oldStart] == '[') if (oldStart < res.Length && res[oldStart] == '[')

View File

@ -15,10 +15,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
public static void Save(string fileName) public static void Save(string fileName)
{ {
using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write))
{
//...
}
} }
public override bool IsMine(List<string> lines, string fileName) public override bool IsMine(List<string> lines, string fileName)
@ -137,7 +133,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
buffer[7] == 0x32) buffer[7] == 0x32)
{ {
i = 396; i = 396;
int start = i;
int number = 0; int number = 0;
while (i < buffer.Length - 66) while (i < buffer.Length - 66)
{ {
@ -178,7 +173,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
else else
{ {
//System.Windows.Forms.MessageBox.Show("Problem at with a length of " + length.ToString() + " at file position " + (i + 2) + " which gives remainer: " + (length % 14));
if (length % 14 == 8) if (length % 14 == 8)
{ {
count++; count++;

View File

@ -1205,7 +1205,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
} }
} }
// text = text.Replace("<i>", " <i>");
text = text.Replace("</i>", "</i> "); text = text.Replace("</i>", "</i> ");
text = text.Replace(" ", " "); text = text.Replace(" ", " ");
return text.Replace(" " + Environment.NewLine, Environment.NewLine).Trim(); return text.Replace(" " + Environment.NewLine, Environment.NewLine).Trim();
@ -1627,7 +1626,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
return HebrewCodes[b].Character; return HebrewCodes[b].Character;
} }
return string.Empty;//string.Format("({0})", b); return string.Empty;
} }
public static string GetLatinString(Encoding encoding, byte[] buffer, ref int index) public static string GetLatinString(Encoding encoding, byte[] buffer, ref int index)
@ -1681,7 +1680,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
} }
return string.Empty;//string.Format("({0})", b); return string.Empty;
} }
public static string GetGreekString(byte[] buffer, ref int index) public static string GetGreekString(byte[] buffer, ref int index)
@ -1734,7 +1733,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
} }
return string.Empty;//string.Format("({0})", b); return string.Empty;
} }
internal static TimeCode GetTimeCode(int timeCodeIndex, byte[] buffer) internal static TimeCode GetTimeCode(int timeCodeIndex, byte[] buffer)

View File

@ -36,7 +36,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
private const string TimeCodeRegEx = @"^\d+:\d\d:\d\d[:,]\d\d\t"; private const string TimeCodeRegEx = @"^\d+:\d\d:\d\d[:,]\d\d\t";
private static readonly Regex Regex = new Regex(TimeCodeRegEx, RegexOptions.Compiled); private static readonly Regex Regex = new Regex(TimeCodeRegEx, RegexOptions.Compiled);
protected virtual Regex RegexTimeCodes => Regex; protected virtual Regex RegexTimeCodes => Regex;
protected bool DropFrame = false; protected bool DropFrame;
public static List<KeyValuePair<string, string>> LetterDictionary = new List<KeyValuePair<string, string>> public static List<KeyValuePair<string, string>> LetterDictionary = new List<KeyValuePair<string, string>>
{ {

View File

@ -118,34 +118,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
0x17, 0x21, // 0x1721=center, 0x1722=right ? 0x17, 0x21, // 0x1721=center, 0x1722=right ?
}; };
//if (text.StartsWith("{\\a6}"))
//{
// text = p.Text.Remove(0, 5);
// buffer[7] = 1; // align top
//}
//else if (text.StartsWith("{\\a1}"))
//{
// text = p.Text.Remove(0, 5);
// buffer[8] = 0x0A; // align left
//}
//else if (text.StartsWith("{\\a3}"))
//{
// text = p.Text.Remove(0, 5);
// buffer[8] = 0x1E; // align right
//}
//else if (text.StartsWith("{\\a5}"))
//{
// text = p.Text.Remove(0, 5);
// buffer[7] = 1; // align top
// buffer[8] = 05; // align left
//}
//else if (text.StartsWith("{\\a7}"))
//{
// text = p.Text.Remove(0, 5);
// buffer[7] = 1; // align top
// buffer[8] = 0xc; // align right
//}
fs.WriteByte(0xF1); //ID of start record fs.WriteByte(0xF1); //ID of start record
// length // length
@ -248,7 +220,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
sb.Clear(); sb.Clear();
int skipCount = 0; int skipCount = 0;
bool italics = false; bool italics = false;
//bool font = false;
for (int k = start; k < length + i; k++) for (int k = start; k < length + i; k++)
{ {
byte b = buffer[k]; byte b = buffer[k];
@ -262,178 +233,23 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
skipCount = 1; skipCount = 1;
if (sb.Length > 0 && !sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal) && !sb.EndsWith('>')) if (sb.Length > 0 && !sb.ToString().EndsWith(Environment.NewLine, StringComparison.Ordinal) && !sb.EndsWith('>'))
{ {
//if (font)
// sb.Append("</font>");
if (italics) if (italics)
{ {
sb.Append("</i>"); sb.Append("</i>");
} }
sb.AppendLine(); sb.AppendLine();
//font = false;
italics = false; italics = false;
} }
//string code = VobSub.Helper.IntToBin(buffer[k] * 256 + buffer[k+1], 16);
//var codeBytes = new List<char>();
//if (b == 0x11 && b2 == 0x28)
//{
// sb.Append("<font color=\"red\">");
// font = true;
//}
//else
if (b == 0x11 && b2 == 0x2e) if (b == 0x11 && b2 == 0x2e)
{ {
sb.Append("<i>"); sb.Append("<i>");
italics = true; italics = true;
} }
//foreach (char ch in code)
// codeBytes.Insert(0, ch);
//if (codeBytes[13] == '0' && codeBytes[14] == '0' && codeBytes[12] == '1' && codeBytes[6] == '1')
//{ // preamble address code
// if (code.Substring(11, 4) == "1000")
// {
// sb.Append("<font color=\"green\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0010")
// {
// sb.Append("<font color=\"blue\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0011")
// {
// sb.Append("<font color=\"cyan\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0100")
// {
// sb.Append("<font color=\"red\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0101")
// {
// sb.Append("<font color=\"yellow\">");
// font = true;
// }
// //else if (code.Substring(11, 4) == "0110")
// //{
// // sb.Append("<font color=\"magenta\">");
// // font = true;
// //}
//}
//else if (codeBytes[14] == '0' && codeBytes[13] == '0' && codeBytes[10] == '0' && codeBytes[9] == '0' && codeBytes[6] == '0' &&
// codeBytes[12] == '1' && codeBytes[8] == '1' && codeBytes[6] == '1')
//{ // midrow code
// if (code.Substring(11, 4) == "1000")
// {
// sb.Append("<font color=\"green\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0010")
// {
// sb.Append("<font color=\"blue\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0011")
// {
// sb.Append("<font color=\"cyan\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0100")
// {
// sb.Append("<font color=\"red\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0101")
// {
// sb.Append("<font color=\"yellow\">");
// font = true;
// }
// //else if (code.Substring(11, 4) == "0110")
// //{
// // sb.Append("<font color=\"magenta\">");
// // font = true;
// //}
//}
//else if ((codeBytes[14] == '0' && codeBytes[13] == '0' && codeBytes[9] == '0' && codeBytes[6] == '0' && codeBytes[4] == '0' &&
// codeBytes[12] == '1' && codeBytes[10] == '1' && codeBytes[5] == '1') || b == 0x11)
//{ // codeBytes[10] == 0 ???
// //control codes
// if (code.Substring(11, 4) == "0111" && buffer[k] == 0x11)
// {
// sb.Append("<i>");
// italics = true;
// }
// else if (code.Substring(11, 4) == "1000")
// {
// sb.Append("<font color=\"green\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0010")
// {
// sb.Append("<font color=\"blue\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0011")
// {
// sb.Append("<font color=\"cyan\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0100")
// {
// sb.Append("<font color=\"red\">");
// font = true;
// }
// else if (code.Substring(11, 4) == "0101")
// {
// sb.Append("<font color=\"yellow\">");
// font = true;
// }
// //else if (code.Substring(11, 4) == "0110")
// //{
// // sb.Append("<font color=\"magenta\">");
// // font = true;
// //}
//}
//else
//{
// if (code.Substring(11, 4) == "0111" && buffer[k] == 0x11)
// {
// sb.Append("<i>");
// italics = true;
// }
// else if (code.Substring(11, 4) == "0101" && b == 0x11)
// {
// sb.Append("<font color=\"yellow\">");
// font = true;
// }
//// if (code.Substring(11, 4) == "0111")
//// {
//// //System.Windows.Forms.MessageBox.Show(code);
//// sb.Append("<i>");
//// }
//// else if (code.Substring(11, 4) == "0101")
//// sb.Append("<font color=\"yellow\">");
//}
} }
else if (b == 0x80) else if (b == 0x80)
{ {
//if (sb.Length == 0)
// break;
//if (sb.Length > 0 && !sb.ToString().EndsWith(Environment.NewLine))
//{
// if (font)
// sb.Append("</font>");
// if (italics)
// sb.Append("</i>");
// sb.AppendLine();
// font = false;
// italics = false;
//}
} }
else else
{ {
@ -441,8 +257,6 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
} }
p.Text = sb.ToString().Trim(); p.Text = sb.ToString().Trim();
//if (font)
// p.Text += "</font>";
if (italics) if (italics)
{ {
p.Text += "</i>"; p.Text += "</i>";
@ -478,6 +292,5 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
} }
public override List<string> AlternateExtensions => new List<string> { ".uld" }; // Ultech drop frame public override List<string> AlternateExtensions => new List<string> { ".uld" }; // Ultech drop frame
} }
} }

View File

@ -11,8 +11,6 @@ namespace Nikse.SubtitleEdit.Core.VobSub
public readonly UInt32 StartCode; public readonly UInt32 StartCode;
public readonly byte PackIndentifier; public readonly byte PackIndentifier;
//public readonly UInt64 SystemClockReferenceQuotient;
//public readonly UInt64 SystemClockReferenceRemainder;
public readonly UInt64 ProgramMuxRate; public readonly UInt64 ProgramMuxRate;
public readonly int PackStuffingLength; public readonly int PackStuffingLength;
@ -20,15 +18,7 @@ namespace Nikse.SubtitleEdit.Core.VobSub
{ {
StartCode = Helper.GetEndian(buffer, 0, 3); StartCode = Helper.GetEndian(buffer, 0, 3);
PackIndentifier = buffer[3]; PackIndentifier = buffer[3];
//string b4To9AsBinary = Helper.GetBinaryString(buffer, 4, 6);
//b4To9AsBinary = b4To9AsBinary.Substring(2,3) + b4To9AsBinary.Substring(6,15) + b4To9AsBinary.Substring(22,15);
//SystemClockReferenceQuotient = Helper.GetUInt32FromBinaryString(b4To9AsBinary);
//SystemClockReferenceRemainder = (ulong)(((buffer[8] & Helper.B00000011) << 8) + buffer[9])
ProgramMuxRate = Helper.GetEndian(buffer, 10, 3) >> 2; ProgramMuxRate = Helper.GetEndian(buffer, 10, 3) >> 2;
PackStuffingLength = buffer[13] & Helper.B00000111; PackStuffingLength = buffer[13] & Helper.B00000111;
} }

View File

@ -124,7 +124,6 @@ namespace Nikse.SubtitleEdit.Core.VobSub
// Control Sequence Table // Control Sequence Table
// Write delay - subtitle duration // Write delay - subtitle duration
WriteEndianWord(Convert.ToInt32(p.Duration.TotalMilliseconds * 90.0) >> 10, ms); WriteEndianWord(Convert.ToInt32(p.Duration.TotalMilliseconds * 90.0) >> 10, ms);
// WriteEndianWord(Convert.ToInt32(p.Duration.TotalMilliseconds * 90.0 - 1023) >> 10, ms);
// next display control sequence table address (use current is last) // next display control sequence table address (use current is last)
WriteEndianWord(startDisplayControlSequenceTableAddress + 24, ms); // start of display control sequence table address WriteEndianWord(startDisplayControlSequenceTableAddress + 24, ms); // start of display control sequence table address

View File

@ -812,7 +812,6 @@ namespace Nikse.SubtitleEdit.Core
if (endPaddingSampleCount > 0) if (endPaddingSampleCount > 0)
{ {
Array.Clear(chunkSamples, chunkSampleOffset, endPaddingSampleCount); Array.Clear(chunkSamples, chunkSampleOffset, endPaddingSampleCount);
chunkSampleOffset += endPaddingSampleCount;
} }
// generate spectrogram for this chunk // generate spectrogram for this chunk
@ -820,10 +819,7 @@ namespace Nikse.SubtitleEdit.Core
images.Add(bmp); images.Add(bmp);
// wait for previous image to finish saving // wait for previous image to finish saving
if (saveImageTask != null) saveImageTask?.Wait();
{
saveImageTask.Wait();
}
// save image // save image
string imagePath = Path.Combine(spectrogramDirectory, iChunk + ".gif"); string imagePath = Path.Combine(spectrogramDirectory, iChunk + ".gif");
@ -834,10 +830,7 @@ namespace Nikse.SubtitleEdit.Core
} }
// wait for last image to finish saving // wait for last image to finish saving
if (saveImageTask != null) saveImageTask?.Wait();
{
saveImageTask.Wait();
}
var doc = new XmlDocument(); var doc = new XmlDocument();
var culture = CultureInfo.InvariantCulture; var culture = CultureInfo.InvariantCulture;

View File

@ -1503,12 +1503,6 @@ namespace Nikse.SubtitleEdit.Controls
} }
else else
{ {
//SHOW DEBUG MSG SolidBrush tBrush = new SolidBrush(Color.Turquoise);
//var g = this.CreateGraphics();
//g.DrawString("AllowMovePrevOrNext: " + AllowMovePrevOrNext.ToString() + ", GapStart: " + _gapAtStart.ToString(), Font, tBrush, new PointF(100, 100));
//tBrush.Dispose();
//g.Dispose();
OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext)); OnTimeChanged?.Invoke(this, new ParagraphEventArgs(seconds, _mouseDownParagraph, _oldParagraph, _mouseDownParagraphType, AllowMovePrevOrNext));
Refresh(); Refresh();
return; return;

View File

@ -727,7 +727,7 @@ namespace Nikse.SubtitleEdit.Controls
Cursor.Hide(); Cursor.Hide();
} }
private int _cursorStatus = 0; private int _cursorStatus;
public void ShowCursor() public void ShowCursor()
{ {

View File

@ -172,7 +172,6 @@ namespace Nikse.SubtitleEdit.Forms
var output = new StringBuilder(); var output = new StringBuilder();
var path = Path.Combine(Configuration.DataDirectory, "pocketsphinx"); var path = Path.Combine(Configuration.DataDirectory, "pocketsphinx");
var fileName = Path.Combine(path, "bin", "Release", "Win32", "pocketsphinx_continuous.exe"); var fileName = Path.Combine(path, "bin", "Release", "Win32", "pocketsphinx_continuous.exe");
// var fileName = Path.Combine(path, "bin", "Release", "x64", "pocketsphinx_continuous.exe");
var hmm = Path.Combine(path, "model", "en-us", "en-us"); var hmm = Path.Combine(path, "model", "en-us", "en-us");
var lm = Path.Combine(path, "model", "en-us", "en-us.lm.bin"); var lm = Path.Combine(path, "model", "en-us", "en-us.lm.bin");
var dict = Path.Combine(path, "model", "en-us", "cmudict-en-us.dict"); var dict = Path.Combine(path, "model", "en-us", "cmudict-en-us.dict");

View File

@ -20,7 +20,7 @@ namespace Nikse.SubtitleEdit.Forms
//private System.Windows.Forms.Timer timer1; //private System.Windows.Forms.Timer timer1;
private const int lineChecksWidth = 50; private const int lineChecksWidth = 50;
private const int lineChecksHeight = 25; private const int lineChecksHeight = 25;
public string OcrFileName = null; public string OcrFileName;
public HardSubExtract(string videoFileName) public HardSubExtract(string videoFileName)
{ {

View File

@ -91,7 +91,7 @@ namespace Nikse.SubtitleEdit.Forms
private int _repeatCount = -1; private int _repeatCount = -1;
private double _endSeconds = -1; private double _endSeconds = -1;
private double _endSecondsNewPosition = -1; private double _endSecondsNewPosition = -1;
private long _endSecondsNewPositionTicks = 0; private long _endSecondsNewPositionTicks;
private const double EndDelay = 0.05; private const double EndDelay = 0.05;
private int _autoContinueDelayCount = -1; private int _autoContinueDelayCount = -1;
private long _lastTextKeyDownTicks; private long _lastTextKeyDownTicks;
@ -104,7 +104,7 @@ namespace Nikse.SubtitleEdit.Forms
private string _textAutoBackup; private string _textAutoBackup;
private string _textAutoBackupOriginal; private string _textAutoBackupOriginal;
private List<string> _statusLog = new List<string>(); private List<string> _statusLog = new List<string>();
private bool _hideStatusLog = false; private bool _hideStatusLog;
private StatusLog _statusLogForm; private StatusLog _statusLogForm;
private bool _makeHistoryPaused; private bool _makeHistoryPaused;
private bool _saveAsCalled; private bool _saveAsCalled;

View File

@ -192,7 +192,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
} }
} }
texts.Sort(); texts.Sort();
labelCount.Text = string.Format("{0:#,##0}", count); labelCount.Text = $"{count:#,##0}";
comboBoxTexts.Items.Clear(); comboBoxTexts.Items.Clear();
foreach (string text in texts) foreach (string text in texts)
@ -303,15 +303,10 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (bob != null) if (bob != null)
{ {
bmp = bob.ToOldBitmap(); bmp = bob.ToOldBitmap();
labelImageInfo.Text = string.Format("Top:{0}, {1} colored pixels of {2}", bob.Y, bob.NumberOfColoredPixels, (bob.Width * bob.Height)); labelImageInfo.Text = $"Top:{bob.Y}, {bob.NumberOfColoredPixels} colored pixels of {(bob.Width * bob.Height)}";
//bool italicI;
//var isI = bob.IsLowercaseI(out italicI);
//labelImageInfo.Text = string.Format("T:{0} j{1} :{2} i{3}{4} '{5} #{6}/{7}", bob.Y, bob.IsLowercaseJ(), bob.IsColon(), isI, italicI ? "i" : "", bob.IsApostrophe(), bob.NumberOfColoredPixels, (bob.Width * bob.Height));
if (bob.ExpandCount > 0) if (bob.ExpandCount > 0)
{ {
labelExpandCount.Text = string.Format("Expand count: {0}", bob.ExpandCount); labelExpandCount.Text = $"Expand count: {bob.ExpandCount}";
} }
} }
} }
@ -353,7 +348,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
var bob = GetSelectedBinOcrBitmap(); var bob = GetSelectedBinOcrBitmap();
foreach (var a in Additions) foreach (var a in Additions)
{ {
if (bob != null && bob.Text != null && bob.Key == a.Name) if (bob?.Text != null && bob.Key == a.Name)
{ {
textBoxText.Text = a.Text; textBoxText.Text = a.Text;
checkBoxItalic.Checked = a.Italic; checkBoxItalic.Checked = a.Italic;

View File

@ -2854,7 +2854,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{ {
if (!oc.IsSensitive) if (!oc.IsSensitive)
{ {
if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Height > 11) // && oc.Height > 12 && oc.Width > 16 && nbmp.Width > 16 && nbmp.Height > 12 && Math.Abs(oc.MarginTop - topMargin) < 15) if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Height > 11)
{ {
bool ok = true; bool ok = true;
foreach (NOcrPoint op in oc.LinesForeground) foreach (NOcrPoint op in oc.LinesForeground)

View File

@ -615,7 +615,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (ok && IsMatchPointForeGround(op, !tempVeryPrecise, nbmp, nOcrChar)) if (ok && IsMatchPointForeGround(op, !tempVeryPrecise, nbmp, nOcrChar))
{ {
nOcrChar.LinesForeground.Add(op); nOcrChar.LinesForeground.Add(op);
//AddHistoryItem(nOcrChar);
hits++; hits++;
} }
count++; count++;
@ -675,7 +674,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
if (ok && IsMatchPointBackGround(op, !tempVeryPrecise, nbmp, nOcrChar)) if (ok && IsMatchPointBackGround(op, !tempVeryPrecise, nbmp, nOcrChar))
{ {
nOcrChar.LinesBackground.Add(op); nOcrChar.LinesBackground.Add(op);
//AddHistoryItem(nOcrChar);
hits++; hits++;
} }
count++; count++;

View File

@ -74,7 +74,6 @@ namespace Nikse.SubtitleEdit.Logic
if (iterations < 1) if (iterations < 1)
{ {
// note: no need to restore the colors set are constants // note: no need to restore the colors set are constants
//_isConfigUpdated = false;
return; return;
} }
@ -146,7 +145,6 @@ namespace Nikse.SubtitleEdit.Logic
c.BackColor = BackColor; c.BackColor = BackColor;
c.ForeColor = ForeColor; c.ForeColor = ForeColor;
//c.Paint += C_Paint;
} }
} }
FixControl(ctrl); FixControl(ctrl);

View File

@ -75,8 +75,6 @@ namespace Nikse.SubtitleEdit.Logic
startTop++; startTop++;
} }
//if (startTop > 9)
//startTop -= 5; // if top space > 9, then allways leave blank 5 pixels on top (so . is not confused with ').
topCropping = startTop; topCropping = startTop;
int h = bmp.Height; int h = bmp.Height;
@ -204,9 +202,7 @@ namespace Nikse.SubtitleEdit.Logic
if (size > 2) if (size > 2)
{ {
NikseBitmap part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); NikseBitmap part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1));
// part.Save("c:\\line_0_to_width.bmp");
parts.Add(new ImageSplitterItem(0, startY, part)); parts.Add(new ImageSplitterItem(0, startY, part));
// bmp.Save("c:\\original.bmp");
} }
size = 0; size = 0;
startY = y; startY = y;
@ -264,9 +260,7 @@ namespace Nikse.SubtitleEdit.Logic
if (size > 8) if (size > 8)
{ {
NikseBitmap part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1)); NikseBitmap part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1));
// part.Save("c:\\line_0_to_width.bmp");
parts.Add(new ImageSplitterItem(0, startY, part)); parts.Add(new ImageSplitterItem(0, startY, part));
// bmp.Save("c:\\original.bmp");
} }
size = 0; size = 0;
startY = y; startY = y;

View File

@ -220,13 +220,7 @@ namespace Nikse.SubtitleEdit.Logic.VideoPlayers
private void VideoLoaderDoWork(object sender, DoWorkEventArgs e) private void VideoLoaderDoWork(object sender, DoWorkEventArgs e)
{ {
//int i = 0;
//while (CurrentPosition < 1 && i < 100)
//{
Application.DoEvents(); Application.DoEvents();
// System.Threading.Thread.Sleep(5);
// i++;
//}
} }
private void VideoLoaderRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) private void VideoLoaderRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)