Skip to content

Commit eaa7ec3

Browse files
committed
demux: ts: merge arib/pmt descriptor loop
1 parent be7e07b commit eaa7ec3

File tree

1 file changed

+29
-39
lines changed
  • modules/demux/mpeg

1 file changed

+29
-39
lines changed

modules/demux/mpeg/ts.c

Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ typedef enum
292292
{
293293
TS_PMT_REGISTRATION_NONE = 0,
294294
TS_PMT_REGISTRATION_BLURAY,
295-
TS_PMT_REGISTRATION_ATSC
295+
TS_PMT_REGISTRATION_ATSC,
296+
TS_PMT_REGISTRATION_ARIB,
296297
} ts_pmt_registration_type_t;
297298

298299
typedef enum
@@ -5282,7 +5283,9 @@ static void FillPESFromDvbpsiES( demux_t *p_demux,
52825283
static void ParsePMTRegistrations( demux_t *p_demux, const dvbpsi_descriptor_t *p_firstdr,
52835284
ts_pmt_t *p_pmt, ts_pmt_registration_type_t *p_registration_type )
52845285
{
5286+
demux_sys_t *p_sys = p_demux->p_sys;
52855287
ts_pmt_registration_type_t registration_type = *p_registration_type;
5288+
int i_arib_score_flags = 0; /* Descriptors can be repeated */
52865289

52875290
for( const dvbpsi_descriptor_t *p_dr = p_firstdr; p_dr != NULL; p_dr = p_dr->p_next )
52885291
{
@@ -5320,9 +5323,13 @@ static void ParsePMTRegistrations( demux_t *p_demux, const dvbpsi_descriptor_t
53205323
break;
53215324

53225325
case 0x09:
5323-
msg_Dbg( p_demux, " * PMT descriptor : CA (0x9) SysID 0x%x",
5324-
(p_dr->p_data[0] << 8) | p_dr->p_data[1] );
5325-
break;
5326+
{
5327+
dvbpsi_ca_dr_t *p_cadr = dvbpsi_DecodeCADr( p_dr );
5328+
msg_Dbg( p_demux, " * PMT descriptor : CA (0x09) SysID 0x%x",
5329+
p_cadr->i_ca_system_id );
5330+
i_arib_score_flags |= (p_cadr->i_ca_system_id == 0x05);
5331+
}
5332+
break;
53265333

53275334
case 0x0f:
53285335
msg_Dbg( p_demux, " * PMT descriptor : Private Data (0x0f)" );
@@ -5340,6 +5347,11 @@ static void ParsePMTRegistrations( demux_t *p_demux, const dvbpsi_descriptor_t
53405347

53415348
case 0xC1:
53425349
msg_Dbg( p_demux, " * PMT descriptor : Digital copy control (0xC1)" );
5350+
i_arib_score_flags |= 1 << 2;
5351+
break;
5352+
5353+
case 0xF6:
5354+
i_arib_score_flags |= 1 << 1;
53435355
break;
53445356

53455357
default:
@@ -5348,6 +5360,14 @@ static void ParsePMTRegistrations( demux_t *p_demux, const dvbpsi_descriptor_t
53485360
}
53495361
}
53505362

5363+
if ( p_sys->arib.e_mode == ARIBMODE_AUTO &&
5364+
registration_type == TS_PMT_REGISTRATION_NONE &&
5365+
i_arib_score_flags == 0x07 ) //0b111
5366+
{
5367+
registration_type = TS_PMT_REGISTRATION_ARIB;
5368+
p_sys->arib.e_mode = ARIBMODE_ENABLED;
5369+
}
5370+
53515371
*p_registration_type = registration_type;
53525372
}
53535373

@@ -5423,36 +5443,6 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
54235443

54245444
/* Parse PMT descriptors */
54255445
ts_pmt_registration_type_t registration_type = TS_PMT_REGISTRATION_NONE;
5426-
dvbpsi_descriptor_t *p_dr;
5427-
5428-
/* First pass for standard detection */
5429-
if ( p_sys->arib.e_mode == ARIBMODE_AUTO )
5430-
{
5431-
int i_arib_flags = 0; /* Descriptors can be repeated */
5432-
for( p_dr = p_dvbpsipmt->p_first_descriptor; p_dr != NULL; p_dr = p_dr->p_next )
5433-
{
5434-
switch(p_dr->i_tag)
5435-
{
5436-
case 0x09:
5437-
{
5438-
dvbpsi_ca_dr_t *p_cadr = dvbpsi_DecodeCADr( p_dr );
5439-
i_arib_flags |= (p_cadr->i_ca_system_id == 0x05);
5440-
}
5441-
break;
5442-
case 0xF6:
5443-
i_arib_flags |= 1 << 1;
5444-
break;
5445-
case 0xC1:
5446-
i_arib_flags |= 1 << 2;
5447-
break;
5448-
default:
5449-
break;
5450-
}
5451-
}
5452-
if ( i_arib_flags == 0x07 ) //0b111
5453-
p_sys->arib.e_mode = ARIBMODE_ENABLED;
5454-
}
5455-
54565446
ParsePMTRegistrations( p_demux, p_dvbpsipmt->p_first_descriptor, p_pmt, &registration_type );
54575447

54585448
dvbpsi_pmt_es_t *p_dvbpsies;
@@ -5529,10 +5519,10 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
55295519
msg_Dbg( p_demux, " * pid=%d type=0x%x %s",
55305520
p_dvbpsies->i_pid, p_dvbpsies->i_type, psz_typedesc );
55315521

5532-
for( p_dr = p_dvbpsies->p_first_descriptor; p_dr != NULL;
5533-
p_dr = p_dr->p_next )
5522+
for( dvbpsi_descriptor_t *p_dr = p_dvbpsies->p_first_descriptor;
5523+
p_dr != NULL; p_dr = p_dr->p_next )
55345524
{
5535-
msg_Dbg( p_demux, " - descriptor tag 0x%x",
5525+
msg_Dbg( p_demux, " - ES descriptor tag 0x%x",
55365526
p_dr->i_tag );
55375527
}
55385528

@@ -5583,10 +5573,10 @@ static void PMTCallBack( void *data, dvbpsi_pmt_t *p_dvbpsipmt )
55835573
p_dvbpsies->i_pid, (char*)&p_pes->p_es->fmt.i_codec );
55845574
}
55855575

5586-
p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x09 );
5576+
dvbpsi_descriptor_t *p_dr = PMTEsFindDescriptor( p_dvbpsies, 0x09 );
55875577
if( p_dr && p_dr->i_length >= 2 )
55885578
{
5589-
msg_Dbg( p_demux, " * PMT descriptor : CA (0x9) SysID 0x%x",
5579+
msg_Dbg( p_demux, " - ES descriptor : CA (0x9) SysID 0x%x",
55905580
(p_dr->p_data[0] << 8) | p_dr->p_data[1] );
55915581
}
55925582

0 commit comments

Comments
 (0)