[mythtv] [PATCH] pcHDTV: Use sequence-start headers when GOP headers are absent

Jason Hoos jhoos at thwack.net
Tue Jan 6 01:54:28 EST 2004


Attached is the patch I was working on before the holidays to handle 
HDTV streams that don't have GOP headers in them.  It does away with 
my previous hack in hdtvrecorder.cpp of using picture start headers 
in favor of using sequence start headers, which would seem to be the 
correct way of doing things.  In addition, it updates
avformatdecoder.cpp with the same logic, something I overlooked with
the picture start stuff.  With this patch, my GOP-less station is
working quite nicely now, with seeking and everything.  

Jason


-------------- next part --------------
Index: hdtvrecorder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/hdtvrecorder.cpp,v
retrieving revision 1.17
diff -u -r1.17 hdtvrecorder.cpp
--- hdtvrecorder.cpp	1 Jan 2004 03:38:41 -0000	1.17
+++ hdtvrecorder.cpp	6 Jan 2004 06:38:44 -0000
@@ -94,7 +94,8 @@
     keyframedist = 30;
     gopset = false;
     m_in_mpg_headers = false;
-    pict_start_is_gop = false;
+    seq_start_is_gop = false;
+    seq_count = false;
     m_header_sync = 0;
 
     firstgoppos = 0;
@@ -347,18 +348,17 @@
                             if (gopset || firstgoppos > 0)
                                 framesWritten++;
                             framesSeen++;
-                            if (framesSeen >= 30 && firstgoppos <= 0)
+                        }
+                        if (buffer[i+1] == 0xB3)
+                        {
+                            seq_count ++;
+                            if (seq_count > 1 && !gopset) 
                             {
-                                // seen 30 frames with no GOP; assume that
-                                // each GOP only contains one I-frame, and
-                                // treat the I-frame as the beginning of the
-                                // GOP.
-                                pict_start_is_gop = true;
+                                seq_start_is_gop = true;
                             }
                         }
                         if (buffer[i+1] == 0xB8 || 
-                            (pict_start_is_gop && buffer[i+1] == 0x00 &&
-                             (framesSeen) % 15 == 0))
+                            (seq_start_is_gop && buffer[i+1] == 0xB3))
                         {
                             // group_of_pictures
                             int frameNum = framesWritten - 1;
@@ -799,7 +799,6 @@
     framesSeen = 0;
     gopset = false;
     m_in_mpg_headers = false;
-    pict_start_is_gop = false;
     m_header_sync = 0;
     firstgoppos = 0;
     ts_packets = 0;
Index: hdtvrecorder.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/hdtvrecorder.h,v
retrieving revision 1.13
diff -u -r1.13 hdtvrecorder.h
--- hdtvrecorder.h	19 Dec 2003 19:59:13 -0000	1.13
+++ hdtvrecorder.h	6 Jan 2004 06:38:44 -0000
@@ -69,7 +69,8 @@
     int keyframedist;
     bool gopset;
     bool m_in_mpg_headers;
-    bool pict_start_is_gop;
+    bool seq_start_is_gop;
+    int seq_count;
     int m_header_sync;
 
     QMap<long long, long long> positionMap;
Index: avformatdecoder.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/avformatdecoder.cpp,v
retrieving revision 1.72
diff -u -r1.72 avformatdecoder.cpp
--- avformatdecoder.cpp	1 Jan 2004 03:38:41 -0000	1.72
+++ avformatdecoder.cpp	6 Jan 2004 06:38:45 -0000
@@ -51,6 +51,7 @@
     exitafterdecoded = false;
     ateof = false;
     gopset = false;
+    seen_gop = false;
     firstgoppos = 0;
     prevgoppos = 0;
 
@@ -899,11 +901,15 @@
                         video_last_P_pts = lastapts = lastvpts = 0;
                     }
                 }
+                if (!seen_gop) {
+                    HandleGopStart(pkt);
+                }
                 break;
 
                 case GOP_START:
                 {
                     HandleGopStart(pkt);
+                    seen_gop = true;
                 }
                 break;
             }
Index: avformatdecoder.h
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/avformatdecoder.h,v
retrieving revision 1.36
diff -u -r1.36 avformatdecoder.h
--- avformatdecoder.h	5 Jan 2004 02:09:04 -0000	1.36
+++ avformatdecoder.h	6 Jan 2004 06:38:46 -0000
@@ -141,6 +141,7 @@
     bool ateof;
 
     bool gopset;
+    bool seen_gop;
 
     QSqlDatabase *m_db;
     ProgramInfo *m_playbackinfo;


More information about the mythtv-dev mailing list