I have corrupted video stream with this header/parameters in the beginning.
[sps]
00 00 00 01
67 64 00 2A AD 84 01 0C 20 08 61 00 43 08 02 18 40 10 C2 00 84 2B 50 3C 01 13 F2 C2 00 00 03 00 02 00 00 03 00 79 08
[pps]
68 EE 3C B0
I’m trying to figure out the actual values, but i didn't.
Does anybody know what other bytes stand for?
I want to know how to calculate video dimensions (Width x Height).
Here you go:
### Sequence Parameter Set
profile_idc 100
constraint_set0_flag 0
constraint_set1_flag 0
constraint_set2_flag 0
constraint_set3_flag 0
level_idc 42
seq_parameter_set_id 0
chroma_format_idc 1
// TODO: ...
// TODO: ...
num_ref_frames 1
gaps_in_frame_num_value_allowed_flag 1
pic_width_in_mbs_minus1 119
pic_height_in_map_units_minus1 67
frame_mbs_only_flag 1
direct_8x8_inference_flag 1
frame_cropping_flag 1
frame_crop_left_offset 0
frame_crop_right_offset 0
frame_crop_top_offset 0
frame_crop_bottom_offset 4
vui_parameters_present_flag 1
// TODO: ...
### Picture Parameter Set
pic_parameter_set_id 0
seq_parameter_set_id 0
entropy_coding_mode_flag 1
num_slice_groups_minus1 0
// TODO: ...
It's 1920x1080 video: you basically parse out the values per specification, and then you calculate the dimensions as described in this post: Fetching the dimensions of a H264Video stream
Specifically:
width = ((pic_width_in_mbs_minus1 + 1) * 16)
- (frame_crop_left_offset + frame_crop_right_offset) * 2
height= (2 - frame_mbs_only_flag) * ((pic_height_in_map_units_minus1 + 1) * 16)
- (frame_crop_top_offset + frame_crop_bottom_offset) * 2
gets you 120 * 16
by 68 * 16 - 8
(Assuming 4:2:0 Color Sampling).
2014-10-10 UPD: I am putting this up from edit/comment:
The conversion from field to frame
(2 - frame_mbs_only_flag)
is applied to the clipping region as well. The x2 for subWidthC and subHeightC is only for Color sampling 4:2:0. 4:4:4, 4:2:2, and Monochrome use x1 for one or both of the x2s.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With