[mythtv] New teletext patch, ready for CVS.

Martin Moeller martin at martinm-76.dk
Sun Jul 27 22:03:25 EDT 2003


Hmm. With the data I seem to be getting with the original debug-patch,
I've made another, since it doesn't seem to do me any good to monitor
linebufpos and c anyway. The naming matches the previous ones...

Nothing much to see yet...

/Martin.

søn, 2003-07-27 kl. 19:37 skrev Martin Moeller:
> In the time I have had it running I have had two cases where this line
> popped up:
> IOBOUND - blocking in ThreadedFileWriter::Write()
> 
> It didn't crash MythTV though, it just kept chucking along..
> 
> I have now made liberal sprinklings of debug statements in the
> FormatTeletextSubtitle function.
> 
> Could someone that have had these overflow happen please try this patch?
> I will be running with it myself for some time and see if I can get a
> handle on what is supposed to be wrong...
> 
> It may not be quite the way it should be, any help appreciated...
> 
> teletext-debug: My patch from before with extra debug statements.
> 
> teletext-NVR : Only diffed NuppelVideoRecorder.cpp
> 
> 
> 
> søn, 2003-07-27 kl. 16:57 skrev Isaac Richards:
> > On Sunday 27 July 2003 10:14 am, Martin Moeller wrote:
> > > Hi everyone.
> > >
> > > With a bit of luck this will mark the phasing out of my frequent updates
> > > about teletext since it seems to be working A-OK for me now, including
> > > setting the page in the database on-the-fly (well, nearly).
> > 
> > This does absolutely nothing to fix the buffer overruns.  I'm not accepting a 
> > patch that doesn't fix the actual bugs in the code.
> > 
> > Isaac
> > _______________________________________________
> > mythtv-dev mailing list
> > mythtv-dev at snowman.net
> > http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-dev
> 
> ______________________________________________________________________
> 
> _______________________________________________
> mythtv-dev mailing list
> mythtv-dev at snowman.net
> http://lists.snowman.net/cgi-bin/mailman/listinfo/mythtv-dev
-- 
Martin Moeller <martin at martinm-76.dk>
-------------- next part --------------
? 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	27 Jul 2003 19:00:45 -0000
@@ -7,13 +7,14 @@
 #
 
 DELETE FROM settings WHERE value='DBSchemaVer';
-INSERT INTO settings VALUES ('DBSchemaVer', 1003, NULL);
+INSERT INTO settings VALUES ('DBSchemaVer', 1004, NULL);
 
 #
 #   Below are the recent alterations to the database.
 #   The most recent are listed first. Execution should fail
 #   when a previously executed command is encountered.
 #
+INSERT INTO settings SET value="VBIpageNr", data=888;
 
 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	27 Jul 2003 19:00:50 -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/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	27 Jul 2003 19:00:53 -0000
@@ -1782,6 +1782,7 @@
 
     for (int y = 0; y < VT_HEIGHT; y++)
     {
+        //printf("\n"); /* Make sure we change lines */
         char c = ' ';
         char last_c = ' ';
         int hid = 0;
@@ -1797,6 +1798,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 +1874,12 @@
                 }
             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 */
                 if (!visible)
                 {
                     st.row = y;
@@ -1895,6 +1898,7 @@
         if (visible)
         {
             st.len = linebufpos - linebuf + 1;;
+printf("1 - st.len : %d\n",st.len);
             memcpy(outpos, &st, sizeof(st));
             outpos += sizeof(st);
             memcpy(outpos, linebuf, st.len);
@@ -1905,6 +1909,7 @@
 
     textbuffer[act]->bufferlen = outpos - textbuffer[act]->buffer + 1;
     textbuffer[act]->freeToBuffer = 0;
+printf("2 - act : %d, bufferlen : %d\n", act, textbuffer[act]->bufferlen);
     act_text_buffer++;
     if (act_text_buffer >= text_buffer_count)
         act_text_buffer = 0;
@@ -2100,9 +2105,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	27 Jul 2003 19:00:54 -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	27 Jul 2003 19:00:55 -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	27 Jul 2003 19:00:56 -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);
 }
-
-------------- next part --------------
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	27 Jul 2003 19:00:35 -0000
@@ -1782,6 +1782,7 @@
 
     for (int y = 0; y < VT_HEIGHT; y++)
     {
+        //printf("\n"); /* Make sure we change lines */
         char c = ' ';
         char last_c = ' ';
         int hid = 0;
@@ -1797,6 +1798,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 +1874,12 @@
                 }
             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 */
                 if (!visible)
                 {
                     st.row = y;
@@ -1895,6 +1898,7 @@
         if (visible)
         {
             st.len = linebufpos - linebuf + 1;;
+printf("1 - st.len : %d\n",st.len);
             memcpy(outpos, &st, sizeof(st));
             outpos += sizeof(st);
             memcpy(outpos, linebuf, st.len);
@@ -1905,6 +1909,7 @@
 
     textbuffer[act]->bufferlen = outpos - textbuffer[act]->buffer + 1;
     textbuffer[act]->freeToBuffer = 0;
+printf("2 - act : %d, bufferlen : %d\n", act, textbuffer[act]->bufferlen);
     act_text_buffer++;
     if (act_text_buffer >= text_buffer_count)
         act_text_buffer = 0;
@@ -2100,9 +2105,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));
             }


More information about the mythtv-dev mailing list