comparison swfdec.c @ 4707:f153437e1ac0 libavformat

Set pkt->pos correctly (to the start of header of the packet) in swfdec.
author reimar
date Fri, 13 Mar 2009 22:26:45 +0000
parents a3f213a1d3a8
children 6e9e1f5426a5
comparison
equal deleted inserted replaced
4706:a3f213a1d3a8 4707:f153437e1ac0
85 ByteIOContext *pb = s->pb; 85 ByteIOContext *pb = s->pb;
86 AVStream *vst = NULL, *ast = NULL, *st = 0; 86 AVStream *vst = NULL, *ast = NULL, *st = 0;
87 int tag, len, i, frame, v; 87 int tag, len, i, frame, v;
88 88
89 for(;;) { 89 for(;;) {
90 uint64_t pos = url_ftell(pb);
90 tag = get_swf_tag(pb, &len); 91 tag = get_swf_tag(pb, &len);
91 if (tag < 0) 92 if (tag < 0)
92 return AVERROR(EIO); 93 return AVERROR(EIO);
93 if (tag == TAG_VIDEOSTREAM) { 94 if (tag == TAG_VIDEOSTREAM) {
94 int ch_id = get_le16(pb); 95 int ch_id = get_le16(pb);
146 for(i=0; i<s->nb_streams; i++) { 147 for(i=0; i<s->nb_streams; i++) {
147 st = s->streams[i]; 148 st = s->streams[i];
148 if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id) { 149 if (st->codec->codec_type == CODEC_TYPE_VIDEO && st->id == ch_id) {
149 frame = get_le16(pb); 150 frame = get_le16(pb);
150 av_get_packet(pb, pkt, len-2); 151 av_get_packet(pb, pkt, len-2);
152 pkt->pos = pos;
151 pkt->pts = frame; 153 pkt->pts = frame;
152 pkt->stream_index = st->index; 154 pkt->stream_index = st->index;
153 return pkt->size; 155 return pkt->size;
154 } 156 }
155 } 157 }
161 url_fskip(pb, 4); 163 url_fskip(pb, 4);
162 av_get_packet(pb, pkt, len-4); 164 av_get_packet(pb, pkt, len-4);
163 } else { // ADPCM, PCM 165 } else { // ADPCM, PCM
164 av_get_packet(pb, pkt, len); 166 av_get_packet(pb, pkt, len);
165 } 167 }
168 pkt->pos = pos;
166 pkt->stream_index = st->index; 169 pkt->stream_index = st->index;
167 return pkt->size; 170 return pkt->size;
168 } 171 }
169 } 172 }
170 } else if (tag == TAG_JPEG2) { 173 } else if (tag == TAG_JPEG2) {
193 pkt->size -= 4; 196 pkt->size -= 4;
194 get_buffer(pb, pkt->data, pkt->size); 197 get_buffer(pb, pkt->data, pkt->size);
195 } else { 198 } else {
196 get_buffer(pb, pkt->data + 4, pkt->size - 4); 199 get_buffer(pb, pkt->data + 4, pkt->size - 4);
197 } 200 }
201 pkt->pos = pos;
198 pkt->stream_index = st->index; 202 pkt->stream_index = st->index;
199 return pkt->size; 203 return pkt->size;
200 } 204 }
201 skip: 205 skip:
202 url_fskip(pb, len); 206 url_fskip(pb, len);