hevc

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 7 Imported by: 9

Documentation

Overview

Copyright (c) 2019,CAOHONGJU All rights reserved. Use of this source code is governed by a MIT-style license that can be found in the LICENSE file.

Translate from FFmpeg cbs_h265.h cbs_h265_syntax_template.c

Index

Constants

View Source
const (
	NalTrailN    = 0
	NalTrailR    = 1
	NalTsaN      = 2
	NalTsaR      = 3
	NalStsaN     = 4
	NalStsaR     = 5
	NalRadlN     = 6
	NalRadlR     = 7
	NalRaslN     = 8
	NalRaslR     = 9
	NalVclN10    = 10
	NalVclR11    = 11
	NalVclN12    = 12
	NalVclR13    = 13
	NalVclN14    = 14
	NalVclR15    = 15
	NalBlaWLp    = 16
	NalBlaWRadl  = 17
	NalBlaNLp    = 18
	NalIdrWRadl  = 19
	NalIdrNLp    = 20
	NalCraNut    = 21
	NalIrapVcl22 = 22
	NalIrapVcl23 = 23
	NalRsvVcl24  = 24
	NalRsvVcl25  = 25
	NalRsvVcl26  = 26
	NalRsvVcl27  = 27
	NalRsvVcl28  = 28
	NalRsvVcl29  = 29
	NalRsvVcl30  = 30
	NalRsvVcl31  = 31
	NalVps       = 32
	NalSps       = 33
	NalPps       = 34
	NalAud       = 35
	NalEosNut    = 36
	NalEobNut    = 37
	NalFdNut     = 38
	NalSeiPrefix = 39
	NalSeiSuffix = 40
	NalRsvNvcl41 = 41
	NalRsvNvcl42 = 42
	NalRsvNvcl43 = 43
	NalRsvNvcl44 = 44
	NalRsvNvcl45 = 45
	NalRsvNvcl46 = 46
	NalRsvNvcl47 = 47
	NalUnspec48  = 48
	NalUnspec49  = 49
	NalUnspec50  = 50
	NalUnspec51  = 51
	NalUnspec52  = 52
	NalUnspec53  = 53
	NalUnspec54  = 54
	NalUnspec55  = 55
	NalUnspec56  = 56
	NalUnspec57  = 57
	NalUnspec58  = 58
	NalUnspec59  = 59
	NalUnspec60  = 60
	NalUnspec61  = 61
	NalUnspec62  = 62
	NalUnspec63  = 63

	// RTP 中扩展
	NalStapInRtp = 48
	NalFuInRtp   = 49
)

*

  • Table 7-1 – NAL unit type codes and NAL unit type classes in
  • T-REC-H.265-201802
View Source
const (
	SliceB = 0
	SliceP = 1
	SliceI = 2
)

HEVC(h265) 的图像片类型

