[mythtv] Believed final teletext patch. Apply please? :)

Martin Moeller martin at martinm-76.dk
Thu Jul 31 20:19:04 EDT 2003


Oops. Embarrasing. Here's the Patch...
Too excited to notice first time around... :)

/Martin.

tor, 2003-07-31 kl. 18:12 skrev Martin Moeller:
> Okay.
> 
> I've tested my latest patch for about 2 days now and it seems rock
> solid. I've recorded at least 5 shows that would previously have caused
> mythbackend to crash and it hasn't. The only thing added in this patch
> is upping MAXTBUFFER to 21 (may be more than needed but it works) so
> that I can get ALL subtitles on BBC Prime. Works like a charm.
> 
> Isaac, what do you say? Is this okay?
> 
> /Martin.
-- 
Martin Moeller <martin at martinm-76.dk>
-------------- next part --------------
? libs/libmythtv/.NuppelVideoRecorder.cpp.swp
? programs/menutest/Makefile
? programs/menutest/menutest
Index: database/cvs.sql
===================================================================
RCS file: /var/lib/mythcvs/mythtv/database/cvs.sql,v
retrieving revision 1.39
diff -u -w -r1.39 cvs.sql
--- database/cvs.sql	17 Jul 2003 01:04:13 -0000	1.39
+++ database/cvs.sql	31 Jul 2003 16:06:36 -0000
@@ -14,6 +14,8 @@
 #   The most recent are listed first. Execution should fail
 #   when a previously executed command is encountered.
 #
+#INSERT INTO settings SET value="VBIpageNr", data=888;
+# Apply this if you use Teletext and it isn't already there.
 
 ALTER TABLE record ADD recorddups INT DEFAULT 0 NOT NULL;
 ALTER TABLE record ADD maxnewest INT DEFAULT 0 NOT NULL;
Index: libs/libmythtv/NuppelVideoPlayer.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp,v
retrieving revision 1.231
diff -u -w -r1.231 NuppelVideoPlayer.cpp
--- libs/libmythtv/NuppelVideoPlayer.cpp	23 Jul 2003 19:58:27 -0000	1.231
+++ libs/libmythtv/NuppelVideoPlayer.cpp	31 Jul 2003 16:06:39 -0000
@@ -49,7 +49,18 @@
     prebuffering = false;
 
     vbimode = ' ';
+    //vbipagenr = 0x08880000;
+
+    bool valid;
+    //QString hostname = gContext->GetHostName();
+    //QString mypage = gContext->GetSettingOnHost("VBIpageNr", hostname, "888");
+    QString mypage = gContext->GetSetting("VBIpageNr", "888");
+    if (mypage)
+      vbipagenr = mypage.toInt(&valid, 16) << 16;
+    else
     vbipagenr = 0x08880000;
+    //printf("vbipagenr : %x\n", vbipagenr); /* Debug */
+
     video_height = 0;
     video_width = 0;
     video_size = 0;
@@ -741,10 +752,13 @@
             memcpy(&pagenr, inpos, sizeof(int));
             inpos += sizeof(int);
 
+            printf("pagenr : %x, vbipagenr : %x \n", pagenr, vbipagenr); /* Debug test of page numbers */
             if (pagenr == vbipagenr)
             {
                 // show teletext subtitles
                 osd->ClearAllCCText();
+
+		(*inpos)++;
                 while (*inpos)
                 {
                     struct teletextsubtitle st;
Index: libs/libmythtv/NuppelVideoPlayer.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoPlayer.h,v
retrieving revision 1.96
diff -u -w -r1.96 NuppelVideoPlayer.h
--- libs/libmythtv/NuppelVideoPlayer.h	23 Jul 2003 19:58:27 -0000	1.96
+++ libs/libmythtv/NuppelVideoPlayer.h	31 Jul 2003 16:06:39 -0000
@@ -18,7 +18,7 @@
 using namespace std;
 
 #define MAXVBUFFER 31
-#define MAXTBUFFER 11
+#define MAXTBUFFER 21
 
 #define REENCODE_OK              1
 #define REENCODE_CUTLIST_CHANGE -1
Index: libs/libmythtv/NuppelVideoRecorder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp,v
retrieving revision 1.128
diff -u -w -r1.128 NuppelVideoRecorder.cpp
--- libs/libmythtv/NuppelVideoRecorder.cpp	18 Jul 2003 20:10:58 -0000	1.128
+++ libs/libmythtv/NuppelVideoRecorder.cpp	31 Jul 2003 16:06:41 -0000
@@ -1779,9 +1779,11 @@
     struct teletextsubtitle st;
     unsigned char linebuf[VT_WIDTH + 1];
     unsigned char *linebufpos = linebuf;
+    //bool br = false;
 
     for (int y = 0; y < VT_HEIGHT; y++)
     {
+        //if (br) printf("\n"); /* Make sure we change lines */
         char c = ' ';
         char last_c = ' ';
         int hid = 0;
@@ -1797,6 +1799,7 @@
         for (int x = 0; x < VT_WIDTH; ++x)
         {
             c = *inpos++;
+            //printf("%c", c); /* Output *every* teletext character */
             switch (c)
             {
                 case 0x00 ... 0x07:     /* alpha + fg color */
@@ -1872,11 +1875,13 @@
                 }
             if (hid)
                 c = ' ';
-            if ((c & 0x80) || !c )
-                c = ' ';
+            //if ((c & 0x80) || !c )
+            //    c = ' ';
 
             if (visible || (c != ' '))
             {
+                //printf("%c", c); /* Go with just the visible characters */
+                //br = true;
                 if (!visible)
                 {
                     st.row = y;
@@ -1895,10 +1900,20 @@
         if (visible)
         {
             st.len = linebufpos - linebuf + 1;;
+            int max = 200; /* Set a reasonable amount of characters to pass through. Should always be less than 500 */
+            int bufsize = ((outpos - textbuffer[act]->buffer + 1) + st.len); /* How many do we have now? */
+            if (bufsize > max) break; /* If we're over 'max' then bail. This seems to work quite well (/Martin Moeller) */
             memcpy(outpos, &st, sizeof(st));
             outpos += sizeof(st);
+            if (st.len < 42) {
             memcpy(outpos, linebuf, st.len);
             outpos += st.len;
+            }
+            else {
+              printf("Too much data (%d bytes), writing 41 bytes (*FIXME* - is this the best way to handle it?)\n", st.len);
+              memcpy(outpos, linebuf, 41);
+              outpos += 41;
+            }
             *outpos = 0;
         }
     }
@@ -2100,9 +2115,10 @@
        case EV_PAGE:
        {
             struct vt_page *vtp = (struct vt_page *) ev->p1;
+                //printf("subtitle page %x.%x\n", vtp->pgno, vtp->subno); /* Super debug: If teletext working at all? */
             if (vtp->flags & PG_SUBTITLE)
             {
-                //printf("subtitle page %x.%x\n", vtp->pgno, vtp->subno);
+                printf("subtitle page %x.%x\n", vtp->pgno, vtp->subno); /* Debug: Are we getting any subtitles? */
                 data->foundteletextpage = true;
                 memcpy(&(data->teletextpage), vtp, sizeof(vt_page));
             }
Index: libs/libmythtv/osd.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/osd.cpp,v
retrieving revision 1.69
diff -u -w -r1.69 osd.cpp
--- libs/libmythtv/osd.cpp	23 Jul 2003 19:58:27 -0000	1.69
+++ libs/libmythtv/osd.cpp	31 Jul 2003 16:06:42 -0000
@@ -101,7 +101,8 @@
     if (!ccfont)
     {
         QString name = "cc_font";
-        int fontsize = vid_height / 27;
+//        int fontsize = vid_height / 27;
+        int fontsize = 480 / 27;
         fontsize = (int)(fontsize * hmult);
 
         ccfont = LoadFont(ccfontname, fontsize);
Index: libs/libmythtv/recorderbase.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/recorderbase.cpp,v
retrieving revision 1.6
diff -u -w -r1.6 recorderbase.cpp
--- libs/libmythtv/recorderbase.cpp	6 Jun 2003 15:41:29 -0000	1.6
+++ libs/libmythtv/recorderbase.cpp	31 Jul 2003 16:06:43 -0000
@@ -85,9 +85,9 @@
     }
     else if (name == "vbiformat")
     {
-        //if (value.lower() == "pal teletext")
-        //    vbimode = 1;
-        //else 
+        if (value.lower() == "pal teletext")
+            vbimode = 1;
+        else 
         if (value.lower().left(4) == "ntsc")
             vbimode = 2;
         else
Index: libs/libvbitext/vbi.c
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libvbitext/vbi.c,v
retrieving revision 1.1
diff -u -w -r1.1 vbi.c
--- libs/libvbitext/vbi.c	31 Jan 2003 14:35:49 -0000	1.1
+++ libs/libvbitext/vbi.c	31 Jul 2003 16:06:44 -0000
@@ -24,13 +24,24 @@
 
 /***** v4l2 vbi-api *****/
 
+/* #include "/usr/src/linux/include/linux/videodev2.h" */
+
+enum v4l2_buf_type {
+	V4L2_BUF_TYPE_VIDEO_CAPTURE  = 1,
+	V4L2_BUF_TYPE_VIDEO_OUTPUT   = 2,
+	V4L2_BUF_TYPE_VIDEO_OVERLAY  = 3,
+	V4L2_BUF_TYPE_VBI_CAPTURE    = 4,
+	V4L2_BUF_TYPE_VBI_OUTPUT     = 5,
+	V4L2_BUF_TYPE_PRIVATE        = 0x80,
+};
+
 struct v4l2_vbi_format
 {
     unsigned int sampling_rate;                /* in 1 Hz */
     unsigned int offset;                       /* sampling starts # samples after rising hs */
     unsigned int samples_per_line;
     unsigned int sample_format;                /* V4L2_VBI_SF_* */
-    int start[2];
+    signed int start[2];
     unsigned int count[2];
     unsigned int flags;                        /* V4L2_VBI_* */
     unsigned int reserved2;            /* must be zero */
@@ -38,7 +49,7 @@
 
 struct v4l2_format
 {
-    unsigned int       type;                   /* V4L2_BUF_TYPE_* */
+    enum v4l2_buf_type type;            /* V4L2_BUF_TYPE_* */
     union
     {
        struct v4l2_vbi_format vbi;     /*  VBI data  */
@@ -46,8 +57,7 @@
     } fmt;
 };
 
-#define V4L2_VBI_SF_UBYTE      1
-#define V4L2_BUF_TYPE_VBI       0x00000009
+#define V4L2_PIX_FMT_GREY     0x59455247 /* v4l2_fourcc('G','R','E','Y') *//*  8  Greyscale     */
 #define VIDIOC_G_FMT           _IOWR('V',  4, struct v4l2_format)
 
 /***** end of api definitions *****/
@@ -424,8 +434,19 @@
     vbi->seq = seq;
 
     if (seq > 1)       // the first may contain data from prev channel
+    {
+#if 1
        for (i = 0; i+vbi->bpl <= n; i += vbi->bpl)
            vbi_line(vbi, rawbuf + i);
+#else
+        /* work-around for old saa7134 driver versions (prior 0.2.6) */
+	for (i = 16 * vbi->bpl; i + vbi->bpl <= n; i += vbi->bpl)
+	    vbi_line(vbi, rawbuf + i);
+
+	for (i = 0; i + vbi->bpl <= 16 * vbi->bpl; i += vbi->bpl)
+	    vbi_line(vbi, rawbuf + i);
+#endif
+    }
 }
 
 
@@ -469,8 +490,9 @@
     int soc, eoc;      // start/end of clock run-in
     int bpl;           // bytes per line
 
-    if (p->sample_format != V4L2_VBI_SF_UBYTE)
+    if (p->sample_format != V4L2_PIX_FMT_GREY)
     {
+        fprintf(stderr, "got pix fmt %x\n", p->sample_format);
        error("v4l2: unsupported vbi data format");
        return -1;
     }
@@ -527,13 +549,15 @@
     struct v4l2_format v4l2_format[1];
     struct v4l2_vbi_format *vbifmt = &v4l2_format->fmt.vbi;
 
-    if (ioctl(vbi->fd, VIDIOC_G_FMT, v4l2_format) == -1
-       || v4l2_format->type != V4L2_BUF_TYPE_VBI)
+    memset(&v4l2_format, 0, sizeof(v4l2_format));
+    v4l2_format->type = V4L2_BUF_TYPE_VBI_CAPTURE;
+    if (ioctl(vbi->fd, VIDIOC_G_FMT, v4l2_format) == -1)
     {
        // not a v4l2 device.  assume bttv and create a standard fmt-struct.
        int size;
+        perror("ioctl VIDIOC_G_FMT");
 
-       vbifmt->sample_format = V4L2_VBI_SF_UBYTE;
+	vbifmt->sample_format = V4L2_PIX_FMT_GREY;
        vbifmt->sampling_rate = 35468950;
        vbifmt->samples_per_line = 2048;
        vbifmt->offset = 244;
@@ -663,4 +687,3 @@
 //     vbi->cache->op->reset(vbi->cache);
     vbi_send(vbi, EV_RESET, 0, 0, 0, 0);
 }
-


More information about the mythtv-dev mailing list