comparison gxf.c @ 3400:75d4db7ae5c9 libavformat

Check for av_new_stream failure, fixes CID76 RUN2
author reimar
date Thu, 29 May 2008 15:22:45 +0000
parents 6f61c3b36632
children 7a0230981402
comparison
equal deleted inserted replaced
3399:d280eb6ace33 3400:75d4db7ae5c9
80 for (i = 0; i < s->nb_streams; i++) { 80 for (i = 0; i < s->nb_streams; i++) {
81 if (s->streams[i]->id == id) 81 if (s->streams[i]->id == id)
82 return i; 82 return i;
83 } 83 }
84 st = av_new_stream(s, id); 84 st = av_new_stream(s, id);
85 if (!st)
86 return AVERROR(ENOMEM);
85 switch (format) { 87 switch (format) {
86 case 3: 88 case 3:
87 case 4: 89 case 4:
88 st->codec->codec_type = CODEC_TYPE_VIDEO; 90 st->codec->codec_type = CODEC_TYPE_VIDEO;
89 st->codec->codec_id = CODEC_ID_MJPEG; 91 st->codec->codec_id = CODEC_ID_MJPEG;
413 pkt_type_t pkt_type; 415 pkt_type_t pkt_type;
414 int pkt_len; 416 int pkt_len;
415 while (!url_feof(pb)) { 417 while (!url_feof(pb)) {
416 int track_type, track_id, ret; 418 int track_type, track_id, ret;
417 int field_nr; 419 int field_nr;
420 int stream_index;
418 if (!parse_packet_header(pb, &pkt_type, &pkt_len)) { 421 if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {
419 if (!url_feof(pb)) 422 if (!url_feof(pb))
420 av_log(s, AV_LOG_ERROR, "GXF: sync lost\n"); 423 av_log(s, AV_LOG_ERROR, "GXF: sync lost\n");
421 return -1; 424 return -1;
422 } 425 }
433 continue; 436 continue;
434 } 437 }
435 pkt_len -= 16; 438 pkt_len -= 16;
436 track_type = get_byte(pb); 439 track_type = get_byte(pb);
437 track_id = get_byte(pb); 440 track_id = get_byte(pb);
441 stream_index = get_sindex(s, track_id, track_type);
442 if (stream_index < 0)
443 return stream_index;
438 field_nr = get_be32(pb); 444 field_nr = get_be32(pb);
439 get_be32(pb); // field information 445 get_be32(pb); // field information
440 get_be32(pb); // "timeline" field number 446 get_be32(pb); // "timeline" field number
441 get_byte(pb); // flags 447 get_byte(pb); // flags
442 get_byte(pb); // reserved 448 get_byte(pb); // reserved
443 // NOTE: there is also data length information in the 449 // NOTE: there is also data length information in the
444 // field information, it might be better to take this into account 450 // field information, it might be better to take this into account
445 // as well. 451 // as well.
446 ret = av_get_packet(pb, pkt, pkt_len); 452 ret = av_get_packet(pb, pkt, pkt_len);
447 pkt->stream_index = get_sindex(s, track_id, track_type); 453 pkt->stream_index = stream_index;
448 pkt->dts = field_nr; 454 pkt->dts = field_nr;
449 return ret; 455 return ret;
450 } 456 }
451 return AVERROR(EIO); 457 return AVERROR(EIO);
452 } 458 }