mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-26 05:02:36 +01:00
parent
d45a47738f
commit
7d91bd3e7c
@ -691,26 +691,26 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
}
|
||||
}
|
||||
|
||||
public DialogPresentationSegment(byte[] buffer)
|
||||
public DialogPresentationSegment(byte[] buffer, int idx)
|
||||
{
|
||||
StartPts = buffer[13];
|
||||
StartPts += (ulong)buffer[12] << 8;
|
||||
StartPts += (ulong)buffer[11] << 16;
|
||||
StartPts += (ulong)buffer[10] << 24;
|
||||
StartPts += (ulong)(buffer[9] & Helper.B00000001) << 32;
|
||||
StartPts = buffer[idx + 13];
|
||||
StartPts += (ulong)buffer[idx + 12] << 8;
|
||||
StartPts += (ulong)buffer[idx + 11] << 16;
|
||||
StartPts += (ulong)buffer[idx + 10] << 24;
|
||||
StartPts += (ulong)(buffer[idx + 9] & Helper.B00000001) << 32;
|
||||
|
||||
EndPts = buffer[18];
|
||||
EndPts += (ulong)buffer[17] << 8;
|
||||
EndPts += (ulong)buffer[16] << 16;
|
||||
EndPts += (ulong)buffer[15] << 24;
|
||||
EndPts += (ulong)(buffer[14] & Helper.B00000001) << 32;
|
||||
EndPts = buffer[idx + 18];
|
||||
EndPts += (ulong)buffer[idx + 17] << 8;
|
||||
EndPts += (ulong)buffer[idx + 16] << 16;
|
||||
EndPts += (ulong)buffer[idx + 15] << 24;
|
||||
EndPts += (ulong)(buffer[idx + 14] & Helper.B00000001) << 32;
|
||||
|
||||
PaletteUpdate = (buffer[19] & Helper.B10000000) > 0;
|
||||
int idx = 20;
|
||||
PaletteUpdate = (buffer[idx + 19] & Helper.B10000000) > 0;
|
||||
idx += 20;
|
||||
PaletteUpdates = new List<Palette>();
|
||||
if (PaletteUpdate)
|
||||
{
|
||||
int numberOfPaletteEntries = buffer[21] + (buffer[20] << 8);
|
||||
int numberOfPaletteEntries = buffer[idx + 21] + (buffer[idx + 20] << 8);
|
||||
for (int i = 0; i < numberOfPaletteEntries; i++)
|
||||
{
|
||||
PaletteUpdates.Add(new Palette
|
||||
@ -1034,7 +1034,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
if (buffer[6] == SegmentTypeDialogPresentation)
|
||||
{
|
||||
var dps = new DialogPresentationSegment(buffer);
|
||||
var dps = new DialogPresentationSegment(buffer, 0);
|
||||
PresentationSegments.Add(dps);
|
||||
subtitle.Paragraphs.Add(new Paragraph(dps.Text.Trim(), dps.StartPtsMilliseconds, dps.EndPtsMilliseconds));
|
||||
}
|
||||
@ -1103,7 +1103,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
{
|
||||
if (item.Payload[6] == SegmentTypeDialogPresentation)
|
||||
{
|
||||
var dps = new DialogPresentationSegment(item.Payload);
|
||||
var dps = new DialogPresentationSegment(item.Payload, 0);
|
||||
PresentationSegments.Add(dps);
|
||||
subtitle.Paragraphs.Add(new Paragraph(dps.Text.Trim(), dps.StartPtsMilliseconds, dps.EndPtsMilliseconds));
|
||||
}
|
||||
|
@ -8905,6 +8905,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return false;
|
||||
return LoadBluRaySubFromMatroska(matroskaSubtitleInfo, matroska);
|
||||
}
|
||||
if (matroskaSubtitleInfo.CodecId.Equals("S_HDMV/TEXTST", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (batchMode)
|
||||
return false;
|
||||
return LoadTextSTFromMatroska(matroskaSubtitleInfo, matroska, batchMode);
|
||||
}
|
||||
|
||||
ShowStatus(_language.ParsingMatroskaFile);
|
||||
Refresh();
|
||||
@ -8964,6 +8970,72 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool LoadTextSTFromMatroska(MatroskaTrackInfo matroskaSubtitleInfo, MatroskaFile matroska, bool batchMode)
|
||||
{
|
||||
ShowStatus(_language.ParsingMatroskaFile);
|
||||
Refresh();
|
||||
Cursor.Current = Cursors.WaitCursor;
|
||||
var sub = matroska.GetSubtitle(matroskaSubtitleInfo.TrackNumber, MatroskaProgress);
|
||||
TaskbarList.SetProgressState(Handle, TaskbarButtonProgressFlags.NoProgress);
|
||||
Cursor.Current = Cursors.Default;
|
||||
|
||||
MakeHistoryForUndo(_language.BeforeImportFromMatroskaFile);
|
||||
_subtitleListViewIndex = -1;
|
||||
if (!batchMode)
|
||||
ResetSubtitle();
|
||||
_subtitle.Paragraphs.Clear();
|
||||
|
||||
Utilities.LoadMatroskaTextSubtitle(matroskaSubtitleInfo, matroska, sub, _subtitle);
|
||||
for (int index = 0; index < sub.Count; index++)
|
||||
{
|
||||
try
|
||||
{
|
||||
var msub = sub[index];
|
||||
int idx = -6; // MakeMKV starts at DialogPresentationSegment
|
||||
if (VobSubParser.IsPrivateStream2(msub.Data, 0))
|
||||
idx = 0; // starts with MPEG2 private stream 2 (just to be sure)
|
||||
var dps = new Nikse.SubtitleEdit.Core.SubtitleFormats.TextST.DialogPresentationSegment(msub.Data, idx);
|
||||
_subtitle.Paragraphs[index].Text = dps.Text;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_subtitle.Paragraphs[index].Text = exception.Message;
|
||||
}
|
||||
}
|
||||
|
||||
if (_networkSession == null && SubtitleListview1.IsExtraColumnVisible)
|
||||
{
|
||||
SubtitleListview1.HideExtraColumn();
|
||||
}
|
||||
comboBoxSubtitleFormats.SelectedIndexChanged -= ComboBoxSubtitleFormatsSelectedIndexChanged;
|
||||
SetCurrentFormat(Configuration.Settings.General.DefaultSubtitleFormat);
|
||||
comboBoxSubtitleFormats.SelectedIndexChanged += ComboBoxSubtitleFormatsSelectedIndexChanged;
|
||||
SetEncoding(Encoding.UTF8);
|
||||
ShowStatus(_language.SubtitleImportedFromMatroskaFile);
|
||||
_subtitle.Renumber();
|
||||
_subtitle.WasLoadedWithFrameNumbers = false;
|
||||
if (matroska.Path.EndsWith(".mkv", StringComparison.OrdinalIgnoreCase) || matroska.Path.EndsWith(".mks", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_fileName = matroska.Path.Remove(matroska.Path.Length - 4);
|
||||
Text = Title + " - " + _fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
Text = Title;
|
||||
}
|
||||
_fileDateTime = new DateTime();
|
||||
_converted = true;
|
||||
if (batchMode)
|
||||
return true;
|
||||
|
||||
SubtitleListview1.Fill(_subtitle, _subtitleAlternate);
|
||||
if (_subtitle.Paragraphs.Count > 0)
|
||||
SubtitleListview1.SelectIndexAndEnsureVisible(0);
|
||||
|
||||
ShowSource();
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void CopyStream(Stream input, Stream output)
|
||||
{
|
||||
var buffer = new byte[128 * 1024];
|
||||
|
Loading…
Reference in New Issue
Block a user