@ -444,7 +444,7 @@ static void write_section_data(MpegTSContext *ts, MpegTSFilter *tss1,
offset = 0 ;
cur_section_buf = tss - > section_buf ;
while ( cur_section_buf - tss - > section_buf < MAX_SECTION_SIZE & & cur_section_buf [ 0 ] ! = 0xff ) {
while ( cur_section_buf - tss - > section_buf < MAX_SECTION_SIZE & & cur_section_buf [ 0 ] ! = STUFFING_BYTE ) {
/* compute section length if possible */
if ( tss - > section_h_size = = - 1 & & tss - > section_index - offset > = 3 ) {
len = ( AV_RB16 ( cur_section_buf + 1 ) & 0xfff ) + 3 ;
@ -590,7 +590,7 @@ static int analyze(const uint8_t *buf, int size, int packet_size,
memset ( stat , 0 , packet_size * sizeof ( * stat ) ) ;
for ( i = 0 ; i < size - 3 ; i + + ) {
if ( buf [ i ] = = 0x47 ) {
if ( buf [ i ] = = SYNC_BYTE ) {
int pid = AV_RB16 ( buf + 1 ) & 0x1FFF ;
int asc = buf [ i + 3 ] & 0x30 ;
if ( ! probe | | pid = = 0x1FFF | | asc ) {
@ -798,66 +798,66 @@ typedef struct StreamType {
} StreamType ;
static const StreamType ISO_types [ ] = {
{ 0x01 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_MPEG2VIDEO } ,
{ 0x02 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_MPEG2VIDEO } ,
{ 0x03 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_MP3 } ,
{ 0x04 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_MP3 } ,
{ 0x0f , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC } ,
{ 0x10 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_MPEG4 } ,
{ STREAM_TYPE_VIDEO_MPEG1 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_MPEG2VIDEO } ,
{ STREAM_TYPE_VIDEO_MPEG2 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_MPEG2VIDEO } ,
{ STREAM_TYPE_AUDIO_MPEG1 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_MP3 } ,
{ STREAM_TYPE_AUDIO_MPEG2 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_MP3 } ,
{ STREAM_TYPE_AUDIO_AAC , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC } ,
{ STREAM_TYPE_VIDEO_MPEG4 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_MPEG4 } ,
/* Makito encoder sets stream type 0x11 for AAC,
* so auto - detect LOAS / LATM instead of hardcoding it . */
# if !CONFIG_LOAS_DEMUXER
{ 0x11 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC_LATM } , /* LATM syntax */
{ STREAM_TYPE_AUDIO_AAC_LATM , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC_LATM } , /* LATM syntax */
# endif
{ 0x1b , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_H264 } ,
{ 0x1c , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC } ,
{ 0x20 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_H264 } ,
{ 0x21 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_JPEG2000 } ,
{ 0x24 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_HEVC } ,
{ 0x33 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_VVC } ,
{ 0x42 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_CAVS } ,
{ 0xd1 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_DIRAC } ,
{ 0xd2 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_AVS2 } ,
{ 0xd4 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_AVS3 } ,
{ 0xea , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_VC1 } ,
{ STREAM_TYPE_VIDEO_H264 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_H264 } ,
{ STREAM_TYPE_AUDIO_MPEG4 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC } ,
{ STREAM_TYPE_VIDEO_MVC , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_H264 } ,
{ STREAM_TYPE_VIDEO_JPEG2000 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_JPEG2000 } ,
{ STREAM_TYPE_VIDEO_HEVC , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_HEVC } ,
{ STREAM_TYPE_VIDEO_VVC , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_VVC } ,
{ STREAM_TYPE_VIDEO_CAVS , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_CAVS } ,
{ STREAM_TYPE_VIDEO_DIRAC , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_DIRAC } ,
{ STREAM_TYPE_VIDEO_AVS2 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_AVS2 } ,
{ STREAM_TYPE_VIDEO_AVS3 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_AVS3 } ,
{ STREAM_TYPE_VIDEO_VC1 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_VC1 } ,
{ 0 } ,
} ;
static const StreamType HDMV_types [ ] = {
{ 0x80 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_PCM_BLURAY } ,
{ 0x81 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ 0x82 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ 0x83 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_TRUEHD } ,
{ 0x84 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ 0x85 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } , /* DTS HD */
{ 0x86 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } , /* DTS HD MASTER*/
{ 0xa1 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } , /* E-AC3 Secondary Audio */
{ 0xa2 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } , /* DTS Express Secondary Audio */
{ 0x90 , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_HDMV_PGS_SUBTITLE } ,
{ 0x92 , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_HDMV_TEXT_SUBTITLE } ,
{ STREAM_TYPE_BLURAY_AUDIO_PCM_BLURAY , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_PCM_BLURAY } ,
{ STREAM_TYPE_BLURAY_AUDIO_AC3 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ STREAM_TYPE_BLURAY_AUDIO_DTS , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ STREAM_TYPE_BLURAY_AUDIO_TRUEHD , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_TRUEHD } ,
{ STREAM_TYPE_BLURAY_AUDIO_EAC3 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ STREAM_TYPE_BLURAY_AUDIO_DTS_HD , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ STREAM_TYPE_BLURAY_AUDIO_DTS_HD_MASTER , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ STREAM_TYPE_BLURAY_AUDIO_EAC3_SECONDARY , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ STREAM_TYPE_BLURAY_AUDIO_DTS_EXPRESS_SECONDARY , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ STREAM_TYPE_BLURAY_SUBTITLE_PGS , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_HDMV_PGS_SUBTITLE } ,
{ STREAM_TYPE_BLURAY_SUBTITLE_TEXT , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_HDMV_TEXT_SUBTITLE } ,
{ 0 } ,
} ;
/* SCTE types */
static const StreamType SCTE_types [ ] = {
{ 0x86 , AVMEDIA_TYPE_DATA , AV_CODEC_ID_SCTE_35 } ,
{ STREAM_TYPE_SCTE_DATA_SCTE_35 , AVMEDIA_TYPE_DATA , AV_CODEC_ID_SCTE_35 } ,
{ 0 } ,
} ;
/* ATSC ? */
static const StreamType MISC_types [ ] = {
{ 0x81 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ 0x87 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ STREAM_TYPE_ATSC_AUDIO_AC3 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ STREAM_TYPE_ATSC_AUDIO_EAC3 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ 0x8a , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ 0 } ,
} ;
/* HLS Sample Encryption Types */
static const StreamType HLS_SAMPLE_ENC_types [ ] = {
{ 0xdb , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_H264 } ,
{ 0xcf , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC } ,
{ 0xc1 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ 0xc2 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ STREAM_TYPE_HLS_SE_VIDEO_H264 , AVMEDIA_TYPE_VIDEO , AV_CODEC_ID_H264 } ,
{ STREAM_TYPE_HLS_SE_AUDIO_AAC , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AAC } ,
{ STREAM_TYPE_HLS_SE_AUDIO_AC3 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ STREAM_TYPE_HLS_SE_AUDIO_EAC3 , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ 0 } ,
} ;
@ -888,11 +888,11 @@ static const StreamType METADATA_types[] = {
/* descriptor present */
static const StreamType DESC_types [ ] = {
{ 0x6a , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } , /* AC-3 descriptor */
{ 0x7a , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } , /* E-AC-3 descriptor */
{ 0x7b , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ 0x56 , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_DVB_TELETEXT } ,
{ 0x59 , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_DVB_SUBTITLE } , /* subtitling descriptor */
{ AC3_DESCRIPTOR , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_AC3 } ,
{ ENHANCED_AC3_DESCRIPTOR , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_EAC3 } ,
{ DTS_DESCRIPTOR , AVMEDIA_TYPE_AUDIO , AV_CODEC_ID_DTS } ,
{ TELETEXT_DESCRIPTOR , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_DVB_TELETEXT } ,
{ SUBTITLING_DESCRIPTOR , AVMEDIA_TYPE_SUBTITLE , AV_CODEC_ID_DVB_SUBTITLE } ,
{ 0 } ,
} ;
@ -937,13 +937,13 @@ static int mpegts_set_stream_info(AVStream *st, PESContext *pes,
st - > codecpar - > codec_tag = pes - > stream_type ;
mpegts_find_stream_type ( st , pes - > stream_type , ISO_types ) ;
if ( pes - > stream_type = = 4 | | pes - > stream_type = = 0x0f )
if ( pes - > stream_type = = STREAM_TYPE_AUDIO_MPEG2 | | pes - > stream_type = = STREAM_TYPE_AUDIO_AAC )
sti - > request_probe = 50 ;
if ( ( prog_reg_desc = = AV_RL32 ( " HDMV " ) | |
prog_reg_desc = = AV_RL32 ( " HDPR " ) ) & &
st - > codecpar - > codec_id = = AV_CODEC_ID_NONE ) {
mpegts_find_stream_type ( st , pes - > stream_type , HDMV_types ) ;
if ( pes - > stream_type = = 0x83 ) {
if ( pes - > stream_type = = STREAM_TYPE_BLURAY_AUDIO_TRUEHD ) {
// HDMV TrueHD streams also contain an AC3 coded version of the
// audio track - add a second stream for this
AVStream * sub_st ;
@ -1028,7 +1028,7 @@ static int new_pes_packet(PESContext *pes, AVPacket *pkt)
memset ( pkt - > data + pkt - > size , 0 , AV_INPUT_BUFFER_PADDING_SIZE ) ;
// Separate out the AC3 substream from an HDMV combined TrueHD/AC3 PID
if ( pes - > sub_st & & pes - > stream_type = = 0x83 & & pes - > extended_stream_id = = 0x76 )
if ( pes - > sub_st & & pes - > stream_type = = STREAM_TYPE_BLURAY_AUDIO_TRUEHD & & pes - > extended_stream_id = = 0x76 )
pkt - > stream_index = pes - > sub_st - > index ;
else
pkt - > stream_index = pes - > st - > index ;
@ -1299,7 +1299,7 @@ skip:
/* we got the full header. We parse it and get the payload */
pes - > state = MPEGTS_PAYLOAD ;
pes - > data_index = 0 ;
if ( pes - > stream_type = = 0x12 & & buf_size > 0 ) {
if ( pes - > stream_type = = STREAM_TYPE_ISO_IEC_14496_PES & & buf_size > 0 ) {
int sl_header_bytes = read_sl_header ( pes , & pes - > sl , p ,
buf_size ) ;
pes - > pes_header_size + = sl_header_bytes ;
@ -1343,7 +1343,7 @@ skip:
// the standard says they should be handled after 40.6 ms at most,
// and the pcr error to this packet should be no more than 100 ms.
// TODO: we should interpolate the PCR, not just use the last one
int64_t pcr = f - > last_pcr / 300 ;
int64_t pcr = f - > last_pcr / SYSTEM_CLOCK_FREQUENCY_DIVISOR ;
pcr_found = 1 ;
if ( st ) {
const FFStream * const sti = ffstream ( st ) ;
@ -1395,7 +1395,7 @@ skip:
ts - > stop_parse = 1 ;
} else if ( pes - > data_index = = 0 & &
buf_size > max_packet_size ) {
// pes packet size is < ts size packet and pes data is padded with 0xff
// pes packet size is < ts size packet and pes data is padded with STUFFING_BYTE
// not sure if this is legal in ts but see issue #2392
buf_size = max_packet_size ;
}
@ -1788,7 +1788,7 @@ static void scte_data_cb(MpegTSFilter *filter, const uint8_t *section,
if ( prg & & prg - > pcr_pid ! = - 1 & & prg - > discard ! = AVDISCARD_ALL ) {
MpegTSFilter * f = ts - > pids [ prg - > pcr_pid ] ;
if ( f & & f - > last_pcr ! = - 1 )
ts - > pkt - > pts = ts - > pkt - > dts = f - > last_pcr / 300 ;
ts - > pkt - > pts = ts - > pkt - > dts = f - > last_pcr / SYSTEM_CLOCK_FREQUENCY_DIVISOR ;
}
ts - > stop_parse = 1 ;
@ -1888,7 +1888,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
break ;
case 0x56 : /* DVB teletext descriptor */
case TELETEXT_DESCRIPTOR :
{
uint8_t * extradata = NULL ;
int language_count = desc_len / 5 , ret ;
@ -1929,7 +1929,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
break ;
case 0x59 : /* subtitling descriptor */
case SUBTITLING_DESCRIPTOR :
{
/* 8 bytes per DVB subtitle substream data:
* ISO_639_language_code ( 3 bytes ) ,
@ -2028,7 +2028,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
sti - > request_probe = 50 ;
}
break ;
case 0x52 : /* stream identifier descriptor */
case STREAM_IDENTIFIER_DESCRIPTOR :
sti - > stream_identifier = 1 + get8 ( pp , desc_end ) ;
break ;
case METADATA_DESCRIPTOR :
@ -2040,7 +2040,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
mpegts_find_stream_type ( st , st - > codecpar - > codec_tag , METADATA_types ) ;
}
break ;
case 0x7f : /* DVB extension descriptor */
case EXTENSION_DESCRIPTOR : /* DVB extension descriptor */
ext_desc_tag = get8 ( pp , desc_end ) ;
if ( ext_desc_tag < 0 )
return AVERROR_INVALIDDATA ;
@ -2073,7 +2073,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
sti - > need_context_update = 1 ;
}
}
if ( ext_desc_tag = = 0x06 ) { /* supplementary audio descriptor */
if ( ext_desc_tag = = SUPPLEMENTARY_AUDIO_DESCRIPTOR ) {
int flags ;
if ( desc_len < 1 )
@ -2111,7 +2111,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
break ;
case 0x6a : /* ac-3_descriptor */
case AC3_DESCRIPTOR :
{
int component_type_flag = get8 ( pp , desc_end ) & ( 1 < < 7 ) ;
if ( component_type_flag ) {
@ -2125,7 +2125,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
break ;
case 0x7a : /* enhanced_ac-3_descriptor */
case ENHANCED_AC3_DESCRIPTOR :
{
int component_type_flag = get8 ( pp , desc_end ) & ( 1 < < 7 ) ;
if ( component_type_flag ) {
@ -2139,7 +2139,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
}
}
break ;
case 0xfd : /* ARIB data coding type descriptor */
case DATA_COMPONENT_DESCRIPTOR :
// STD-B24, fascicle 3, chapter 4 defines private_stream_1
// for captions
if ( stream_type = = STREAM_TYPE_PRIVATE_DATA ) {
@ -2187,7 +2187,7 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type
sti - > need_parsing = 0 ;
}
break ;
case 0xb0 : /* DOVI video stream descriptor */
case DOVI_VIDEO_STREAM_DESCRIPTOR :
{
uint32_t buf ;
AVDOVIDecoderConfigurationRecord * dovi ;
@ -2305,7 +2305,7 @@ static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
if ( desc_end > desc_list_end )
return - 1 ;
if ( desc_tag = = 0x52 ) {
if ( desc_tag = = STREAM_IDENTIFIER_DESCRIPTOR ) {
return get8 ( pp , desc_end ) ;
}
* pp = desc_end ;
@ -2316,8 +2316,8 @@ static int parse_stream_identifier_desc(const uint8_t *p, const uint8_t *p_end)
static int is_pes_stream ( int stream_type , uint32_t prog_reg_desc )
{
return ! ( stream_type = = 0x13 | |
( stream_type = = 0x86 & & prog_reg_desc = = AV_RL32 ( " CUEI " ) ) ) ;
return ! ( stream_type = = STREAM_TYPE_ISO_IEC_14496_SECTION | |
( stream_type = = STREAM_TYPE_SCTE_DATA_SCTE_35 & & prog_reg_desc = = AV_RL32 ( " CUEI " ) ) ) ;
}
static void pmt_cb ( MpegTSFilter * filter , const uint8_t * section , int section_len )
@ -2487,7 +2487,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
goto out ;
st - > id = pid ;
st - > codecpar - > codec_type = AVMEDIA_TYPE_DATA ;
if ( stream_type = = 0x86 & & prog_reg_desc = = AV_RL32 ( " CUEI " ) ) {
if ( stream_type = = STREAM_TYPE_SCTE_DATA_SCTE_35 & & prog_reg_desc = = AV_RL32 ( " CUEI " ) ) {
mpegts_find_stream_type ( st , stream_type , SCTE_types ) ;
mpegts_open_section_filter ( ts , pid , scte_data_cb , ts , 1 ) ;
}
@ -2523,7 +2523,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
break ;
if ( pes & & prog_reg_desc = = AV_RL32 ( " HDMV " ) & &
stream_type = = 0x83 & & pes - > sub_st ) {
stream_type = = STREAM_TYPE_BLURAY_AUDIO_TRUEHD & & pes - > sub_st ) {
av_program_add_stream_index ( ts - > stream , h - > id ,
pes - > sub_st - > index ) ;
pes - > sub_st - > codecpar - > codec_tag = st - > codecpar - > codec_tag ;
@ -2740,7 +2740,7 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
desc_tag , desc_len ) ;
switch ( desc_tag ) {
case 0x48 :
case SERVICE_DESCRIPTOR :
service_type = get8 ( & p , desc_end ) ;
if ( service_type < 0 )
break ;
@ -2806,7 +2806,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet, int64_t pos)
/* continuity check (currently not used) */
cc = ( packet [ 3 ] & 0xf ) ;
expected_cc = has_payload ? ( tss - > last_cc + 1 ) & 0x0f : tss - > last_cc ;
cc_ok = pid = = 0x1FFF | | // null packet PID
cc_ok = pid = = NULL_PID | |
is_discontinuity | |
tss - > last_cc < 0 | |
expected_cc = = cc ;
@ -2835,7 +2835,7 @@ static int handle_packet(MpegTSContext *ts, const uint8_t *packet, int64_t pos)
int64_t pcr_h ;
int pcr_l ;
if ( parse_pcr ( & pcr_h , & pcr_l , packet ) = = 0 )
tss - > last_pcr = pcr_h * 300 + pcr_l ;
tss - > last_pcr = pcr_h * SYSTEM_CLOCK_FREQUENCY_DIVISOR + pcr_l ;
/* skip adaptation field */
p + = p [ 0 ] + 1 ;
}
@ -2911,7 +2911,7 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren
int64_t back = FFMIN ( seekback , pos ) ;
//Special case for files like 01c56b0dc1.ts
if ( current_packet [ 0 ] = = 0x80 & & current_packet [ 12 ] = = 0x47 & & pos > = TS_PACKET_SIZE ) {
if ( current_packet [ 0 ] = = 0x80 & & current_packet [ 12 ] = = SYNC_BYTE & & pos > = TS_PACKET_SIZE ) {
avio_seek ( pb , 12 - TS_PACKET_SIZE , SEEK_CUR ) ;
return 0 ;
}
@ -2922,7 +2922,7 @@ static int mpegts_resync(AVFormatContext *s, int seekback, const uint8_t *curren
c = avio_r8 ( pb ) ;
if ( avio_feof ( pb ) )
return AVERROR_EOF ;
if ( c = = 0x47 ) {
if ( c = = SYNC_BYTE ) {
int new_packet_size , ret ;
avio_seek ( pb , - 1 , SEEK_CUR ) ;
pos = avio_tell ( pb ) ;
@ -2956,7 +2956,7 @@ static int read_packet(AVFormatContext *s, uint8_t *buf, int raw_packet_size,
if ( len ! = TS_PACKET_SIZE )
return len < 0 ? len : AVERROR_EOF ;
/* check packet sync byte */
if ( ( * data ) [ 0 ] ! = 0x47 ) {
if ( ( * data ) [ 0 ] ! = SYNC_BYTE ) {
/* find a new packet start */
if ( mpegts_resync ( s , raw_packet_size , * data ) < 0 )
@ -3175,7 +3175,7 @@ static int mpegts_read_header(AVFormatContext *s)
parse_pcr ( & pcr_h , & pcr_l , data ) = = 0 ) {
finished_reading_packet ( s , ts - > raw_packet_size ) ;
pcr_pid = pid ;
pcrs [ nb_pcrs ] = pcr_h * 300 + pcr_l ;
pcrs [ nb_pcrs ] = pcr_h * SYSTEM_CLOCK_FREQUENCY_DIVISOR + pcr_l ;
nb_pcrs + + ;
if ( nb_pcrs > = 2 ) {
if ( pcrs [ 1 ] - pcrs [ 0 ] > 0 ) {
@ -3240,14 +3240,14 @@ static int mpegts_raw_read_packet(AVFormatContext *s, AVPacket *pkt)
if ( parse_pcr ( & next_pcr_h , & next_pcr_l , pcr_buf ) = = 0 ) {
/* XXX: not precise enough */
ts - > pcr_incr =
( ( next_pcr_h - pcr_h ) * 300 + ( next_pcr_l - pcr_l ) ) /
( ( next_pcr_h - pcr_h ) * SYSTEM_CLOCK_FREQUENCY_DIVISOR + ( next_pcr_l - pcr_l ) ) /
( i + 1 ) ;
break ;
}
}
avio_seek ( s - > pb , pos , SEEK_SET ) ;
/* no next PCR found: we use previous increment */
ts - > cur_pcr = pcr_h * 300 + pcr_l ;
ts - > cur_pcr = pcr_h * SYSTEM_CLOCK_FREQUENCY_DIVISOR + pcr_l ;
}
pkt - > pts = ts - > cur_pcr ;
pkt - > duration = ts - > pcr_incr ;
@ -3325,7 +3325,7 @@ static av_unused int64_t mpegts_get_pcr(AVFormatContext *s, int stream_index,
return AV_NOPTS_VALUE ;
if ( avio_read ( s - > pb , buf , TS_PACKET_SIZE ) ! = TS_PACKET_SIZE )
return AV_NOPTS_VALUE ;
if ( buf [ 0 ] ! = 0x47 ) {
if ( buf [ 0 ] ! = SYNC_BYTE ) {
if ( mpegts_resync ( s , TS_PACKET_SIZE , buf ) < 0 )
return AV_NOPTS_VALUE ;
pos = avio_tell ( s - > pb ) ;
@ -3416,7 +3416,7 @@ int avpriv_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
ts - > stop_parse = 0 ;
if ( len < TS_PACKET_SIZE )
return AVERROR_INVALIDDATA ;
if ( buf [ 0 ] ! = 0x47 ) {
if ( buf [ 0 ] ! = SYNC_BYTE ) {
buf + + ;
len - - ;
} else {