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

Function dcstr_read_header

libavformat/dcstr.c:34–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34static int dcstr_read_header(AVFormatContext *s)
35{
36 unsigned codec, align;
37 int mult;
38 AVStream *st;
39
40 st = avformat_new_stream(s, NULL);
41 if (!st)
42 return AVERROR(ENOMEM);
43
44 st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
45 st->codecpar->ch_layout.nb_channels = avio_rl32(s->pb);
46 st->codecpar->sample_rate = avio_rl32(s->pb);
47 if (st->codecpar->sample_rate <= 0)
48 return AVERROR_INVALIDDATA;
49 codec = avio_rl32(s->pb);
50 align = avio_rl32(s->pb);
51 avio_skip(s->pb, 4);
52 st->duration = avio_rl32(s->pb);
53 mult = avio_rl32(s->pb);
54 if (st->codecpar->ch_layout.nb_channels <= 0 || mult <= 0 ||
55 mult > INT_MAX / st->codecpar->ch_layout.nb_channels) {
56 av_log(s, AV_LOG_ERROR, "invalid number of channels %d x %d\n",
57 st->codecpar->ch_layout.nb_channels, mult);
58 return AVERROR_INVALIDDATA;
59 }
60 st->codecpar->ch_layout.nb_channels *= mult;
61 if (!align || align > INT_MAX / st->codecpar->ch_layout.nb_channels)
62 return AVERROR_INVALIDDATA;
63 st->codecpar->block_align = align * st->codecpar->ch_layout.nb_channels;
64
65 switch (codec) {
66 case 4: st->codecpar->codec_id = AV_CODEC_ID_ADPCM_AICA; break;
67 case 16: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE_PLANAR; break;
68 default: avpriv_request_sample(s, "codec %X", codec);
69 return AVERROR_PATCHWELCOME;
70 }
71
72 avio_skip(s->pb, 0x800 - avio_tell(s->pb));
73 avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
74
75 return 0;
76}
77
78static int dcstr_read_packet(AVFormatContext *s, AVPacket *pkt)
79{

Callers

nothing calls this directly

Calls 7

avformat_new_streamFunction · 0.85
avio_rl32Function · 0.85
avio_skipFunction · 0.85
av_logFunction · 0.85
avpriv_request_sampleFunction · 0.85
avio_tellFunction · 0.85
avpriv_set_pts_infoFunction · 0.85

Tested by

no test coverage detected