MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / rm_read_header

Function rm_read_header

libavformat/rmdec.c:550–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

548}
549
550static int rm_read_header(AVFormatContext *s)
551{
552 RMDemuxContext *rm = s->priv_data;
553 AVStream *st;
554 AVIOContext *pb = s->pb;
555 unsigned int tag;
556 int tag_size;
557 int ver;
558 unsigned int start_time, duration;
559 unsigned int data_off = 0;
560 uint64_t indx_off = 0;
561 char buf[128], mime[128];
562 int flags = 0;
563 int ret;
564 unsigned size, v;
565 int64_t codec_pos;
566
567 tag = avio_rl32(pb);
568 if (tag == MKTAG('.', 'r', 'a', 0xfd)) {
569 /* very old .ra format */
570 return rm_read_header_old(s);
571 } else if (tag != MKTAG('.', 'R', 'M', 'F') && tag != MKTAG('.', 'R', 'M', 'P')) {
572 return AVERROR_INVALIDDATA;
573 }
574
575 tag_size = avio_rb32(pb);
576 if (tag_size < 0)
577 return AVERROR_INVALIDDATA;
578 avio_skip(pb, tag_size - 8);
579
580 for(;;) {
581 if (avio_feof(pb))
582 return AVERROR_INVALIDDATA;
583 tag = avio_rl32(pb);
584 tag_size = avio_rb32(pb);
585 ver = avio_rb16(pb);
586 av_log(s, AV_LOG_TRACE, "tag=%s size=%d\n",
587 av_fourcc2str(tag), tag_size);
588 if ((tag_size < 10 && tag != MKTAG('D', 'A', 'T', 'A')) ||
589 (ver != 0 && ver != 2))
590 return AVERROR_INVALIDDATA;
591 switch(tag) {
592 case MKTAG('P', 'R', 'O', 'P'):
593 /* file header */
594 avio_rb32(pb); /* max bit rate */
595 avio_rb32(pb); /* avg bit rate */
596 avio_rb32(pb); /* max packet size */
597 avio_rb32(pb); /* avg packet size */
598 avio_rb32(pb); /* nb packets */
599 duration = avio_rb32(pb); /* duration */
600 s->duration = av_rescale(duration, AV_TIME_BASE, 1000);
601 avio_rb32(pb); /* preroll */
602 indx_off = (ver == 0) ? avio_rb32(pb) : avio_rb64(pb); /* index offset */
603 data_off = avio_rb32(pb); /* data offset */
604 avio_rb16(pb); /* nb streams */
605 flags = avio_rb16(pb); /* flags */
606 break;
607 case MKTAG('C', 'O', 'N', 'T'):

Callers

nothing calls this directly

Calls 15

avio_rl32Function · 0.85
rm_read_header_oldFunction · 0.85
avio_rb32Function · 0.85
avio_skipFunction · 0.85
avio_feofFunction · 0.85
avio_rb16Function · 0.85
av_logFunction · 0.85
av_rescaleFunction · 0.85
avio_rb64Function · 0.85
rm_read_metadataFunction · 0.85
avformat_new_streamFunction · 0.85
get_str8Function · 0.85

Tested by

no test coverage detected