comparison 4xm.c @ 2771:d52c718e83f9 libavformat

Use dynamically allocated ByteIOContext in AVFormatContext patch by: Bj«Órn Axelsson, bjorn d axelsson a intinor d se thread: [PATCH] Remove static ByteIOContexts, 06 nov 2007
author andoma
date Wed, 21 Nov 2007 07:41:00 +0000
parents 9b58a031620e
children 7a0230981402
comparison
equal deleted inserted replaced
2770:a7e42cf4b364 2771:d52c718e83f9
90 } 90 }
91 91
92 static int fourxm_read_header(AVFormatContext *s, 92 static int fourxm_read_header(AVFormatContext *s,
93 AVFormatParameters *ap) 93 AVFormatParameters *ap)
94 { 94 {
95 ByteIOContext *pb = &s->pb; 95 ByteIOContext *pb = s->pb;
96 unsigned int fourcc_tag; 96 unsigned int fourcc_tag;
97 unsigned int size; 97 unsigned int size;
98 int header_size; 98 int header_size;
99 FourxmDemuxContext *fourxm = s->priv_data; 99 FourxmDemuxContext *fourxm = s->priv_data;
100 unsigned char *header; 100 unsigned char *header;
222 222
223 static int fourxm_read_packet(AVFormatContext *s, 223 static int fourxm_read_packet(AVFormatContext *s,
224 AVPacket *pkt) 224 AVPacket *pkt)
225 { 225 {
226 FourxmDemuxContext *fourxm = s->priv_data; 226 FourxmDemuxContext *fourxm = s->priv_data;
227 ByteIOContext *pb = &s->pb; 227 ByteIOContext *pb = s->pb;
228 unsigned int fourcc_tag; 228 unsigned int fourcc_tag;
229 unsigned int size, out_size; 229 unsigned int size, out_size;
230 int ret = 0; 230 int ret = 0;
231 int track_number; 231 int track_number;
232 int packet_read = 0; 232 int packet_read = 0;
233 unsigned char header[8]; 233 unsigned char header[8];
234 int audio_frame_count; 234 int audio_frame_count;
235 235
236 while (!packet_read) { 236 while (!packet_read) {
237 237
238 if ((ret = get_buffer(&s->pb, header, 8)) < 0) 238 if ((ret = get_buffer(s->pb, header, 8)) < 0)
239 return ret; 239 return ret;
240 fourcc_tag = AV_RL32(&header[0]); 240 fourcc_tag = AV_RL32(&header[0]);
241 size = AV_RL32(&header[4]); 241 size = AV_RL32(&header[4]);
242 if (url_feof(pb)) 242 if (url_feof(pb))
243 return AVERROR(EIO); 243 return AVERROR(EIO);
263 * and size */ 263 * and size */
264 if (size + 8 < size || av_new_packet(pkt, size + 8)) 264 if (size + 8 < size || av_new_packet(pkt, size + 8))
265 return AVERROR(EIO); 265 return AVERROR(EIO);
266 pkt->stream_index = fourxm->video_stream_index; 266 pkt->stream_index = fourxm->video_stream_index;
267 pkt->pts = fourxm->video_pts; 267 pkt->pts = fourxm->video_pts;
268 pkt->pos = url_ftell(&s->pb); 268 pkt->pos = url_ftell(s->pb);
269 memcpy(pkt->data, header, 8); 269 memcpy(pkt->data, header, 8);
270 ret = get_buffer(&s->pb, &pkt->data[8], size); 270 ret = get_buffer(s->pb, &pkt->data[8], size);
271 271
272 if (ret < 0) 272 if (ret < 0)
273 av_free_packet(pkt); 273 av_free_packet(pkt);
274 else 274 else
275 packet_read = 1; 275 packet_read = 1;
280 track_number = get_le32(pb); 280 track_number = get_le32(pb);
281 out_size= get_le32(pb); 281 out_size= get_le32(pb);
282 size-=8; 282 size-=8;
283 283
284 if (track_number == fourxm->selected_track) { 284 if (track_number == fourxm->selected_track) {
285 ret= av_get_packet(&s->pb, pkt, size); 285 ret= av_get_packet(s->pb, pkt, size);
286 if(ret<0) 286 if(ret<0)
287 return AVERROR(EIO); 287 return AVERROR(EIO);
288 pkt->stream_index = 288 pkt->stream_index =
289 fourxm->tracks[fourxm->selected_track].stream_index; 289 fourxm->tracks[fourxm->selected_track].stream_index;
290 pkt->pts = fourxm->audio_pts; 290 pkt->pts = fourxm->audio_pts;