internal VpsExtension(ref BitReader reader, byte vps_max_layers, bool vps_base_layer_internal_flag, byte vps_max_sub_layers) { // F.7.3.2.1.1 Video parameter set extension syntax, page 444 // F.7.4.3.1.1 Video parameter set extension semantics, page 464 if (vps_max_layers > 1 && vps_base_layer_internal_flag) { ProfileTierLevel.skip(ref reader, false, vps_max_sub_layers); } bool splitting_flag = reader.readBit(); int NumScalabilityTypes = NumberOfSetBits(reader.readInt(16)); // scalability_mask_flag[ i ] Span <byte> dimension_id_len = stackalloc byte[NumScalabilityTypes]; for (int j = 0; j < (NumScalabilityTypes - ((splitting_flag) ? 1 : 0)); j++) { dimension_id_len[j] = (byte)(reader.readInt(3) + 1); // dimension_id_len_minus1[ j ] } bool vps_nuh_layer_id_present_flag = reader.readBit(); for (int i = 1; i < vps_max_layers; i++) { if (vps_nuh_layer_id_present_flag) { reader.skipBits(6); // layer_id_in_nuh[ i ] } if (!splitting_flag) { for (int j = 0; j < NumScalabilityTypes; j++) { reader.skipBits(dimension_id_len[j]); // dimension_id[ i ][ j ] } } } byte view_id_len = reader.readByte(4); /* int NumViews = 1; * for( int i = 1; i < vps_max_layers; i++ ) * { * bool newViewFlag = true; * for( int j = 0; j < i; j++ ) * { * if( ViewOrderIdx[ lId ] = ViewOrderIdx[ layer_id_in_nuh[ j ] ] ) newViewFlag = 0 * } * } * * if( view_id_len > 0 ) * { * for( int i = 0; i < NumViews; i++ ) * { * * } * } */ }
public SequenceParameterSet(ReadOnlySpan <byte> span, Dictionary <byte, VideoParameterSet> vpsDict, byte nuh_layer_id = 0) { // System.IO.File.WriteAllBytes( @"C:\Temp\2remove\mkv\sps.bin", span.ToArray() ); // MiscUtils.writeBinaryText( @"C:\Temp\2remove\mkv\sps.txt", span ); BitReader reader = new BitReader(span); checked { // F.7.3.2.2.1 General sequence parameter set RBSP syntax, page 450 vpsId = reader.readByte(4); // sps_video_parameter_set_id VideoParameterSet vps = vpsDict[vpsId]; maxSubLayers = (byte)(reader.readInt(3) + 1); // sps_max_sub_layers_minus1 or sps_ext_or_max_sub_layers_minus1 sps_temporal_id_nesting_flag = reader.readBit(); // const bool MultiLayerExtSpsFlag = false; // nuh_layer_id != 0 && sps_ext_or_max_sub_layers_minus1 = = 7 ProfileTierLevel.skip(ref reader, true, maxSubLayers); sps_seq_parameter_set_id = reader.unsignedGolomb(); chromaFormat = (eChromaFormat)reader.unsignedGolomb(); if (chromaFormat == eChromaFormat.c444) { separate_colour_plane_flag = reader.readBit(); } else { separate_colour_plane_flag = false; } CSize size = default; size.cx = (int)reader.unsignedGolomb(); size.cy = (int)reader.unsignedGolomb(); CRect rc; if (reader.readBit()) // conformance_window_flag { rc = default; int scalingX = (chromaFormat < eChromaFormat.c444) ? 2 : 1; rc.left = scalingX * (int)reader.unsignedGolomb(); // conf_win_vps_left_offset rc.right = size.cx - scalingX * (int)reader.unsignedGolomb(); // conf_win_vps_right_offset int scalingY = (chromaFormat < eChromaFormat.c422) ? 2 : 1; rc.top = scalingY * (int)reader.unsignedGolomb(); // conf_win_vps_top_offset rc.bottom = size.cy - scalingY * (int)reader.unsignedGolomb(); // conf_win_vps_bottom_offset } else { rc = new CRect(default, size);