comparison asf.c @ 820:feca73904e67 libavformat

changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
author michael
date Sun, 17 Jul 2005 22:24:36 +0000
parents 2680c3d05ca8
children a5af9ba25343
comparison
equal deleted inserted replaced
819:a6c035e7f429 820:feca73904e67
214 st->id = get_le16(pb) & 0x7f; /* stream id */ 214 st->id = get_le16(pb) & 0x7f; /* stream id */
215 // mapping of asf ID to AV stream ID; 215 // mapping of asf ID to AV stream ID;
216 asf->asfid2avid[st->id] = s->nb_streams - 1; 216 asf->asfid2avid[st->id] = s->nb_streams - 1;
217 217
218 get_le32(pb); 218 get_le32(pb);
219 st->codec.codec_type = type; 219 st->codec->codec_type = type;
220 if (type == CODEC_TYPE_AUDIO) { 220 if (type == CODEC_TYPE_AUDIO) {
221 get_wav_header(pb, &st->codec, type_specific_size); 221 get_wav_header(pb, st->codec, type_specific_size);
222 st->need_parsing = 1; 222 st->need_parsing = 1;
223 /* We have to init the frame size at some point .... */ 223 /* We have to init the frame size at some point .... */
224 pos2 = url_ftell(pb); 224 pos2 = url_ftell(pb);
225 if (gsize > (pos2 + 8 - pos1 + 24)) { 225 if (gsize > (pos2 + 8 - pos1 + 24)) {
226 asf_st->ds_span = get_byte(pb); 226 asf_st->ds_span = get_byte(pb);
235 if (asf_st->ds_span > 1) { 235 if (asf_st->ds_span > 1) {
236 if (!asf_st->ds_chunk_size 236 if (!asf_st->ds_chunk_size
237 || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1)) 237 || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1))
238 asf_st->ds_span = 0; // disable descrambling 238 asf_st->ds_span = 0; // disable descrambling
239 } 239 }
240 switch (st->codec.codec_id) { 240 switch (st->codec->codec_id) {
241 case CODEC_ID_MP3: 241 case CODEC_ID_MP3:
242 st->codec.frame_size = MPA_FRAME_SIZE; 242 st->codec->frame_size = MPA_FRAME_SIZE;
243 break; 243 break;
244 case CODEC_ID_PCM_S16LE: 244 case CODEC_ID_PCM_S16LE:
245 case CODEC_ID_PCM_S16BE: 245 case CODEC_ID_PCM_S16BE:
246 case CODEC_ID_PCM_U16LE: 246 case CODEC_ID_PCM_U16LE:
247 case CODEC_ID_PCM_U16BE: 247 case CODEC_ID_PCM_U16BE:
248 case CODEC_ID_PCM_S8: 248 case CODEC_ID_PCM_S8:
249 case CODEC_ID_PCM_U8: 249 case CODEC_ID_PCM_U8:
250 case CODEC_ID_PCM_ALAW: 250 case CODEC_ID_PCM_ALAW:
251 case CODEC_ID_PCM_MULAW: 251 case CODEC_ID_PCM_MULAW:
252 st->codec.frame_size = 1; 252 st->codec->frame_size = 1;
253 break; 253 break;
254 default: 254 default:
255 /* This is probably wrong, but it prevents a crash later */ 255 /* This is probably wrong, but it prevents a crash later */
256 st->codec.frame_size = 1; 256 st->codec->frame_size = 1;
257 break; 257 break;
258 } 258 }
259 } else { 259 } else {
260 get_le32(pb); 260 get_le32(pb);
261 get_le32(pb); 261 get_le32(pb);
262 get_byte(pb); 262 get_byte(pb);
263 size = get_le16(pb); /* size */ 263 size = get_le16(pb); /* size */
264 sizeX= get_le32(pb); /* size */ 264 sizeX= get_le32(pb); /* size */
265 st->codec.width = get_le32(pb); 265 st->codec->width = get_le32(pb);
266 st->codec.height = get_le32(pb); 266 st->codec->height = get_le32(pb);
267 /* not available for asf */ 267 /* not available for asf */
268 get_le16(pb); /* panes */ 268 get_le16(pb); /* panes */
269 st->codec.bits_per_sample = get_le16(pb); /* depth */ 269 st->codec->bits_per_sample = get_le16(pb); /* depth */
270 tag1 = get_le32(pb); 270 tag1 = get_le32(pb);
271 url_fskip(pb, 20); 271 url_fskip(pb, 20);
272 // av_log(NULL, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX); 272 // av_log(NULL, AV_LOG_DEBUG, "size:%d tsize:%d sizeX:%d\n", size, total_size, sizeX);
273 size= sizeX; 273 size= sizeX;
274 if (size > 40) { 274 if (size > 40) {
275 st->codec.extradata_size = size - 40; 275 st->codec->extradata_size = size - 40;
276 st->codec.extradata = av_mallocz(st->codec.extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); 276 st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
277 get_buffer(pb, st->codec.extradata, st->codec.extradata_size); 277 get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
278 } 278 }
279 279
280 /* Extract palette from extradata if bpp <= 8 */ 280 /* Extract palette from extradata if bpp <= 8 */
281 /* This code assumes that extradata contains only palette */ 281 /* This code assumes that extradata contains only palette */
282 /* This is true for all paletted codecs implemented in ffmpeg */ 282 /* This is true for all paletted codecs implemented in ffmpeg */
283 if (st->codec.extradata_size && (st->codec.bits_per_sample <= 8)) { 283 if (st->codec->extradata_size && (st->codec->bits_per_sample <= 8)) {
284 st->codec.palctrl = av_mallocz(sizeof(AVPaletteControl)); 284 st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
285 #ifdef WORDS_BIGENDIAN 285 #ifdef WORDS_BIGENDIAN
286 for (i = 0; i < FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)/4; i++) 286 for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
287 st->codec.palctrl->palette[i] = bswap_32(((uint32_t*)st->codec.extradata)[i]); 287 st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
288 #else 288 #else
289 memcpy(st->codec.palctrl->palette, st->codec.extradata, 289 memcpy(st->codec->palctrl->palette, st->codec->extradata,
290 FFMIN(st->codec.extradata_size, AVPALETTE_SIZE)); 290 FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
291 #endif 291 #endif
292 st->codec.palctrl->palette_changed = 1; 292 st->codec->palctrl->palette_changed = 1;
293 } 293 }
294 294
295 st->codec.codec_tag = tag1; 295 st->codec->codec_tag = tag1;
296 st->codec.codec_id = codec_get_id(codec_bmp_tags, tag1); 296 st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
297 if(tag1 == MKTAG('D', 'V', 'R', ' ')) 297 if(tag1 == MKTAG('D', 'V', 'R', ' '))
298 st->need_parsing = 1; 298 st->need_parsing = 1;
299 } 299 }
300 pos2 = url_ftell(pb); 300 pos2 = url_ftell(pb);
301 url_fskip(pb, gsize - (pos2 - pos1 + 24)); 301 url_fskip(pb, gsize - (pos2 - pos1 + 24));
396 fail: 396 fail:
397 for(i=0;i<s->nb_streams;i++) { 397 for(i=0;i<s->nb_streams;i++) {
398 AVStream *st = s->streams[i]; 398 AVStream *st = s->streams[i];
399 if (st) { 399 if (st) {
400 av_free(st->priv_data); 400 av_free(st->priv_data);
401 av_free(st->codec.extradata); 401 av_free(st->codec->extradata);
402 } 402 }
403 av_free(st); 403 av_free(st);
404 } 404 }
405 return -1; 405 return -1;
406 } 406 }
606 asf_st->pkt.stream_index = asf->stream_index; 606 asf_st->pkt.stream_index = asf->stream_index;
607 asf_st->pkt.pos = 607 asf_st->pkt.pos =
608 asf_st->packet_pos= asf->packet_pos; 608 asf_st->packet_pos= asf->packet_pos;
609 //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n", 609 //printf("new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
610 //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY, 610 //asf->stream_index, asf->packet_key_frame, asf_st->pkt.flags & PKT_FLAG_KEY,
611 //s->streams[asf->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size); 611 //s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO, asf->packet_obj_size);
612 if (s->streams[asf->stream_index]->codec.codec_type == CODEC_TYPE_AUDIO) 612 if (s->streams[asf->stream_index]->codec->codec_type == CODEC_TYPE_AUDIO)
613 asf->packet_key_frame = 1; 613 asf->packet_key_frame = 1;
614 if (asf->packet_key_frame) 614 if (asf->packet_key_frame)
615 asf_st->pkt.flags |= PKT_FLAG_KEY; 615 asf_st->pkt.flags |= PKT_FLAG_KEY;
616 } 616 }
617 617
664 int i; 664 int i;
665 665
666 for(i=0;i<s->nb_streams;i++) { 666 for(i=0;i<s->nb_streams;i++) {
667 AVStream *st = s->streams[i]; 667 AVStream *st = s->streams[i];
668 av_free(st->priv_data); 668 av_free(st->priv_data);
669 av_free(st->codec.extradata); 669 av_free(st->codec->extradata);
670 av_free(st->codec.palctrl); 670 av_free(st->codec->palctrl);
671 } 671 }
672 return 0; 672 return 0;
673 } 673 }
674 674
675 // Added to support seeking after packets have been read 675 // Added to support seeking after packets have been read