--- va.h.orig 2011-08-16 22:08:32.055187500 -0700 +++ va.h 2011-08-01 10:17:21.436797200 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007-2009 Intel Corporation. All Rights Reserved. + * Copyright (c) 2007-2011 Intel Corporation. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -24,7 +24,7 @@ /* * Video Acceleration (VA) API Specification * - * Rev. 0.30 + * Rev. 0.32.2 * * * Revision History: @@ -61,6 +61,10 @@ * screen relative rather than source video relative. * rev 0.32.0 (01/13/2011 Xiang Haihao) - Add profile into VAPictureParameterBufferVC1 * update VAAPI to 0.32.0 + * rev 0.32.1 (05/04/2011) - Linux VA encoding API extension proposal + * + * + * rev 0.32.2 (07/05/2011 Jonathan Bian/Andrey Yakovenko) - Video Processing interface * * Acknowledgements: * Some concepts borrowed from XvMC and XvImage. @@ -223,9 +227,13 @@ const char *func ); +#define VA_ENUM_MAX 16384 + + /* Currently defined profiles */ typedef enum { + VAProfileNone = -1, /* to be used for post-processing etc. */ VAProfileMPEG2Simple = 0, VAProfileMPEG2Main = 1, VAProfileMPEG4Simple = 2, @@ -239,11 +247,11 @@ VAProfileVC1Advanced = 10, VAProfileH263Baseline = 11, VAProfileJPEGBaseline = 12, - VAProfileH264ConstrainedBaseline = 13 + VAProfileH264ConstrainedBaseline = 13, + VAProfileMax = VA_ENUM_MAX } VAProfile; /* - * Currently defined entrypoints */ typedef enum { @@ -253,7 +261,9 @@ VAEntrypointMoComp = 4, VAEntrypointDeblocking = 5, VAEntrypointEncSlice = 6, /* slice level encode */ - VAEntrypointEncPicture = 7 /* pictuer encode, JPEG, etc */ + VAEntrypointEncPicture = 7, /* pictuer encode, JPEG, etc */ + VAEntrypointVideoProc = 8, /* video pre/post processing */ + VAEntrypointMax = VA_ENUM_MAX } VAEntrypoint; /* Currently defined configuration attribute types */ @@ -264,7 +274,12 @@ VAConfigAttribSpatialClipping = 2, VAConfigAttribIntraResidual = 3, VAConfigAttribEncryption = 4, - VAConfigAttribRateControl = 5 + VAConfigAttribStartCodeAndEPB = 5, + VAConfigAttribRateControl = 30, /*encode related attributes starting here */ + VAConfigAttribEncHeaderPacking = 31, + VAConfigAttribEncInterlaced = 32, + VAConifgAttribEncSliceStructure = 33, + VAConfigAttribTypeMax = VA_ENUM_MAX } VAConfigAttribType; /* @@ -282,14 +297,37 @@ #define VA_RT_FORMAT_YUV420 0x00000001 #define VA_RT_FORMAT_YUV422 0x00000002 #define VA_RT_FORMAT_YUV444 0x00000004 +#define VA_RT_FORMAT_RGB 0x00000010 #define VA_RT_FORMAT_PROTECTED 0x80000000 +/* attribute value for VAConfigAttribStartCodeAndEPB */ +#define VA_STARTCODE_AND_EPB_NO_SKIP 0x00000000 /* include start code and EPB when setting up slice params */ +#define VA_STARTCODE_AND_EBP_SKIP 0x00000001 /* skip start code and EPB when setting up slice params */ + /* attribute value for VAConfigAttribRateControl */ #define VA_RC_NONE 0x00000001 #define VA_RC_CBR 0x00000002 #define VA_RC_VBR 0x00000004 #define VA_RC_VCM 0x00000008 /* video conference mode */ +/* attribute value for VAConfigAttribEncHeaderPacking */ +#define VA_ENC_HEADER_PACKING_NONE 0x00000000 +#define VA_ENC_HEADER_PACKING_SPS 0x00000001 +#define VA_ENC_HEADER_PACKING_PPS 0x00000002 +#define VA_ENC_HEADER_PACKING_SLICE 0x00000004 + +/* attribute value for VAConfigAttribEncInterlaced */ +#define VA_ENC_INTERLACED_NONE 0x00000000 /* no interlface coding support */ +#define VA_ENC_INTERLACED_FRAME 0x00000001 /* interlace frame coding */ +#define VA_ENC_INTERLACED_FIELD 0x00000002 /* interlace field coding */ +#define VA_ENC_INTERLACED_MBAFF 0x00000004 /* Macroblock Adaptive Frame Field */ +#define VA_ENC_INTERLACED_PIC_AFF 0x00000008 /* Picture Adaptive Frame Field */ + +/* attribute value for VAConfigAttribEncSliceStructure */ +#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS 0x00000000 +#define VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS 0x00000001 +#define VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS 0x00000002 + /* * if an attribute is not applicable for a given * profile/entrypoint pair, then set the value to the following @@ -519,11 +557,49 @@ VAEncH264VUIBufferType = 25, VAEncH264SEIBufferType = 26, VAEncMiscParameterBufferType = 27, - VABufferTypeMax = 0xff + + VAEncSequenceParameterBufferExtType = 28, + VAEncPictureParameterBufferExtType = 29, + VAEncSliceParameterBufferExtType = 30, + VAEncDecRefPicMarkingBufferH264Type = 31, + + /* New packed header buffer types: + * Buffers contain NAL units packed by application + * Driver only needs to put them to bitstream buffer "as is" + * Header packing on host simplifies driver development and allows + * to implement new features and fix/work-around wide range of issues without changing driver + */ + VAEncPackedHeaderParameterBufferType = 32, + VAEncPackedHeaderDataBufferType = 33, + + /* Following are video processing buffer types */ + VAProcPipelineParameterBufferType = 60, + VAProcInputParameterBufferType = 61, + VAProcFilterBaseParameterBufferType = 62, /* general video processing filter */ + VAProcFilterDeinterlacingParameterBufferType = 63, + VAProcFilterProcAmpParameterBufferType = 64, + VABufferTypeMax = VA_ENUM_MAX } VABufferType; typedef enum { + VAEncPackedHeaderSPS = 1, + VAEncPackedHeaderPPS = 2, + VAEncPackedHeaderSlice = 3 +} VAEncPackedHeaderType; + +typedef struct _VAEncPackedHeaderParameterBuffer +{ + VAEncPackedHeaderType type; + unsigned int insert_emulation_bytes; /* set to 1 to insert startcode emulataion prevention bytes */ + unsigned int skip_emulation_check_count; + unsigned int num_headers; /* number of headers in the buffer, must be 1 for SPS or PPS */ + unsigned int *length_in_bits; /* array allocated by client to indicate length for each header, with num_header entries */ + unsigned int *offset_in_bytes; /* array allocated by client to indicate offset from the beginning of the buffer for each header, with num_header entries */ +} VAEncPackedHeaderParameterBuffer; + +typedef enum +{ VAEncMiscParameterTypeFrameRate = 0, VAEncMiscParameterTypeRateControl = 1, VAEncMiscParameterTypeMaxSliceSize = 2, @@ -562,7 +638,16 @@ unsigned int window_size; /* windows size in milliseconds. For example if this is set to 500, then the rate control will guarantee the */ /* target bit-rate over a 500 ms window */ unsigned int initial_qp; /* initial QP at I frames */ - unsigned int min_qp; + unsigned int min_qp; + union + { + struct + { + unsigned int reset : 1; + unsigned int : 31; + } bits; + unsigned int value; + } rc_flags; } VAEncMiscParameterRateControl; typedef struct _VAEncMiscParameterFrameRate @@ -580,6 +665,16 @@ unsigned int max_slice_size; } VAEncMiscParameterMaxSliceSize; +/* + * Allow a maximum frame size to be specified (in bits). + * The encoder will attempt to make sure that individual frames do not exceed this size + * Or to signal applicate if the frame size exceed this size, see "status" of VACodedBufferSegment + */ +typedef struct _VAEncMiscParameterMaxFrameSize +{ + unsigned int max_frame_size; +} VAEncMiscParameterMaxFrameSize; + typedef struct _VAEncMiscParameterAIR { unsigned int air_num_mbs; @@ -1181,6 +1276,55 @@ } slice_flags; } VAEncSliceParameterBuffer; +typedef struct _VAEncSliceParameterBufferH264Ext +{ + unsigned int starting_macroblock_address; /* starting MB address for this slice */ + unsigned int number_of_mbs; /* number of MBs in this slice */ + unsigned char pic_parameter_set_id; /* (0..255) */ + unsigned char slice_type; /* (0..2, 5..7) */ + unsigned char direct_spatial_mv_pred_flag; + unsigned char num_ref_idx_l0_active_minus1; /* (0..31) */ + unsigned char num_ref_idx_l1_active_minus1; /* (0..31) */ + unsigned char cabac_init_idc; /* (0..2) */ + signed char slice_qp_delta; + unsigned char disable_deblocking_filter_idc; /* (0..2) */ + signed char slice_alpha_c0_offset_div2; + signed char slice_beta_offset_div2; + unsigned short idr_pic_id; /* (0..65535) */ + unsigned short pic_order_cnt_lsb; + int delta_pic_order_cnt_bottom; + int delta_pic_order_cnt[2]; + unsigned char num_ref_idx_active_override_flag; + + VAPictureH264 RefPicList0[32]; + VAPictureH264 RefPicList1[32]; + + /* ref_pic_list_modification() */ + unsigned char ref_pic_list_modification_flag_l0; + unsigned char ref_pic_list_modification_flag_l1; + unsigned char modification_of_pic_nums_idc_l0[32]; + unsigned char modification_of_pic_nums_idc_l1[32]; + unsigned int value_l0[32]; + unsigned int value_l1[32]; + + // weights + unsigned char luma_log2_weight_denom; + unsigned char chroma_log2_weight_denom; + unsigned char luma_weight_l0_flag; + signed short luma_weight_l0[32]; + signed short luma_offset_l0[32]; + unsigned char chroma_weight_l0_flag; + signed short chroma_weight_l0[32][2]; + signed short chroma_offset_l0[32][2]; + unsigned char luma_weight_l1_flag; + signed short luma_weight_l1[32]; + signed short luma_offset_l1[32]; + unsigned char chroma_weight_l1_flag; + signed short chroma_weight_l1[32][2]; + signed short chroma_offset_l1[32][2]; + +} VAEncSliceParameterBufferH264Ext; + /**************************** * H.264 specific encode data structures ****************************/ @@ -1202,6 +1346,117 @@ unsigned char vui_flag; } VAEncSequenceParameterBufferH264; +typedef struct _VAEncSequenceParameterBufferH264Ext +{ + unsigned char seq_parameter_set_id; + unsigned char profile_idc; + unsigned char level_idc; + unsigned int intra_period; + unsigned int ip_period; + unsigned int max_num_ref_frames; + unsigned int picture_width_in_mbs; + unsigned int picture_height_in_mbs; + unsigned char frame_mbs_only_flag; /* for interlace */ + unsigned char target_usage; /* quality/performance control (1..7) */ + + /* bitrate control parameters*/ + unsigned char rate_control_method; /* cbr/vbr/constqp/others */ + unsigned int bits_per_second; /* target bitrate */ + unsigned int max_bits_per_second; /* for vbr */ + unsigned int min_bits_per_second; /* brc uses this information */ + unsigned int initial_hrd_buffer_fullness; /* in bits, brc uses it to guarantee hrd conformance */ + unsigned int hrd_buffer_size; /* in bits, brc uses it to guarantee hrd conformance */ + unsigned int time_scale; + unsigned int num_units_in_tick; /* fps = time_scale / (2 * num_units_in_tick) */ + + /* cropping, needed for 1080p */ + unsigned char frame_cropping_flag; + unsigned int frame_crop_left_offset; + unsigned int frame_crop_right_offset; + unsigned int frame_crop_top_offset; + unsigned int frame_crop_bottom_offset; + + unsigned char pic_order_cnt_type; /* (0..2) see avc 7.3.2.1.1 */ + unsigned char direct_8x8_inference_flag; /* see avc 7.3.2.1.1 */ + + unsigned char log2_max_frame_num_minus4; /* (0..12) see avc 7.3.2.1.1 */ + unsigned char log2_max_pic_order_cnt_lsb_minus4; /* for pic_order_cnt = 0 */ + + unsigned char vui_flag; + + /* fields required by header packing */ + union { + struct { + unsigned int chroma_format_idc : 2; + unsigned int seq_scaling_matrix_present_flag : 1; + unsigned int seq_scaling_list_present_flag : 1; + unsigned int delta_pic_order_always_zero_flag : 1; + } bits; + unsigned int value; + } seq_fields; + unsigned char bit_depth_luma_minus8; + unsigned char bit_depth_chroma_minus8; + unsigned char num_ref_frames_in_pic_order_cnt_cycle; + int offset_for_non_ref_pic; + int offset_for_top_to_bottom_field; + int offset_for_ref_frame[256]; +} VAEncSequenceParameterBufferH264Ext; + +/* + * if packed-buffers are adopted + * vui_paramters() will be generated by host application as a part of sps header + * then entire vui structure can be removed from interface + */ +typedef struct _VAEncH264VUIBufferH264 +{ + unsigned int aspect_ratio_info_present_flag : 1; + unsigned int overscan_info_present_flag : 1; + unsigned int overscan_appropriate_flag : 1; + unsigned int video_signal_type_present_flag : 1; + unsigned int video_full_range_flag : 1; + unsigned int colour_description_present_flag : 1; + unsigned int chroma_loc_info_present_flag : 1; + unsigned int timing_info_present_flag : 1; + unsigned int fixed_frame_rate_flag : 1; + unsigned int nal_hrd_parameters_present_flag : 1; + unsigned int vcl_hrd_parameters_present_flag : 1; + unsigned int low_delay_hrd_flag : 1; + unsigned int pic_struct_present_flag : 1; + unsigned int bitstream_restriction_flag : 1; + unsigned int motion_vectors_over_pic_boundaries_flag : 1; + unsigned int : 17; + + unsigned short sar_width; + unsigned short sar_height; + unsigned char aspect_ratio_idc; + unsigned char video_format; + unsigned char colour_primaries; + unsigned char transfer_characteristics; + unsigned char matrix_coefficients; + unsigned char chroma_sample_loc_type_top_field; + unsigned char chroma_sample_loc_type_bottom_field; + unsigned char max_bytes_per_pic_denom; + unsigned char max_bits_per_mb_denom; + unsigned char log2_max_mv_length_horizontal; + unsigned char log2_max_mv_length_vertical; + unsigned char num_reorder_frames; + unsigned int num_units_in_tick; + unsigned int time_scale; + unsigned char max_dec_frame_buffering; + + // HRD parameters + unsigned char cpb_cnt_minus1; + unsigned char bit_rate_scale; + unsigned char cpb_size_scale; + unsigned int bit_rate_value_minus1[32]; + unsigned int cpb_size_value_minus1[32]; + unsigned int cbr_flag; // bit 0 represent SchedSelIdx 0 and so on + unsigned char initial_cpb_removal_delay_length_minus1; + unsigned char cpb_removal_delay_length_minus1; + unsigned char dpb_output_delay_length_minus1; + unsigned char time_offset_length; +} VAEncH264VUIBufferH264; + #define H264_LAST_PICTURE_EOSEQ 0x01 /* the last picture in the sequence */ #define H264_LAST_PICTURE_EOSTREAM 0x02 /* the last picture in the stream */ typedef struct _VAEncPictureParameterBufferH264 @@ -1214,6 +1469,57 @@ unsigned char last_picture; } VAEncPictureParameterBufferH264; +typedef struct _VAEncPictureParameterBufferH264Ext +{ + VAPictureH264 CurrPic; + VAPictureH264 ReferenceFrames[16]; /* DPB */ + VABufferID CodedBuf; + + unsigned char seq_parameter_set_id; /* (0..31) */ + unsigned char pic_parameter_set_id; /* (0..255) )*/ + + unsigned char last_picture; /* for bd-rom compliance */ + + unsigned short frame_num; /* (0..65535) */ + unsigned char coding_type; /* for convenience */ + + unsigned char pic_init_qp; /* (0..51) for const qp */ + unsigned char num_ref_idx_l0_active_minus1; /* (0..31) */ + unsigned char num_ref_idx_l1_active_minus1; /* (0..31) */ + signed char chroma_qp_index_offset; /* (-12..12) */ + signed char second_chroma_qp_index_offset; /* (-12..12) */ + + union + { + struct + { + unsigned int idr_pic_flag : 1; + unsigned int reference_pic_flag : 1; /* nal_ref_idc != 0 */ + unsigned int entropy_coding_mode_flag : 1; /* CAVLC/CABAC */ + unsigned int weighted_pred_flag : 1; + unsigned int weighted_bipred_idc : 2; /* (0..2) */ + unsigned int constrained_intra_pred_flag : 1; + unsigned int transform_8x8_mode_flag : 1; + unsigned int deblocking_filter_control_present_flag : 1; + unsigned int pic_order_present_flag : 1; + unsigned int pic_scaling_matrix_present_flag : 1; + unsigned int pic_scaling_list_present_flag : 1; + } bits; + + unsigned int value; + } pic_fields; + +} VAEncPictureParameterBufferH264Ext; + +typedef struct _VAEncH264DecRefPicMarkingBuffer +{ + unsigned char no_output_of_prior_pics_flag; + unsigned char long_term_reference_flag; + unsigned char adaptive_ref_pic_marking_mode_flag; + unsigned char memory_management_control_operation[32]; + unsigned int value[32][2]; +} VAEncH264DecRefPicMarkingBuffer; + /**************************** * H.263 specific encode data structures ****************************/