Created
October 8, 2019 15:13
-
-
Save gyf304/e0144d0b0a010f0b0d4dc77415360862 to your computer and use it in GitHub Desktop.
Kaitai NAL byte-stream parser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meta: | |
id: nal_byte_stream | |
file-extension: h264 | |
endian: be | |
license: CC0-1.0 | |
doc-ref: https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.264-200305-S!!PDF-E&type=items | |
seq: | |
- id: nal_byte_stream_segments | |
type: nal_byte_stream_segment | |
repeat: eos | |
types: | |
nal_byte_stream_segment: | |
seq: | |
- id: start_code | |
type: start_code | |
- id: nal_unit | |
type: nal_unit | |
start_code: | |
seq: | |
- id: look_ahead | |
type: start_code_look_ahead | |
- id: start_code | |
size: look_ahead.type_1 == 1 ? 3 : look_ahead.type_2 == 1 ? 4 : 0 | |
nal_unit: | |
seq: | |
- id: forbidden_zero_bit | |
type: b1 | |
- id: nal_ref_idc | |
type: b2 | |
- id: nal_unit_type | |
type: b5 | |
enum: nal_unit_type | |
- id: rbsp | |
type: rbsp | |
rbsp: | |
seq: | |
- id: payload_segment | |
type: payload_segment | |
repeat: until | |
repeat-until: _.look_ahead.valid or _io.eof | |
payload_segment: | |
seq: | |
- id: data | |
size: 1 | |
- id: look_ahead | |
type: start_code_look_ahead | |
start_code_look_ahead: | |
seq: [] | |
instances: | |
type_1: | |
pos: _io.pos | |
type: b24 | |
if: _io.pos + 4 < _io.size | |
type_2: | |
pos: _io.pos | |
type: u4 | |
if: _io.pos + 4 < _io.size | |
valid: | |
value: _io.pos + 4 < _io.size and (type_1 == 1 or type_2 == 1) | |
enums: | |
nal_unit_type: | |
1: slice_layer_without_partitioning | |
2: slice_data_partition_a_layer | |
3: slice_data_partition_b_layer | |
4: slice_data_partition_c_layer | |
5: slice_layer_without_partitioning | |
6: sei | |
7: seq_parameter_set | |
8: pic_parameter_set | |
9: access_unit_delimiter | |
10: end_of_seq | |
11: end_of_stream | |
12: filler_data | |
13: seq_parameter_set_extension | |
14: prefix_nal_unit | |
15: subset_seq_parameter_set | |
19: slice_layer_without_partitioning | |
20: slice_layer_extension | |
21: slice_layer_extension_for_depth_view |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment