From 4aac94ddc3d7a32417bea848bc4f634fdf6c4497 Mon Sep 17 00:00:00 2001 From: Nikolaj Olsson Date: Mon, 29 Mar 2021 11:10:18 +0200 Subject: [PATCH] Work on mcc --- src/libse/Cea708/CcDataSection.cs | 10 +++++----- src/libse/Cea708/CcServiceInfoSection.cs | 9 ++------- src/libse/Cea708/Smpte291M.cs | 9 +++++++-- src/libse/Cea708/VancDataWriter.cs | 10 +++++----- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libse/Cea708/CcDataSection.cs b/src/libse/Cea708/CcDataSection.cs index 10f10056c..1b2b74bc4 100644 --- a/src/libse/Cea708/CcDataSection.cs +++ b/src/libse/Cea708/CcDataSection.cs @@ -64,8 +64,8 @@ namespace Nikse.SubtitleEdit.Core.Cea708 { Valid = true, Type = 0, - Data1 = 0x97, - Data2 = 0xa2, + Data1 = 0x80, + Data2 = 0x80, }; } else if (i == 1) @@ -82,13 +82,13 @@ namespace Nikse.SubtitleEdit.Core.Cea708 { var rollingSequence = sequenceCount % 4; // rolling sequence 0-3 var ccContentLength = bytes.Length / 2 + 2; - var x = (byte)((rollingSequence << 6) + ccContentLength); + var sequenceAndLength = (byte)((rollingSequence << 6) + ccContentLength); CcData[i] = new CcData { Valid = true, Type = 3, - Data1 = (byte)x, - Data2 = 0x33, + Data1 = sequenceAndLength, + Data2 = 0x33, // What is this? }; } else diff --git a/src/libse/Cea708/CcServiceInfoSection.cs b/src/libse/Cea708/CcServiceInfoSection.cs index 9ae408904..992d864b2 100644 --- a/src/libse/Cea708/CcServiceInfoSection.cs +++ b/src/libse/Cea708/CcServiceInfoSection.cs @@ -23,18 +23,13 @@ namespace Nikse.SubtitleEdit.Core.Cea708 Start = true; Change = true; Complete = true; - ServiceCount = 2; + ServiceCount = 1; CcServiceInfoSectionElements = new[] { new CcServiceInfoSectionElement { CaptionServiceNumber = 0, - ServiceDataByte = new byte[] { 32, 32, 32, 126, 127, 255}, - }, - new CcServiceInfoSectionElement - { - CaptionServiceNumber = 1, - ServiceDataByte = new byte[] { 101, 110, 103, 193, 127, 255}, + ServiceDataByte = new byte[] { 0x65, 0x6e, 0x67, 0xc1, 0xff, 0xff }, }, }; } diff --git a/src/libse/Cea708/Smpte291M.cs b/src/libse/Cea708/Smpte291M.cs index d3d713a3c..cc161a24c 100644 --- a/src/libse/Cea708/Smpte291M.cs +++ b/src/libse/Cea708/Smpte291M.cs @@ -48,7 +48,6 @@ namespace Nikse.SubtitleEdit.Core.Cea708 { DataId = 0x61; SecondaryDataId = 1; - DataCount = 0x59; CaptionDistributionPacketId = 0x9669; CaptionDistributionPacketDataCount = 0x59; CaptionDistributionPacketFramingRate = 4; // 29.97 @@ -64,6 +63,8 @@ namespace Nikse.SubtitleEdit.Core.Cea708 CcDataSectionCcData = new CcDataSection(ccDataCount, bytes, sequenceCount); CcServiceInfoSection = new CcServiceInfoSection(); + + DataCount = 8 + CcDataSectionCcData.GetLength() + CcServiceInfoSection.GetLength(); } public Smpte291M(byte[] bytes) @@ -138,9 +139,13 @@ namespace Nikse.SubtitleEdit.Core.Cea708 0xbb }).ToArray(); + // Data count + result[2] = (byte)(result.Length - 4); + result[5] = (byte)(result.Length - 4); + // Calculate number that will make the checksum zero long total = 0; - for (var i = 3; i < result.Length - 3; i++) + for (var i = 3; i < result.Length - 2; i++) { total += result[i]; } diff --git a/src/libse/Cea708/VancDataWriter.cs b/src/libse/Cea708/VancDataWriter.cs index 11fe0fbb0..2e17aaead 100644 --- a/src/libse/Cea708/VancDataWriter.cs +++ b/src/libse/Cea708/VancDataWriter.cs @@ -32,11 +32,11 @@ namespace Nikse.SubtitleEdit.Core.Cea708 { var bytes = new List(); var smpte291M = new Smpte291M(counter, 20, bytes.ToArray()); - smpte291M.CcDataSectionCcData.CcData[2].Valid = false; - smpte291M.CcDataSectionCcData.CcData[2].Type = 2; - smpte291M.CcDataSectionCcData.CcData[2].Data1 = 0; - smpte291M.CcDataSectionCcData.CcData[2].Data2 = 0; - smpte291M.CcDataSectionCcData.CcData[3].Valid = false; + //smpte291M.CcDataSectionCcData.CcData[2].Valid = false; + //smpte291M.CcDataSectionCcData.CcData[2].Type = 2; + //smpte291M.CcDataSectionCcData.CcData[2].Data1 = 0; + //smpte291M.CcDataSectionCcData.CcData[2].Data2 = 0; + //smpte291M.CcDataSectionCcData.CcData[3].Valid = false; var resultBytes = smpte291M.GetBytes(); var hex = ByteArrayToHexString(resultBytes); return hex;