22#include "config_components.h"
53#define MAX_RESYNC_SIZE 65536
56#define TS_PAYLOAD_SIZE (TS_PACKET_SIZE - 4)
58#define MAX_MP4_DESCR_COUNT 16
60#define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend) \
62 if ((prev_dividend) == 0 || (dividend) - (prev_dividend) != (divisor)) \
63 (modulus) = (dividend) % (divisor); \
64 (prev_dividend) = (dividend); \
67#define PROBE_PACKET_MAX_BUF 8192
68#define PROBE_PACKET_MARGIN 5
121#define MAX_STREAMS_PER_PROGRAM 128
122#define MAX_PIDS_PER_PROGRAM (MAX_STREAMS_PER_PROGRAM + 2)
203#define MPEGTS_OPTIONS \
204 { "resync_size", "set size limit for looking up a new synchronization", \
205 offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT, \
206 { .i64 = MAX_RESYNC_SIZE}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, \
207 { "ts_id", "transport stream id", \
208 offsetof(MpegTSContext, id), AV_OPT_TYPE_INT, \
209 { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }, \
210 { "ts_packetsize", "output option carrying the raw packet size", \
211 offsetof(MpegTSContext, raw_packet_size), AV_OPT_TYPE_INT, \
212 { .i64 = 0 }, 0, INT_MAX, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY }
225 {.i64 = 0}, 0, 1, 0 },
227 {.i64 = 0}, 0, 1, 0 },
234 .class_name =
"mpegts demuxer",
242 {
"compute_pcr",
"compute exact PCR for each transport stream packet",
249 .class_name =
"mpegtsraw demuxer",
266#define PES_START_SIZE 6
267#define PES_HEADER_SIZE 9
268#define MAX_PES_HEADER_SIZE (9 + 255)
302 if (ts->
prg[
i].
id == programid) {
330 p->nb_stream_groups = 0;
331 memset(p->stream_groups, 0,
sizeof(p->stream_groups));
375 for (
i = 0;
i < p->nb_pids;
i++)
376 if (p->pids[
i] == pid)
379 p->pids[p->nb_pids++] = pid;
386 for (
i = 0;
i <
s->nb_programs;
i++) {
388 if (program->
id == programid) {
389 int old_pcr_pid = program->
pcr_pid,
394 if (old_version != -1 && old_version !=
version) {
396 "detected PMT change (program=%d, version=%d/%d, pcr_pid=0x%x/0x%x)\n",
397 programid, old_version,
version, old_pcr_pid, pid);
415 int used = 0, discarded = 0;
431 for (j = 0; j < p->nb_pids; j++) {
432 if (p->pids[j] != pid)
446 return !used && discarded;
454 const uint8_t *buf,
int buf_size,
int is_start)
457 uint8_t *cur_section_buf =
NULL;
480 len = (
AV_RB16(cur_section_buf + 1) & 0xfff) + 3;
560 sec = &
filter->u.section_filter;
580 pes = &
filter->u.pes_filter;
620 memset(stat, 0, packet_size *
sizeof(*stat));
622 for (
i = 0;
i <
size - 3;
i++) {
624 int pid =
AV_RB16(buf+1) & 0x1FFF;
625 int asc = buf[
i + 3] & 0x30;
626 if (!
probe || pid == 0x1FFF || asc) {
627 int x =
i % packet_size;
630 if (stat[x] > best_score) {
631 best_score = stat[x];
637 return best_score -
FFMAX(stat_all - 10*best_score, 0)/10;
643 int score, fec_score, dvhs_score;
650 int max_iterations = 16;
662 buf_size, score, dvhs_score, fec_score);
664 margin =
mid_pred(score, fec_score, dvhs_score);
671 else if (dvhs_score > margin)
673 else if (fec_score > margin)
699static inline int get8(
const uint8_t **pp,
const uint8_t *p_end)
712static inline int get16(
const uint8_t **pp,
const uint8_t *p_end)
727static char *
getstr8(
const uint8_t **pp,
const uint8_t *p_end)
741 const char *encodings[] = {
742 "ISO6937",
"ISO-8859-5",
"ISO-8859-6",
"ISO-8859-7",
743 "ISO-8859-8",
"ISO-8859-9",
"ISO-8859-10",
"ISO-8859-11",
744 "",
"ISO-8859-13",
"ISO-8859-14",
"ISO-8859-15",
"",
"",
"",
"",
745 "",
"UCS-2BE",
"KSC_5601",
"GB2312",
"UCS-2BE",
"UTF-8",
"",
"",
746 "",
"",
"",
"",
"",
"",
"",
""
750 size_t inlen =
len, outlen = inlen * 6 + 1;
751 if (
len >= 3 && p[0] == 0x10 && !p[1] && p[2] && p[2] <= 0xf && p[2] != 0xc) {
753 snprintf(iso8859,
sizeof(iso8859),
"ISO-8859-%d", p[2]);
756 cd = iconv_open(
"UTF-8", iso8859);
757 }
else if (p[0] < 0x20) {
760 cd = iconv_open(
"UTF-8", encodings[*p]);
763 cd = iconv_open(
"UTF-8", encodings[0]);
765 if (cd == (iconv_t)-1)
772 if (iconv(cd, &in, &inlen, &
out, &outlen) == -1) {
795 const uint8_t **pp,
const uint8_t *p_end)
811 h->version = (
val >> 1) & 0x1f;
812 h->current_next =
val & 0x01;
820 h->last_sec_num =
val;
839#if !CONFIG_LOAS_DEMUXER
932 uint32_t stream_type,
950 uint32_t stream_type, uint32_t prog_reg_desc)
966 "stream=%d stream_type=%x pid=%x prog_reg_desc=%.4s\n",
976 if ((prog_reg_desc ==
AV_RL32(
"HDMV") ||
977 prog_reg_desc ==
AV_RL32(
"HDPR")) &&
995 sub_st->
id = pes->
pid;
1089 pkt->size >= 8 && memcmp(
pkt->data + 4,
"jxes", 4) == 0)
1092 if (header_size >
pkt->size) {
1094 "Invalid JPEG-XS header size %"PRIu32
" > packet size %d\n",
1095 header_size,
pkt->size);
1098 pkt->data += header_size;
1099 pkt->size -= header_size;
1141 const uint8_t *buf,
int buf_size)
1144 int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
1145 int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
1146 int dts_flag = -1, cts_flag = -1;
1151 memcpy(buf_padded, buf, buf_padded_size);
1160 au_start_flag = au_end_flag = 1;
1170 if (!idle_flag && (!padding_flag || padding_bits != 0)) {
1178 if (au_start_flag) {
1196 if (inst_bitrate_flag)
1225 const uint8_t *buf,
int buf_size,
int is_start,
1249 while (buf_size > 0) {
1250 switch (pes->
state) {
1262 if (pes->
header[0] == 0x00 && pes->
header[1] == 0x00 &&
1263 pes->
header[2] == 0x01) {
1302 "pid=%x stream_type=%x probing\n",
1356 if ((
flags & 0xc0) == 0x80) {
1359 }
else if ((
flags & 0xc0) == 0xc0) {
1369 skip = (pes_ext >> 4) & 0xb;
1372 if ((pes_ext & 0x41) == 0x01 &&
1375 if ((
r[0] & 0x7f) > 0 && (
r[1] & 0x80) == 0)
1387 p += sl_header_bytes;
1388 buf_size -= sl_header_bytes;
1416 for (
i = 0;
i < p->nb_stream_indexes;
i++) {
1422 if (
f->last_pcr != -1 && !
f->discard) {
1437 pes->
pts = pes->
dts = pcr;
1439 pes->
dts > pcr + 3654 + 9000) {
1440 pes->
pts = pes->
dts = pcr + 3654 + 9000;
1442 pes->
dts > pcr + 10*90000) {
1443 pes->
pts = pes->
dts = pcr + 3654 + 9000;
1454 "Forcing DTS/PTS to be unset for a "
1455 "non-trustworthy PES packet for PID %d as "
1456 "PCR hasn't been received yet.\n",
1472 max_packet_size = pes_payload_size;
1476 pes->
data_index + buf_size > max_packet_size) {
1484 buf_size > max_packet_size) {
1487 buf_size = max_packet_size;
1558 const uint8_t *buf,
unsigned size,
1559 Mp4Descr *descr,
int max_descr_count)
1561 if (
size > (1 << 30))
1579 (*len) -= new_off - *off;
1616 if (!(id_flags & 0x0020)) {
1668#define R8_CHECK_CLIP_MAX(dst, maxv) do { \
1669 descr->sl.dst = avio_r8(pb); \
1670 if (descr->sl.dst > maxv) { \
1671 descr->sl.dst = maxv; \
1672 return AVERROR_INVALIDDATA; \
1714 "Tag %x length violation new length %d bytes remaining %d\n",
1725 if (target_tag &&
tag != target_tag) {
1758 Mp4Descr *descr,
int *descr_count,
int max_descr_count)
1776 Mp4Descr *descr,
int *descr_count,
int max_descr_count)
1797 const uint8_t *p, *p_end;
1798 int mp4_descr_count = 0;
1803 p_end = section + section_len - 4;
1812 mp4_read_od(
s, p, (
unsigned) (p_end - p), mp4_descr, &mp4_descr_count,
1818 for (
i = 0;
i < mp4_descr_count;
i++) {
1835 pes->
sl = mp4_descr[
i].
sl;
1838 mp4_descr[
i].dec_config_descr_len);
1851 for (
i = 0;
i < mp4_descr_count;
i++)
1852 av_free(mp4_descr[
i].dec_config_descr);
1877 if (
f &&
f->last_pcr != -1)
1885 1, 0, 1, 1, 2, 2, 2, 3, 3
1889 1, 1, 1, 2, 2, 3, 4, 4, 5,
1900 { 0,6,1,2,3,4,5,7 },
1904 const uint8_t **pp,
const uint8_t *desc_end,
1907 int ext_tag =
get8(pp, desc_end);
1912 int horizontal_size, vertical_size, schar;
1914 int descriptor_version, interlace_mode, n_fields;
1917 if (desc_end - *pp < 29)
1920 descriptor_version =
get8(pp, desc_end);
1921 if (descriptor_version) {
1926 horizontal_size =
get16(pp, desc_end);
1927 vertical_size =
get16(pp, desc_end);
1929 frat = bytestream_get_be32(pp);
1930 schar =
get16(pp, desc_end);
1935 colour_primaries =
get8(pp, desc_end);
1937 matrix_coefficients =
get8(pp, desc_end);
1938 video_full_range_flag = (
get8(pp, desc_end) & 0x80) == 0x80 ? 1 : 0;
1940 interlace_mode = (frat >> 30) & 0x3;
1941 if (interlace_mode == 3) {
1954 int framerate_num = (frat & 0x0000FFFFU);
1955 int framerate_den = ((frat >> 24) & 0x0000003FU);
1957 if (framerate_den == 2) {
1958 framerate_num *= 1000;
1959 framerate_den = 1001;
1960 }
else if (framerate_den != 1) {
1969 switch (schar & 0xf) {
1987 int lcevc_stream_tag =
get8(pp, desc_end);
1996 for (
i = 0;
i < p->nb_stream_groups;
i++) {
1997 stg = &p->stream_groups[
i];
2000 if (stg->
id == lcevc_stream_tag)
2003 if (
i == p->nb_stream_groups) {
2006 p->nb_stream_groups++;
2009 stg = &p->stream_groups[
i];
2010 stg->
id = lcevc_stream_tag;
2029 int num_lcevc_stream_tags =
get8(pp, desc_end);
2037 for (
int i = 0;
i < num_lcevc_stream_tags;
i++) {
2039 int lcevc_stream_tag =
get8(pp, desc_end);;
2042 for (j = 0; j < p->nb_stream_groups; j++) {
2043 stg = &p->stream_groups[j];
2046 if (stg->
id == lcevc_stream_tag)
2049 if (j == p->nb_stream_groups) {
2052 p->nb_stream_groups++;
2055 stg = &p->stream_groups[j];
2056 stg->
id = lcevc_stream_tag;
2078 const uint8_t **pp,
const uint8_t *desc_list_end,
2079 Mp4Descr *mp4_descr,
int mp4_descr_count,
int pid,
2083 const uint8_t *desc_end;
2084 int desc_len, desc_tag, desc_es_id, ext_desc_tag,
channels, channel_config_code;
2088 desc_tag =
get8(pp, desc_list_end);
2091 desc_len =
get8(pp, desc_list_end);
2094 desc_end = *pp + desc_len;
2095 if (desc_end > desc_list_end)
2106 if (
get8(pp, desc_end) & 0x1) {
2111 desc_es_id =
get16(pp, desc_end);
2114 if (ts && ts->
pids[pid])
2116 for (
i = 0;
i < mp4_descr_count;
i++)
2117 if (mp4_descr[
i].dec_config_descr_len &&
2118 mp4_descr[
i].es_id == desc_es_id) {
2121 mp4_descr[
i].dec_config_descr_len);
2133 if (
get16(pp, desc_end) < 0)
2135 if (mp4_descr_count > 0 &&
2154 uint8_t *extradata =
NULL;
2155 int language_count = desc_len / 5, ret;
2157 if (desc_len > 0 && desc_len % 5 != 0)
2160 if (language_count > 0) {
2162 av_assert0(language_count <=
sizeof(language) / 4);
2175 for (
i = 0;
i < language_count;
i++) {
2176 language[
i * 4 + 0] =
get8(pp, desc_end);
2177 language[
i * 4 + 1] =
get8(pp, desc_end);
2178 language[
i * 4 + 2] =
get8(pp, desc_end);
2179 language[
i * 4 + 3] =
',';
2181 memcpy(extradata, *pp, 2);
2187 language[
i * 4 - 1] = 0;
2200 int language_count = desc_len / 8, ret;
2202 if (desc_len > 0 && desc_len % 8 != 0)
2205 if (language_count > 1) {
2209 if (language_count > 0) {
2213 av_assert0(language_count <=
sizeof(language) / 4);
2226 for (
i = 0;
i < language_count;
i++) {
2227 language[
i * 4 + 0] =
get8(pp, desc_end);
2228 language[
i * 4 + 1] =
get8(pp, desc_end);
2229 language[
i * 4 + 2] =
get8(pp, desc_end);
2230 language[
i * 4 + 3] =
',';
2244 extradata[4] =
get8(pp, desc_end);
2245 memcpy(extradata, *pp, 4);
2251 language[
i * 4 - 1] = 0;
2258 for (
i = 0;
i + 4 <= desc_len;
i += 4) {
2259 language[
i + 0] =
get8(pp, desc_end);
2260 language[
i + 1] =
get8(pp, desc_end);
2261 language[
i + 2] =
get8(pp, desc_end);
2262 language[
i + 3] =
',';
2263 switch (
get8(pp, desc_end)) {
2276 if (
i && language[0]) {
2277 language[
i - 1] = 0;
2296 if (
get16(pp, desc_end) == 0xFFFF)
2298 if (
get8(pp, desc_end) == 0xFF) {
2305 ext_desc_tag =
get8(pp, desc_end);
2306 if (ext_desc_tag < 0)
2309 ext_desc_tag == 0x80) {
2319 channel_config_code =
get8(pp, desc_end);
2320 if (channel_config_code < 0)
2322 if (channel_config_code <= 0x8) {
2345 if ((
flags & 0x80) == 0)
2348 switch ((
flags >> 2) & 0x1F) {
2364 language[0] =
get8(pp, desc_end);
2365 language[1] =
get8(pp, desc_end);
2366 language[2] =
get8(pp, desc_end);
2384 int component_type_flag =
get8(pp, desc_end) & (1 << 7);
2385 if (component_type_flag) {
2386 int component_type =
get8(pp, desc_end);
2387 int service_type_mask = 0x38;
2388 int service_type = ((component_type & service_type_mask) >> 3);
2389 if (service_type == 0x02 ) {
2407 int data_component_id =
get16(pp, desc_end);
2408 if (data_component_id < 0)
2411 switch (data_component_id) {
2415 if (actual_component_tag >= 0x30 &&
2416 actual_component_tag <= 0x37) {
2423 if (actual_component_tag == 0x87) {
2449 int dependency_pid = -1;
2451 if (desc_end - *pp < 4)
2460 buf =
get16(pp, desc_end);
2462 dovi->
dv_level = (buf >> 3) & 0x3f;
2467 buf =
get16(pp, desc_end);
2468 dependency_pid = buf >> 3;
2470 if (desc_end - *pp >= 1) {
2471 buf =
get8(pp, desc_end);
2484 (uint8_t *)dovi, dovi_size, 0)) {
2490 "rpu flag: %d, el flag: %d, bl flag: %d, dependency_pid: %d, "
2491 "compatibility id: %d, compression: %d\n",
2513 for (gi = 0; gi < p->nb_stream_groups; gi++) {
2514 stg = &p->stream_groups[gi];
2519 if (gi == p->nb_stream_groups) {
2522 p->nb_stream_groups++;
2523 stg = &p->stream_groups[gi];
2528 stg->
dep_pid = dependency_pid;
2548 int stream_identifier,
int pmt_stream_idx,
struct Program *p)
2553 if (stream_identifier) {
2554 for (
int i = 0;
i < p->nb_streams;
i++) {
2555 if (p->streams[
i].stream_identifier == stream_identifier)
2556 if (!found || pmt_stream_idx ==
i)
2557 found =
s->streams[p->streams[
i].idx];
2560 found =
s->streams[p->streams[pmt_stream_idx].idx];
2565 "reusing existing %s stream %d (pid=0x%x) for new pid=0x%x\n",
2567 found->
index, found->
id, pid);
2575 const uint8_t **pp = &p;
2576 const uint8_t *desc_list_end;
2577 const uint8_t *desc_end;
2579 int desc_len, desc_tag;
2581 desc_list_len =
get16(pp, p_end);
2582 if (desc_list_len < 0)
2584 desc_list_len &= 0xfff;
2585 desc_list_end = p + desc_list_len;
2586 if (desc_list_end > p_end)
2590 desc_tag =
get8(pp, desc_list_end);
2593 desc_len =
get8(pp, desc_list_end);
2596 desc_end = *pp + desc_len;
2597 if (desc_end > desc_list_end)
2601 return get8(pp, desc_end);
2611 switch (stream_type) {
2619 return !(prog_reg_desc ==
AV_RL32(
"CUEI"));
2633 uint32_t prog_reg_desc)
2638 if (prog_reg_desc !=
AV_RL32(
"HDMV"))
2663 if (!bl_st || !el_st)
2668 grp->
id = el_st->id;
2704 if (stg->
id == grp->
id)
2720 switch (grp->
type) {
2748 const uint8_t *p, *p_end, *desc_list_end;
2749 int program_info_length, pcr_pid, pid, stream_type;
2751 uint32_t prog_reg_desc = 0;
2752 int stream_identifier = -1;
2755 int mp4_descr_count = 0;
2762 p_end = section + section_len - 4;
2768 if (!
h->current_next)
2774 h->id,
h->sec_num,
h->last_sec_num,
h->version,
h->tid);
2794 pcr_pid =
get16(&p, p_end);
2803 program_info_length =
get16(&p, p_end);
2805 if (program_info_length < 0 || (program_info_length & 0xFFF) > p_end - p)
2807 program_info_length &= 0xfff;
2808 while (program_info_length >= 2) {
2815 program_info_length -= 2;
2816 if (
len > program_info_length)
2819 program_info_length -=
len;
2827 prog_reg_desc = bytestream_get_le32(&p);
2832 p += program_info_length;
2846 stream_type =
get8(&p, p_end);
2847 if (stream_type < 0)
2849 pid =
get16(&p, p_end);
2888 if (pes && !pes->
st) {
2930 desc_list_len =
get16(&p, p_end);
2931 if (desc_list_len < 0)
2933 desc_list_len &= 0xfff;
2934 desc_list_end = p + desc_list_len;
2935 if (desc_list_end > p_end)
2939 desc_list_end, mp4_descr,
2940 mp4_descr_count, pid, ts) < 0)
2943 if (pes && prog_reg_desc ==
AV_RL32(
"HDMV") &&
2953 if (!ts->
pids[pcr_pid])
2962 for (
i = 0;
i < mp4_descr_count;
i++)
2963 av_free(mp4_descr[
i].dec_config_descr);
2971 const uint8_t *p, *p_end;
2979 p_end = section + section_len - 4;
2985 if (!
h->current_next)
2995 sid =
get16(&p, p_end);
2998 pmt_pid =
get16(&p, p_end);
3003 if (pmt_pid <= 0x000F || pmt_pid == 0x1FFF) {
3005 "Ignoring invalid PAT entry: sid=0x%x pid=0x%x\n", sid, pmt_pid);
3011 if (sid == 0x0000) {
3023 || fil->
pid != pmt_pid
3027 if (!ts->
pids[pmt_pid])
3031 unsigned prg_idx = prg - ts->
prg;
3035 if (prg_idx > nb_prg)
3037 if (prg_idx >= nb_prg)
3060 const uint8_t *p, *p_end;
3080 p_end = section + section_len - 4;
3094 if (
h->id == 0xFFFF) {
3116 const uint8_t *p, *p_end, *desc_list_end, *desc_end;
3117 int onid,
val, sid, desc_list_len, desc_tag, desc_len, service_type;
3118 char *
name, *provider_name;
3123 p_end = section + section_len - 4;
3129 if (!
h->current_next)
3136 onid =
get16(&p, p_end);
3143 sid =
get16(&p, p_end);
3149 desc_list_len =
get16(&p, p_end);
3150 if (desc_list_len < 0)
3152 desc_list_len &= 0xfff;
3153 desc_list_end = p + desc_list_len;
3154 if (desc_list_end > p_end)
3157 desc_tag =
get8(&p, desc_list_end);
3160 desc_len =
get8(&p, desc_list_end);
3161 desc_end = p + desc_len;
3162 if (desc_len < 0 || desc_end > desc_list_end)
3166 desc_tag, desc_len);
3170 service_type =
get8(&p, desc_end);
3171 if (service_type < 0)
3173 provider_name =
getstr8(&p, desc_end);
3198 const uint8_t *packet);
3204 int len, pid, cc, expected_cc, cc_ok, afc, is_start, is_discontinuity,
3205 has_adaptation, has_payload;
3206 const uint8_t *p, *p_end;
3208 pid =
AV_RB16(packet + 1) & 0x1fff;
3209 is_start = packet[1] & 0x40;
3210 tss = ts->
pids[pid];
3213 tss = ts->
pids[pid];
3223 afc = (packet[3] >> 4) & 3;
3226 has_adaptation = afc & 2;
3227 has_payload = afc & 1;
3228 is_discontinuity = has_adaptation &&
3233 cc = (packet[3] & 0xf);
3234 expected_cc = has_payload ? (tss->
last_cc + 1) & 0x0f : tss->
last_cc;
3243 "Continuity check failed for pid %d expected %d got %d\n",
3244 pid, expected_cc, cc);
3251 if (packet[1] & 0x80) {
3260 if (has_adaptation) {
3263 if (
parse_pcr(&pcr_h, &pcr_l, packet) == 0)
3270 if (p >= p_end || !has_payload)
3282 if (
len > p_end - p)
3352 int new_packet_size, ret;
3368 "max resync size reached, could not find sync byte\n");
3375 const uint8_t **
data)
3421 const uint8_t *
data;
3450 if (nb_packets != 0 && packet_num >= nb_packets ||
3472 const int size = p->buf_size;
3477#define CHECK_COUNT 10
3478#define CHECK_BLOCK 100
3488 score =
FFMAX3(score, dvhs_score, fec_score);
3490 maxscore =
FFMAX(maxscore, score);
3496 ff_dlog(0,
"TS score: %d %d\n", sumscore, maxscore);
3502 }
else if (check_count >=
CHECK_COUNT && sumscore > 6) {
3504 }
else if (check_count >=
CHECK_COUNT && maxscore > 6) {
3506 }
else if (sumscore > 6) {
3521 afc = (packet[3] >> 4) & 3;
3531 if (!(
flags & 0x10))
3536 *ppcr_high = ((
int64_t) v << 1) | (p[4] >> 7);
3537 *ppcr_low = ((p[4] & 1) << 8) | p[5];
3589 int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l;
3592 const uint8_t *
data;
3612 if ((pcr_pid == -1 || pcr_pid == pid) &&
3619 if (pcrs[1] - pcrs[0] > 0) {
3649#define MAX_PACKET_READAHEAD ((128 * 1024) / 188)
3656 int pcr_l, next_pcr_l;
3657 uint8_t pcr_buf[12];
3658 const uint8_t *
data;
3678 if (
parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
3694 pkt->stream_index = 0;
3723 if (!ret &&
pkt->size < 0)
3755 int pcr_l, pcr_pid =
3756 ((
PESContext *)
s->streams[stream_index]->priv_data)->pcr_pid;
3761 while(
pos < pos_limit) {
3772 if ((pcr_pid < 0 || (
AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
3773 parse_pcr(×tamp, &pcr_l, buf) == 0) {
3797 while(
pos < pos_limit) {
3806 if (
pkt->stream_index == stream_index &&
pkt->pos >= *ppos) {
3847 const uint8_t *buf,
int len)
3892 .p.name =
"mpegtsraw",
static int probe(const AVProbeData *p)
static double val(void *priv, double ch)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
unsigned int avio_rb16(AVIOContext *s)
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
void ffio_init_read_context(FFIOContext *s, const uint8_t *buffer, int buffer_size)
Wrap a buffer in an AVIOContext for reading.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
refcounted data buffer API
static int FUNC metadata(CodedBitstreamContext *ctx, RWContext *rw, APVRawMetadata *current)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
Public header for CRC hash function implementation.
static const uint16_t fc[]
Misc types and constants that do not belong anywhere else.
#define AV_PROFILE_ARIB_PROFILE_A
#define AV_PROFILE_UNKNOWN
#define AV_PROFILE_ARIB_PROFILE_C
@ AV_FIELD_TT
Top coded_first, top displayed first.
@ AV_FIELD_BB
Bottom coded first, bottom displayed first.
#define FF_INFMT_FLAG_PREFER_CODEC_FRAMERATE
int ff_find_stream_index(const AVFormatContext *s, int id)
Find stream index based on format-specific stream ID.
void ff_read_frame_flush(AVFormatContext *s)
Flush the frame reader.
void ff_reduce_index(AVFormatContext *s, int stream_index)
Ensure the index uses less memory than the maximum specified in AVFormatContext.max_index_size by dis...
static const uint8_t bits[8]
static unsigned int nb_streams
static int read_header(FFV1Context *f, RangeCoder *c)
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static uint64_t get_bits64(GetBitContext *s, int n)
Read 0-64 bits.
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
Get the type of the given codec.
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_MPEG2TS
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
@ AV_CODEC_ID_HDMV_PGS_SUBTITLE
@ AV_CODEC_ID_DVB_SUBTITLE
@ AV_CODEC_ID_HDMV_TEXT_SUBTITLE
@ AV_CODEC_ID_SCTE_35
Contain timestamp estimated through PCR of program stream.
@ AV_CODEC_ID_ARIB_CAPTION
@ AV_CODEC_ID_DVB_TELETEXT
@ AV_CODEC_ID_MPEG4SYSTEMS
FAKE codec to indicate a MPEG-4 Systems stream (only used by libavformat)
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
AVPacketSideData * av_packet_side_data_add(AVPacketSideData **psd, int *pnb_sd, enum AVPacketSideDataType type, void *data, size_t size, int flags)
Wrap existing data as packet side data.
@ AV_PKT_DATA_MPEGTS_STREAM_ID
MPEGTS stream ID as uint8_t, this is required to pass the stream ID information from the demuxer to t...
@ AV_PKT_DATA_DOVI_CONF
DOVI configuration ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2....
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVProgram * av_new_program(AVFormatContext *ac, int id)
AVStreamGroup * avformat_stream_group_create(AVFormatContext *s, enum AVStreamGroupParamsType type, AVDictionary **options)
Add a new empty stream group to a media file.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int avformat_stream_group_add_stream(AVStreamGroup *stg, AVStream *st)
Add an already allocated stream to a stream group.
AVProgram * av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s)
Find the programs which belong to a given stream.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
AVBufferPool * av_buffer_pool_init(size_t size, AVBufferRef *(*alloc)(size_t size))
Allocate and initialize a buffer pool.
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
int av_size_mult(size_t a, size_t b, size_t *r)
Multiply two size_t values checking for overflow.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta *extra_meta)
Parse PRIV tags into a dictionary.
void ff_id3v2_read_dict(AVFormatContext *s, AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta)
Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id)
int ff_mp4_read_dec_config_descr(void *logctx, AVStream *st, AVIOContext *pb)
int ff_mp4_read_descr(void *logctx, AVIOContext *pb, int *tag)
#define MP4DecConfigDescrTag
#define u(width, name, range_min, range_max)
static const struct TransferCharacteristics transfer_characteristics[]
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static av_cold int read_close(AVFormatContext *ctx)
#define FFSWAP(type, a, b)
#define MKTAG(a, b, c, d)
Memory handling functions.
#define STREAM_TYPE_VIDEO_MPEG4
#define STREAM_TYPE_VIDEO_CAVS
#define STREAM_TYPE_AUDIO_MPEG2
#define STREAM_TYPE_VIDEO_HEVC
#define STREAM_TYPE_PRIVATE_SECTION
#define STREAM_TYPE_VIDEO_VVC
#define STREAM_TYPE_PRIVATE_DATA
#define STREAM_TYPE_VIDEO_MPEG1
#define STREAM_TYPE_AUDIO_AAC
#define STREAM_TYPE_VIDEO_H264
#define STREAM_TYPE_AUDIO_MPEG1
static int64_t ff_parse_pes_pts(const uint8_t *buf)
Parse MPEG-PES five-byte timestamp.
#define STREAM_TYPE_VIDEO_MPEG2
#define MAX_PIDS_PER_PROGRAM
#define R8_CHECK_CLIP_MAX(dst, maxv)
static const StreamType ISO_types[]
static void mpegts_free(MpegTSContext *ts)
static void clear_program(struct Program *p)
static int parse_mp4_descr_arr(MP4DescrParseContext *d, int64_t off, int len)
#define MAX_STREAMS_PER_PROGRAM
static void seek_back(AVFormatContext *s, AVIOContext *pb, int64_t pos)
static void add_pid_to_program(struct Program *p, unsigned int pid)
static void write_section_data(MpegTSContext *ts, MpegTSFilter *tss1, const uint8_t *buf, int buf_size, int is_start)
Assemble PES packets out of TS packets, and then call the "section_cb" function when they are complet...
static const uint8_t opus_channel_map[8][8]
void avpriv_mpegts_parse_close(MpegTSContext *ts)
static int parse_MP4SLDescrTag(MP4DescrParseContext *d, int64_t off, int len)
static const StreamType MISC_types[]
static void detect_bdmv_dovi_group(MpegTSContext *ts, struct Program *prg, uint32_t prog_reg_desc)
static int skip_identical(const SectionHeader *h, MpegTSSectionFilter *tssf)
int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type, int prg_id, const uint8_t **pp, const uint8_t *desc_list_end, Mp4Descr *mp4_descr, int mp4_descr_count, int pid, MpegTSContext *ts)
Parse an MPEG-2 descriptor.
static int timed_id3_update_metadata(AVStream *s, AVPacket *pkt)
static int parse_MP4DecConfigDescrTag(MP4DescrParseContext *d, int64_t off, int len)
static int init_MP4DescrParseContext(MP4DescrParseContext *d, AVFormatContext *s, const uint8_t *buf, unsigned size, Mp4Descr *descr, int max_descr_count)
static void reset_pes_packet_state(PESContext *pes)
static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, const uint8_t *packet)
static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
static const uint8_t opus_coupled_stream_cnt[9]
static int get_packet_size(AVFormatContext *s)
static av_unused int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt)
static int parse_MP4ESDescrTag(MP4DescrParseContext *d, int64_t off, int len)
static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
static MpegTSFilter * mpegts_open_pcr_filter(MpegTSContext *ts, unsigned int pid)
static struct Program * get_program(MpegTSContext *ts, unsigned int programid)
static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len, int target_tag)
static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
static const StreamType REGD_types[]
static int mpegts_set_stream_info(AVStream *st, PESContext *pes, uint32_t stream_type, uint32_t prog_reg_desc)
static const StreamType HLS_SAMPLE_ENC_types[]
static void clear_avprogram(MpegTSContext *ts, unsigned int programid)
static void finished_reading_packet(AVFormatContext *s, int raw_packet_size)
static void clear_programs(MpegTSContext *ts)
static int analyze(const uint8_t *buf, int size, int packet_size, int probe)
static const StreamType METADATA_types[]
static int new_pes_packet(PESContext *pes, AVPacket *pkt)
static const AVClass mpegts_class
static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size, Mp4Descr *descr, int *descr_count, int max_descr_count)
void SetServiceCallback(void *opaque, int ret)
static int mpegts_read_header(AVFormatContext *s)
static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
static AVBufferRef * buffer_pool_get(MpegTSContext *ts, int size)
static void new_data_packet(const uint8_t *buffer, int len, AVPacket *pkt)
static uint64_t get_ts64(GetBitContext *gb, int bits)
static void create_stream_groups(MpegTSContext *ts, struct Program *prg)
#define PROBE_PACKET_MARGIN
static int parse_section_header(SectionHeader *h, const uint8_t **pp, const uint8_t *p_end)
void SectionCallback(MpegTSFilter *f, const uint8_t *buf, int len)
static int is_pes_stream(int stream_type, uint32_t prog_reg_desc)
static int mpegts_push_data(MpegTSFilter *filter, const uint8_t *buf, int buf_size, int is_start, int64_t pos)
MpegTSContext * avpriv_mpegts_parse_open(AVFormatContext *s)
static MpegTSFilter * mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid, SectionCallback *section_cb, void *opaque, int check_crc)
static int discard_pid(MpegTSContext *ts, unsigned int pid)
discard_pid() decides if the pid is to be discarded according to caller's programs selection
static int handle_packets(MpegTSContext *ts, int64_t nb_packets)
static void eit_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size, const uint8_t **data)
static MpegTSFilter * mpegts_open_filter(MpegTSContext *ts, unsigned int pid, enum MpegTSFilterType type)
static void update_av_program_info(AVFormatContext *s, unsigned int programid, unsigned int pid, int version)
static int get8(const uint8_t **pp, const uint8_t *p_end)
static char * getstr8(const uint8_t **pp, const uint8_t *p_end)
int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
static int mpegts_read_close(AVFormatContext *s)
static void mpegts_find_stream_type(AVStream *st, uint32_t stream_type, const StreamType *types)
#define PROBE_PACKET_MAX_BUF
static const uint8_t opus_stream_cnt[9]
static void update_offsets(AVIOContext *pb, int64_t *off, int *len)
int PESCallback(MpegTSFilter *f, const uint8_t *buf, int len, int is_start, int64_t pos)
static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
#define MAX_MP4_DESCR_COUNT
static int get16(const uint8_t **pp, const uint8_t *p_end)
static const AVOption raw_options[]
static const AVClass mpegtsraw_class
static int mp4_read_od(AVFormatContext *s, const uint8_t *buf, unsigned size, Mp4Descr *descr, int *descr_count, int max_descr_count)
static int handle_packet(MpegTSContext *ts, const uint8_t *packet, int64_t pos)
static const StreamType SCTE_types[]
static const StreamType DESC_types[]
#define MAX_PES_HEADER_SIZE
static int mpegts_probe(const AVProbeData *p)
static const StreamType HDMV_types[]
static struct Program * add_program(MpegTSContext *ts, unsigned int programid)
static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *current_packet)
static int parse_mpeg2_extension_descriptor(AVFormatContext *fc, AVStream *st, int prg_id, const uint8_t **pp, const uint8_t *desc_end, MpegTSContext *ts)
static int parse_MP4ODescrTag(MP4DescrParseContext *d, int64_t off, int len)
static AVStream * find_matching_stream(MpegTSContext *ts, int pid, unsigned int programid, int stream_identifier, int pmt_stream_idx, struct Program *p)
static MpegTSFilter * mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, PESCallback *pes_cb, void *opaque)
static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
static int parse_MP4IODescrTag(MP4DescrParseContext *d, int64_t off, int len)
#define MAX_PACKET_READAHEAD
static void scte_data_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
static PESContext * add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid)
#define STREAM_ID_PRIVATE_STREAM_2
#define STREAM_TYPE_HLS_SE_AUDIO_AC3
#define TS_MAX_PACKET_SIZE
#define STREAM_TYPE_VIDEO_AVS3
#define STREAM_TYPE_VIDEO_MVC
#define STREAM_TYPE_VIDEO_DIRAC
#define STREAM_ID_PADDING_STREAM
#define DVB_EXTENSION_DESCRIPTOR
#define STREAM_TYPE_BLURAY_SUBTITLE_TEXT
#define STREAM_TYPE_AUDIO_MPEG4
ISO/IEC 14496-3 Audio, without using any additional transport syntax, such as DST,...
#define STREAM_TYPE_VIDEO_VC1
#define STREAM_TYPE_ATSC_AUDIO_AC3
#define M2TS_VIDEO_EL_PID
#define STREAM_TYPE_BLURAY_AUDIO_EAC3
#define TS_FEC_PACKET_SIZE
#define STREAM_ID_METADATA_STREAM
#define STREAM_TYPE_BLURAY_SUBTITLE_PGS
#define STREAM_TYPE_HLS_SE_AUDIO_AAC
#define STREAM_TYPE_VIDEO_JPEGXS
#define SUBTITLING_DESCRIPTOR
#define STREAM_ID_EMM_STREAM
#define STREAM_TYPE_BLURAY_AUDIO_DTS_EXPRESS_SECONDARY
#define STREAM_TYPE_BLURAY_AUDIO_TRUEHD
#define LCEVC_LINKAGE_DESCRIPTOR
#define STREAM_TYPE_ISO_IEC_14496_SECTION
ISO/IEC 14496-1 (MPEG-4 Systems) SL-packetized stream or FlexMux stream carried in ISO_IEC_14496_sect...
#define STREAM_TYPE_BLURAY_AUDIO_DTS
#define STREAM_TYPE_AUDIO_AAC_LATM
#define STREAM_TYPE_BLURAY_AUDIO_EAC3_SECONDARY
#define SUPPLEMENTARY_AUDIO_DESCRIPTOR
#define ISO_639_LANGUAGE_DESCRIPTOR
#define JXS_VIDEO_DESCRIPTOR
#define STREAM_IDENTIFIER_DESCRIPTOR
#define TELETEXT_DESCRIPTOR
#define STREAM_TYPE_VIDEO_LCEVC
#define LCEVC_VIDEO_DESCRIPTOR
#define TS_DVHS_PACKET_SIZE
#define STREAM_TYPE_VIDEO_JPEG2000
#define STREAM_TYPE_VIDEO_AVS2
#define STREAM_TYPE_ATSC_AUDIO_EAC3
#define REGISTRATION_DESCRIPTOR
#define SERVICE_DESCRIPTOR
#define STREAM_TYPE_BLURAY_AUDIO_PCM_BLURAY
#define STREAM_ID_PROGRAM_STREAM_DIRECTORY
#define STREAM_TYPE_BLURAY_AUDIO_AC3
#define STREAM_ID_DSMCC_STREAM
#define ENHANCED_AC3_DESCRIPTOR
#define DATA_COMPONENT_DESCRIPTOR
#define STREAM_ID_PROGRAM_STREAM_MAP
#define STREAM_ID_ECM_STREAM
#define METADATA_DESCRIPTOR
#define STREAM_TYPE_HLS_SE_AUDIO_EAC3
#define STREAM_TYPE_HLS_SE_VIDEO_H264
#define STREAM_ID_TYPE_E_STREAM
#define VIDEO_STREAM_DESCRIPTOR
#define STREAM_TYPE_BLURAY_AUDIO_DTS_HD
#define SYSTEM_CLOCK_FREQUENCY_DIVISOR
#define STREAM_TYPE_BLURAY_AUDIO_DTS_HD_MASTER
#define STREAM_TYPE_SCTE_DATA_SCTE_35
#define EXTENSION_DESCRIPTOR
#define STREAM_TYPE_METADATA
#define STREAM_TYPE_ISO_IEC_14496_PES
ISO/IEC 14496-1 (MPEG-4 Systems) SL-packetized stream or FlexMux stream carried in PES packets.
#define DOVI_VIDEO_STREAM_DESCRIPTOR
see "Dolby Vision Streams Within the MPEG-2 Transport Stream Format" https://professional....
static const uint8_t opus_default_extradata[30]
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
@ AV_PIX_FMT_YUV422P10LE
planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
@ AV_PIX_FMT_YUV444P10LE
planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
static int64_t read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, int64_t(*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t))
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
enum AVColorSpace color_space
int extradata_size
Size of the extradata content in bytes.
enum AVFieldOrder field_order
The order of the fields in interlaced video.
int height
The height of the video frame in pixels.
int nb_coded_side_data
Amount of entries in coded_side_data.
int width
The width of the video frame in pixels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
AVRational framerate
Number of frames per second, for streams with constant frame durations.
int profile
Codec-specific bitstream restrictions that the stream conforms to.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
enum AVColorPrimaries color_primaries
enum AVColorTransferCharacteristic color_trc
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
enum AVColorRange color_range
Additional colorspace characteristics.
uint8_t dv_md_compression
uint8_t dv_bl_signal_compatibility_id
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVStreamGroup ** stream_groups
A list of all stream groups in the file.
int ctx_flags
Flags signalling stream properties.
unsigned int nb_stream_groups
Number of elements in AVFormatContext.stream_groups.
AVStream ** streams
A list of all streams in the file.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
This structure stores compressed data.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
This structure contains the data a format has to probe a file.
New fields can be added to the end with minor version bumps.
unsigned int nb_stream_indexes
enum AVDiscard discard
selects which program to discard and which to feed to the caller
int height
Height of the final image for presentation.
unsigned int el_index
Index of the enhancement layer stream in AVStreamGroup.
int width
Width of the final stream for presentation.
union AVStreamGroup::@166361102046003066253145020066347265153020354020 params
Group type-specific parameters.
unsigned int nb_streams
Number of elements in AVStreamGroup.streams.
int64_t id
Group type-specific group ID.
struct AVStreamGroupLayeredVideo * layered_video
AVCodecParameters * codecpar
Codec parameters associated with this stream.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
int disposition
Stream disposition - a combination of AV_DISPOSITION_* flags.
int64_t pts_wrap_reference
Internal data to check for wrapping of the time stamp.
int probe_packets
Number of packets to buffer for codec probing.
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
int pts_wrap_behavior
Options for behavior, when a wrap is detected.
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
int stream_identifier
Stream Identifier This is the MPEG-TS stream identifier +1 0 means unknown.
enum AVStreamParseType need_parsing
int predefined_SLConfigDescriptor_seen
uint8_t * dec_config_descr
int fix_teletext_pts
fix dvb teletext pts
int raw_packet_size
raw packet size, including FEC if present
int stop_parse
stop parsing loop
MpegTSFilter * pids[NB_PID_MAX]
filters for various streams specified by PMT + for the PAT and PMT
int8_t crc_validity[NB_PID_MAX]
int64_t pcr_incr
used to estimate the exact PCR
int auto_guess
if true, all pids are analyzed to find streams
int64_t last_pos
to detect seek
AVPacket * pkt
packet containing Audio/Video data
int mpeg2ts_compute_pcr
compute exact PCR for each transport stream packet
int64_t cur_pcr
used to estimate the exact PCR
unsigned int nb_prg
structure to keep track of Program->pids mapping
unsigned int prg_size
allocated size of prg in bytes
enum MpegTSFilterType type
MpegTSSectionFilter section_filter
MpegTSPESFilter pes_filter
union MpegTSFilter::@312121205260244256256257337225030272055136325323 u
SectionCallback * section_cb
unsigned int end_of_section_reached
int64_t ts_packet_pos
position of first TS packet of this PES packet
int pcr_pid
if -1 then all packets containing PCR are considered
uint8_t header[MAX_PES_HEADER_SIZE]
AVStream * sub_st
stream for the embedded AC3 stream in HDMV TrueHD
int flags
copied to the AVPacket flags
unsigned int nb_stream_groups
int pmt_found
have we found pmt for this program
struct StreamGroup stream_groups[MAX_STREAMS_PER_PROGRAM]
unsigned int pids[MAX_PIDS_PER_PROGRAM]
struct Stream streams[MAX_STREAMS_PER_PROGRAM]
AVStream * streams[MAX_STREAMS_PER_PROGRAM]
enum AVStreamGroupParamsType type
enum AVMediaType codec_type
#define avpriv_request_sample(...)
static void check_crc(const AVCRC *table_new, const char *name, size_t size, size_t offset)
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)