[mythtv] PATCH: closed caption support
Gregorio Gervasio Jr.
gtgj at pacbell.net
Wed Mar 26 03:14:47 EST 2003
This looks pretty good. I noticed there are two styles of
captioning:
1. rowcount set to 0; number of actual rows = 1,2,3
- usually for movies and non-live TV series
2. rowcount set to 1,2,3; number of actual rows = 1
- usually for news, sports, live events
The first style looks good. The second style is harder to read
because the single line gets overwritten quickly. I don't have a
CC-capable TV to check against right now but I think that in the
second style, text is meant to "scroll" within a box with height equal
to the specified rowcount. I've included a patch that tries to
implement that. (I also adjusted the rowcount in the encoder to match
the comments since that looked better but I guess it should be checked
against a real decoder.)
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmythtv/NuppelVideoPlayer.cpp,v
retrieving revision 1.155
diff -u -b -r1.155 NuppelVideoPlayer.cpp
--- libs/libmythtv/NuppelVideoPlayer.cpp 24 Mar 2003 18:55:47 -0000 1.155
+++ libs/libmythtv/NuppelVideoPlayer.cpp 26 Mar 2003 10:45:58 -0000
@@ -1555,7 +1555,7 @@
if (subtitle.clr)
{
//printf ("erase displayed memory\n");
- for (j = 0; j < 3; j++)
+ for (j = 0; j < 4; j++)
{
cclines[j] = "";
}
@@ -1565,7 +1565,28 @@
if (subtitle.len)
{
unsigned char *end = inpos + subtitle.len;
- int row = 0;
+ int row;
+
+ if (subtitle.rowcount == 0)
+ {
+ // overwrite
+ row = 0;
+ }
+ else
+ {
+ if (subtitle.rowcount > 4)
+ {
+ subtitle.rowcount = 4;
+ }
+ // scroll up one line
+ for (j = 0; j < subtitle.rowcount-1; j++)
+ {
+ cclines[j] = cclines[j+1];
+ }
+ cclines[subtitle.rowcount-1] = "";
+ row = subtitle.rowcount - 1;
+ }
+
while (inpos < end)
{
unsigned char *cur = inpos;
@@ -1575,23 +1596,38 @@
cur++;
*cur = 0;
- if (row < 3)
+ if (subtitle.rowcount > 0 && row >= subtitle.rowcount)
+ {
+ // multi-line in scroll mode -- shouldn't happen?
+ // scroll up again
+ for (j = 0; j < subtitle.rowcount-1; j++)
+ {
+ cclines[j] = cclines[j+1];
+ }
+ row = subtitle.rowcount - 1;
+ }
+ if (row < 4)
{
cclines[row++] = QString((const char *)inpos);
//printf ("CC text: %s\n", inpos);
}
+#if 0
+ else
+ {
+ printf("CC overflow: %s\n", inpos);
+ }
+#endif
inpos = cur + 1;
}
- if (subtitle.rowcount != row)
+ if (subtitle.rowcount == 0)
subtitle.rowcount = row;
-
}
//redraw
osd->ClearAllCCText ();
- for (j = 0; j < subtitle.rowcount && j < 3; j++)
+ for (j = 0; j < subtitle.rowcount && j < 4; j++)
{
if (cclines[j].isNull() || cclines[j].isEmpty())
continue;
Index: libs/libmythtv/NuppelVideoRecorder.cpp
===================================================================
RCS file: /var/lib/cvs/MC/libs/libmythtv/NuppelVideoRecorder.cpp,v
retrieving revision 1.90
diff -u -b -r1.90 NuppelVideoRecorder.cpp
--- libs/libmythtv/NuppelVideoRecorder.cpp 24 Mar 2003 18:55:47 -0000 1.90
+++ libs/libmythtv/NuppelVideoRecorder.cpp 26 Mar 2003 10:45:59 -0000
@@ -1808,13 +1808,13 @@
cc->ccbuf[cc->ccmode][len--] = 0;
break;
case 0x25: //2 row caption
- subtitle->rowcount = 1;
+ subtitle->rowcount = 2;
break;
case 0x26: //3 row caption
- subtitle->rowcount = 2;
+ subtitle->rowcount = 3;
break;
case 0x27: //4 row caption
- subtitle->rowcount = 3;
+ subtitle->rowcount = 4;
break;
case 0x29: //resume direct caption
printf ("\nresume direct caption\n");
--
Gregorio Gervasio, Jr.
gtgj at pacbell.net
More information about the mythtv-dev
mailing list