View Source
const (
	// 7.4.3.1: vps_max_layers_minus1 is in [0, 62].
	HEVC_MAX_LAYERS = 63
	// 7.4.3.1: vps_max_sub_layers_minus1 is in [0, 6].
	HEVC_MAX_SUB_LAYERS = 7
	// 7.4.3.1: vps_num_layer_sets_minus1 is in [0, 1023].
	HEVC_MAX_LAYER_SETS = 1024

	// 7.4.2.1: vps_video_parameter_set_id is u(4).
	HEVC_MAX_VPS_COUNT = 16
	// 7.4.3.2.1: sps_seq_parameter_set_id is in [0, 15].
	HEVC_MAX_SPS_COUNT = 16
	// 7.4.3.3.1: pps_pic_parameter_set_id is in [0, 63].
	HEVC_MAX_PPS_COUNT = 64

	// A.4.2: MaxDpbSize is bounded above by 16.
	HEVC_MAX_DPB_SIZE = 16
	// 7.4.3.1: vps_max_dec_pic_buffering_minus1[i] is in [0, MaxDpbSize - 1].
	HEVC_MAX_REFS = HEVC_MAX_DPB_SIZE

	// 7.4.3.2.1: num_short_term_ref_pic_sets is in [0, 64].
	HEVC_MAX_SHORT_TERM_REF_PIC_SETS = 64
	// 7.4.3.2.1: num_long_term_ref_pics_sps is in [0, 32].
	HEVC_MAX_LONG_TERM_REF_PICS = 32

	// A.3: all profiles require that CtbLog2SizeY is in [4, 6].
	HEVC_MIN_LOG2_CTB_SIZE = 4
	HEVC_MAX_LOG2_CTB_SIZE = 6

	// E.3.2: cpb_cnt_minus1[i] is in [0, 31].
	HEVC_MAX_CPB_CNT = 32

	// A.4.1: in table A.6 the highest level allows a MaxLumaPs of 35 651 584.
	HEVC_MAX_LUMA_PS = 35651584
	// A.4.1: pic_width_in_luma_samples and pic_height_in_luma_samples are
	// constrained to be not greater than sqrt(MaxLumaPs * 8).  Hence height/
	// width are bounded above by sqrt(8 * 35651584) = 16888.2 samples.
	HEVC_MAX_WIDTH  = 16888
	HEVC_MAX_HEIGHT = 16888

	// A.4.1: table A.6 allows at most 22 tile rows for any level.
	HEVC_MAX_TILE_ROWS = 22
	// A.4.1: table A.6 allows at most 20 tile columns for any level.
	HEVC_MAX_TILE_COLUMNS = 20

	// A.4.2: table A.6 allows at most 600 slice segments for any level.
	HEVC_MAX_SLICE_SEGMENTS = 600

	// 7.4.7.1: in the worst case (tiles_enabled_flag and
	// entropy_coding_sync_enabled_flag are both set), entry points can be
	// placed at the beginning of every Ctb row in every tile, giving an
	// upper bound of (num_tile_columns_minus1 + 1) * PicHeightInCtbsY - 1.
	// Only a stream with very high resolution and perverse parameters could
	// get near that, though, so set a lower limit here with the maximum
	// possible value for 4K video (at most 135 16x16 Ctb rows).
	HEVC_MAX_ENTRY_POINT_OFFSETS = HEVC_MAX_TILE_COLUMNS * 135
)

Variables

This section is empty.

Functions

func MetadataIsReady added in v1.1.0

func MetadataIsReady(vm *codec.VideoMeta) bool

MetadataIsReady .

func NulType added in v1.1.0

func NulType(nt byte) byte

NulType .

Types

type H265RawHRDParameters added in v1.1.0

type H265RawHRDParameters struct {
	Nal_hrd_parameters_present_flag uint8
	Vcl_hrd_parameters_present_flag uint8

	Sub_pic_hrd_params_present_flag              uint8
	Tick_divisor_minus2                          uint8
	Du_cpb_removal_delay_increment_length_minus1 uint8
	Sub_pic_cpb_params_in_pic_timing_sei_flag    uint8
	Dpb_output_delay_du_length_minus1            uint8

	Bit_rate_scale    uint8
	Cpb_size_scale    uint8
	Cpb_size_du_scale uint8

	Initial_cpb_removal_delay_length_minus1 uint8
	Au_cpb_removal_delay_length_minus1      uint8
	Dpb_output_delay_length_minus1          uint8

	Fixed_pic_rate_general_flag     [HEVC_MAX_SUB_LAYERS]uint8
	Fixed_pic_rate_within_cvs_flag  [HEVC_MAX_SUB_LAYERS]uint8
	Elemental_duration_in_tc_minus1 [HEVC_MAX_SUB_LAYERS]uint16
	Low_delay_hrd_flag              [HEVC_MAX_SUB_LAYERS]uint8
	Cpb_cnt_minus1                  [HEVC_MAX_SUB_LAYERS]uint8
	Nal_sub_layer_hrd_parameters    [HEVC_MAX_SUB_LAYERS]H265RawSubLayerHRDParameters
	Vcl_sub_layer_hrd_parameters    [HEVC_MAX_SUB_LAYERS]H265RawSubLayerHRDParameters
}

type H265RawNALUnitHeader added in v1.1.0

type H265RawNALUnitHeader struct {
	Nal_unit_type         uint8
	Nuh_layer_id          uint8
	Nuh_temporal_id_plus1 uint8
}

type H265RawProfileTierLevel added in v1.1.0

