X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fi965_drv_video.h;h=b4326e5faa28ee80715e787b6fe7eb7af752d109;hb=fa31cc010dc7e339332b351a0f4d3909fcd4980a;hp=f67599e97ad67549641ac93863707d75c776b46b;hpb=768c7bfb8ecb59432f902a4b7c28bc0c64bc631d;p=android-x86%2Fhardware-intel-common-vaapi.git diff --git a/src/i965_drv_video.h b/src/i965_drv_video.h index f67599e..b4326e5 100644 --- a/src/i965_drv_video.h +++ b/src/i965_drv_video.h @@ -39,6 +39,10 @@ #include #include #include +#include +#include + +#include "va_backend_compat.h" #include "i965_mutext.h" #include "object_heap.h" @@ -46,12 +50,12 @@ #include "i965_fourcc.h" #define I965_MAX_PROFILES 20 -#define I965_MAX_ENTRYPOINTS 5 +#define I965_MAX_ENTRYPOINTS 7 #define I965_MAX_CONFIG_ATTRIBUTES 32 #define I965_MAX_IMAGE_FORMATS 10 #define I965_MAX_SUBPIC_FORMATS 6 #define I965_MAX_SUBPIC_SUM 4 -#define I965_MAX_SURFACE_ATTRIBUTES 16 +#define I965_MAX_SURFACE_ATTRIBUTES 32 #define INTEL_STR_DRIVER_VENDOR "Intel" #define INTEL_STR_DRIVER_NAME "i965" @@ -69,23 +73,118 @@ #define DEFAULT_SATURATION 50 #define ENCODER_QUALITY_RANGE 2 +#define ENCODER_QUALITY_RANGE_AVC 7 +#define ENCODER_QUALITY_RANGE_HEVC 7 +#define ENCODER_QUALITY_RANGE_VP9 7 #define ENCODER_DEFAULT_QUALITY 1 +#define ENCODER_DEFAULT_QUALITY_AVC 4 +#define ENCODER_DEFAULT_QUALITY_HEVC 4 +#define ENCODER_DEFAULT_QUALITY_VP9 4 #define ENCODER_HIGH_QUALITY ENCODER_DEFAULT_QUALITY #define ENCODER_LOW_QUALITY 2 +#define I965_MIN_CODEC_ENC_RESOLUTION_WIDTH_HEIGHT 32 #define I965_MAX_NUM_ROI_REGIONS 8 +#define I965_MAX_NUM_SLICE 32 #define ENCODER_LP_QUALITY_RANGE 8 -struct i965_surface -{ +#define STATS_MAX_NUM_PAST_REFS 1 +#define STATS_MAX_NUM_FUTURE_REFS 1 +#define STATS_MAX_NUM_OUTPUTS 2 +#define STATS_INTERLACED_SUPPORT 0 + +#define HAS_MPEG2_DECODING(ctx) ((ctx)->codec_info->has_mpeg2_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_MPEG2_ENCODING(ctx) ((ctx)->codec_info->has_mpeg2_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_H264_DECODING(ctx) ((ctx)->codec_info->has_h264_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_H264_ENCODING(ctx) ((ctx)->codec_info->has_h264_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_LP_H264_ENCODING(ctx) ((ctx)->codec_info->has_lp_h264_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_FEI_H264_ENCODING(ctx) ((ctx)->codec_info->has_fei_h264_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_H264_PREENC(ctx) ((ctx)->codec_info->has_h264_preenc) + +#define HAS_VC1_DECODING(ctx) ((ctx)->codec_info->has_vc1_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_JPEG_DECODING(ctx) ((ctx)->codec_info->has_jpeg_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_JPEG_ENCODING(ctx) ((ctx)->codec_info->has_jpeg_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_VPP(ctx) ((ctx)->codec_info->has_vpp) + +#define HAS_ACCELERATED_GETIMAGE(ctx) ((ctx)->codec_info->has_accelerated_getimage) + +#define HAS_ACCELERATED_PUTIMAGE(ctx) ((ctx)->codec_info->has_accelerated_putimage) + +#define HAS_TILED_SURFACE(ctx) ((ctx)->codec_info->has_tiled_surface) + +#define HAS_VP8_DECODING(ctx) ((ctx)->codec_info->has_vp8_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_VP8_ENCODING(ctx) ((ctx)->codec_info->has_vp8_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_H264_MVC_DECODING(ctx) \ + (HAS_H264_DECODING(ctx) && (ctx)->codec_info->h264_mvc_dec_profiles) + +#define HAS_H264_MVC_DECODING_PROFILE(ctx, profile) \ + (HAS_H264_MVC_DECODING(ctx) && \ + ((ctx)->codec_info->h264_mvc_dec_profiles & (1U << profile))) + +#define HAS_H264_MVC_ENCODING(ctx) ((ctx)->codec_info->has_h264_mvc_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_HEVC_DECODING(ctx) ((ctx)->codec_info->has_hevc_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_HEVC_ENCODING(ctx) ((ctx)->codec_info->has_hevc_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_VP9_DECODING(ctx) ((ctx)->codec_info->has_vp9_decoding && \ + (ctx)->intel.has_bsd) + +#define HAS_VP9_DECODING_PROFILE(ctx, profile) \ + (HAS_VP9_DECODING(ctx) && \ + ((ctx)->codec_info->vp9_dec_profiles & (1U << (profile - VAProfileVP9Profile0)))) + +#define HAS_HEVC10_DECODING(ctx) ((ctx)->codec_info->has_hevc10_decoding && \ + (ctx)->intel.has_bsd) +#define HAS_HEVC10_ENCODING(ctx) ((ctx)->codec_info->has_hevc10_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_VPP_P010(ctx) ((ctx)->codec_info->has_vpp_p010 && \ + (ctx)->intel.has_bsd) + +#define HAS_VP9_ENCODING(ctx) ((ctx)->codec_info->has_vp9_encoding && \ + (ctx)->intel.has_bsd) + +#define HAS_LP_VP9_ENCODING(ctx) ((ctx)->codec_info->has_lp_vp9_encoding && \ + (ctx)->intel.has_huc) + +#define HAS_VP9_ENCODING_PROFILE(ctx, profile) \ + (HAS_VP9_ENCODING(ctx) && \ + ((ctx)->codec_info->vp9_enc_profiles & (1U << (profile - VAProfileVP9Profile0)))) + +struct i965_surface { struct object_base *base; int type; int flags; }; -struct i965_kernel -{ +struct i965_kernel { char *name; int interface; const uint32_t (*bin)[4]; @@ -94,16 +193,14 @@ struct i965_kernel unsigned int kernel_offset; }; -struct buffer_store -{ +struct buffer_store { unsigned char *buffer; dri_bo *bo; int ref_count; int num_elements; }; - -struct object_config -{ + +struct object_config { struct object_base base; VAProfile profile; VAEntrypoint entrypoint; @@ -119,8 +216,7 @@ struct codec_state_base { uint32_t chroma_formats; }; -struct decode_state -{ +struct decode_state { struct codec_state_base base; struct buffer_store *pic_param; struct buffer_store **slice_params; @@ -142,18 +238,11 @@ struct decode_state #define SLICE_PACKED_DATA_INDEX_TYPE 0x80000000 #define SLICE_PACKED_DATA_INDEX_MASK 0x00FFFFFF -struct encode_state -{ +struct encode_state { struct codec_state_base base; - struct buffer_store *seq_param; - struct buffer_store *pic_param; - struct buffer_store *pic_control; struct buffer_store *iq_matrix; struct buffer_store *q_matrix; - struct buffer_store **slice_params; struct buffer_store *huffman_table; - int max_slice_params; - int num_slice_params; /* for ext */ struct buffer_store *seq_param_ext; @@ -190,7 +279,7 @@ struct encode_state int *slice_rawdata_index; /* This is to store the number of packed data for one slice. * Both packed rawdata and slice_header data are tracked by this - * this variable. That is to say: When one packed slice_header is parsed, + * variable. That is to say: When one packed slice_header is parsed, * this variable will also be increased. */ int *slice_rawdata_count; @@ -200,7 +289,12 @@ struct encode_state int last_packed_header_type; - struct buffer_store *misc_param[16]; + int has_layers; + + struct buffer_store *misc_param[19][8]; + + /* To store the VAStatsStatisticsParameterBufferType buffers */ + struct buffer_store *stat_param_ext; VASurfaceID current_render_target; struct object_surface *input_yuv_object; @@ -209,8 +303,7 @@ struct encode_state struct object_surface *reference_objects[16]; /* Up to 2 reference surfaces are valid for MPEG-2,*/ }; -struct proc_state -{ +struct proc_state { struct codec_state_base base; struct buffer_store *pipeline_param; @@ -220,34 +313,32 @@ struct proc_state #define CODEC_DEC 0 #define CODEC_ENC 1 #define CODEC_PROC 2 +#define CODEC_PREENC 3 -union codec_state -{ +union codec_state { struct codec_state_base base; struct decode_state decode; struct encode_state encode; struct proc_state proc; }; -struct hw_context -{ - VAStatus (*run)(VADriverContextP ctx, - VAProfile profile, - union codec_state *codec_state, - struct hw_context *hw_context); +struct hw_context { + VAStatus(*run)(VADriverContextP ctx, + VAProfile profile, + union codec_state *codec_state, + struct hw_context *hw_context); void (*destroy)(void *); - VAStatus (*get_status)(VADriverContextP ctx, - struct hw_context *hw_context, - void *buffer); + VAStatus(*get_status)(VADriverContextP ctx, + struct hw_context *hw_context, + void *buffer); struct intel_batchbuffer *batch; }; -struct object_context -{ +struct object_context { struct object_base base; VAContextID context_id; struct object_config *obj_config; - VASurfaceID *render_targets; //input->encode, output->decode + VASurfaceID *render_targets; //input->encode, output->decode int num_render_targets; int picture_width; int picture_height; @@ -264,8 +355,7 @@ struct object_context #define SURFACE_ALL_MASK ((SURFACE_REFERENCED) | \ (SURFACE_DERIVED)) -struct object_surface -{ +struct object_surface { struct object_base base; VASurfaceStatus status; VASubpictureID subpic[I965_MAX_SUBPIC_SUM]; @@ -278,7 +368,7 @@ struct object_surface int orig_width; /* the width of plane 0 in pixels */ int orig_height; /* the height of plane 0 in pixels */ int flags; - unsigned int fourcc; + unsigned int fourcc; dri_bo *bo; unsigned int expected_format; VAImageID locked_image_id; @@ -306,8 +396,7 @@ struct object_surface int exported_primefd; }; -struct object_buffer -{ +struct object_buffer { struct object_base base; struct buffer_store *buffer_store; int max_num_elements; @@ -323,8 +412,7 @@ struct object_buffer VAContextID context_id; }; -struct object_image -{ +struct object_image { struct object_base base; VAImage image; dri_bo *bo; @@ -332,8 +420,7 @@ struct object_image VASurfaceID derived_surface; }; -struct object_subpic -{ +struct object_subpic { struct object_base base; VAImageID image; struct object_image *obj_image; @@ -353,16 +440,14 @@ struct object_subpic #define I965_RING_BLT 2 #define I965_RING_VEBOX 3 -struct i965_filter -{ +struct i965_filter { VAProcFilterType type; int ring; }; struct i965_driver_data; -struct hw_codec_info -{ +struct hw_codec_info { struct hw_context *(*dec_hw_context_init)(VADriverContextP, struct object_config *); struct hw_context *(*enc_hw_context_init)(VADriverContextP, struct object_config *); struct hw_context *(*proc_hw_context_init)(VADriverContextP, struct object_config *); @@ -384,6 +469,7 @@ struct hw_codec_info unsigned int h264_mvc_dec_profiles; unsigned int vp9_dec_profiles; + unsigned int vp9_enc_profiles; unsigned int h264_dec_chroma_formats; unsigned int jpeg_dec_chroma_formats; @@ -391,32 +477,40 @@ struct hw_codec_info unsigned int hevc_dec_chroma_formats; unsigned int vp9_dec_chroma_formats; - unsigned int has_mpeg2_decoding:1; - unsigned int has_mpeg2_encoding:1; - unsigned int has_h264_decoding:1; - unsigned int has_h264_encoding:1; - unsigned int has_vc1_decoding:1; - unsigned int has_vc1_encoding:1; - unsigned int has_jpeg_decoding:1; - unsigned int has_jpeg_encoding:1; - unsigned int has_vpp:1; - unsigned int has_accelerated_getimage:1; - unsigned int has_accelerated_putimage:1; - unsigned int has_tiled_surface:1; - unsigned int has_di_motion_adptive:1; - unsigned int has_di_motion_compensated:1; - unsigned int has_vp8_decoding:1; - unsigned int has_vp8_encoding:1; - unsigned int has_h264_mvc_encoding:1; - unsigned int has_hevc_decoding:1; - unsigned int has_hevc_encoding:1; - unsigned int has_hevc10_decoding:1; - unsigned int has_vp9_decoding:1; - unsigned int has_vpp_p010:1; - unsigned int has_lp_h264_encoding:1; - unsigned int has_vp9_encoding:1; + unsigned int has_mpeg2_decoding: 1; + unsigned int has_mpeg2_encoding: 1; + unsigned int has_h264_decoding: 1; + unsigned int has_h264_encoding: 1; + unsigned int has_vc1_decoding: 1; + unsigned int has_vc1_encoding: 1; + unsigned int has_jpeg_decoding: 1; + unsigned int has_jpeg_encoding: 1; + unsigned int has_vpp: 1; + unsigned int has_accelerated_getimage: 1; + unsigned int has_accelerated_putimage: 1; + unsigned int has_tiled_surface: 1; + unsigned int has_di_motion_adptive: 1; + unsigned int has_di_motion_compensated: 1; + unsigned int has_vp8_decoding: 1; + unsigned int has_vp8_encoding: 1; + unsigned int has_h264_mvc_encoding: 1; + unsigned int has_hevc_decoding: 1; + unsigned int has_hevc_encoding: 1; + unsigned int has_hevc10_encoding: 1; + unsigned int has_hevc10_decoding: 1; + unsigned int has_vp9_decoding: 1; + unsigned int has_vpp_p010: 1; + unsigned int has_lp_h264_encoding: 1; + unsigned int has_vp9_encoding: 1; + unsigned int has_fei_h264_encoding: 1; + unsigned int has_h264_preenc: 1; + unsigned int has_lp_vp9_encoding: 1; unsigned int lp_h264_brc_mode; + unsigned int lp_vp9_brc_mode; + + unsigned int h264_brc_mode; + unsigned int vp9_brc_mode; unsigned int num_filters; struct i965_filter filters[VAProcFilterCount]; @@ -424,9 +518,9 @@ struct hw_codec_info #include "i965_render.h" +#include "i965_gpe_utils.h" -struct i965_driver_data -{ +struct i965_driver_data { struct intel_driver_data intel; struct object_heap config_heap; struct object_heap context_heap; @@ -443,7 +537,7 @@ struct i965_driver_data struct i965_render_state render_state; void *pp_context; char va_vendor[256]; - + VADisplayAttribute *display_attributes; unsigned int num_display_attributes; VADisplayAttribute *rotation_attrib; @@ -460,6 +554,8 @@ struct i965_driver_data struct va_wl_output *wl_output; VADriverContextP wrapper_pdrvctx; + + struct i965_gpe_table gpe_table; }; #define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap); @@ -525,8 +621,7 @@ va_enc_packed_type_to_idx(int packed_type); #define HEVC_DELIMITER3 0x00 #define HEVC_DELIMITER4 0x00 -struct i965_coded_buffer_segment -{ +struct i965_coded_buffer_segment { union { VACodedBufferSegment base; unsigned char pad0[64]; /* change the size if sizeof(VACodedBufferSegment) > 64 */ @@ -543,21 +638,21 @@ struct i965_coded_buffer_segment #define I965_CODEDBUFFER_HEADER_SIZE ALIGN(sizeof(struct i965_coded_buffer_segment), 0x1000) extern VAStatus i965_MapBuffer(VADriverContextP ctx, - VABufferID buf_id, /* in */ - void **pbuf); /* out */ + VABufferID buf_id, /* in */ + void **pbuf); /* out */ extern VAStatus i965_UnmapBuffer(VADriverContextP ctx, VABufferID buf_id); extern VAStatus i965_DestroySurfaces(VADriverContextP ctx, - VASurfaceID *surface_list, - int num_surfaces); + VASurfaceID *surface_list, + int num_surfaces); extern VAStatus i965_CreateSurfaces(VADriverContextP ctx, - int width, - int height, - int format, - int num_surfaces, - VASurfaceID *surfaces); + int width, + int height, + int format, + int num_surfaces, + VASurfaceID *surfaces); #define I965_SURFACE_MEM_NATIVE 0 #define I965_SURFACE_MEM_GEM_FLINK 1 @@ -566,4 +661,8 @@ extern VAStatus i965_CreateSurfaces(VADriverContextP ctx, void i965_destroy_surface_storage(struct object_surface *obj_surface); +// Logging functions for errors (to be shown to users) and info (useful for developers). +void i965_log_error(VADriverContextP ctx, const char *format, ...); +void i965_log_info(VADriverContextP ctx, const char *format, ...); + #endif /* _I965_DRV_VIDEO_H_ */