comparison westwood.c @ 482:0fdc96c2f2fe libavformat

sweeping change from -EIO -> AVERROR_IO
author melanson
date Sat, 19 Jun 2004 03:59:34 +0000
parents b69898ffc92a
children c5077fdab490
comparison
equal deleted inserted replaced
481:f1430abbbd8b 482:0fdc96c2f2fe
117 ByteIOContext *pb = &s->pb; 117 ByteIOContext *pb = &s->pb;
118 AVStream *st; 118 AVStream *st;
119 unsigned char header[AUD_HEADER_SIZE]; 119 unsigned char header[AUD_HEADER_SIZE];
120 120
121 if (get_buffer(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE) 121 if (get_buffer(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
122 return -EIO; 122 return AVERROR_IO;
123 wsaud->audio_samplerate = LE_16(&header[0]); 123 wsaud->audio_samplerate = LE_16(&header[0]);
124 if (header[11] == 99) 124 if (header[11] == 99)
125 wsaud->audio_type = CODEC_ID_ADPCM_IMA_WS; 125 wsaud->audio_type = CODEC_ID_ADPCM_IMA_WS;
126 else 126 else
127 return AVERROR_INVALIDDATA; 127 return AVERROR_INVALIDDATA;
161 unsigned int chunk_size; 161 unsigned int chunk_size;
162 int ret = 0; 162 int ret = 0;
163 163
164 if (get_buffer(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) != 164 if (get_buffer(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=
165 AUD_CHUNK_PREAMBLE_SIZE) 165 AUD_CHUNK_PREAMBLE_SIZE)
166 return -EIO; 166 return AVERROR_IO;
167 167
168 /* validate the chunk */ 168 /* validate the chunk */
169 if (LE_32(&preamble[4]) != AUD_CHUNK_SIGNATURE) 169 if (LE_32(&preamble[4]) != AUD_CHUNK_SIGNATURE)
170 return AVERROR_INVALIDDATA; 170 return AVERROR_INVALIDDATA;
171 171
172 chunk_size = LE_16(&preamble[0]); 172 chunk_size = LE_16(&preamble[0]);
173 if (av_new_packet(pkt, chunk_size)) 173 if (av_new_packet(pkt, chunk_size))
174 return -EIO; 174 return AVERROR_IO;
175 pkt->stream_index = wsaud->audio_stream_index; 175 pkt->stream_index = wsaud->audio_stream_index;
176 pkt->pts = wsaud->audio_frame_counter; 176 pkt->pts = wsaud->audio_frame_counter;
177 pkt->pts /= wsaud->audio_samplerate; 177 pkt->pts /= wsaud->audio_samplerate;
178 if ((ret = get_buffer(pb, pkt->data, chunk_size)) != chunk_size) { 178 if ((ret = get_buffer(pb, pkt->data, chunk_size)) != chunk_size) {
179 av_free_packet(pkt); 179 av_free_packet(pkt);
180 ret = -EIO; 180 ret = AVERROR_IO;
181 } 181 }
182 182
183 /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */ 183 /* 2 samples/byte, 1 or 2 samples per frame depending on stereo */
184 wsaud->audio_frame_counter += (chunk_size * 2) / wsaud->audio_channels; 184 wsaud->audio_frame_counter += (chunk_size * 2) / wsaud->audio_channels;
185 185
237 st->codec.extradata = av_malloc(VQA_HEADER_SIZE); 237 st->codec.extradata = av_malloc(VQA_HEADER_SIZE);
238 header = (unsigned char *)st->codec.extradata; 238 header = (unsigned char *)st->codec.extradata;
239 if (get_buffer(pb, st->codec.extradata, VQA_HEADER_SIZE) != 239 if (get_buffer(pb, st->codec.extradata, VQA_HEADER_SIZE) !=
240 VQA_HEADER_SIZE) { 240 VQA_HEADER_SIZE) {
241 av_free(st->codec.extradata); 241 av_free(st->codec.extradata);
242 return -EIO; 242 return AVERROR_IO;
243 } 243 }
244 st->codec.width = LE_16(&header[6]); 244 st->codec.width = LE_16(&header[6]);
245 st->codec.height = LE_16(&header[8]); 245 st->codec.height = LE_16(&header[8]);
246 246
247 /* initialize the audio decoder stream is sample rate is non-zero */ 247 /* initialize the audio decoder stream is sample rate is non-zero */
269 /* there are 0 or more chunks before the FINF chunk; iterate until 269 /* there are 0 or more chunks before the FINF chunk; iterate until
270 * FINF has been skipped and the file will be ready to be demuxed */ 270 * FINF has been skipped and the file will be ready to be demuxed */
271 do { 271 do {
272 if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) { 272 if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
273 av_free(st->codec.extradata); 273 av_free(st->codec.extradata);
274 return -EIO; 274 return AVERROR_IO;
275 } 275 }
276 chunk_tag = BE_32(&scratch[0]); 276 chunk_tag = BE_32(&scratch[0]);
277 chunk_size = BE_32(&scratch[4]); 277 chunk_size = BE_32(&scratch[4]);
278 278
279 /* catch any unknown header tags, for curiousity */ 279 /* catch any unknown header tags, for curiousity */
312 unsigned int chunk_type; 312 unsigned int chunk_type;
313 unsigned int chunk_size; 313 unsigned int chunk_size;
314 int skip_byte; 314 int skip_byte;
315 315
316 if (get_buffer(pb, preamble, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) 316 if (get_buffer(pb, preamble, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
317 return -EIO; 317 return AVERROR_IO;
318 318
319 chunk_type = BE_32(&preamble[0]); 319 chunk_type = BE_32(&preamble[0]);
320 chunk_size = BE_32(&preamble[4]); 320 chunk_size = BE_32(&preamble[4]);
321 skip_byte = chunk_size & 0x01; 321 skip_byte = chunk_size & 0x01;
322 322
323 if ((chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) { 323 if ((chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) {
324 324
325 if (av_new_packet(pkt, chunk_size)) 325 if (av_new_packet(pkt, chunk_size))
326 return -EIO; 326 return AVERROR_IO;
327 ret = get_buffer(pb, pkt->data, chunk_size); 327 ret = get_buffer(pb, pkt->data, chunk_size);
328 if (ret != chunk_size) { 328 if (ret != chunk_size) {
329 av_free_packet(pkt); 329 av_free_packet(pkt);
330 ret = -EIO; 330 ret = AVERROR_IO;
331 } 331 }
332 332
333 if (chunk_type == SND2_TAG) { 333 if (chunk_type == SND2_TAG) {
334 pkt->stream_index = wsvqa->audio_stream_index; 334 pkt->stream_index = wsvqa->audio_stream_index;
335 335