Mercurial > libavformat.hg
comparison au.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 | 213268d7594e |
children | 473906f5a3b9 |
comparison
equal
deleted
inserted
replaced
2770:a7e42cf4b364 | 2771:d52c718e83f9 |
---|---|
57 return 0; | 57 return 0; |
58 } | 58 } |
59 | 59 |
60 static int au_write_header(AVFormatContext *s) | 60 static int au_write_header(AVFormatContext *s) |
61 { | 61 { |
62 ByteIOContext *pb = &s->pb; | 62 ByteIOContext *pb = s->pb; |
63 | 63 |
64 s->priv_data = NULL; | 64 s->priv_data = NULL; |
65 | 65 |
66 /* format header */ | 66 /* format header */ |
67 if (put_au_header(pb, s->streams[0]->codec) < 0) { | 67 if (put_au_header(pb, s->streams[0]->codec) < 0) { |
73 return 0; | 73 return 0; |
74 } | 74 } |
75 | 75 |
76 static int au_write_packet(AVFormatContext *s, AVPacket *pkt) | 76 static int au_write_packet(AVFormatContext *s, AVPacket *pkt) |
77 { | 77 { |
78 ByteIOContext *pb = &s->pb; | 78 ByteIOContext *pb = s->pb; |
79 put_buffer(pb, pkt->data, pkt->size); | 79 put_buffer(pb, pkt->data, pkt->size); |
80 return 0; | 80 return 0; |
81 } | 81 } |
82 | 82 |
83 static int au_write_trailer(AVFormatContext *s) | 83 static int au_write_trailer(AVFormatContext *s) |
84 { | 84 { |
85 ByteIOContext *pb = &s->pb; | 85 ByteIOContext *pb = s->pb; |
86 offset_t file_size; | 86 offset_t file_size; |
87 | 87 |
88 if (!url_is_streamed(&s->pb)) { | 88 if (!url_is_streamed(s->pb)) { |
89 | 89 |
90 /* update file size */ | 90 /* update file size */ |
91 file_size = url_ftell(pb); | 91 file_size = url_ftell(pb); |
92 url_fseek(pb, 8, SEEK_SET); | 92 url_fseek(pb, 8, SEEK_SET); |
93 put_be32(pb, (uint32_t)(file_size - 24)); | 93 put_be32(pb, (uint32_t)(file_size - 24)); |
114 static int au_read_header(AVFormatContext *s, | 114 static int au_read_header(AVFormatContext *s, |
115 AVFormatParameters *ap) | 115 AVFormatParameters *ap) |
116 { | 116 { |
117 int size; | 117 int size; |
118 unsigned int tag; | 118 unsigned int tag; |
119 ByteIOContext *pb = &s->pb; | 119 ByteIOContext *pb = s->pb; |
120 unsigned int id, codec, channels, rate; | 120 unsigned int id, codec, channels, rate; |
121 AVStream *st; | 121 AVStream *st; |
122 | 122 |
123 /* check ".snd" header */ | 123 /* check ".snd" header */ |
124 tag = get_le32(pb); | 124 tag = get_le32(pb); |
156 static int au_read_packet(AVFormatContext *s, | 156 static int au_read_packet(AVFormatContext *s, |
157 AVPacket *pkt) | 157 AVPacket *pkt) |
158 { | 158 { |
159 int ret; | 159 int ret; |
160 | 160 |
161 if (url_feof(&s->pb)) | 161 if (url_feof(s->pb)) |
162 return AVERROR(EIO); | 162 return AVERROR(EIO); |
163 ret= av_get_packet(&s->pb, pkt, MAX_SIZE); | 163 ret= av_get_packet(s->pb, pkt, MAX_SIZE); |
164 if (ret < 0) | 164 if (ret < 0) |
165 return AVERROR(EIO); | 165 return AVERROR(EIO); |
166 pkt->stream_index = 0; | 166 pkt->stream_index = 0; |
167 | 167 |
168 /* note: we need to modify the packet size here to handle the last | 168 /* note: we need to modify the packet size here to handle the last |