Mercurial > libavformat.hg
comparison avienc.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 | 8cf17fde9a1c |
children | 5f769b20cc76 |
comparison
equal
deleted
inserted
replaced
2770:a7e42cf4b364 | 2771:d52c718e83f9 |
---|---|
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 static int avi_write_counters(AVFormatContext* s, int riff_id) | 106 static int avi_write_counters(AVFormatContext* s, int riff_id) |
107 { | 107 { |
108 ByteIOContext *pb = &s->pb; | 108 ByteIOContext *pb = s->pb; |
109 AVIContext *avi = s->priv_data; | 109 AVIContext *avi = s->priv_data; |
110 int n, au_byterate, au_ssize, au_scale, nb_frames = 0; | 110 int n, au_byterate, au_ssize, au_scale, nb_frames = 0; |
111 offset_t file_size; | 111 offset_t file_size; |
112 AVCodecContext* stream; | 112 AVCodecContext* stream; |
113 | 113 |
136 } | 136 } |
137 | 137 |
138 static int avi_write_header(AVFormatContext *s) | 138 static int avi_write_header(AVFormatContext *s) |
139 { | 139 { |
140 AVIContext *avi = s->priv_data; | 140 AVIContext *avi = s->priv_data; |
141 ByteIOContext *pb = &s->pb; | 141 ByteIOContext *pb = s->pb; |
142 int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; | 142 int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; |
143 AVCodecContext *stream, *video_enc; | 143 AVCodecContext *stream, *video_enc; |
144 offset_t list1, list2, strh, strf; | 144 offset_t list1, list2, strh, strf; |
145 | 145 |
146 /* header list */ | 146 /* header list */ |
330 return 0; | 330 return 0; |
331 } | 331 } |
332 | 332 |
333 static int avi_write_ix(AVFormatContext *s) | 333 static int avi_write_ix(AVFormatContext *s) |
334 { | 334 { |
335 ByteIOContext *pb = &s->pb; | 335 ByteIOContext *pb = s->pb; |
336 AVIContext *avi = s->priv_data; | 336 AVIContext *avi = s->priv_data; |
337 char tag[5]; | 337 char tag[5]; |
338 char ix_tag[] = "ix00"; | 338 char ix_tag[] = "ix00"; |
339 int i, j; | 339 int i, j; |
340 | 340 |
387 return 0; | 387 return 0; |
388 } | 388 } |
389 | 389 |
390 static int avi_write_idx1(AVFormatContext *s) | 390 static int avi_write_idx1(AVFormatContext *s) |
391 { | 391 { |
392 ByteIOContext *pb = &s->pb; | 392 ByteIOContext *pb = s->pb; |
393 AVIContext *avi = s->priv_data; | 393 AVIContext *avi = s->priv_data; |
394 offset_t idx_chunk; | 394 offset_t idx_chunk; |
395 int i; | 395 int i; |
396 char tag[5]; | 396 char tag[5]; |
397 | 397 |
433 } | 433 } |
434 | 434 |
435 static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) | 435 static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) |
436 { | 436 { |
437 AVIContext *avi = s->priv_data; | 437 AVIContext *avi = s->priv_data; |
438 ByteIOContext *pb = &s->pb; | 438 ByteIOContext *pb = s->pb; |
439 unsigned char tag[5]; | 439 unsigned char tag[5]; |
440 unsigned int flags=0; | 440 unsigned int flags=0; |
441 const int stream_index= pkt->stream_index; | 441 const int stream_index= pkt->stream_index; |
442 AVCodecContext *enc= s->streams[stream_index]->codec; | 442 AVCodecContext *enc= s->streams[stream_index]->codec; |
443 int size= pkt->size; | 443 int size= pkt->size; |
474 flags = 0x10; | 474 flags = 0x10; |
475 if (enc->codec_type == CODEC_TYPE_AUDIO) { | 475 if (enc->codec_type == CODEC_TYPE_AUDIO) { |
476 avi->audio_strm_length[stream_index] += size; | 476 avi->audio_strm_length[stream_index] += size; |
477 } | 477 } |
478 | 478 |
479 if (!url_is_streamed(&s->pb)) { | 479 if (!url_is_streamed(s->pb)) { |
480 AVIIndex* idx = &avi->indexes[stream_index]; | 480 AVIIndex* idx = &avi->indexes[stream_index]; |
481 int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE; | 481 int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE; |
482 int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; | 482 int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; |
483 if (idx->ents_allocated <= idx->entry) { | 483 if (idx->ents_allocated <= idx->entry) { |
484 idx->cluster = av_realloc(idx->cluster, (cl+1)*sizeof(void*)); | 484 idx->cluster = av_realloc(idx->cluster, (cl+1)*sizeof(void*)); |
507 } | 507 } |
508 | 508 |
509 static int avi_write_trailer(AVFormatContext *s) | 509 static int avi_write_trailer(AVFormatContext *s) |
510 { | 510 { |
511 AVIContext *avi = s->priv_data; | 511 AVIContext *avi = s->priv_data; |
512 ByteIOContext *pb = &s->pb; | 512 ByteIOContext *pb = s->pb; |
513 int res = 0; | 513 int res = 0; |
514 int i, j, n, nb_frames; | 514 int i, j, n, nb_frames; |
515 offset_t file_size; | 515 offset_t file_size; |
516 | 516 |
517 if (!url_is_streamed(pb)){ | 517 if (!url_is_streamed(pb)){ |