Commit 195a04c4 authored by bcoudurier's avatar bcoudurier

fix swf seeking by fixing new stream detection

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@17952 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
parent 37f5204f
...@@ -90,8 +90,16 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -90,8 +90,16 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
tag = get_swf_tag(pb, &len); tag = get_swf_tag(pb, &len);
if (tag < 0) if (tag < 0)
return AVERROR(EIO); return AVERROR(EIO);
if (tag == TAG_VIDEOSTREAM && !vst) { if (tag == TAG_VIDEOSTREAM) {
int ch_id = get_le16(pb); 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); get_le16(pb);
get_le16(pb); get_le16(pb);
...@@ -104,10 +112,17 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -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)); vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb));
av_set_pts_info(vst, 64, 256, swf->frame_rate); av_set_pts_info(vst, 64, 256, swf->frame_rate);
vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; vst->codec->time_base = (AVRational){ 256, swf->frame_rate };
len -= 10; len -= 8;
} else if ((tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) && !ast) { } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) {
/* streaming found */ /* streaming found */
int sample_rate_code; 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); get_byte(pb);
v = get_byte(pb); v = get_byte(pb);
swf->samples_per_frame = get_le16(pb); swf->samples_per_frame = get_le16(pb);
...@@ -139,7 +154,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -139,7 +154,9 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
} }
} else if (tag == TAG_STREAMBLOCK) { } 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) { if (st->codec->codec_id == CODEC_ID_MP3) {
url_fskip(pb, 4); url_fskip(pb, 4);
av_get_packet(pb, pkt, len-4); av_get_packet(pb, pkt, len-4);
...@@ -148,10 +165,12 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -148,10 +165,12 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
} }
pkt->stream_index = st->index; pkt->stream_index = st->index;
return pkt->size; return pkt->size;
}
}
} else if (tag == TAG_JPEG2) { } else if (tag == TAG_JPEG2) {
for (i=0; i<s->nb_streams; i++) { for (i=0; i<s->nb_streams; i++) {
st = s->streams[i]; st = s->streams[i];
if (st->id == -2) if (st->codec->codec_id == CODEC_ID_MJPEG && st->id == -2)
break; break;
} }
if (i == s->nb_streams) { if (i == s->nb_streams) {
...@@ -179,6 +198,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) ...@@ -179,6 +198,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->stream_index = st->index; pkt->stream_index = st->index;
return pkt->size; return pkt->size;
} }
skip:
url_fskip(pb, len); url_fskip(pb, len);
} }
return 0; return 0;
......
...@@ -3518,28 +3518,28 @@ ret:-1 st:-1 ts:-1.000000 flags:0 ...@@ -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:-1 ts:1.894167 flags:1
ret:-1 st: 0 ts:0.800000 flags:0 ret:-1 st: 0 ts:0.800000 flags:0
ret:-1 st: 0 ts:-0.320000 flags:1 ret:-1 st: 0 ts:-0.320000 flags:1
ret:-1 st: 1 ts:2.560000 flags:0 ret:-1 st:-1 ts:2.576668 flags:0
ret:-1 st: 1 ts:1.480000 flags:1 ret:-1 st:-1 ts:1.470835 flags:1
ret:-1 st: 2 ts:0.360000 flags:0 ret:-1 st: 0 ts:0.360000 flags:0
ret:-1 st: 2 ts:-0.760000 flags:1 ret:-1 st: 0 ts:-0.760000 flags:1
ret:-1 st: 3 ts:2.160000 flags:0 ret:-1 st:-1 ts:2.153336 flags:0
ret:-1 st: 3 ts:1.040000 flags:1 ret:-1 st:-1 ts:1.047503 flags:1
ret:-1 st: 4 ts:-0.040000 flags:0 ret:-1 st: 0 ts:-0.040000 flags:0
ret:-1 st: 4 ts:2.840000 flags:1 ret:-1 st: 0 ts:2.840000 flags:1
ret:-1 st: 5 ts:1.720000 flags:0 ret:-1 st:-1 ts:1.730004 flags:0
ret:-1 st: 5 ts:0.640000 flags:1 ret:-1 st:-1 ts:0.624171 flags:1
ret:-1 st: 6 ts:-0.480000 flags:0 ret:-1 st: 0 ts:-0.480000 flags:0
ret:-1 st: 6 ts:2.400000 flags:1 ret:-1 st: 0 ts:2.400000 flags:1
ret:-1 st: 7 ts:1.320000 flags:0 ret:-1 st:-1 ts:1.306672 flags:0
ret:-1 st: 7 ts:0.200000 flags:1 ret:-1 st:-1 ts:0.200839 flags:1
ret:-1 st: 8 ts:-0.920000 flags:0 ret:-1 st: 0 ts:-0.920000 flags:0
ret:-1 st: 8 ts:2.000000 flags:1 ret:-1 st: 0 ts:2.000000 flags:1
ret:-1 st: 9 ts:0.880000 flags:0 ret:-1 st:-1 ts:0.883340 flags:0
ret:-1 st: 9 ts:-0.240000 flags:1 ret:-1 st:-1 ts:-0.222493 flags:1
ret:-1 st:10 ts:2.680000 flags:0 ret:-1 st: 0 ts:2.680000 flags:0
ret:-1 st:10 ts:1.560000 flags:1 ret:-1 st: 0 ts:1.560000 flags:1
ret:-1 st:11 ts:0.480000 flags:0 ret:-1 st:-1 ts:0.460008 flags:0
ret:-1 st:11 ts:-0.640000 flags:1 ret:-1 st:-1 ts:-0.645825 flags:1
---------------- ----------------
tests/data/b-libav.ts tests/data/b-libav.ts
ret: 0 st: 0 dts:0.660000 pts:0.700000 pos:564 size:24921 flags:1 ret: 0 st: 0 dts:0.660000 pts:0.700000 pos:564 size:24921 flags:1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment