View Full Version : Who is familiar with ISO 13818-1 ?
oof
15th November 2003, 20:42
I know lots of you guys have read the MPEG2 System spec.
I'm trying to parse a system file.
I find a number of occurences similar to the following:
for( i = 0 ; i < N ; i++ ) {
some_kind_of_byte
}
The problem is that they never explain where they get N
(or N1 or N2)
Several, but not all, have a "count" field of some sort immediately
before the loop, which I guess is N. I have of course searched for N1
but no luck.
Anybody know ?
unixfs
16th November 2003, 09:20
Hi,
are you parsing the PSM or the PMT?
Usually just before those magic N numbers there are:
1) the total length in bytes of the block of descriptors
2) the length in bytes of the current descriptor,
that's why you don't need to know the value of N;
just set a variable to the size of the global length and decrease it
by the length of the current descriptor.
oof
16th November 2003, 16:47
The one that bothers me the most is the PES packet
I can't figure out what N1 and N2 are
I hate to put the whole thing in here but here it is:
Table 2-18 -- PES packet
Syntax No. of Bits Mnemonic
PES_packet() {
packet_start_code_prefix 24 bslbf
stream_id 8 uimsbf
PES_packet_length 16 uimsbf
if( stream_id != program_stream_map
&& stream_id != padding_stream
&& stream_id != private_stream_2
&& stream_id != ECM
&& stream_id != EMM
&& stream_id != program_stream_directory
&& stream_id != DSMCC_stream
&& stream_id != ITU-T Rec. H.222.1 type E_stream) {
'10' 2 bslbf
PES_scrambling_control 2 bslbf
PES_priority 1 bslbf
data_alignment_indicator 1 bslbf
copyright 1 bslbf
original_or_copy 1 bslbf
PTS_DTS_flags 2 bslbf
ESCR_flag 1 bslbf
ES_rate_flag 1 bslbf
DSM_trick_mode_flag 1 bslbf
additional_copy_info_flag 1 bslbf
PES_CRC_flag 1 bslbf
PES_extension_flag 1 bslbf
PES_header_data_length 8 uimsbf
if (PTS_DTS_flags =='10' ) {
'0010' 4 bslbf
PTS [32..30] 3 bslbf
marker_bit 1 bslbf
PTS [29..15] 15 bslbf
marker_bit 1 bslbf
PTS [14..0] 15 bslbf
marker_bit 1 bslbf
}
if (PTS_DTS_flags ==‘11’ ) {
'0011' 4 bslbf
PTS [32..30] 3 bslbf
marker_bit 1 bslbf
PTS [29..15] 15 bslbf
marker_bit 1 bslbf
PTS [14..0] 15 bslbf
marker_bit 1 bslbf
'0001' 4 bslbf
DTS [32..30] 3 bslbf
marker_bit 1 bslbf
DTS [29..15] 15 bslbf
marker_bit 1 bslbf
DTS [14..0] 15 bslbf
marker_bit 1 bslbf
}
if (ESCR_flag=='1') {
reserved 2 bslbf
ESCR_base[32..30] 3 bslbf
marker_bit 1 bslbf
ESCR_base[29..15] 15 bslbf
marker_bit 1 bslbf
ESCR_base[14..0] 15 bslbf
marker_bit 1 bslbf
ESCR_extension 9 uimsbf
marker_bit 1 bslbf
}
if (ES_rate_flag == '1') {
marker_bit 1 bslbf
ES_rate 22 uimsbf
marker_bit 1 bslbf
}
if (DSM_trick_mode_flag == '1') {
trick_mode_control 3 uimsbf
if ( trick_mode_control == fast_forward ) {
field_id 2 bslbf
intra_slice_refresh 1 bslbf
frequency_truncation 2 bslbf
}
else if ( trick_mode_control == slow_motion ) {
rep_cntrl 5 uimsbf
}
else if ( trick_mode_control == freeze_frame) {
field_id 2 uimsbf
reserved 3 bslbf
}
else if ( trick_mode_control == fast_reverse' ) {
field_id 2 bslbf
intra_slice_refresh 1 bslbf
frequency_truncation 2 bslbf
else if ( trick_mode_control == slow_reverse ) {
rep_cntrl 5 uimsbf
}
else
reserved 5 bslbf
}
if ( additional_copy_info_flag == '1' ) {
marker_bit 1 bslbf
additional_copy_info 7 bslbf
}
if ( PES_CRC_flag == '1' ) {
previous_PES_packet_CRC 16 bslbf
}
if ( PES_extension_flag == '1' ) {
PES_private_data_flag 1 bslbf
pack_header_field_flag 1 bslbf
program_packet_sequence_counter_flag 1 bslbf
P-STD_buffer_flag 1 bslbf
reserved 3 bslbf
PES_extension_flag_2 1 bslbf
if ( PES_private_data_flag == '1' ) {
PES_private_data 128 bslbf
}
if (pack_header_field_flag == '1' ) {
pack_field_length 8 uimsbf
pack_header()
}
if(program_packet_sequence_counter_flag== '1'){
marker_bit 1 bslbf
program_packet_sequence_counter 7 uimsbf
marker_bit 1 bslbf
MPEG1_MPEG2_identifier 1 bslbf
original_stuff_length 6 uimsbf
}
if ( P-STD_buffer_flag == '1' ) {
'01' 2 bslbf
P-STD_buffer_scale 1 bslbf
P-STD_buffer_size 13 uimsbf
}
if ( PES_extension_flag_2 == '1'){
marker_bit 1 bslbf
PES_extension_field_length 7 uimsbf
for(i=0;i<PES_extension_field_length;i++) {
reserved 8 bslbf
}
}
}
for (i=0;i<N1;i++) {
stuffing_byte 8 bslbf
}
for (i=0;i<N2;i++) {
PES_packet_data_byte 8 bslbf
}
}
else if ( stream_id == program_stream_map
|| stream_id == private_stream_2
|| stream_id == ECM
|| stream_id == EMM
|| stream_id == program_stream_directory
|| stream_id == DSMCC_stream)
|| stream_id == ITU-T Rec. H.222.1 type E stream {
for ( i=0;i<PES_packet_length;i++) {
PES_packet_data_byte 8 bslbf
}
}
else if ( stream_id == padding_stream) {
for ( i=0;i<PES_packet_length;i++) {
padding_byte 8 bslbf
}
}
}
unixfs
16th November 2003, 17:14
N1) stuFFing_byte is a repetition of no more than 32 0xFF bytes, so
something like
count=0; while(next_byte == 0xff && count <32);
will do
N2)pes_packet_data_byte is the PES payload; its length (N2) is
PES_packet_length - length(all previous headers)
Hope it helps.
oof
16th November 2003, 19:15
That helps lots. Thanks. Why don't they say so ?
Or did they and I missed it ?
If I was a compiler I would say "undefined variable" :)
unixfs
16th November 2003, 20:13
Many things are still a mistery to me.
I would definitively love a simplified explanation of these
topics, or a redefinition of MPEG syntax in simpler and shorter terms, ("MPEG complete for dummies") :)
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.