41 #define MAX_RESYNC_SIZE 65536 43 #define MAX_PES_PAYLOAD 200 * 1024 45 #define MAX_MP4_DESCR_COUNT 16 47 #define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend) \ 49 if ((prev_dividend) == 0 || (dividend) - (prev_dividend) != (divisor)) \ 50 (modulus) = (dividend) % (divisor); \ 51 (prev_dividend) = (dividend); \ 62 int is_start, int64_t pos);
95 #define MAX_PIDS_PER_PROGRAM 64 143 #define MPEGTS_OPTIONS \ 144 { "resync_size", "Size limit for looking up a new synchronization.", offsetof(MpegTSContext, resync_size), AV_OPT_TYPE_INT, { .i64 = MAX_RESYNC_SIZE}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM } 160 {
"compute_pcr",
"Compute exact PCR for each transport stream packet.",
163 {
"ts_packetsize",
"Output option carrying the raw packet size.",
188 #define PES_START_SIZE 6 189 #define PES_HEADER_SIZE 9 190 #define MAX_PES_HEADER_SIZE (9 + 255) 220 for (i = 0; i < ts->
nb_prg; i++)
221 if (ts->
prg[i].
id == programid)
249 for (i = 0; i < ts->
nb_prg; i++) {
250 if (ts->
prg[i].
id == programid) {
274 int used = 0, discarded = 0;
285 for (i = 0; i < ts->
nb_prg; i++) {
287 for (j = 0; j < p->
nb_pids; j++) {
288 if (p->
pids[j] != pid)
302 return !used && discarded;
310 const uint8_t *buf,
int buf_size,
int is_start)
439 memset(stat, 0, packet_size *
sizeof(
int));
441 for (x = i = 0; i < size - 3; i++) {
442 if (buf[i] == 0x47 &&
443 (!probe || (!(buf[i + 1] & 0x80) && (buf[i + 3] & 0x30)))) {
445 if (stat[x] > best_score) {
446 best_score = stat[x];
453 if (x == packet_size)
463 int score, fec_score, dvhs_score;
472 score, dvhs_score, fec_score);
474 if (score > fec_score && score > dvhs_score)
476 else if (dvhs_score > score && dvhs_score > fec_score)
478 else if (score < fec_score && dvhs_score < fec_score)
511 if ((p + 1) >= p_end)
527 len =
get8(&p, p_end);
530 if ((p + len) > p_end)
547 val =
get8(pp, p_end);
552 val =
get16(pp, p_end);
556 val =
get8(pp, p_end);
559 h->
version = (val >> 1) & 0x1f;
560 val =
get8(pp, p_end);
564 val =
get8(pp, p_end);
637 uint32_t stream_type,
649 uint32_t stream_type, uint32_t prog_reg_desc)
660 "stream=%d stream_type=%x pid=%x prog_reg_desc=%.4s\n",
666 if (prog_reg_desc ==
AV_RL32(
"HDMV") &&
677 memcpy(sub_pes, pes,
sizeof(*sub_pes));
685 sub_st->
id = pes->
pid;
736 const uint8_t *buf,
int buf_size)
739 int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0;
740 int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0;
741 int dts_flag = -1, cts_flag = -1;
750 au_start_flag = au_end_flag = 1;
760 if (!idle_flag && (!padding_flag || padding_bits != 0)) {
786 if (inst_bitrate_flag)
803 const uint8_t *buf,
int buf_size,
int is_start,
824 while (buf_size > 0) {
825 switch (pes->
state) {
840 code = pes->
header[3] | 0x100;
871 if (code != 0x1bc && code != 0x1bf &&
872 code != 0x1f0 && code != 0x1f1 &&
873 code != 0x1ff && code != 0x1f2 &&
878 "pid=%x stream_type=%x probing\n",
925 unsigned int flags, pes_ext, skip;
931 if ((flags & 0xc0) == 0x80) {
934 }
else if ((flags & 0xc0) == 0xc0) {
944 skip = (pes_ext >> 4) & 0xb;
947 if ((pes_ext & 0x41) == 0x01 &&
950 if ((r[0] & 0x7f) > 0 && (r[1] & 0x80) == 0)
962 p += sl_header_bytes;
963 buf_size -= sl_header_bytes;
968 if (buf_size > 0 && pes->
buffer) {
1045 Mp4Descr *descr,
int max_descr_count)
1048 if (size > (1 << 30))
1068 (*len) -= new_off - *off;
1104 if (!(id_flags & 0x0020)) {
1193 if (len < 0 || len1 > len || len1 <= 0) {
1195 "Tag %x length violation new length %d bytes remaining %d\n",
1206 if (target_tag && tag != target_tag) {
1239 Mp4Descr *descr,
int *descr_count,
int max_descr_count)
1255 Mp4Descr *descr,
int *descr_count,
int max_descr_count)
1278 int mp4_descr_count = 0;
1283 p_end = section + section_len - 4;
1293 mp4_read_od(s, p, (
unsigned) (p_end - p), mp4_descr, &mp4_descr_count,
1299 for (i = 0; i < mp4_descr_count; i++) {
1313 pes->
sl = mp4_descr[i].
sl;
1316 mp4_descr[i].dec_config_descr_len, 0,
1329 for (i = 0; i < mp4_descr_count; i++)
1330 av_free(mp4_descr[i].dec_config_descr);
1334 1, 0, 1, 1, 2, 2, 2, 3, 3
1338 1, 1, 1, 2, 2, 3, 4, 4, 5,
1349 { 0,6,1,2,3,4,5,7 },
1354 Mp4Descr *mp4_descr,
int mp4_descr_count,
int pid,
1358 int desc_len, desc_tag, desc_es_id, ext_desc_tag, channels, channel_config_code;
1362 desc_tag =
get8(pp, desc_list_end);
1365 desc_len =
get8(pp, desc_list_end);
1368 desc_end = *pp + desc_len;
1369 if (desc_end > desc_list_end)
1380 desc_es_id =
get16(pp, desc_end);
1383 if (ts && ts->
pids[pid])
1385 for (i = 0; i < mp4_descr_count; i++)
1386 if (mp4_descr[i].dec_config_descr_len &&
1387 mp4_descr[i].es_id == desc_es_id) {
1390 mp4_descr[i].dec_config_descr_len, 0,
1401 if (
get16(pp, desc_end) < 0)
1403 if (mp4_descr_count > 0 &&
1417 language[0] =
get8(pp, desc_end);
1418 language[1] =
get8(pp, desc_end);
1419 language[2] =
get8(pp, desc_end);
1424 language[0] =
get8(pp, desc_end);
1425 language[1] =
get8(pp, desc_end);
1426 language[2] =
get8(pp, desc_end);
1429 switch (
get8(pp, desc_end)) {
1454 for (i = 0; i + 4 <= desc_len; i += 4) {
1455 language[i + 0] =
get8(pp, desc_end);
1456 language[i + 1] =
get8(pp, desc_end);
1457 language[i + 2] =
get8(pp, desc_end);
1458 language[i + 3] =
',';
1459 switch (
get8(pp, desc_end)) {
1471 if (i && language[0]) {
1472 language[i - 1] = 0;
1483 ext_desc_tag =
get8(pp, desc_end);
1484 if (ext_desc_tag < 0)
1487 ext_desc_tag == 0x80) {
1497 channel_config_code =
get8(pp, desc_end);
1498 if (channel_config_code < 0)
1500 if (channel_config_code <= 0x8) {
1501 st->
codecpar->
extradata[9] = channels = channel_config_code ? channel_config_code : 2;
1527 const uint8_t *p, *p_end, *desc_list_end;
1528 int program_info_length, pcr_pid, pid, stream_type;
1530 uint32_t prog_reg_desc = 0;
1532 int mp4_descr_count = 0;
1539 p_end = section + section_len - 4;
1554 pcr_pid =
get16(&p, p_end);
1562 program_info_length =
get16(&p, p_end);
1563 if (program_info_length < 0)
1565 program_info_length &= 0xfff;
1566 while (program_info_length >= 2) {
1568 tag =
get8(&p, p_end);
1569 len =
get8(&p, p_end);
1573 if (len > program_info_length - 2)
1576 program_info_length -= len + 2;
1583 }
else if (tag == 0x05 && len >= 4) {
1584 prog_reg_desc = bytestream_get_le32(&p);
1589 p += program_info_length;
1601 stream_type =
get8(&p, p_end);
1602 if (stream_type < 0)
1604 pid =
get16(&p, p_end);
1617 }
else if (stream_type != 0x13) {
1646 desc_list_len =
get16(&p, p_end);
1647 if (desc_list_len < 0)
1649 desc_list_len &= 0xfff;
1650 desc_list_end = p + desc_list_len;
1651 if (desc_list_end > p_end)
1655 desc_list_end, mp4_descr,
1656 mp4_descr_count, pid, ts) < 0)
1659 if (pes && prog_reg_desc ==
AV_RL32(
"HDMV") &&
1660 stream_type == 0x83 && pes->
sub_st) {
1670 for (i = 0; i < mp4_descr_count; i++)
1671 av_free(mp4_descr[i].dec_config_descr);
1685 p_end = section + section_len - 4;
1697 sid =
get16(&p, p_end);
1700 pmt_pid =
get16(&p, p_end);
1707 if (sid == 0x0000) {
1711 if (ts->
pids[pmt_pid])
1726 const uint8_t *p, *p_end, *desc_list_end, *desc_end;
1727 int onid, val, sid, desc_list_len, desc_tag, desc_len, service_type;
1728 char *
name, *provider_name;
1733 p_end = section + section_len - 4;
1743 onid =
get16(&p, p_end);
1746 val =
get8(&p, p_end);
1750 sid =
get16(&p, p_end);
1753 val =
get8(&p, p_end);
1756 desc_list_len =
get16(&p, p_end);
1757 if (desc_list_len < 0)
1759 desc_list_len &= 0xfff;
1760 desc_list_end = p + desc_list_len;
1761 if (desc_list_end > p_end)
1764 desc_tag =
get8(&p, desc_list_end);
1767 desc_len =
get8(&p, desc_list_end);
1768 desc_end = p + desc_len;
1769 if (desc_end > desc_list_end)
1773 desc_tag, desc_len);
1777 service_type =
get8(&p, p_end);
1778 if (service_type < 0)
1780 provider_name =
getstr8(&p, p_end);
1808 int len, pid, cc, expected_cc, cc_ok, afc, is_start, is_discontinuity,
1809 has_adaptation, has_payload;
1813 pid =
AV_RB16(packet + 1) & 0x1fff;
1816 is_start = packet[1] & 0x40;
1817 tss = ts->
pids[pid];
1820 tss = ts->
pids[pid];
1825 afc = (packet[3] >> 4) & 3;
1828 has_adaptation = afc & 2;
1829 has_payload = afc & 1;
1830 is_discontinuity = has_adaptation &&
1835 cc = (packet[3] & 0xf);
1836 expected_cc = has_payload ? (tss->
last_cc + 1) & 0x0f : tss->
last_cc;
1837 cc_ok = pid == 0x1FFF ||
1845 "Continuity check failed for pid %d expected %d got %d\n",
1846 pid, expected_cc, cc);
1856 if (has_adaptation) {
1872 if (p + len > p_end)
1922 "max resync size reached, could not find sync byte\n");
1939 if ((*data)[0] != 0x47) {
1966 int packet_num, ret = 0;
1992 if (nb_packets != 0 && packet_num >= nb_packets)
2009 int score, fec_score, dvhs_score;
2011 #define CHECK_COUNT 10 2023 score, dvhs_score, fec_score);
2027 if (score > fec_score && score > dvhs_score && score > 6)
2029 else if (dvhs_score > score && dvhs_score > fec_score && dvhs_score > 6)
2031 else if (fec_score > 6)
2045 afc = (packet[3] >> 4) & 3;
2055 if (!(flags & 0x10))
2060 *ppcr_high = ((int64_t) v << 1) | (p[4] >> 7);
2061 *ppcr_low = ((p[4] & 1) << 8) | p[5];
2078 if (len !=
sizeof(buf))
2086 if (s->
iformat == &ff_mpegts_demuxer) {
2107 int pcr_pid, pid, nb_packets, nb_pcrs, ret, pcr_l;
2108 int64_t pcrs[2], pcr_h;
2109 int packet_count[2];
2130 pid =
AV_RB16(data + 1) & 0x1fff;
2131 if ((pcr_pid == -1 || pcr_pid == pid) &&
2135 packet_count[nb_pcrs] = nb_packets;
2136 pcrs[nb_pcrs] = pcr_h * 300 + pcr_l;
2148 ts->
pcr_incr = (pcrs[1] - pcrs[0]) / (packet_count[1] - packet_count[0]);
2161 #define MAX_PACKET_READAHEAD ((128 * 1024) / 188) 2167 int64_t pcr_h, next_pcr_h, pos;
2168 int pcr_l, next_pcr_l;
2180 if (data != pkt->
data)
2191 if (
parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) {
2194 ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) /
2201 ts->
cur_pcr = pcr_h * 300 + pcr_l;
2233 if (!ret && pkt->
size < 0)
2257 int64_t *ppos, int64_t pos_limit)
2260 int64_t pos, timestamp;
2262 int pcr_l, pcr_pid =
2264 const int find_next = 1;
2273 if ((pcr_pid < 0 || (
AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
2274 parse_pcr(×tamp, &pcr_l, buf) == 0) {
2287 if ((pcr_pid < 0 || (
AV_RB16(buf + 1) & 0x1fff) == pcr_pid) &&
2288 parse_pcr(×tamp, &pcr_l, buf) == 0) {
2360 if (buf[0] != 0x47) {
2389 .priv_class = &mpegts_class,
2393 .
name =
"mpegtsraw",
2402 .priv_class = &mpegtsraw_class,
static void mpegts_free(MpegTSContext *ts)
codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it ...
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
static int mpegts_resync(AVFormatContext *s)
void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id)
static void finished_reading_packet(AVFormatContext *s, int raw_packet_size)
uint32_t av_crc(const AVCRC *ctx, uint32_t crc, const uint8_t *buffer, size_t length)
Calculate the CRC of a block.
int64_t cur_pcr
used to estimate the exact PCR
#define AV_OPT_FLAG_EXPORT
The option is intended for exporting values to the caller.
#define MAX_PACKET_READAHEAD
enum AVMediaType codec_type
static int parse_MP4ODescrTag(MP4DescrParseContext *d, int64_t off, int len)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int handle_packet(MpegTSContext *ts, const uint8_t *packet)
int64_t pos
byte position in stream, -1 if unknown
static void clear_program(MpegTSContext *ts, unsigned int programid)
static void skip_bits_long(GetBitContext *s, int n)
static int mpegts_probe(AVProbeData *p)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int index
stream index in AVFormatContext
MpegTSPESFilter pes_filter
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
enum AVMediaType codec_type
AVInputFormat ff_mpegts_demuxer
static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
static int parse_section_header(SectionHeader *h, const uint8_t **pp, const uint8_t *p_end)
enum MpegTSFilterType type
static int mpegts_read_packet(AVFormatContext *s, AVPacket *pkt)
unsigned int avio_rb16(AVIOContext *s)
int ctx_flags
Flags signalling stream properties.
int pcr_pid
if -1 then all packets containing PCR are considered
unsigned int nb_prg
structure to keep track of Program->pids mapping
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size, const uint8_t **data)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
unsigned int pids[MAX_PIDS_PER_PROGRAM]
static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size)
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
MpegTSFilter * pids[NB_PID_MAX]
filters for various streams specified by PMT + for the PAT and PMT
static int mpegts_read_header(AVFormatContext *s)
Opaque data information usually continuous.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
unsigned int avio_rb32(AVIOContext *s)
int stop_parse
stop parsing loop
static int parse_MP4ESDescrTag(MP4DescrParseContext *d, int64_t off, int len)
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 ...
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
static void add_pat_entry(MpegTSContext *ts, unsigned int programid)
static int mpegts_push_data(MpegTSFilter *filter, const uint8_t *buf, int buf_size, int is_start, int64_t pos)
int id
Format-specific stream ID.
enum AVStreamParseType need_parsing
static const AVOption raw_options[]
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static const uint8_t opus_channel_map[8][8]
AVStream ** streams
A list of all streams in the file.
int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data)
Read size bytes from AVIOContext, returning a pointer.
static void update_offsets(AVIOContext *pb, int64_t *off, int *len)
AVProgram * av_new_program(AVFormatContext *s, int id)
static int get_bits_count(const GetBitContext *s)
#define AVERROR_EOF
End of file.
bitstream reader API header.
static av_cold int read_close(AVFormatContext *ctx)
union MpegTSFilter::@144 u
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
enum AVDiscard discard
selects which program to discard and which to feed to the caller
static PESContext * add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static MpegTSFilter * mpegts_open_pes_filter(MpegTSContext *ts, unsigned int pid, PESCallback *pes_cb, void *opaque)
AVInputFormat ff_mpegtsraw_demuxer
static int init_MP4DescrParseContext(MP4DescrParseContext *d, AVFormatContext *s, const uint8_t *buf, unsigned size, Mp4Descr *descr, int max_descr_count)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static uint64_t get_bits64(GetBitContext *s, int n)
static const uint8_t opus_default_extradata[30]
int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb)
int av_reallocp_array(void *ptr, size_t nmemb, size_t size)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static const StreamType HDMV_types[]
static int mpegts_read_close(AVFormatContext *s)
static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
enum AVMediaType codec_type
General type of the encoded data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
enum AVMediaType avcodec_get_type(enum AVCodecID codec_id)
Get the type of the given codec.
#define TS_FEC_PACKET_SIZE
New fields can be added to the end with minor version bumps.
static int64_t ff_parse_pes_pts(const uint8_t *buf)
Parse MPEG-PES five-byte timestamp.
static int parse_MP4DecConfigDescrTag(MP4DescrParseContext *d, int64_t off, int len)
int flags
copied to the AVPacket flags
int pcr_incr
used to estimate the exact PCR
int flags
A combination of AV_PKT_FLAG values.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
MpegTSContext * ff_mpegts_parse_open(AVFormatContext *s)
int bit_rate
The average bitrate of the encoded data (in bits per second).
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static void filter(MpegAudioContext *s, int ch, const short *samples, int incr)
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int64_t ts_packet_pos
position of first TS packet of this PES packet
SectionCallback * section_cb
static const StreamType REGD_types[]
int PESCallback(MpegTSFilter *f, const uint8_t *buf, int len, int is_start, int64_t pos)
static const StreamType MISC_types[]
static int mp4_read_od(AVFormatContext *s, const uint8_t *buf, unsigned size, Mp4Descr *descr, int *descr_count, int max_descr_count)
#define TS_DVHS_PACKET_SIZE
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int handle_packets(MpegTSContext *ts, int nb_packets)
static int mpegts_set_stream_info(AVStream *st, PESContext *pes, uint32_t stream_type, uint32_t prog_reg_desc)
static const uint8_t opus_stream_cnt[9]
static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len, int target_tag)
static int parse_MP4SLDescrTag(MP4DescrParseContext *d, int64_t off, int len)
int mpeg2ts_compute_pcr
compute exact PCR for each transport stream packet
static const AVClass mpegtsraw_class
MpegTSSectionFilter section_filter
static const uint8_t opus_coupled_stream_cnt[9]
unsigned int probesize
Maximum size of the data read from input for determining the input container format.
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt, const uint8_t *buf, int len)
preferred ID for MPEG-1/2 video decoding
int auto_guess
if true, all pids are analyzed to find streams
int raw_packet_size
raw packet size, including FEC if present
static const StreamType ISO_types[]
static int read_header(FFV1Context *f)
if(ac->has_optimized_func)
FAKE codec to indicate a MPEG-4 Systems stream (only used by libavformat)
#define TS_MAX_PACKET_SIZE
uint8_t * dec_config_descr
#define MP4DecConfigDescrTag
static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
AVIOContext * pb
I/O context.
static int parse_mp4_descr_arr(MP4DescrParseContext *d, int64_t off, int len)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * data
The data buffer.
static void new_pes_packet(PESContext *pes, AVPacket *pkt)
static int get_packet_size(const uint8_t *buf, int size)
#define STREAM_TYPE_PRIVATE_DATA
static int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
#define MAX_PES_HEADER_SIZE
static int get8(const uint8_t **pp, const uint8_t *p_end)
#define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend)
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 AVERROR_BUG
Bug detected, please report the issue.
#define MAX_PIDS_PER_PROGRAM
static unsigned int get_bits1(GetBitContext *s)
static int parse_pcr(int64_t *ppcr_high, int *ppcr_low, const uint8_t *packet)
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static int analyze(const uint8_t *buf, int size, int packet_size, int *index, int probe)
refcounted data buffer API
static void mpegts_close_filter(MpegTSContext *ts, MpegTSFilter *filter)
static const StreamType DESC_types[]
This structure contains the data a format has to probe a file.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
unsigned int end_of_section_reached
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...
int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type, 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 void clear_programs(MpegTSContext *ts)
A reference to a data buffer.
static const AVOption options[]
static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
int ff_mp4_read_descr(AVFormatContext *fc, AVIOContext *pb, int *tag)
void ff_mpegts_parse_close(MpegTSContext *ts)
static const AVClass mpegts_class
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
int disposition
AV_DISPOSITION_* bit field.
int64_t pos
position corresponding to pos47, or 0 if pos47 invalid
uint8_t header[MAX_PES_HEADER_SIZE]
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
struct AVInputFormat * iformat
The input container format.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static MpegTSFilter * mpegts_open_section_filter(MpegTSContext *ts, unsigned int pid, SectionCallback *section_cb, void *opaque, int check_crc)
FAKE codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
static int get16(const uint8_t **pp, const uint8_t *p_end)
int eof_reached
true if eof reached
AVPacket * pkt
packet containing Audio/Video data
void * priv_data
Format private data.
int64_t last_pos
to detect seek
#define AV_OPT_FLAG_READONLY
The option may not be set through the AVOptions API, only read.
static void add_pid_to_pmt(MpegTSContext *ts, unsigned int programid, unsigned int pid)
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
void SetServiceCallback(void *opaque, int ret)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
int bit_rate
Total stream bitrate in bit/s, 0 if not available.
AVCodecParameters * codecpar
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static int parse_MP4IODescrTag(MP4DescrParseContext *d, int64_t off, int len)
static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_len)
#define MAX_MP4_DESCR_COUNT
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static void mpegts_find_stream_type(AVStream *st, uint32_t stream_type, const StreamType *types)
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static char * getstr8(const uint8_t **pp, const uint8_t *p_end)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.
void SectionCallback(MpegTSFilter *f, const uint8_t *buf, int len)
AVStream * sub_st
stream for the embedded AC3 stream in HDMV TrueHD
static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size, Mp4Descr *descr, int *descr_count, int max_descr_count)