[SCM] libav/experimental: fix swf seeking by fixing new stream detection

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:41:15 UTC 2013


The following commit has been merged in the experimental branch:
commit 4e35ffa978a95855854301c36f8fd94ac69b646a
Author: Baptiste Coudurier <baptiste.coudurier at gmail.com>
Date:   Fri Mar 13 19:37:05 2009 +0000

    fix swf seeking by fixing new stream detection
    
    Originally committed as revision 17952 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index 468611c..84510ee 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -90,8 +90,16 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
         tag = get_swf_tag(pb, &len);
         if (tag < 0)
             return AVERROR(EIO);
-        if (tag == TAG_VIDEOSTREAM && !vst) {
+        if (tag == TAG_VIDEOSTREAM) {
             int ch_id = get_le16(pb);
+            len -= 2;
+
+            for (i=0; i<s->nb_streams; i++) {
+                st = s->streams[i];
+                if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id)
+                    goto skip;
+            }
+
             get_le16(pb);
             get_le16(pb);
             get_le16(pb);
@@ -104,10 +112,17 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
             vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
             av_set_pts_info(vst, 64, 256, swf->frame_rate);
             vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
-            len -= 10;
-        } else if ((tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) && !ast) {
+            len -= 8;
+        } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
             /* streaming found */
             int sample_rate_code;
+
+            for (i=0; i<s->nb_streams; i++) {
+                st = s->streams[i];
+                if (st->codec->codec_type == CODEC_TYPE_AUDIO && st->id == -1)
+                    goto skip;
+            }
+
             get_byte(pb);
             v = get_byte(pb);
             swf->samples_per_frame = get_le16(pb);
@@ -139,7 +154,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
                 }
             }
         } else if (tag == TAG_STREAMBLOCK) {
-            st = s->streams[swf->audio_stream_index];
+            for (i = 0; i < s->nb_streams; i++) {
+                st = s->streams[i];
+                if (st->codec->codec_type == CODEC_TYPE_AUDIO && st->id == -1) {
             if (st->codec->codec_id == CODEC_ID_MP3) {
                 url_fskip(pb, 4);
                 av_get_packet(pb, pkt, len-4);
@@ -148,10 +165,12 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
             }
             pkt->stream_index = st->index;
             return pkt->size;
+                }
+            }
         } else if (tag == TAG_JPEG2) {
             for (i=0; i<s->nb_streams; i++) {
                 st = s->streams[i];
-                if (st->id == -2)
+                if (st->codec->codec_id == CODEC_ID_MJPEG && st->id == -2)
                     break;
             }
             if (i == s->nb_streams) {
@@ -179,6 +198,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
             pkt->stream_index = st->index;
             return pkt->size;
         }
+    skip:
         url_fskip(pb, len);
     }
     return 0;
diff --git a/tests/seek.regression.ref b/tests/seek.regression.ref
index 06e539d..e046ac6 100644
--- a/tests/seek.regression.ref
+++ b/tests/seek.regression.ref
@@ -3518,28 +3518,28 @@ ret:-1 st:-1 ts:-1.000000 flags:0
 ret:-1 st:-1 ts:1.894167 flags:1
 ret:-1 st: 0 ts:0.800000 flags:0
 ret:-1 st: 0 ts:-0.320000 flags:1
-ret:-1 st: 1 ts:2.560000 flags:0
-ret:-1 st: 1 ts:1.480000 flags:1
-ret:-1 st: 2 ts:0.360000 flags:0
-ret:-1 st: 2 ts:-0.760000 flags:1
-ret:-1 st: 3 ts:2.160000 flags:0
-ret:-1 st: 3 ts:1.040000 flags:1
-ret:-1 st: 4 ts:-0.040000 flags:0
-ret:-1 st: 4 ts:2.840000 flags:1
-ret:-1 st: 5 ts:1.720000 flags:0
-ret:-1 st: 5 ts:0.640000 flags:1
-ret:-1 st: 6 ts:-0.480000 flags:0
-ret:-1 st: 6 ts:2.400000 flags:1
-ret:-1 st: 7 ts:1.320000 flags:0
-ret:-1 st: 7 ts:0.200000 flags:1
-ret:-1 st: 8 ts:-0.920000 flags:0
-ret:-1 st: 8 ts:2.000000 flags:1
-ret:-1 st: 9 ts:0.880000 flags:0
-ret:-1 st: 9 ts:-0.240000 flags:1
-ret:-1 st:10 ts:2.680000 flags:0
-ret:-1 st:10 ts:1.560000 flags:1
-ret:-1 st:11 ts:0.480000 flags:0
-ret:-1 st:11 ts:-0.640000 flags:1
+ret:-1 st:-1 ts:2.576668 flags:0
+ret:-1 st:-1 ts:1.470835 flags:1
+ret:-1 st: 0 ts:0.360000 flags:0
+ret:-1 st: 0 ts:-0.760000 flags:1
+ret:-1 st:-1 ts:2.153336 flags:0
+ret:-1 st:-1 ts:1.047503 flags:1
+ret:-1 st: 0 ts:-0.040000 flags:0
+ret:-1 st: 0 ts:2.840000 flags:1
+ret:-1 st:-1 ts:1.730004 flags:0
+ret:-1 st:-1 ts:0.624171 flags:1
+ret:-1 st: 0 ts:-0.480000 flags:0
+ret:-1 st: 0 ts:2.400000 flags:1
+ret:-1 st:-1 ts:1.306672 flags:0
+ret:-1 st:-1 ts:0.200839 flags:1
+ret:-1 st: 0 ts:-0.920000 flags:0
+ret:-1 st: 0 ts:2.000000 flags:1
+ret:-1 st:-1 ts:0.883340 flags:0
+ret:-1 st:-1 ts:-0.222493 flags:1
+ret:-1 st: 0 ts:2.680000 flags:0
+ret:-1 st: 0 ts:1.560000 flags:1
+ret:-1 st:-1 ts:0.460008 flags:0
+ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/b-libav.ts
 ret: 0 st: 0 dts:0.660000 pts:0.700000 pos:564 size:24921 flags:1

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list