Mercurial > libavformat.hg
comparison swfdec.c @ 4706:a3f213a1d3a8 libavformat
fix swf seeking by fixing new stream detection
author | bcoudurier |
---|---|
date | Fri, 13 Mar 2009 19:37:05 +0000 |
parents | 77e0c7511d41 |
children | f153437e1ac0 |
comparison
equal
deleted
inserted
replaced
4705:492dd0722ee1 | 4706:a3f213a1d3a8 |
---|---|
88 | 88 |
89 for(;;) { | 89 for(;;) { |
90 tag = get_swf_tag(pb, &len); | 90 tag = get_swf_tag(pb, &len); |
91 if (tag < 0) | 91 if (tag < 0) |
92 return AVERROR(EIO); | 92 return AVERROR(EIO); |
93 if (tag == TAG_VIDEOSTREAM && !vst) { | 93 if (tag == TAG_VIDEOSTREAM) { |
94 int ch_id = get_le16(pb); | 94 int ch_id = get_le16(pb); |
95 len -= 2; | |
96 | |
97 for (i=0; i<s->nb_streams; i++) { | |
98 st = s->streams[i]; | |
99 if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id) | |
100 goto skip; | |
101 } | |
102 | |
95 get_le16(pb); | 103 get_le16(pb); |
96 get_le16(pb); | 104 get_le16(pb); |
97 get_le16(pb); | 105 get_le16(pb); |
98 get_byte(pb); | 106 get_byte(pb); |
99 /* Check for FLV1 */ | 107 /* Check for FLV1 */ |
102 return -1; | 110 return -1; |
103 vst->codec->codec_type = CODEC_TYPE_VIDEO; | 111 vst->codec->codec_type = CODEC_TYPE_VIDEO; |
104 vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb)); | 112 vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb)); |
105 av_set_pts_info(vst, 64, 256, swf->frame_rate); | 113 av_set_pts_info(vst, 64, 256, swf->frame_rate); |
106 vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; | 114 vst->codec->time_base = (AVRational){ 256, swf->frame_rate }; |
107 len -= 10; | 115 len -= 8; |
108 } else if ((tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) && !ast) { | 116 } else if (tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2) { |
109 /* streaming found */ | 117 /* streaming found */ |
110 int sample_rate_code; | 118 int sample_rate_code; |
119 | |
120 for (i=0; i<s->nb_streams; i++) { | |
121 st = s->streams[i]; | |
122 if (st->codec->codec_type == CODEC_TYPE_AUDIO && st->id == -1) | |
123 goto skip; | |
124 } | |
125 | |
111 get_byte(pb); | 126 get_byte(pb); |
112 v = get_byte(pb); | 127 v = get_byte(pb); |
113 swf->samples_per_frame = get_le16(pb); | 128 swf->samples_per_frame = get_le16(pb); |
114 ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */ | 129 ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */ |
115 if (!ast) | 130 if (!ast) |
137 pkt->stream_index = st->index; | 152 pkt->stream_index = st->index; |
138 return pkt->size; | 153 return pkt->size; |
139 } | 154 } |
140 } | 155 } |
141 } else if (tag == TAG_STREAMBLOCK) { | 156 } else if (tag == TAG_STREAMBLOCK) { |
142 st = s->streams[swf->audio_stream_index]; | 157 for (i = 0; i < s->nb_streams; i++) { |
158 st = s->streams[i]; | |
159 if (st->codec->codec_type == CODEC_TYPE_AUDIO && st->id == -1) { | |
143 if (st->codec->codec_id == CODEC_ID_MP3) { | 160 if (st->codec->codec_id == CODEC_ID_MP3) { |
144 url_fskip(pb, 4); | 161 url_fskip(pb, 4); |
145 av_get_packet(pb, pkt, len-4); | 162 av_get_packet(pb, pkt, len-4); |
146 } else { // ADPCM, PCM | 163 } else { // ADPCM, PCM |
147 av_get_packet(pb, pkt, len); | 164 av_get_packet(pb, pkt, len); |
148 } | 165 } |
149 pkt->stream_index = st->index; | 166 pkt->stream_index = st->index; |
150 return pkt->size; | 167 return pkt->size; |
168 } | |
169 } | |
151 } else if (tag == TAG_JPEG2) { | 170 } else if (tag == TAG_JPEG2) { |
152 for (i=0; i<s->nb_streams; i++) { | 171 for (i=0; i<s->nb_streams; i++) { |
153 st = s->streams[i]; | 172 st = s->streams[i]; |
154 if (st->id == -2) | 173 if (st->codec->codec_id == CODEC_ID_MJPEG && st->id == -2) |
155 break; | 174 break; |
156 } | 175 } |
157 if (i == s->nb_streams) { | 176 if (i == s->nb_streams) { |
158 vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */ | 177 vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */ |
159 if (!vst) | 178 if (!vst) |
177 get_buffer(pb, pkt->data + 4, pkt->size - 4); | 196 get_buffer(pb, pkt->data + 4, pkt->size - 4); |
178 } | 197 } |
179 pkt->stream_index = st->index; | 198 pkt->stream_index = st->index; |
180 return pkt->size; | 199 return pkt->size; |
181 } | 200 } |
201 skip: | |
182 url_fskip(pb, len); | 202 url_fskip(pb, len); |
183 } | 203 } |
184 return 0; | 204 return 0; |
185 } | 205 } |
186 | 206 |