Skip to content

Treat CEA-608 mid-row codes as a space - #8163

Open
bardrop wants to merge 1 commit into
video-dev:masterfrom
bardrop-oss:bugfix/cea608-midrow-space
Open

bardrop wants to merge 1 commit into
video-dev:masterfrom
bardrop-oss:bugfix/cea608-midrow-space

Conversation

@bardrop

@bardrop bardrop commented Nov 12, 2026

Copy link
Copy Markdown

This PR will...

Make CEA-608 mid-row codes (color / italics / underline changes inside a row) take up one column and show as a space.

Why is this Pull Request needed?

Cea608Channel.ccMIDROW only called setPen(). In CEA-608 a mid-row code is a spacing attribute: it is shown as if a standard space (0x20) had been received (47 CFR 79.101). Because the cursor did not move, the next character was written in the column of the code, so Hi + italics + there came out as Hithere, and every later character on the row was one column to the left. FFmpeg, mux.js and pycaption all give Hi there for the issue's caption data.

The fix writes a space with the new pen right after setPen() (same order as FFmpeg's handle_textattr). It goes through insertChars([0x20]), not just moveCursor(1), so:

  • a character already in that column (paint-on / roll-up overwrite) is replaced by the space, and
  • paint-on and roll-up modes send a screen update, like any other character.

Are there any points in the code the reviewer needs to double check?

  • A mid-row code at the start of a row now leaves one leading space. In cues.ts that counts as 1 column of indent, which rounds to the same cue position as before (floor(1 * 8 / 32) = 0), and the cue text is trimmed.
  • Flash On (ccFON) is also a spacing attribute in the spec, but I left it alone to keep this PR to the reported bug.

Resolves issues:

Fixes #8147

Checklist

  • changes have been done against master branch, and PR does not conflict
  • new unit / functional tests have been added (whenever applicable)
  • API or design changes are documented in API.md

Tests: 3 new cases in tests/unit/utils/cea-608-parser.ts (the issue's data, a color mid-row code, and a paint-on overwrite). All 3 fail on master and pass with the fix. npm run test:unit 1286 passing; eslint, prettier --check and type-check clean.

A mid-row code is a spacing attribute: it takes up one column and shows
as a space. ccMIDROW only changed the pen, so the next character was
written where the code should be ("Hi" + italics + "there" gave
"Hithere") and the rest of the row was one column off.

Write a space with the new pen after setting it, through insertChars so
paint-on and roll-up captions update too.

Fixes video-dev#8147
@iamboorrito

Copy link
Copy Markdown
Collaborator

I ran into some Github permission issues for forked branches. I created a PR with your authored commits here: #8166

@bardrop

bardrop commented Nov 13, 2026

Copy link
Copy Markdown
Author

Thanks for carrying it over in #8166, and sorry about the fork permission trouble. Happy for this one to be closed once #8166 lands.

@bardrop

bardrop commented Nov 13, 2026

Copy link
Copy Markdown
Author

I saw #8166 got closed. Is there anything I can do on this one to help it land? The branch is up to date with master, and the only red check is the optional Firefox functional job. Happy to rebase or change anything.

@iamboorrito

Copy link
Copy Markdown
Collaborator

I saw #8166 got closed. Is there anything I can do on this one to help it land? The branch is up to date with master, and the only red check is the optional Firefox functional job. Happy to rebase or change anything.

I had to open the other PR to run the CI temporarily. I see the CI failure was due to a timeout, so there should be nothing more you need to do at this time. I talked with @robwalch about it since it was surprising I could not run the functional tests.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CEA-608: mid-row style codes do not advance the cursor by one column, so words around italics run together

2 participants