type H265RawProfileTierLevel struct {
	General_profile_space uint8
	General_tier_flag     uint8
	General_profile_idc   uint8

	General_profile_compatibility_flag [32]uint8
	GeneralProfileCompatibilityFlags   uint32 // shortcut flags 32bits

	General_progressive_source_flag    uint8
	General_interlaced_source_flag     uint8
	General_non_packed_constraint_flag uint8
	General_frame_only_constraint_flag uint8

	General_max_12bit_constraint_flag        uint8
	General_max_10bit_constraint_flag        uint8
	General_max_8bit_constraint_flag         uint8
	General_max_422chroma_constraint_flag    uint8
	General_max_420chroma_constraint_flag    uint8
	General_max_monochrome_constraint_flag   uint8
	General_intra_constraint_flag            uint8
	General_one_picture_only_constraint_flag uint8
	General_lower_bit_rate_constraint_flag   uint8
	General_max_14bit_constraint_flag        uint8

	General_inbld_flag              uint8
	GeneralConstraintIndicatorFlags uint64 // shortcut flags 48bits

	General_level_idc uint8

	Sub_layer_profile_present_flag [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_level_present_flag   [HEVC_MAX_SUB_LAYERS]uint8

	Sub_layer_profile_space [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_tier_flag     [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_profile_idc   [HEVC_MAX_SUB_LAYERS]uint8

	Sub_layer_profile_compatibility_flag [HEVC_MAX_SUB_LAYERS][32]uint8

	Sub_layer_progressive_source_flag    [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_interlaced_source_flag     [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_non_packed_constraint_flag [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_frame_only_constraint_flag [HEVC_MAX_SUB_LAYERS]uint8

	Sub_layer_max_12bit_constraint_flag        [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_max_10bit_constraint_flag        [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_max_8bit_constraint_flag         [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_max_422chroma_constraint_flag    [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_max_420chroma_constraint_flag    [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_max_monochrome_constraint_flag   [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_intra_constraint_flag            [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_one_picture_only_constraint_flag [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_lower_bit_rate_constraint_flag   [HEVC_MAX_SUB_LAYERS]uint8
	Sub_layer_max_14bit_constraint_flag        [HEVC_MAX_SUB_LAYERS]uint8

	Sub_layer_inbld_flag [HEVC_MAX_SUB_LAYERS]uint8

	Sub_layer_level_idc [HEVC_MAX_SUB_LAYERS]uint8
}

type H265RawSPS added in v1.1.0

type H265RawSPS struct {
	Nal_unit_header H265RawNALUnitHeader

	Sps_video_parameter_set_id uint8

	Sps_max_sub_layers_minus1    uint8
	Sps_temporal_id_nesting_flag uint8

	Profile_tier_level H265RawProfileTierLevel

	Sps_seq_parameter_set_id uint8

	Chroma_format_idc          uint8
	Separate_colour_plane_flag uint8

	Pic_width_in_luma_samples  uint16
	Pic_height_in_luma_samples uint16

	Conformance_window_flag uint8
	Conf_win_left_offset    uint16
	Conf_win_right_offset   uint16
	Conf_win_top_offset     uint16
	Conf_win_bottom_offset  uint16

	Bit_depth_luma_minus8   uint8
	Bit_depth_chroma_minus8 uint8

	Log2_max_pic_order_cnt_lsb_minus4 uint8

	Sps_sub_layer_ordering_info_present_flag uint8
	Sps_max_dec_pic_buffering_minus1         [HEVC_MAX_SUB_LAYERS]uint8
	Sps_max_num_reorder_pics                 [HEVC_MAX_SUB_LAYERS]uint8
	Sps_max_latency_increase_plus1           [HEVC_MAX_SUB_LAYERS]uint32

	Log2_min_luma_coding_block_size_minus3      uint8
	Log2_diff_max_min_luma_coding_block_size    uint8
	Log2_min_luma_transform_block_size_minus2   uint8
	Log2_diff_max_min_luma_transform_block_size uint8
	Max_transform_hierarchy_depth_inter         uint8
	Max_transform_hierarchy_depth_intra         uint8

	Scaling_list_enabled_flag          uint8
	Sps_scaling_list_data_present_flag uint8
	Scaling_list                       *H265RawScalingList

	Amp_enabled_flag                    uint8
	Sample_adaptive_offset_enabled_flag uint8

	Pcm_enabled_flag                             uint8
	Pcm_sample_bit_depth_luma_minus1             uint8
	Pcm_sample_bit_depth_chroma_minus1           uint8
	Log2_min_pcm_luma_coding_block_size_minus3   uint8
	Log2_diff_max_min_pcm_luma_coding_block_size uint8
	Pcm_loop_filter_disabled_flag                uint8

	Num_short_term_ref_pic_sets uint8
	St_ref_pic_set              []H265RawSTRefPicSet //[HEVC_MAX_SHORT_TERM_REF_PIC_SETS]H265RawSTRefPicSet

	Long_term_ref_pics_present_flag uint8
	Num_long_term_ref_pics_sps      uint8
	Lt_ref_pic_poc_lsb_sps          [HEVC_MAX_LONG_TERM_REF_PICS]uint16
	Used_by_curr_pic_lt_sps_flag    [HEVC_MAX_LONG_TERM_REF_PICS]uint8

	Sps_temporal_mvp_enabled_flag       uint8
	Strong_intra_smoothing_enabled_flag uint8

	Vui_parameters_present_flag uint8
	Vui                         H265RawVUI

	Sps_extension_present_flag    uint8
	Sps_range_extension_flag      uint8
	Sps_multilayer_extension_flag uint8
	Sps_3d_extension_flag         uint8
	Sps_scc_extension_flag        uint8
	Sps_extension_4bits           uint8
}

func (*H265RawSPS) Decode added in v1.1.0

func (sps *H265RawSPS) Decode(data []byte) (err error)

Decode 从字节序列中解码 sps NAL

func (*H265RawSPS) DecodeString added in v1.1.0

func (sps *H265RawSPS) DecodeString(b64 string) error

DecodeString 从 base64 字串解码 sps NAL

func (*H265RawSPS) FrameRate added in v1.1.0

func (sps *H265RawSPS) FrameRate() float64

FrameRate Video frame rate

func (*H265RawSPS) Height added in v1.1.0

func (sps *H265RawSPS) Height() int

Height 视频高度(像素)

func (*H265RawSPS) IsFixedFrameRate added in v1.1.0

func (sps *H265RawSPS) IsFixedFrameRate() bool

IsFixedFrameRate 是否固定帧率

func (*H265RawSPS) Width added in v1.1.0

func (sps *H265RawSPS) Width() int

Width 视频宽度(像素)

type H265RawSTRefPicSet added in v1.1.0

type H265RawSTRefPicSet struct {
	Inter_ref_pic_set_prediction_flag uint8

	Delta_idx_minus1     uint8
	Delta_rps_sign       uint8
	Abs_delta_rps_minus1 uint16

	Used_by_curr_pic_flag [HEVC_MAX_REFS]uint8
	Use_delta_flag        [HEVC_MAX_REFS]uint8

	Num_negative_pics        uint8
	Num_positive_pics        uint8
	Delta_poc_s0_minus1      [HEVC_MAX_REFS]uint16
	Used_by_curr_pic_s0_flag [HEVC_MAX_REFS]uint8
	Delta_poc_s1_minus1      [HEVC_MAX_REFS]uint16
	Used_by_curr_pic_s1_flag [HEVC_MAX_REFS]uint8
}

type H265RawScalingList added in v1.1.0

type H265RawScalingList struct {
	Scaling_list_pred_mode_flag       [4][6]uint8
	Scaling_list_pred_matrix_id_delta [4][6]uint8
	Scaling_list_dc_coef_minus8       [4][6]int16
	Scaling_list_delta_coeff          [4][6][64]int8
}

type H265RawSubLayerHRDParameters added in v1.1.0

type H265RawSubLayerHRDParameters struct {
	Bit_rate_value_minus1    [HEVC_MAX_CPB_CNT]uint32
	Cpb_size_value_minus1    [HEVC_MAX_CPB_CNT]uint32
	Cpb_size_du_value_minus1 [HEVC_MAX_CPB_CNT]uint32
	Bit_rate_du_value_minus1 [HEVC_MAX_CPB_CNT]uint32
	Cbr_flag                 [HEVC_MAX_CPB_CNT]uint8
}

type H265RawVPS added in v1.1.0

type H265RawVPS struct {
	Nal_unit_header H265RawNALUnitHeader

	Vps_video_parameter_set_id uint8

	Vps_base_layer_internal_flag  uint8
	Vps_base_layer_available_flag uint8
	Vps_max_layers_minus1         uint8
	Vps_max_sub_layers_minus1     uint8
	Vps_temporal_id_nesting_flag  uint8

	Profile_tier_level H265RawProfileTierLevel

	Vps_sub_layer_ordering_info_present_flag uint8
	Vps_max_dec_pic_buffering_minus1         [HEVC_MAX_SUB_LAYERS]uint8
	Vps_max_num_reorder_pics                 [HEVC_MAX_SUB_LAYERS]uint8
	Vps_max_latency_increase_plus1           [HEVC_MAX_SUB_LAYERS]uint32

	Vps_max_layer_id          uint8
	Vps_num_layer_sets_minus1 uint16
	Layer_id_included_flag    [][HEVC_MAX_LAYERS]uint8 //[HEVC_MAX_LAYER_SETS][HEVC_MAX_LAYERS]uint8

	Vps_timing_info_present_flag        uint8
	Vps_num_units_in_tick               uint32
	Vps_time_scale                      uint32
	Vps_poc_proportional_to_timing_flag uint8
	Vps_num_ticks_poc_diff_one_minus1   uint32
	Vps_num_hrd_parameters              uint16
	Hrd_layer_set_idx                   []uint16               //[HEVC_MAX_LAYER_SETS]uint16
	Cprms_present_flag                  []uint8                //[HEVC_MAX_LAYER_SETS]uint8
	Hrd_parameters                      []H265RawHRDParameters //[HEVC_MAX_LAYER_SETS]H265RawHRDParameters

	Vps_extension_flag uint8
}

func (*H265RawVPS) Decode added in v1.1.0

func (vps *H265RawVPS) Decode(data []byte) (err error)

Decode 从字节序列中解码 vps NAL

func (*H265RawVPS) DecodeString added in v1.1.0

func (vps *H265RawVPS) DecodeString(b64 string) error

DecodeString 从 base64 字串解码 vps NAL

type H265RawVUI added in v1.1.0

type H265RawVUI struct {
	Aspect_ratio_info_present_flag uint8
	Aspect_ratio_idc               uint8
	Sar_width                      uint16
	Sar_height                     uint16

	Overscan_info_present_flag uint8
	Overscan_appropriate_flag  uint8

	Video_signal_type_present_flag  uint8
	Video_format                    uint8
	Video_full_range_flag           uint8
	Colour_description_present_flag uint8
	Colour_primaries                uint8
	Transfer_characteristics        uint8
	Matrix_coefficients             uint8

	Chroma_loc_info_present_flag        uint8
	Chroma_sample_loc_type_top_field    uint8
	Chroma_sample_loc_type_bottom_field uint8

	Neutral_chroma_indication_flag uint8
	Field_seq_flag                 uint8
	Frame_field_info_present_flag  uint8

	Default_display_window_flag uint8
	Def_disp_win_left_offset    uint16
	Def_disp_win_right_offset   uint16
	Def_disp_win_top_offset     uint16
	Def_disp_win_bottom_offset  uint16

	Vui_timing_info_present_flag        uint8
	Vui_num_units_in_tick               uint32
	Vui_time_scale                      uint32
	Vui_poc_proportional_to_timing_flag uint8
	Vui_num_ticks_poc_diff_one_minus1   uint32
	Vui_hrd_parameters_present_flag     uint8
	Hrd_parameters                      H265RawHRDParameters

	Bitstream_restriction_flag              uint8
	Tiles_fixed_structure_flag              uint8
	Motion_vectors_over_pic_boundaries_flag uint8
	Restricted_ref_pic_lists_flag           uint8
	Min_spatial_segmentation_idc            uint16
	Max_bytes_per_pic_denom                 uint8
	Max_bits_per_min_cu_denom               uint8
	Log2_max_mv_length_horizontal           uint8
	Log2_max_mv_length_vertical             uint8
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL