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

Function ff_parse_mpeg2_descriptor

libavformat/mpegts.c:2019–2464  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2017}
2018
2019int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type, int prg_id,
2020 const uint8_t **pp, const uint8_t *desc_list_end,
2021 Mp4Descr *mp4_descr, int mp4_descr_count, int pid,
2022 MpegTSContext *ts)
2023{
2024 FFStream *const sti = ffstream(st);
2025 const uint8_t *desc_end;
2026 int desc_len, desc_tag, desc_es_id, ext_desc_tag, channels, channel_config_code;
2027 char language[252];
2028 int i;
2029
2030 desc_tag = get8(pp, desc_list_end);
2031 if (desc_tag < 0)
2032 return AVERROR_INVALIDDATA;
2033 desc_len = get8(pp, desc_list_end);
2034 if (desc_len < 0)
2035 return AVERROR_INVALIDDATA;
2036 desc_end = *pp + desc_len;
2037 if (desc_end > desc_list_end)
2038 return AVERROR_INVALIDDATA;
2039
2040 av_log(fc, AV_LOG_TRACE, "tag: 0x%02x len=%d\n", desc_tag, desc_len);
2041
2042 if ((st->codecpar->codec_id == AV_CODEC_ID_NONE || sti->request_probe > 0) &&
2043 stream_type == STREAM_TYPE_PRIVATE_DATA)
2044 mpegts_find_stream_type(st, desc_tag, DESC_types);
2045
2046 switch (desc_tag) {
2047 case VIDEO_STREAM_DESCRIPTOR:
2048 if (get8(pp, desc_end) & 0x1) {
2049 st->disposition |= AV_DISPOSITION_STILL_IMAGE;
2050 }
2051 break;
2052 case SL_DESCRIPTOR:
2053 desc_es_id = get16(pp, desc_end);
2054 if (desc_es_id < 0)
2055 break;
2056 if (ts && ts->pids[pid])
2057 ts->pids[pid]->es_id = desc_es_id;
2058 for (i = 0; i < mp4_descr_count; i++)
2059 if (mp4_descr[i].dec_config_descr_len &&
2060 mp4_descr[i].es_id == desc_es_id) {
2061 FFIOContext pb;
2062 ffio_init_read_context(&pb, mp4_descr[i].dec_config_descr,
2063 mp4_descr[i].dec_config_descr_len);
2064 ff_mp4_read_dec_config_descr(fc, st, &pb.pub);
2065 if (st->codecpar->codec_id == AV_CODEC_ID_AAC &&
2066 st->codecpar->extradata_size > 0) {
2067 sti->need_parsing = 0;
2068 sti->need_context_update = 1;
2069 }
2070 if (st->codecpar->codec_id == AV_CODEC_ID_MPEG4SYSTEMS)
2071 mpegts_open_section_filter(ts, pid, m4sl_cb, ts, 1);
2072 }
2073 break;
2074 case FMC_DESCRIPTOR:
2075 if (get16(pp, desc_end) < 0)
2076 break;

Callers 2

pmt_cbFunction · 0.85
parse_chunksFunction · 0.85

Calls 15

ffstreamFunction · 0.85
get8Function · 0.85
av_logFunction · 0.85
mpegts_find_stream_typeFunction · 0.85
get16Function · 0.85
ffio_init_read_contextFunction · 0.85
ff_alloc_extradataFunction · 0.85
av_dict_setFunction · 0.85
avpriv_request_sampleFunction · 0.85
av_dovi_allocFunction · 0.85

Tested by

no test coverage detected