Mercurial > libavformat.hg
comparison gxf.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 | bc13220fb9cd |
children | 6f61c3b36632 |
comparison
equal
deleted
inserted
replaced
2770:a7e42cf4b364 | 2771:d52c718e83f9 |
---|---|
226 | 226 |
227 /** | 227 /** |
228 * \brief read index from FLT packet into stream 0 av_index | 228 * \brief read index from FLT packet into stream 0 av_index |
229 */ | 229 */ |
230 static void gxf_read_index(AVFormatContext *s, int pkt_len) { | 230 static void gxf_read_index(AVFormatContext *s, int pkt_len) { |
231 ByteIOContext *pb = &s->pb; | 231 ByteIOContext *pb = s->pb; |
232 AVStream *st = s->streams[0]; | 232 AVStream *st = s->streams[0]; |
233 uint32_t fields_per_map = get_le32(pb); | 233 uint32_t fields_per_map = get_le32(pb); |
234 uint32_t map_cnt = get_le32(pb); | 234 uint32_t map_cnt = get_le32(pb); |
235 int i; | 235 int i; |
236 pkt_len -= 8; | 236 pkt_len -= 8; |
250 i * (uint64_t)fields_per_map + 1, 0, 0, 0); | 250 i * (uint64_t)fields_per_map + 1, 0, 0, 0); |
251 url_fskip(pb, pkt_len); | 251 url_fskip(pb, pkt_len); |
252 } | 252 } |
253 | 253 |
254 static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { | 254 static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { |
255 ByteIOContext *pb = &s->pb; | 255 ByteIOContext *pb = s->pb; |
256 pkt_type_t pkt_type; | 256 pkt_type_t pkt_type; |
257 int map_len; | 257 int map_len; |
258 int len; | 258 int len; |
259 AVRational main_timebase = {0, 0}; | 259 AVRational main_timebase = {0, 0}; |
260 st_info_t si; | 260 st_info_t si; |
376 uint64_t last_pos; | 376 uint64_t last_pos; |
377 uint64_t last_found_pos = 0; | 377 uint64_t last_found_pos = 0; |
378 int cur_track; | 378 int cur_track; |
379 int64_t cur_timestamp = AV_NOPTS_VALUE; | 379 int64_t cur_timestamp = AV_NOPTS_VALUE; |
380 int len; | 380 int len; |
381 ByteIOContext *pb = &s->pb; | 381 ByteIOContext *pb = s->pb; |
382 pkt_type_t type; | 382 pkt_type_t type; |
383 tmp = get_be32(pb); | 383 tmp = get_be32(pb); |
384 start: | 384 start: |
385 while (tmp) | 385 while (tmp) |
386 READ_ONE(); | 386 READ_ONE(); |
406 url_fseek(pb, last_found_pos, SEEK_SET); | 406 url_fseek(pb, last_found_pos, SEEK_SET); |
407 return cur_timestamp; | 407 return cur_timestamp; |
408 } | 408 } |
409 | 409 |
410 static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { | 410 static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { |
411 ByteIOContext *pb = &s->pb; | 411 ByteIOContext *pb = s->pb; |
412 pkt_type_t pkt_type; | 412 pkt_type_t pkt_type; |
413 int pkt_len; | 413 int pkt_len; |
414 while (!url_feof(pb)) { | 414 while (!url_feof(pb)) { |
415 int track_type, track_id, ret; | 415 int track_type, track_id, ret; |
416 int field_nr; | 416 int field_nr; |
464 return -1; | 464 return -1; |
465 pos = st->index_entries[idx].pos; | 465 pos = st->index_entries[idx].pos; |
466 if (idx < st->nb_index_entries - 2) | 466 if (idx < st->nb_index_entries - 2) |
467 maxlen = st->index_entries[idx + 2].pos - pos; | 467 maxlen = st->index_entries[idx + 2].pos - pos; |
468 maxlen = FFMAX(maxlen, 200 * 1024); | 468 maxlen = FFMAX(maxlen, 200 * 1024); |
469 url_fseek(&s->pb, pos, SEEK_SET); | 469 url_fseek(s->pb, pos, SEEK_SET); |
470 found = gxf_resync_media(s, maxlen, -1, timestamp); | 470 found = gxf_resync_media(s, maxlen, -1, timestamp); |
471 if (FFABS(found - timestamp) > 4) | 471 if (FFABS(found - timestamp) > 4) |
472 return -1; | 472 return -1; |
473 return 0; | 473 return 0; |
474 } | 474 } |
475 | 475 |
476 static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, | 476 static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, |
477 int64_t *pos, int64_t pos_limit) { | 477 int64_t *pos, int64_t pos_limit) { |
478 ByteIOContext *pb = &s->pb; | 478 ByteIOContext *pb = s->pb; |
479 int64_t res; | 479 int64_t res; |
480 url_fseek(pb, *pos, SEEK_SET); | 480 url_fseek(pb, *pos, SEEK_SET); |
481 res = gxf_resync_media(s, pos_limit - *pos, -1, -1); | 481 res = gxf_resync_media(s, pos_limit - *pos, -1, -1); |
482 *pos = url_ftell(pb); | 482 *pos = url_ftell(pb); |
483 return res; | 483 return res; |