@@ -367,10 +367,46 @@ struct SliceHeader {
367367 uint8_t * slice_segment_header_extension_data_byte ; //u(8)
368368};
369369
370+ struct BlockSizes {
371+ uint32_t log2_max_coding_tree_block_size_minus3 ;
372+ uint32_t log2_min_coding_tree_block_size_minus3 ;
373+ uint32_t log2_min_luma_coding_block_size_minus3 ;
374+ uint32_t log2_max_luma_transform_block_size_minus2 ;
375+ uint32_t log2_min_luma_transform_block_size_minus2 ;
376+ uint32_t log2_max_pcm_coding_block_size_minus3 ;
377+ uint32_t log2_min_pcm_coding_block_size_minus3 ;
378+ uint32_t max_max_transform_hierarchy_depth_inter ;
379+ uint32_t min_max_transform_hierarchy_depth_inter ;
380+ uint32_t max_max_transform_hierarchy_depth_intra ;
381+ uint32_t min_max_transform_hierarchy_depth_intra ;
382+ };
383+
384+ struct Features {
385+ uint32_t amp ; //sps->amp_enable_flag
386+ uint32_t constrained_intra_pred ;
387+ uint32_t cu_qp_delta ; // pps->cu_qp_delta_enabled_flag
388+ uint32_t deblocking_filter_disable ;
389+ uint32_t dependent_slices ;
390+ uint32_t pcm ; // sps->pcm_enable_flag
391+ uint32_t sao ; //sps->sample_adaptive_offset_enabled_flag
392+ uint32_t scaling_lists ;
393+ uint32_t separate_colour_planes ;
394+ uint32_t sign_data_hiding ;
395+ uint32_t strong_intra_smoothing ;
396+ uint32_t temporal_mvp ; //sps->sps_temporal_mvp_enabled_flag
397+ uint32_t transform_skip ; // pps->transform_skip_enabled_flag
398+ uint32_t transquant_bypass ;
399+ uint32_t weighted_prediction ;
400+ };
401+
370402static struct VideoParamSet vps ;
371403static struct SeqParamSet sps ;
372404static struct PicParamSet pps ;
373405static struct SliceHeader ssh ;
406+ static struct BlockSizes block_sizes ;
407+ static int use_block_sizes = 0 ;
408+ static struct Features features ;
409+ static int use_features = 0 ;
374410static VADisplay va_dpy ;
375411static VAProfile hevc_profile = ~0 ;
376412static int real_hevc_profile = 0 ;
@@ -746,7 +782,7 @@ void fill_sps_header(struct SeqParamSet *sps, int id)
746782 sps -> sps_seq_parameter_set_id = id ;
747783 sps -> chroma_format_idc = 1 ;
748784 if (sps -> chroma_format_idc == 3 ) {
749- sps -> separate_colour_plane_flag = 0 ;
785+ sps -> separate_colour_plane_flag = use_features ? features . separate_colour_planes : 0 ;
750786 }
751787 frame_width_aligned = ALIGN16 (frame_width );
752788 frame_height_aligned = ALIGN16 (frame_height );
@@ -788,20 +824,21 @@ void fill_sps_header(struct SeqParamSet *sps, int id)
788824 sps -> sps_max_num_reorder_pics [i ] = ip_period != 0 ? ip_period - 1 : 0 ;
789825 sps -> sps_max_latency_increase_plus1 [i ] = 0 ;
790826 }
791- sps -> log2_min_luma_coding_block_size_minus3 = 0 ;
792- int log2_max_luma_coding_block_size = log2 (LCU_SIZE );
827+ sps -> log2_min_luma_coding_block_size_minus3 = use_block_sizes ? block_sizes . log2_min_luma_coding_block_size_minus3 : 0 ;
828+ int log2_max_luma_coding_block_size = use_block_sizes ? block_sizes . log2_max_coding_tree_block_size_minus3 + 3 : log2 (LCU_SIZE );
793829 int log2_min_luma_coding_block_size = sps -> log2_min_luma_coding_block_size_minus3 + 3 ;
794830 sps -> log2_diff_max_min_luma_coding_block_size = log2_max_luma_coding_block_size -
795831 log2_min_luma_coding_block_size ;
796- sps -> log2_min_luma_transform_block_size_minus2 = 0 ;
797- sps -> log2_diff_max_min_luma_transform_block_size = 3 ;
798- sps -> max_transform_hierarchy_depth_inter = 2 ;
799- sps -> max_transform_hierarchy_depth_intra = 2 ;
800- sps -> scaling_list_enabled_flag = 0 ;
801- //sps->sps_scaling_list_data_present_flag; // ignore since scaling_list_enabled_flag equal to 0
802- sps -> amp_enabled_flag = 1 ;
803- sps -> sample_adaptive_offset_enabled_flag = 1 ;
804- sps -> pcm_enabled_flag = 0 ;
832+ sps -> log2_min_luma_transform_block_size_minus2 = use_block_sizes ? block_sizes .log2_min_luma_transform_block_size_minus2 : 0 ;
833+ sps -> log2_diff_max_min_luma_transform_block_size = use_block_sizes ? (block_sizes .log2_max_luma_transform_block_size_minus2 -
834+ sps -> log2_min_luma_transform_block_size_minus2 ) : 3 ;
835+ sps -> max_transform_hierarchy_depth_inter = use_block_sizes ? block_sizes .max_max_transform_hierarchy_depth_inter : 2 ;
836+ sps -> max_transform_hierarchy_depth_intra = use_block_sizes ? block_sizes .max_max_transform_hierarchy_depth_intra : 2 ;
837+ sps -> scaling_list_enabled_flag = use_features ? features .scaling_lists : 0 ;
838+ sps -> sps_scaling_list_data_present_flag = 0 ;
839+ sps -> amp_enabled_flag = use_features ? features .amp : 1 ;
840+ sps -> sample_adaptive_offset_enabled_flag = use_features ? features .sao : 1 ;
841+ sps -> pcm_enabled_flag = use_features ? features .pcm : 0 ;
805842 /* ignore below parameters seting since pcm_enabled_flag equal to 0
806843 pcm_sample_bit_depth_luma_minus1;
807844 pcm_sample_bit_depth_chroma_minus1;
@@ -820,9 +857,9 @@ void fill_sps_header(struct SeqParamSet *sps, int id)
820857 lt_ref_pic_poc_lsb_sps[kMaxLongTermRefPic];
821858 used_by_curr_pic_lt_sps_flag[kMaxLongTermRefPic];
822859 */
823- sps -> sps_temporal_mvp_enabled_flag = 1 ;
824- sps -> strong_intra_smoothing_enabled_flag = 0 ;
825-
860+ sps -> sps_temporal_mvp_enabled_flag = use_features ? features . temporal_mvp : 1 ;
861+ sps -> strong_intra_smoothing_enabled_flag = use_features ? features . strong_intra_smoothing : 0 ;
862+
826863 sps -> vui_parameters_present_flag = 0 ;
827864 sps -> sps_extension_present_flag = 0 ;
828865 /* ignore below parameters seting since sps_extension_present_flag equal to 0
@@ -843,34 +880,34 @@ static void fill_pps_header(
843880
844881 pps -> pps_pic_parameter_set_id = pps_id ;
845882 pps -> pps_seq_parameter_set_id = sps_id ;
846- pps -> dependent_slice_segments_enabled_flag = 0 ;
883+ pps -> dependent_slice_segments_enabled_flag = use_features ? features . dependent_slices : 0 ;
847884 pps -> output_flag_present_flag = 0 ;
848885 pps -> num_extra_slice_header_bits = 0 ;
849- pps -> sign_data_hiding_enabled_flag = 0 ;
886+ pps -> sign_data_hiding_enabled_flag = use_features ? features . sign_data_hiding : 0 ;
850887 pps -> cabac_init_present_flag = 1 ;
851888
852889 pps -> num_ref_idx_l0_default_active_minus1 = 0 ;
853890 pps -> num_ref_idx_l1_default_active_minus1 = 0 ;
854891
855892 pps -> init_qp_minus26 = initial_qp - 26 ;
856- pps -> constrained_intra_pred_flag = 0 ;
857- pps -> transform_skip_enabled_flag = 0 ;
858- pps -> cu_qp_delta_enabled_flag = 1 ;
893+ pps -> constrained_intra_pred_flag = use_features ? features . constrained_intra_pred : 0 ;
894+ pps -> transform_skip_enabled_flag = use_features ? features . transform_skip : 0 ;
895+ pps -> cu_qp_delta_enabled_flag = use_features ? features . cu_qp_delta : 1 ;
859896 if (pps -> cu_qp_delta_enabled_flag )
860897 pps -> diff_cu_qp_delta_depth = 2 ;
861898 pps -> pps_cb_qp_offset = 0 ;
862899 pps -> pps_cr_qp_offset = 0 ;
863900 pps -> pps_slice_chroma_qp_offsets_present_flag = 0 ;
864- pps -> weighted_pred_flag = 0 ;
901+ pps -> weighted_pred_flag = use_features ? features . weighted_prediction : 0 ;
865902 pps -> weighted_bipred_flag = 0 ;
866- pps -> transquant_bypass_enabled_flag = 0 ;
903+ pps -> transquant_bypass_enabled_flag = use_features ? features . transquant_bypass : 0 ;
867904 pps -> entropy_coding_sync_enabled_flag = 0 ;
868905 pps -> tiles_enabled_flag = 0 ;
869906
870907 pps -> pps_loop_filter_across_slices_enabled_flag = 0 ;
871908 pps -> deblocking_filter_control_present_flag = 1 ;
872909 pps -> deblocking_filter_override_enabled_flag = 0 ,
873- pps -> pps_deblocking_filter_disabled_flag = 0 ,
910+ pps -> pps_deblocking_filter_disabled_flag = use_features ? features . deblocking_filter_disable : 0 ,
874911 pps -> pps_beta_offset_div2 = 2 ,
875912 pps -> pps_tc_offset_div2 = 0 ,
876913 pps -> pps_scaling_list_data_present_flag = 0 ;
@@ -893,8 +930,9 @@ static void fill_slice_header(
893930 slice -> pic_order_cnt_lsb = calc_poc ((current_frame_display - current_IDR_display ) % MaxPicOrderCntLsb );
894931
895932 //slice_segment_address (u(v))
896- slice -> picture_height_in_ctus = (frame_height + LCU_SIZE - 1 ) / LCU_SIZE ;
897- slice -> picture_width_in_ctus = (frame_width + LCU_SIZE - 1 ) / LCU_SIZE ;
933+ int lcu_size = use_block_sizes ? (1 << (block_sizes .log2_max_coding_tree_block_size_minus3 + 3 )) : LCU_SIZE ;
934+ slice -> picture_height_in_ctus = (frame_height + lcu_size - 1 ) / lcu_size ;
935+ slice -> picture_width_in_ctus = (frame_width + lcu_size - 1 ) / lcu_size ;
898936 slice -> slice_segment_address = 0 ;
899937 slice -> first_slice_segment_in_pic_flag = ((slice -> slice_segment_address == 0 ) ? 1 : 0 );
900938 slice -> slice_type = current_frame_type == FRAME_P ? (p2b ? SLICE_B : SLICE_P ) :
@@ -908,7 +946,7 @@ static void fill_slice_header(
908946 slice -> strp .num_positive_pics = 0 ;
909947 slice -> slice_sao_luma_flag = 0 ;
910948 slice -> slice_sao_chroma_flag = 0 ;
911- slice -> slice_temporal_mvp_enabled_flag = 1 ;
949+ slice -> slice_temporal_mvp_enabled_flag = use_features ? features . temporal_mvp : 1 ;
912950
913951 slice -> num_ref_idx_l0_active_minus1 = pps -> num_ref_idx_l0_default_active_minus1 ;
914952 slice -> num_ref_idx_l1_active_minus1 = pps -> num_ref_idx_l1_default_active_minus1 ;
@@ -1386,7 +1424,7 @@ static void sliceHeader_rbsp(
13861424 put_ue (bs , slice_header -> num_long_term_pics );
13871425 }
13881426
1389- if (slice_header -> slice_temporal_mvp_enabled_flag )
1427+ if (sps -> sps_temporal_mvp_enabled_flag )
13901428 put_ui (bs , slice_header -> slice_temporal_mvp_enabled_flag , 1 );
13911429
13921430 }
@@ -2168,6 +2206,52 @@ static int init_va(void)
21682206 if (attrib [VAConfigAttribEncMacroblockInfo ].value != VA_ATTRIB_NOT_SUPPORTED ) {
21692207 printf ("Support VAConfigAttribEncMacroblockInfo\n" );
21702208 }
2209+ if (attrib [VAConfigAttribEncHEVCBlockSizes ].value != VA_ATTRIB_NOT_SUPPORTED ) {
2210+ printf ("Support VAConfigAttribEncHEVCBlockSizes\n" );
2211+ uint32_t tmp = attrib [VAConfigAttribEncHEVCBlockSizes ].value ;
2212+ VAConfigAttribValEncHEVCBlockSizes bs = { .value = tmp };
2213+ block_sizes .log2_max_coding_tree_block_size_minus3 = bs .bits .log2_max_coding_tree_block_size_minus3 ;
2214+ block_sizes .log2_min_coding_tree_block_size_minus3 = bs .bits .log2_min_coding_tree_block_size_minus3 ;
2215+ block_sizes .log2_min_luma_coding_block_size_minus3 = bs .bits .log2_min_luma_coding_block_size_minus3 ;
2216+ block_sizes .log2_max_luma_transform_block_size_minus2 = bs .bits .log2_max_luma_transform_block_size_minus2 ;
2217+ block_sizes .log2_min_luma_transform_block_size_minus2 = bs .bits .log2_min_luma_transform_block_size_minus2 ;
2218+ block_sizes .log2_max_pcm_coding_block_size_minus3 = bs .bits .log2_max_pcm_coding_block_size_minus3 ;
2219+ block_sizes .log2_min_pcm_coding_block_size_minus3 = bs .bits .log2_min_pcm_coding_block_size_minus3 ;
2220+ block_sizes .max_max_transform_hierarchy_depth_inter = bs .bits .max_max_transform_hierarchy_depth_inter ;
2221+ block_sizes .min_max_transform_hierarchy_depth_inter = bs .bits .min_max_transform_hierarchy_depth_inter ;
2222+ block_sizes .max_max_transform_hierarchy_depth_intra = bs .bits .max_max_transform_hierarchy_depth_intra ;
2223+ block_sizes .min_max_transform_hierarchy_depth_intra = bs .bits .min_max_transform_hierarchy_depth_intra ;
2224+
2225+ use_block_sizes = 1 ;
2226+ config_attrib [config_attrib_num ].type = VAConfigAttribEncHEVCBlockSizes ;
2227+ config_attrib [config_attrib_num ].value = tmp ;
2228+ config_attrib_num ++ ;
2229+ }
2230+ if (attrib [VAConfigAttribEncHEVCFeatures ].value != VA_ATTRIB_NOT_SUPPORTED ) {
2231+ printf ("Support VAConfigAttribEncHEVCFeatures\n" );
2232+ uint32_t tmp = attrib [VAConfigAttribEncHEVCFeatures ].value ;
2233+ VAConfigAttribValEncHEVCFeatures f = { .value = tmp };
2234+ features .amp = f .bits .amp ;
2235+ features .constrained_intra_pred = f .bits .constrained_intra_pred ;
2236+ features .cu_qp_delta = f .bits .cu_qp_delta ;
2237+ features .deblocking_filter_disable = f .bits .deblocking_filter_disable ;
2238+ features .dependent_slices = f .bits .dependent_slices ;
2239+ features .pcm = f .bits .pcm ;
2240+ features .sao = f .bits .sao ;
2241+ features .scaling_lists = f .bits .scaling_lists ;
2242+ features .separate_colour_planes = f .bits .separate_colour_planes ;
2243+ features .sign_data_hiding = f .bits .sign_data_hiding ;
2244+ features .strong_intra_smoothing = f .bits .strong_intra_smoothing ;
2245+ features .temporal_mvp = f .bits .temporal_mvp ;
2246+ features .transform_skip = f .bits .transform_skip ;
2247+ features .transquant_bypass = f .bits .transquant_bypass ;
2248+ features .weighted_prediction = f .bits .weighted_prediction ;
2249+
2250+ use_features = 1 ;
2251+ config_attrib [config_attrib_num ].type = VAConfigAttribEncHEVCFeatures ;
2252+ config_attrib [config_attrib_num ].value = attrib [VAConfigAttribEncHEVCFeatures ].value ;
2253+ config_attrib_num ++ ;
2254+ }
21712255
21722256 free (entrypoints );
21732257 return 0 ;
@@ -3296,6 +3380,7 @@ int main(int argc, char **argv)
32963380{
32973381 unsigned int start ;
32983382
3383+ va_init_display_args (& argc , argv );
32993384 process_cmdline (argc , argv );
33003385
33013386 print_input ();
0 commit comments