SubtitleEdit/subtitleedit · warning · Exception
Too many bytes for CCData!
Error message
Too many bytes for CCData!
What it means
Thrown by the CEA-708 CcDataSection constructor when the supplied byte array contains more than 16 caption-character pairs (i.e. bytes.Length > 32). Per ATSC A/53 the cc_data block in a picture user-data field holds at most 16 CC pairs per field; exceeding that means the input is malformed or the caller mis-parsed the count.
Source
Thrown at src/libse/Cea708/CcDataSection.cs:52
{
Valid = (bytes[index + i * 3 + 2] & 0b00000100) > 0,
Type = bytes[index + i * 3 + 2] & 0b00000011,
Data1 = bytes[index + i * 3 + 3],
Data2 = bytes[index + i * 3 + 4]
};
}
}
public CcDataSection(int ccDataCount, byte[] bytes, int sequenceCount)
{
DataSection = 0x72;
ProcessEmData = true;
ProcessCcData = true;
AdditionalData = true;
if (bytes.Length / 2 > 16)
{
throw new Exception("Too many bytes for CCData!");
}
CcData = new CcData[ccDataCount];
var bytesIndex = 0;
var lastContent = true;
for (int i = 0; i < ccDataCount; i++)
{
if (i == 0)
{
CcData[i] = new CcData
{
Valid = true,
Type = 0,
Data1 = 0x80,
Data2 = 0x80,
};
}
else if (i == 1)View on GitHub (pinned to 17a9f07487)
Solutions
- Verify bytes.Length <= 32 and ccDataCount == bytes.Length/2 before constructing CcDataSection.
- Split the incoming payload into <=32-byte cc_data chunks per picture before calling the constructor.
- Clamp or truncate oversize buffers with a logged warning instead of throwing.
- Regenerate the captions from a trusted source rather than editing raw bytes.
Example fix
// before
if (bytes.Length / 2 > 16)
{
throw new Exception("Too many bytes for CCData!");
}
// after
const int MaxCcPairs = 16;
var usable = Math.Min(bytes.Length / 2, MaxCcPairs);
if (usable < bytes.Length / 2)
{
Logger.Warn($"CcData truncated from {bytes.Length / 2} to {MaxCcPairs} pairs.");
}
// proceed using `usable` pairs Defensive patterns
Strategy: validation
Validate before calling
if (bytes == null || bytes.Length / 2 > 16 || bytes.Length % 2 != 0) throw new ArgumentException("cc_data must be <= 32 bytes and even length"); Try / catch
try { var section = new CcDataSection(count, bytes, seq); }
catch (Exception ex) when (ex.Message.Contains("CCData")) { /* split or drop packet */ } Prevention
- Always split cc_data by picture boundary before constructing sections.
- Assert ccDataCount == bytes.Length/2 in unit tests of your encoder.
When it happens
Trigger: Passing a raw bytes array larger than 32 to the CcDataSection(int, byte[], int) constructor; ccDataCount not matching bytes.Length/2; feeding concatenated cc_data sections from multiple frames as one.
Common situations: Hand-assembled caption packets; buggy upstream ATSC/SEI extractor that did not split cc_data by frame boundary; corrupted transport stream where the SEI payload length is wrong.
Related errors
- Unable to access bitmap pixel data.
- Color '{colorName}' not found in SKColors.
- Dvd language {code} not found!
- End of file reached before expected
- MXF KLV packet - lenght bytes > 8
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/e77191589a8edd83.
Report an issue: GitHub.