[mythtv] [PATCH] Closed Caption fixes

Gregorio Gervasio, Jr. gtgj at pacbell.net
Tue Mar 9 01:30:38 EST 2004

        Here are patches to fix some NTSC CC problems as well as to
add support for other CC-related stuff (software encoders only):

- Fix row position -- There should only be 15 rows of text.
Previously, the encoder incorrectly specified the row address for
multi-line captions so the last line ended up at row 18 (or more if
there were gaps).

- Fix multi-line popup captions with 0x14 0x20 control codes between
lines -- These were incorrectly displayed one line at a time instead of
all at once and became hard to read.  (Example:  "Monk")

- Fix display of multi-line popup captions with gaps between lines --
Gaps were not always detected properly.  Also, when they were
detected, they were incorrectly counted as part of the four-line limit
so captions could get truncated.  (Example:  "Iron Chef" frequently has
captions with four lines of text plus two blank lines in the middle.)

- Add detection of duplicate codes -- Duplicate codes were previously
ignored.  Since each two-byte code represents a pair of characters,
there was a 50% chance that "remember" became "rember", or "raining"
-> "raing", and a 100% chance that "T-E-E-N" -> "T-E-N".  This also
messed up roll-up captions where the captioner used multiple backspace

- Display partial lines in roll-up captions -- These captions are
meant to be displayed as each CC code is received but the encoder used
to wait for a carriage return.  This caused problems when the
captioner paused in the middle of lines. I didn't want to write a
nuv frame for every CC code so instead, a partial line is flushed if
there's a pause in the stream.  (Example:  "Sportscenter", many live

- Add encoding of CC2, CC3 (TXT1), and CC4 (TXT2) streams.  However,
the only thing I've been able to test is CC2 in "The Tonight Show"
(Spanish subtitles).

... plus other minor fixes.


- Errors due to signal noise can't be fixed (missing character pairs,
missing control codes).

- Most of the fixes affect the backend so problems in existing
recordings won't get fixed.

- The detection of duplicate CC codes works well with the bttv-0.9
driver where the raw VBI reads seem to be fairly reliable (~29.97
reads per second).  This does not seem to be true for bttv-0.7 so
there is a hack to be more conservative in detecting duplicates when
the VBI reads are less consistent.  It works okay for me most of the
time but it will occasionally miss duplicate codes or spit out false
duplicates.  I'd be interested to know how well it works for other
people using both bttv and non-bttv drivers.

- Frontend support for displaying CC2 and other streams is in a
separate patch since I wasn't sure this was a good way of doing it.
What I did is to have the user type a number and then hit "T",
eg. "2T" to display CC2, "1T" to go back to CC1.  ("T" with no
arguments toggles CC display on/off as usual.)  I had initially
implemented "T" to cycle through the different streams but this
doesn't make sense for Teletext and the frontend doesn't know ahead of
time what format it's reading.

- For debugging purposes, I've attached a third patch that will dump
the raw CC codes (during recording) to a ".nuv.txd" file.  I can use
this dump to debug problems and test out fixes.

- Bitstream Vera Mono works nicely as a CC font.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cc_main-20040308.patch.gz
Type: application/x-gzip
Size: 7730 bytes
Desc: main CC patch
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040308/34534336/cc_main-20040308.patch.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cc_disp-20040308.patch.gz
Type: application/x-gzip
Size: 1065 bytes
Desc: CC2 display patch
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040308/34534336/cc_disp-20040308.patch.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cc_dump-20040308.patch.gz
Type: application/x-gzip
Size: 2117 bytes
Desc: CC raw dump patch
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20040308/34534336/cc_dump-20040308.patch.bin
-------------- next part --------------

Gregorio Gervasio, Jr.

More information about the mythtv-dev mailing list