All pastes #332386 Raw Edit

mythtv #3000

public text v1 · immutable
#332386 ·published 2007-01-29 23:15 UTC
rendered paste body
Index: libs/libavformat/mpeg.c
===================================================================
--- libs/libavformat/mpeg.c	(revision 12673)
+++ libs/libavformat/mpeg.c	(working copy)
@@ -1440,15 +1440,18 @@
 {
     MpegDemuxContext *m = s->priv_data;
     int len, size, startcode, c, flags, header_len;
-    int64_t pts, dts, last_pos;
+    int64_t pts, dts;
+    int64_t last_sync= url_ftell(&s->pb);
 
-    last_pos = -1;
+ error_redo:
+        url_fseek(&s->pb, last_sync, SEEK_SET);
  redo:
         /* next start code (should be immediately after) */
         m->header_state = 0xff;
         size = MAX_SYNC_SIZE;
         startcode = find_next_start_code(&s->pb, &size, &m->header_state);
-    //printf("startcode=%x pos=0x%Lx\n", startcode, url_ftell(&s->pb));
+        last_sync = url_ftell(&s->pb);
+    //printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(&s->pb));
     if (startcode < 0)
         return AVERROR_IO;
     if (startcode == PACK_START_CODE)
@@ -1481,7 +1484,7 @@
     /* stuffing */
     for(;;) {
         if (len < 1)
-            goto redo;
+            goto error_redo;
         c = get_byte(&s->pb);
         len--;
         /* XXX: for mpeg1, should test only bit 7 */
@@ -1490,23 +1493,17 @@
     }
     if ((c & 0xc0) == 0x40) {
         /* buffer scale & size */
-        if (len < 2)
-            goto redo;
         get_byte(&s->pb);
         c = get_byte(&s->pb);
         len -= 2;
     }
-    if ((c & 0xf0) == 0x20) {
-        if (len < 4)
-            goto redo;
+    if ((c & 0xe0) == 0x20) {
         dts = pts = get_pts(&s->pb, c);
         len -= 4;
-    } else if ((c & 0xf0) == 0x30) {
-        if (len < 9)
-            goto redo;
-        pts = get_pts(&s->pb, c);
-        dts = get_pts(&s->pb, -1);
-        len -= 9;
+        if (c & 0x10){
+            dts = get_pts(&s->pb, -1);
+            len -= 5;
+        }
     } else if ((c & 0xc0) == 0x80) {
         /* mpeg 2 PES */
 #if 0 /* some streams have this field set for no apparent reason */
@@ -1519,45 +1516,36 @@
         header_len = get_byte(&s->pb);
         len -= 2;
         if (header_len > len)
-            goto redo;
-        if ((flags & 0xc0) == 0x80) {
+            goto error_redo;
+        len -= header_len;
+        if (flags & 0x80) {
             dts = pts = get_pts(&s->pb, -1);
-            if (header_len < 5)
-                goto redo;
             header_len -= 5;
-            len -= 5;
-        } if ((flags & 0xc0) == 0xc0) {
-            pts = get_pts(&s->pb, -1);
-            dts = get_pts(&s->pb, -1);
-            if (header_len < 10)
-                goto redo;
-            header_len -= 10;
-            len -= 10;
+            if (flags & 0x40) {
+                dts = get_pts(&s->pb, -1);
+                header_len -= 5;
+            }
         }
-        len -= header_len;
-        while (header_len > 0) {
-            get_byte(&s->pb);
-            header_len--;
-        }
+        if(header_len < 0)
+            goto error_redo;
+        url_fskip(&s->pb, header_len);
     }
     else if( c!= 0xf )
         goto redo;
 
     if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
-        if (len < 1)
-            goto redo;
         startcode = get_byte(&s->pb);
         len--;
         if (startcode >= 0x80 && startcode <= 0xbf) {
             /* audio: skip header */
-            if (len < 3)
-                goto redo;
             get_byte(&s->pb);
             get_byte(&s->pb);
             get_byte(&s->pb);
             len -= 3;
         }
     }
+    if(len<0)
+        goto error_redo;
     if(dts != AV_NOPTS_VALUE && ppos && s->build_index){
         int i;
         for(i=0; i<s->nb_streams; i++){
Index: libs/libmythtv/avformatdecoder.cpp
===================================================================
--- libs/libmythtv/avformatdecoder.cpp	(revision 12673)
+++ libs/libmythtv/avformatdecoder.cpp	(working copy)
@@ -341,7 +341,7 @@
 {
     if (ic)
     {
-        for (int i = 0; i < ic->nb_streams; i++)
+        for (unsigned int i = 0; i < ic->nb_streams; i++)
         {
             QMutexLocker locker(&avcodeclock);
             AVStream *st = ic->streams[i];
@@ -403,7 +403,7 @@
     getrawframes = false;
 
     AVStream *st = NULL;
-    int i;
+    unsigned int i;
     for (i = 0; i < ic->nb_streams; i++)
     {
         AVStream *st1 = ic->streams[i];
@@ -508,7 +508,7 @@
 
         // Flush the avcodec buffers
         VERBOSE(VB_PLAYBACK, LOC + "SeekReset() flushing");
-        for (int i = 0; i < ic->nb_streams; i++)
+        for (unsigned int i = 0; i < ic->nb_streams; i++)
         {
             AVCodecContext *enc = ic->streams[i]->codec;
             if (enc->codec)
@@ -661,7 +661,10 @@
     ic->pb.pos = 0;
     ic->pb.must_flush = 0;
     ic->pb.eof_reached = 0;
-    ic->pb.is_streamed = 0;
+    if (ringBuffer->isDVD())
+        ic->pb.is_streamed = 1;
+    else
+        ic->pb.is_streamed = 0;
     ic->pb.max_packet_size = 0;
 }
 
@@ -1276,7 +1279,7 @@
     map<int,uint> lang_sub_cnt;
     map<int,uint> lang_aud_cnt;
 
-    for (int i = 0; i < ic->nb_streams; i++)
+    for (unsigned int i = 0; i < ic->nb_streams; i++)
     {
         AVCodecContext *enc = ic->streams[i]->codec;
         VERBOSE(VB_PLAYBACK, LOC +
@@ -1381,7 +1384,7 @@
                     selectedVideoIndex = i;
                 }
 
-                InitVideoCodec(ic->streams[i], enc, selectedVideoIndex == i);
+                InitVideoCodec(ic->streams[i], enc, selectedVideoIndex == (int)i);
 
                 ScanATSCCaptionStreams(i);
 
@@ -2396,7 +2399,7 @@
 
 bool AvFormatDecoder::SetVideoByComponentTag(int tag)
 {
-    for (int i = 0; i < ic->nb_streams; i++)
+    for (unsigned int i = 0; i < ic->nb_streams; i++)
     {
         AVStream *s  = ic->streams[i];
         if (s)
@@ -2778,7 +2781,6 @@
                     delete pkt;
                 return false;
             }
-
             if (waitingForChange && pkt->pos >= readAdjust)
                 FileChanged();
 
@@ -2786,7 +2788,7 @@
                 pkt->pos -= readAdjust;
         }
 
-        if (pkt->stream_index > ic->nb_streams)
+        if (pkt->stream_index > (int)ic->nb_streams)
         {
             VERBOSE(VB_IMPORTANT, LOC_ERR + "Bad stream");
             av_free_packet(pkt);
@@ -3419,7 +3421,7 @@
     AudioInfo old_out = audioOut;
 
     if ((currentTrack[kTrackTypeAudio] >= 0) &&
-        (selectedTrack[kTrackTypeAudio].av_stream_index <= ic->nb_streams) &&
+        (selectedTrack[kTrackTypeAudio].av_stream_index <= (int)ic->nb_streams) &&
         (curstream = ic->streams[selectedTrack[kTrackTypeAudio]
                                  .av_stream_index]))
     {