Log in

View Full Version : About certain fields in VOB


unixfs
20th August 2004, 10:26
Hi,
can anyone answer these questions, please?

1) are the system header and the P_STD optional? if not when should I insert them ?

2) when muxing mp2 audio can I PACK as many frames up to the 2048
pack limit or should I respect an upper bound?
For each PACK, should I pack frames in a single pes packet or in N?
The PTS should be the one corresponding to the first frame, right?

Thanks very much.

jj59
20th August 2004, 20:53
Hi

I'll try to give you some info but I can't verify if it's correct.

Your first question depends on which P-STD you are looking for NV_PCK or PES_Packet

NV_PCK
The MPEG system stream also has a 24-byte System Header. The System header has to be located in the NV_PCK. The same header data should be used in each VOBU for the entire VOBS (Video Object Set).
The system header is defined in the MPEG-2 system layer in 2.5.3.5 and 2.5.3.6. A 4-byte system header start code (000001BBh), 2-byte header length and system parameters construct the system header. Further described are four entries (all Video, all Audio, private_1, private_2) which shall appear in the system_header.

System_header_start_ code shall be 000001BBh

Header_length number of bytes following this field (18 bytes) 0012h

The system_header's parameters:
- audio_bound shall be between 0 and 8
- fixed_flag shall be 0 (variable bit rate).
- CSPS_flag shall be 0.
- system_audio_lock_flag shall be 1
- system_video_lock_flag shall be 1
- video_bound shall be 1

In the system_header:
The order of the entries in the system_header shall be
1. all Video streams the stream_id for all Video shall be 1011 1001b (0xB9)
2. all Audio streams the stream_id for all Audio shall be 1011 1000b (0xB8)
3. private_stream_1 the stream_id for private_1 shall be 1011 1101b (0xBD)
4. private_stream_2 the stream_id for private_2 shall be 1011 1111b (0xBF)
All four entries (all Video, all Audio, private_1, private_2) shall appear in the system_header.

The system_header's P-STD_buf_bound_scale shall be
- buf_size x 1024 bytes for all video streams
- buf_size x 128 bytes for all audio streams
- buf_size x 1024 bytes for private_stream_1
- buf_size x 1024 bytes for private_stream_2

The system_header's P-STD_buf_size_bound shall be
- 237568 bytes for all video streams (232)
- 4096 bytes for all audio streams (32)
- 59392 bytes for private_stream_1 (58)
- 2048 bytes for private_stream_2 (2)

PES_Packet
The only allowed PES_extension data in Video, Audio and SPU packets are the P-STD parameters, whenever the PES_extension_flag is set the packet shall belong to the first VOBU of the VOB.
Only the FIRST PES_Packet may have P-STD parameters encoded. Sub-picture packets and probably also Audio packets can start well after the first VOBU!
PES_extension is only allowed and expected for the first packet of a VOB.

PES_private_data_flag shall be 0
pack_header_field_flag shall be 0
program_packet_sequence_counter_flag shall be 0
PES_extension_flag_2 shall be 0
P-STD_buffer_flag shall be 1.

P-STD_buffer_scale value shall be set to:
0 = unit is 128 bytes
1 = unit is 1024 bytes
MPEG audio is set to 0 (128 bytes)
Private_stream_1 (AC3, DTS, LPCM) is set to 1 (1024 bytes)

P_STD_buffer_size value shall be set to: 46 (MPEG-1)
P_STD_buffer_size value shall be set to: 232 (MPEG-2)
P_STD_buffer_size value shall be set to: 58 (private_stream_1)

http://forum.doom9.org/showthread.php?s=&threadid=66777&perpage=20&pagenumber=2
submux-dvd sources might be helpful and

http://forum.doom9.org/showthread.php?s=&threadid=64377

For the second question I think you're better of by examining the sources of mplex or lvemux or Nic's muxer in Rejig.

I don't think you can put 2048 bytes of audio data in one pack.
The pack header takes 14 bytes, the length of a packet header can vary between 9 and 24 bytes, the first 9 bytes which are always present are packet_start_code_prefix, stream_id, PES_packet_length, extension flags and control and PES_header_data_length.

An Audio PES_packet has a 9-byte packet header when:
The Audio PES_packet does not contain the first sample of an audio frame.
The Audio PES_packet is the LAST Audio PES_packet of a VOB.
The Audio PES_packet is directly before an audio gap.
PTS_DTS_flags value shall be 00b (no PTS/DTS present).
PES_extension_flag is 0.

An Audio PES_packet has a 14-byte packet header when:
The Audio PES_packet contains the first sample of an audio frame.
PTS_DTS_flags value shall be 10b (PTS present).
PES_extension_flag is 0.
PTS is set.

An Audio PES_packet has a 17-byte packet header when:
The Audio PES_packet is the FIRST packet of a VOB.
PTS_DTS_flags value shall be 10b (PTS present).
PES_extension_flag is 1.
P-STD_buffer_flag shall be 1.
P-STD_buffer parameters are set.
Only the FIRST PES_Packet may have P-STD parameters encoded.The only allowed PES_extension data are the P-STD parameters, whenever the PES_extension_flag is set the packet shall belong to the first VOBU of the VOB.

Sub-picture packets and probably also Audio packets can start well after the first VOBU!

If the pack length needs to be adjusted by 1 to 7 stuffing bytes are added to the packet header, the maximum size of the packet header is 24 bytes. When the pack length adjustment is 8 bytes or more a padding packet is inserted.

So you should (in theory) be able to put 2025/2020/2017 (depending on the position in the VOB) or less in an audiopacket the audiopack needs to be 2048 bytes with stuffing/padding. I'm not sure if the 2025 case would be allowed I haven't seen any of them if allowed they seem very rare because usually it's just the last couple of frames or last part of a frame which ususally is padded. So the maximum is (I guess) 2020.
Perhaps someone more knowledgeable can shed some light.
Hope this helps a little
Just out of curiosity were do you need it for, building a muxer?

Regards
jj

unixfs
20th August 2004, 21:17
Thanks for your explanation, it's very useful !
I'm patching (really rewriting almost from scratch) mencoder's muxer
to be able to write different MPEG target types, one of which is DVD with fake Nav Packets.
I hope to complete it :)