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

Function parse_chunk

libavformat/usmdec.c:230–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230static int64_t parse_chunk(AVFormatContext *s, AVIOContext *pb,
231 uint32_t chunk_type, uint32_t chunk_size,
232 AVPacket *pkt)
233{
234 const int is_audio = chunk_type == MKBETAG('@','S','F','A');
235 const int is_alpha = chunk_type == MKBETAG('@','A','L','P');
236 const int is_subtt = chunk_type == MKBETAG('@','S','B','T');
237 USMDemuxContext *usm = s->priv_data;
238 int padding_size, payload_type, payload_offset;
239 const int ch_type = is_subtt ? SUBTTI : is_audio ? AUDIOI : is_alpha ? ALPHAI : VIDEOI;
240 int stream_index, frame_rate;
241 int64_t chunk_start, ret;
242
243 ret = avio_tell(pb);
244 if (ret < 0)
245 return ret;
246 chunk_start = ret;
247 avio_skip(pb, 1);
248 payload_offset = avio_r8(pb);
249 padding_size = avio_rb16(pb);
250 stream_index = avio_r8(pb);
251 avio_skip(pb, 2);
252 payload_type = avio_r8(pb);
253 /*frame_time =*/ avio_rb32(pb);
254 frame_rate = avio_rb32(pb);
255 avio_skip(pb, 8);
256 ret = avio_tell(pb);
257 if (ret < 0)
258 return ret;
259 ret = avio_skip(pb, FFMAX(0, (ret - chunk_start) - payload_offset));
260 if (ret < 0)
261 return ret;
262
263 if (payload_type == 1) {
264 if (usm->ch[ch_type][stream_index].used == 0) {
265 USMChannel *ch = &usm->ch[ch_type][stream_index];
266
267 switch (ch_type) {
268 case ALPHAI:
269 case VIDEOI:
270 ch->type = AVMEDIA_TYPE_VIDEO;
271 break;
272 case AUDIOI:
273 ch->type = AVMEDIA_TYPE_AUDIO;
274 break;
275 case SUBTTI:
276 ch->type = AVMEDIA_TYPE_SUBTITLE;
277 break;
278 default:
279 return AVERROR_INVALIDDATA;
280 }
281
282 ch->used = 1;
283 ch->index = -1;
284 usm->nb_channels[ch_type]++;
285
286 ret = parse_utf(s, pb, ch, ch_type, chunk_size);
287 if (ret < 0)

Callers 1

usm_read_packetFunction · 0.85

Calls 12

avio_tellFunction · 0.85
avio_skipFunction · 0.85
avio_r8Function · 0.85
avio_rb16Function · 0.85
avio_rb32Function · 0.85
parse_utfFunction · 0.85
avformat_new_streamFunction · 0.85
av_make_qFunction · 0.85
avpriv_set_pts_infoFunction · 0.85
ffstreamFunction · 0.85
ff_get_extradataFunction · 0.85
av_get_packetFunction · 0.85

Tested by

no test coverage detected