[mythtv] [PATCH] HDTV Recorder Patch

Daniel Thor Kristjansson danielk at mrl.nyu.edu
Sun Nov 14 20:08:13 UTC 2004


]The only problem I have discovered has to do with  my PBS station.  Skipping
]forward and Fast-Forward do not work well -- if at all -- with programs
]recorded using this patch, from my PBS station.  All of my other digital
]stations work just fine.  I do not know what is special about my PBS station
]that is causing this.  What is weird, is the first couple of minutes of the
]program are okay -- you have to go a couple minutes in, before the problem
]exhibits itself.
Can you try the attached patch with this channel for me?

]You said you "increased the read buffer size" in v31 of your patch.  Where
]exactly is that done.  I would like to play with it, to see if I can tune it a
]bit better for my system.
In HDTVRecorder::HDTVRecorder() look for "_buffer_size = "

-- Daniel
-------------- next part --------------
Index: libs/libavformat/mpegts.c
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libavformat/mpegts.c,v
retrieving revision 1.22
diff -u -r1.22 mpegts.c
--- libs/libavformat/mpegts.c	13 Nov 2004 21:38:35 -0000	1.22
+++ libs/libavformat/mpegts.c	14 Nov 2004 19:27:24 -0000
@@ -986,7 +986,12 @@
 {
     if (!ts->pids[0]) {
         /* make sure we're always scanning for new PAT's */
+#if 0
+#ifdef DEBUG_SI
+        printf("handle_packet: Resetting req_sid to 1.\n");
+#endif
         ts->req_sid = 0x1;
+#endif
         ts->pat_filter = mpegts_open_section_filter(ts, PAT_PID, pat_cb, ts, 1);
     }
     AVFormatContext *s = ts->stream;
@@ -1205,11 +1210,15 @@
     /* read the first 1024 bytes to get packet size */
     pos = url_ftell(pb);
     len = get_buffer(pb, buf, sizeof(buf));
-    if (len != sizeof(buf))
+    if (len != sizeof(buf)) {
+        av_log(NULL, AV_LOG_ERROR, "mpegts_read_header: unable to read first 1024 bytes\n");
         goto fail;
+    }
     ts->raw_packet_size = get_packet_size(buf, sizeof(buf));
-    if (ts->raw_packet_size <= 0)
+    if (ts->raw_packet_size <= 0) {
+        av_log(NULL, AV_LOG_ERROR, "mpegts_read_header: packet size incorrect\n");
         goto fail;
+    }
     ts->stream = s;
     ts->auto_guess = 0;
 
@@ -1235,8 +1244,10 @@
                         mpegts_close_filter(ts, ts->pids[i]);
                 }
                 url_fseek(pb, pos, SEEK_SET);
+                av_log(NULL, AV_LOG_DEBUG, "mpegts_read_header: mpegts_scan_pat()\n");
                 mpegts_scan_pat(ts);
                 
+                av_log(NULL, AV_LOG_DEBUG, "mpegts_read_header: handle_packets()\n");
                 handle_packets(ts, MAX_SCAN_PACKETS);
             }
             
@@ -1247,26 +1258,29 @@
                goto do_pcr;
            }
            
+            av_log(NULL, AV_LOG_DEBUG, "mpegts_read_header: # of services %i\n", ts->nb_services);
             /* tune to first service found */
             for(i=0; i<ts->nb_services && ts->set_service_ret; i++){
-                service = ts->services[0];
+                service = ts->services[i];
                 sid = service->sid;
-#ifdef DEBUG_SI
-                printf("tuning to '%s'\n", service->name);
-#endif
+                av_log(NULL, AV_LOG_DEBUG, "mpegts_read_header: tuning to '%s' sid(0x%x)\n", service->name, sid);
             
                 /* now find the info for the first service if we found any,
                 otherwise try to filter all PATs */
             
                 url_fseek(pb, pos, SEEK_SET);
                 mpegts_set_service(ts, sid, set_service_cb, ts);
+                av_log(NULL, AV_LOG_DEBUG, "mpegts_read_header: req_sid(0x%x)\n", ts->req_sid);
             
+                av_log(NULL, AV_LOG_DEBUG, "mpegts_read_header: handle_packets()\n");
                 handle_packets(ts, MAX_SCAN_PACKETS);
             }
            
             /* if could not find service, exit */
-            if (ts->set_service_ret != 0)
-                return -1;
+            if (ts->set_service_ret != 0) {
+                av_log(NULL, AV_LOG_ERROR, "mpegts_read_header: could not find service\n");
+                goto fail;
+	    }
             
 #ifdef DEBUG_SI
             printf("tuning done\n");
@@ -1283,8 +1297,10 @@
         /* only read packets */
     do_pcr: 
         st = av_new_stream(s, 0);
-        if (!st)
+        if (!st) {
+            av_log(NULL, AV_LOG_ERROR, "mpegts_read_header: av_new_stream() failed\n");
             goto fail;
+        }
         av_set_pts_info(st, 60, 1, 27000000);
         st->codec.codec_type = CODEC_TYPE_DATA;
         st->codec.codec_id = CODEC_ID_MPEG2TS;
@@ -1295,8 +1311,10 @@
         nb_packets = 0;
         for(;;) {
             ret = read_packet(&s->pb, packet, ts->raw_packet_size, &position);
-            if (ret < 0)
-                return -1;
+            if (ret < 0) {
+                av_log(NULL, AV_LOG_ERROR, "mpegts_read_header: read_packet() failed\n");
+                goto fail;
+            }
             pid = ((packet[1] & 0x1f) << 8) | packet[2];
             if ((pcr_pid == -1 || pcr_pid == pid) &&
                 parse_pcr(&pcr_h, &pcr_l, packet) == 0) {


More information about the mythtv-dev mailing list