From 0f5162def402b0b2fa7db332b323e7497b413cc1 Mon Sep 17 00:00:00 2001 From: Austin Yuan Date: Mon, 13 Jan 2014 09:48:25 +0800 Subject: libVA VP8 encode temporal scalability support for SAND BZ: 164045 Change-Id: Iecb73eb73965b6480f63436810603f8e2cd3bb7f Signed-off-by: Austin Yuan --- va/Makefile.am | 1 + va/va.h | 186 ++++++++++++++++++- va/va_backend.h | 1 - va/va_dec_jpeg.h | 2 + va/va_enc_vp8.h | 4 +- va/va_trace.c | 327 ++++++++++++++++++---------------- va/va_vpp.h | 57 +++++- va/vendor/intel/va_intel_fei.h | 268 ++++++++++++++++++++++++++++ va/vendor/intel/va_intel_statistics.h | 175 ++++++++++++++++++ 9 files changed, 851 insertions(+), 170 deletions(-) create mode 100644 va/vendor/intel/va_intel_fei.h create mode 100644 va/vendor/intel/va_intel_statistics.h (limited to 'va') diff --git a/va/Makefile.am b/va/Makefile.am index 425225c..bb9b063 100644 --- a/va/Makefile.am +++ b/va/Makefile.am @@ -26,6 +26,7 @@ INCLUDES = \ $(LIBVA_CFLAGS) \ -I$(top_srcdir) \ -I$(top_srcdir)/va/x11 \ + -I$(top_srcdir)/va/vendor/intel \ -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" LDADD = \ diff --git a/va/va.h b/va/va.h index 616b55b..0872620 100755 --- a/va/va.h +++ b/va/va.h @@ -325,6 +325,49 @@ typedef enum */ VAEntrypointEncSliceLP = 8, VAEntrypointVideoProc = 10, /**< Video pre/post-processing. */ + + /** + * \brief Intel specific entrypoints start at 1001 + */ + /** + * \brief VAEntrypointEncFEIIntel + * + * The purpose of FEI (Flexible Encoding Infrastructure) is to allow applications to + * have more controls and trade off quality for speed with their own IPs. A pre-processing + * function for getting some statistics and motion vectors is added + * and some extra controls for Encode pipeline are provided. + * The application can optionally call the statistics function + * to get motion vectors and statistics before calling encode function. + * The application can also optionally provide input to VME for extra + * encode control and get the output from VME. Application can chose to + * modify the VME output/PAK input during encoding, but the performance + * impact is significant. + * + * On top of the existing buffers for normal encode, there will be + * one extra input buffer (VAEncMiscParameterIntelFEIFrameControl) and + * three extra output buffers (VAIntelEncFEIMVBufferType, VAIntelEncFEIModeBufferType + * and VAIntelEncFEIDistortionBufferType) for VAEntrypointIntelEncFEI entry function. + * If separate PAK is set, two extra input buffers + * (VAIntelEncFEIMVBufferType, VAIntelEncFEIModeBufferType) are needed for PAK input. + * + **/ + VAEntrypointEncFEIIntel = 1001, + /** + * \brief VAEntrypointStatisticsIntel + * + * Statistics, like variances, distortions, motion vectors can be obtained + * via this entry point. Checking whether Statistics is supported can be + * performed with vaQueryConfigEntrypoints() and the profile argument + * set to #VAProfileNone. If Statistics entry point is supported, + * then the list of returned entry-points will include #VAEntrypointIntelStatistics. + * Supported pixel format, maximum resolution and statistics specific attributes + * can be obtained via normal attribute query. + * One input buffer (VAIntelStatsStatisticsParameterBufferType) and one or two + * output buffers (VAIntelStatsStatisticsBufferType and VAIntelStatsMotionVectorBufferType) + * are needed for this entry point. + * + **/ + VAEntrypointStatisticsIntel, VAEntrypointMax } VAEntrypoint; @@ -486,7 +529,7 @@ typedef enum * * This attribute conveys whether the driver supports sending skip frame parameters * (VAEncMiscParameterTypeSkipFrame) to the encoder's rate control, when the user has - * externally skipped frames. + * externally skipped frames. It is a boolean value 0 - unsupported, 1 - supported. */ VAConfigAttribEncSkipFrame = 24, /** @@ -499,7 +542,40 @@ typedef enum * VAEncMiscParameterTypeRoi. */ VAConfigAttribEncRoi = 25, - + /** + * \brief Encoding extended rate control attribute. Read-only. + * + * This attribute conveys whether the driver supports any extended rate control features + * The attribute value is partitioned into fields as defined in the + * VAConfigAttribRateControlExt union. + */ + VAConfigAttribEncRateControlExt = 26, + /** + * \brief Intel specific attributes start at 1001 + */ + /** + * \brief Encode function type. + * + * This attribute conveys whether the driver supports different function types for encode. + * It can be ENC, PAK, or ENC + PAK. Currently it is for FEI entry point only. + * Default is ENC + PAK. + */ + VAConfigAttribEncFunctionTypeIntel = 1001, + /** + * \brief Maximum number of MV predictors. Read-only. + * + * This attribute determines the maximum number of MV predictors the driver + * can support to encode a single frame. 0 means no MV predictor is supported. + */ + VAConfigAttribEncMVPredictorsIntel, + /** + * \brief Statistics attribute. Read-only. + * + * This attribute exposes a number of capabilities of the VAEntrypointStatistics entry + * point. The attribute value is partitioned into fields as defined in the + * VAConfigAttribValStatistics union. + */ + VAConfigAttribStatisticsIntel, /**@}*/ VAConfigAttribTypeMax } VAConfigAttribType; @@ -541,8 +617,9 @@ typedef struct _VAConfigAttrib { #define VA_RC_CQP 0x00000010 /** \brief Variable bitrate with peak rate higher than average bitrate. */ #define VA_RC_VBR_CONSTRAINED 0x00000020 -/** \brief Constant rate factor. */ -#define VA_RC_CRF 0x00000040 +/** \brief Intelligent Constant Quality. Provided an initial ICQ_quality_factor, + * adjusts QP at a frame and MB level based on motion to improve subjective quality. */ +#define VA_RC_ICQ 0x00000040 /** \brief Macroblock based rate control. Per MB control is decided * internally in the encoder. It may be combined with other RC modes, except CQP. */ #define VA_RC_MB 0x00000080 @@ -639,6 +716,65 @@ typedef union _VAConfigAttribValEncJPEG { /**@}*/ +/** \brief Attribute value for VAConfigAttribEncRateControlExt */ +typedef union _VAConfigAttribValEncRateControlExt { + struct { + /** \brief The number of temporal layers with layer specific bit-rate targets + * that are supported. The application will send multiple + * VAEncMiscParameterRateControl and VAEncMiscParameterFrameRate structures + * for each layer, using the temporal_id field as the layer identifier. + * If per temporal layer rate control is not supported, + * num_temporal_layers_minus1 will be 0 and the temporal_id field in + * VAEncMiscParameterRateControl and VAEncMiscParameterFrameRate will be ignored. + */ + unsigned int num_temporal_layers_minus1 : 8; + unsigned int reserved : 24; + } bits; + unsigned int value; +} VAConfigAttribValEncRateControlExt; + +/** + * \brief Intel specific attribute definitions + */ +/** @name Attribute values for VAConfigAttribEncFunctionTypeIntel + * + * The desired type should be passed to driver when creating the configuration. + * If VA_ENC_FUNCTION_ENC_PAK is set, VA_ENC_FUNCTION_ENC and VA_ENC_FUNCTION_PAK + * will be ignored if set also. VA_ENC_FUNCTION_ENC and VA_ENC_FUNCTION_PAK operations + * shall be called separately if ENC and PAK (VA_ENC_FUNCTION_ENC | VA_ENC_FUNCTION_PAK) + * is set for configuration. VA_ENC_FUNCTION_ENC_PAK is recommended for best performance. + * If only VA_ENC_FUNCTION_ENC is set, there will be no bitstream output. + * If VA_ENC_FUNCTION_ENC_PAK is not set and VA_ENC_FUNCTION_PAK is set, then two extra + * input buffers for PAK are needed: VAEncFEIMVBufferType and VAEncFEIModeBufferType. + **/ +/**@{*/ +/** \brief Only default is supported */ +#define VA_ENC_FUNCTION_DEFAULT_INTEL 0x00000000 +/** \brief ENC only is supported */ +#define VA_ENC_FUNCTION_ENC_INTEL 0x00000001 +/** \brief PAK only is supported */ +#define VA_ENC_FUNCTION_PAK_INTEL 0x00000002 +/** \brief ENC_PAK is supported */ +#define VA_ENC_FUNCTION_ENC_PAK_INTEL 0x00000004 + +/**@}*/ + +/** \brief Attribute value for VAConfigAttribStatisticsIntel */ +typedef union _VAConfigAttribValStatisticsIntel { + struct { + /** \brief Max number of past reference frames that are supported. */ + unsigned int max_num_past_references : 4; + /** \brief Max number of future reference frames that are supported. */ + unsigned int max_num_future_references : 4; + /** \brief Number of output surfaces that are supported */ + unsigned int num_outputs : 3; + /** \brief Interlaced content is supported */ + unsigned int interlaced : 1; + unsigned int reserved : 20; + } bits; + unsigned int value; +} VAConfigAttribValStatisticsIntel; + /* * if an attribute is not applicable for a given * profile/entrypoint pair, then set the value to the following @@ -1074,6 +1210,7 @@ typedef enum VAEncMiscParameterBufferType = 27, VAEncMacroblockParameterBufferType = 28, VAEncMacroblockMapBufferType = 29, + VAEncQpBufferType = 30, /* Following are video processing buffer types */ /** * \brief Video processing pipeline parameter buffer. @@ -1097,6 +1234,17 @@ typedef enum VAProcFilterParameterBufferType = 42, VAParsePictureParameterBufferType = 43, VAParseSliceHeaderGroupBufferType = 44, + + /** + * \brief Intel specific buffer types start at 1001 + */ + VAEncFEIMVBufferTypeIntel = 1001, + VAEncFEIModeBufferTypeIntel, + VAEncFEIDistortionBufferTypeIntel, + VAStatsStatisticsParameterBufferTypeIntel, + VAStatsStatisticsBufferTypeIntel, + VAStatsMotionVectorBufferTypeIntel, + VABufferTypeMax } VABufferType; @@ -1121,7 +1269,11 @@ typedef enum /** \brief Buffer type used for region-of-interest (ROI) parameters. */ VAEncMiscParameterTypeROI = 10, /** \brief Buffer type used for Cyclic intra refresh */ - VAEncMiscParameterTypeCIR = 11 + VAEncMiscParameterTypeCIR = 11, + + /* Intel specific types start at 1001 */ + /* VAEntrypointEncFEIIntel */ + VAEncMiscParameterTypeFEIFrameControlIntel = 1001 } VAEncMiscParameterType; /** \brief Packed header type. */ @@ -1209,15 +1361,32 @@ typedef struct _VAEncMiscParameterRateControl unsigned int disable_frame_skip : 1; /* Disable frame skip in rate control mode */ unsigned int disable_bit_stuffing : 1; /* Disable bit stuffing in rate control mode */ unsigned int mb_rate_control : 4; /* Control VA_RC_MB 0: default, 1: enable, 2: disable, other: reserved*/ + /* + * The temporal layer that the rate control parameters are specified for. + */ + unsigned int temporal_id : 8; + unsigned int reserved : 17; } bits; unsigned int value; } rc_flags; - unsigned int CRF_quality_factor; + unsigned int ICQ_quality_factor; /* Initial ICQ quality factor: 1-51. */ } VAEncMiscParameterRateControl; typedef struct _VAEncMiscParameterFrameRate { unsigned int framerate; + union + { + struct + { + /* + * The temporal id the framerate parameters are specified for. + */ + unsigned int temporal_id : 8; + unsigned int reserved : 24; + } bits; + unsigned int value; + } framerate_flags; } VAEncMiscParameterFrameRate; /* @@ -1247,10 +1416,10 @@ typedef struct _VAEncMiscParameterAIR /** \brief the minimum number of macroblocks to refresh in a frame */ unsigned int air_num_mbs; /** - * \brief threshhold of motion estimation block-matching criterion (typically SAD) + * \brief threshhold of blockmatching criterion (typically SAD) * * Macroblocks above that threshold are marked as candidates and - * on subsequent frames a number of these candidates are coded as Intra. + * on subsequent frames a number of these candidates are coded as Intra * Generally the threshhold need to be set and tuned to an appropriate level * according to the feedback of coded frame. */ @@ -2226,6 +2395,7 @@ typedef struct _VACodedBufferSegment { void *next; } VACodedBufferSegment; + /* * H.264 Parsed Slice Header Group Info * After slice header is parsed by decode hardware, diff --git a/va/va_backend.h b/va/va_backend.h index d3ff89c..09f8245 100755 --- a/va/va_backend.h +++ b/va/va_backend.h @@ -30,7 +30,6 @@ #define _VA_BACKEND_H_ #include -#include typedef struct VADriverContext *VADriverContextP; typedef struct VADisplayContext *VADisplayContextP; diff --git a/va/va_dec_jpeg.h b/va/va_dec_jpeg.h index 9936692..6683998 100644 --- a/va/va_dec_jpeg.h +++ b/va/va_dec_jpeg.h @@ -70,6 +70,8 @@ typedef struct _VAPictureParameterBufferJPEGBaseline { } components[255]; /** \brief Number of components in frame (Nf). */ unsigned char num_components; + /** \brief Input color space 0: YUV, 1: RGB, others: reserved */ + unsigned char color_space; } VAPictureParameterBufferJPEGBaseline; /** diff --git a/va/va_enc_vp8.h b/va/va_enc_vp8.h index 1c46967..6d3023c 100644 --- a/va/va_enc_vp8.h +++ b/va/va_enc_vp8.h @@ -128,7 +128,9 @@ typedef struct _VAEncPictureParameterBufferVP8 unsigned int no_ref_gf : 1; /* don't reference the alternate reference frame */ unsigned int no_ref_arf : 1; - unsigned int reserved : 28; + /* The temporal id the frame belongs to. */ + unsigned int temporal_id : 8; + unsigned int reserved : 20; } bits; unsigned int value; } ref_flags; diff --git a/va/va_trace.c b/va/va_trace.c index 0f8467a..8b50261 100755 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -31,8 +31,8 @@ #include "va_enc_h264.h" #include "va_enc_jpeg.h" #include "va_enc_vp8.h" -#include "va_dec_vp8.h" #include "va_dec_jpeg.h" +#include "va_dec_vp8.h" #include "va_vpp.h" #include #include @@ -790,13 +790,20 @@ static void va_TraceVABuffers( { unsigned int i; unsigned char *p = pbuf; + unsigned int dump_size = 64; DPY2TRACECTX(dpy); va_TraceMsg(trace_ctx, "--%s\n", buffer_type_to_string(type)); - if ((trace_flag & VA_TRACE_FLAG_BUFDATA) && trace_ctx->trace_fp_log) { - for (i=0; isize) + dump_size = size; + + if (trace_flag & VA_TRACE_FLAG_BUFDATA) + dump_size = size; + + if (trace_ctx->trace_fp_log) { + for (i=0; iframe_width); - va_TraceMsg(trace_ctx, "\tCurrPic.frame_height = %d\n", p->frame_height); - va_TraceMsg(trace_ctx, "\tCurrPic.last_ref_frame = 0x%x\n", p->last_ref_frame); - va_TraceMsg(trace_ctx, "\tCurrPic.golden_ref_frame = 0x%x\n", p->golden_ref_frame); - va_TraceMsg(trace_ctx, "\tCurrPic.alt_ref_frame = 0x%x\n", p->alt_ref_frame); - va_TraceMsg(trace_ctx, "\tCurrPic.out_of_loop_frame = 0x%x\n", p->out_of_loop_frame); - va_TraceMsg(trace_ctx, "\tCurrPic.pic_fields = 0x%x\n", p->pic_fields.value); - for (i = 0; i < 3; i++) - va_TraceMsg(trace_ctx, "\tCurrPic.mb_segment_tree_probs = %d\n", p->mb_segment_tree_probs[i]); - for (i = 0; i < 4; i++) - va_TraceMsg(trace_ctx, "\tCurrPic.loop_filter_level = %d\n", p->loop_filter_level[i]); - for (i = 0; i < 4; i++) - va_TraceMsg(trace_ctx, "\tCurrPic.loop_filter_deltas_ref_frame = %d\n", p->loop_filter_deltas_ref_frame[i]); - for (i = 0; i < 4; i++) - va_TraceMsg(trace_ctx, "\tCurrPic.loop_filter_deltas_mode = %d\n", p->loop_filter_deltas_mode[i]); - va_TraceMsg(trace_ctx, "\tCurrPic.prob_skip_false = %d\n", p->prob_skip_false); - va_TraceMsg(trace_ctx, "\tCurrPic.prob_intra = %d\n", p->prob_intra); - va_TraceMsg(trace_ctx, "\tCurrPic.prob_last = %d\n", p->prob_last); - va_TraceMsg(trace_ctx, "\tCurrPic.prob_gf = %d\n", p->prob_gf); - for (i = 0; i < 4; i++) - va_TraceMsg(trace_ctx, "\tCurrPic.y_mode_probs = %d\n", p->y_mode_probs[i]); - for (i = 0; i < 3; i++) - va_TraceMsg(trace_ctx, "\tCurrPic.uv_mode_probs = %d\n", p->uv_mode_probs[i]); - for (i = 0; i < 2; i++) - for (j = 0; j < 19; j++) - va_TraceMsg(trace_ctx, "\tCurrPic.mv_probs = %d\n", p->mv_probs[i][j]); - va_TraceMsg(trace_ctx, "\tCurrPic.bool_coder_ctx.range = %d\n", p->bool_coder_ctx.range); - va_TraceMsg(trace_ctx, "\tCurrPic.bool_coder_ctx.value = %d\n", p->bool_coder_ctx.value); - va_TraceMsg(trace_ctx, "\tCurrPic.bool_coder_ctx.count = %d\n", p->bool_coder_ctx.count); - - va_TraceMsg(trace_ctx, NULL); - - return; -} - static void va_TraceVASliceParameterBufferH264( VADisplay dpy, VAContextID context, @@ -1454,34 +1410,6 @@ static void va_TraceVASliceParameterBufferH264( va_TraceMsg(trace_ctx, NULL); } -static void va_TraceVASliceParameterBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data) -{ - int i; - VASliceParameterBufferVP8* p = (VASliceParameterBufferVP8*)data; - DPY2TRACECTX(dpy); - - trace_ctx->trace_slice_no++; - trace_ctx->trace_slice_size = p->slice_data_size; - - va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVP8\n"); - va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size); - va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset); - va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag); - va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset); - va_TraceMsg(trace_ctx, "\tnum_of_partitions = %d\n", p->num_of_partitions); - for (i = 0; i < 9; i++) - va_TraceMsg(trace_ctx, "\tpartition_size = %d\n", p->partition_size[i]); - - va_TraceMsg(trace_ctx, NULL); -} - static void va_TraceVAIQMatrixBufferH264( VADisplay dpy, VAContextID context, @@ -1524,74 +1452,7 @@ static void va_TraceVAIQMatrixBufferH264( va_TraceMsg(trace_ctx, NULL); } -static void va_TraceVAIQMatrixBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data -) -{ - int i, j; - VAIQMatrixBufferVP8* p = (VAIQMatrixBufferVP8* )data; - - DPY2TRACECTX(dpy); - va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferVP8\n"); - for (i = 0; i < 4; i++) - va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferVP8 is %d, %d, %d, %d, %d, %d.\n", \ - p->quantization_index[i][0], \ - p->quantization_index[i][1], \ - p->quantization_index[i][2], \ - p->quantization_index[i][3], \ - p->quantization_index[i][4], \ - p->quantization_index[i][5]); - va_TraceMsg(trace_ctx, NULL); -} - -static void va_TraceVAProbabilityDataBufferVP8( - VADisplay dpy, - VAContextID context, - VABufferID buffer, - VABufferType type, - unsigned int size, - unsigned int num_elements, - void *data -) -{ - int i, j, k, l; - VAProbabilityDataBufferVP8* p = (VAProbabilityDataBufferVP8* )data; - - DPY2TRACECTX(dpy); - - va_TraceMsg(trace_ctx, "\t--VAProbabilityDataBufferVP8\n"); - for (i = 0; i < 4; i++) { - va_TraceMsg(trace_ctx, "\t{\n"); - for (j = 0; j < 8; j++) { - va_TraceMsg(trace_ctx, "\t\t{\n"); - for (k = 0; k < 3; k++) { - va_TraceMsg(trace_ctx, "\t\t\t{ %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d }, \n", \ - p->dct_coeff_probs[i][j][k][0], \ - p->dct_coeff_probs[i][j][k][1], \ - p->dct_coeff_probs[i][j][k][2], \ - p->dct_coeff_probs[i][j][k][3], \ - p->dct_coeff_probs[i][j][k][4], \ - p->dct_coeff_probs[i][j][k][5], \ - p->dct_coeff_probs[i][j][k][6], \ - p->dct_coeff_probs[i][j][k][7], \ - p->dct_coeff_probs[i][j][k][8], \ - p->dct_coeff_probs[i][j][k][9], \ - p->dct_coeff_probs[i][j][k][10]); - } - va_TraceMsg(trace_ctx, "\t\t}\n"); - } - va_TraceMsg(trace_ctx, "\t}\n"); - } - - va_TraceMsg(trace_ctx, NULL); -} static void va_TraceVAEncSequenceParameterBufferH264( VADisplay dpy, @@ -2205,7 +2066,169 @@ static void va_TraceVAEncPictureParameterBufferVP8( return; } +static void va_TraceVAPictureParameterBufferVP8( + VADisplay dpy, + VAContextID context, + VABufferID buffer, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *data) +{ + char tmp[1024]; + VAPictureParameterBufferVP8 *p = (VAPictureParameterBufferVP8 *)data; + DPY2TRACECTX(dpy); + int i,j; + + va_TraceMsg(trace_ctx, "\t--VAPictureParameterBufferVP8\n"); + + va_TraceMsg(trace_ctx, "\tframe_width = %d\n", p->frame_width); + va_TraceMsg(trace_ctx, "\tframe_height = %d\n", p->frame_height); + va_TraceMsg(trace_ctx, "\tlast_ref_frame = %x\n", p->last_ref_frame); + va_TraceMsg(trace_ctx, "\tgolden_ref_frame = %x\n", p->golden_ref_frame); + va_TraceMsg(trace_ctx, "\talt_ref_frame = %x\n", p->alt_ref_frame); + va_TraceMsg(trace_ctx, "\tout_of_loop_frame = %x\n", p->out_of_loop_frame); + + va_TraceMsg(trace_ctx, "\tkey_frame = %d\n", p->pic_fields.bits.key_frame); + va_TraceMsg(trace_ctx, "\tversion = %d\n", p->pic_fields.bits.version); + va_TraceMsg(trace_ctx, "\tsegmentation_enabled = %d\n", p->pic_fields.bits.segmentation_enabled); + va_TraceMsg(trace_ctx, "\tupdate_mb_segmentation_map = %d\n", p->pic_fields.bits.update_mb_segmentation_map); + va_TraceMsg(trace_ctx, "\tupdate_segment_feature_data = %d\n", p->pic_fields.bits.update_segment_feature_data); + va_TraceMsg(trace_ctx, "\tfilter_type = %d\n", p->pic_fields.bits.filter_type); + va_TraceMsg(trace_ctx, "\tsharpness_level = %d\n", p->pic_fields.bits.sharpness_level); + va_TraceMsg(trace_ctx, "\tloop_filter_adj_enable = %d\n", p->pic_fields.bits.loop_filter_adj_enable); + va_TraceMsg(trace_ctx, "\tmode_ref_lf_delta_update = %d\n", p->pic_fields.bits.mode_ref_lf_delta_update); + va_TraceMsg(trace_ctx, "\tsign_bias_golden = %d\n", p->pic_fields.bits.sign_bias_golden); + va_TraceMsg(trace_ctx, "\tsign_bias_alternate = %d\n", p->pic_fields.bits.sign_bias_alternate); + va_TraceMsg(trace_ctx, "\tmb_no_coeff_skip = %d\n", p->pic_fields.bits.mb_no_coeff_skip); + va_TraceMsg(trace_ctx, "\tmb_skip_coeff = %d\n", p->pic_fields.bits.mb_skip_coeff); + va_TraceMsg(trace_ctx, "\tloop_filter_disable = %d\n", p->pic_fields.bits.loop_filter_disable); + + va_TraceMsg(trace_ctx, "\tmb_segment_tree_probs: 0x%2x, 0x%2x, 0x%2x\n", + p->mb_segment_tree_probs[0], p->mb_segment_tree_probs[1], p->mb_segment_tree_probs[2]); + + va_TraceMsg(trace_ctx, "\tloop_filter_level: %d, %d, %d, %d\n", + p->loop_filter_level[0], p->loop_filter_level[1], p->loop_filter_level[2], p->loop_filter_level[3]); + + va_TraceMsg(trace_ctx, "\tloop_filter_deltas_ref_frame: %d, %d, %d, %d\n", + p->loop_filter_deltas_ref_frame[0], p->loop_filter_deltas_ref_frame[1], p->loop_filter_deltas_ref_frame[2], p->loop_filter_deltas_ref_frame[3]); + + va_TraceMsg(trace_ctx, "\tloop_filter_deltas_mode: %d, %d, %d, %d\n", + p->loop_filter_deltas_mode[0], p->loop_filter_deltas_mode[1], p->loop_filter_deltas_mode[2], p->loop_filter_deltas_mode[3]); + + va_TraceMsg(trace_ctx, "\tprob_skip_false = %2x\n", p->prob_skip_false); + va_TraceMsg(trace_ctx, "\tprob_intra = %2x\n", p->prob_intra); + va_TraceMsg(trace_ctx, "\tprob_last = %2x\n", p->prob_last); + va_TraceMsg(trace_ctx, "\tprob_gf = %2x\n", p->prob_gf); + + va_TraceMsg(trace_ctx, "\ty_mode_probs: 0x%2x, 0x%2x, 0x%2x, 0x%2x\n", + p->y_mode_probs[0], p->y_mode_probs[1], p->y_mode_probs[2], p->y_mode_probs[3]); + + va_TraceMsg(trace_ctx, "\tuv_mode_probs: 0x%2x, 0x%2x, 0x%2x\n", + p->uv_mode_probs[0], p->uv_mode_probs[1], p->uv_mode_probs[2]); + + va_TraceMsg(trace_ctx, "\tmv_probs[2][19]:\n"); + for(i = 0; i<2; ++i) { + memset(tmp, 0, sizeof tmp); + for (j=0; j<19; j++) + sprintf(tmp + strlen(tmp), "%2x ", p->mv_probs[i][j]); + va_TraceMsg(trace_ctx,"\t\t[%d] = %s\n", i, tmp); + } + + va_TraceMsg(trace_ctx, "\tbool_coder_ctx: range = %02x, value = %02x, count = %d\n", + p->bool_coder_ctx.range, p->bool_coder_ctx.value, p->bool_coder_ctx.count); + + va_TraceMsg(trace_ctx, NULL); + + return; +} + +static void va_TraceVASliceParameterBufferVP8( + VADisplay dpy, + VAContextID context, + VABufferID buffer, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *data) +{ + VASliceParameterBufferVP8 *p = (VASliceParameterBufferVP8 *)data; + DPY2TRACECTX(dpy); + int i; + + va_TraceMsg(trace_ctx, "\t--VASliceParameterBufferVP8\n"); + + va_TraceMsg(trace_ctx, "\tslice_data_size = %d\n", p->slice_data_size); + va_TraceMsg(trace_ctx, "\tslice_data_offset = %d\n", p->slice_data_offset); + va_TraceMsg(trace_ctx, "\tslice_data_flag = %d\n", p->slice_data_flag); + va_TraceMsg(trace_ctx, "\tmacroblock_offset = %d\n", p->macroblock_offset); + va_TraceMsg(trace_ctx, "\tnum_of_partitions = %d\n", p->num_of_partitions); + + for(i = 0; i<9; ++i) + va_TraceMsg(trace_ctx, "\tpartition_size[%d] = %d\n", i, p->partition_size[i]); + + va_TraceMsg(trace_ctx, NULL); + + return; +} + +static void va_TraceVAIQMatrixBufferVP8( + VADisplay dpy, + VAContextID context, + VABufferID buffer, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *data) +{ + char tmp[1024]; + VAIQMatrixBufferVP8 *p = (VAIQMatrixBufferVP8 *)data; + DPY2TRACECTX(dpy); + int i,j; + va_TraceMsg(trace_ctx, "\t--VAIQMatrixBufferVP8\n"); + + va_TraceMsg(trace_ctx, "\tquantization_index[4][6]=\n"); + for (i = 0; i < 4; i++) { + memset(tmp, 0, sizeof tmp); + for (j = 0; j < 6; j++) + sprintf(tmp + strlen(tmp), "%4x, ", p->quantization_index[i][j]); + va_TraceMsg(trace_ctx,"\t\t[%d] = %s\n", i, tmp); + } + + va_TraceMsg(trace_ctx, NULL); + + return; +} +static void va_TraceVAProbabilityBufferVP8( + VADisplay dpy, + VAContextID context, + VABufferID buffer, + VABufferType type, + unsigned int size, + unsigned int num_elements, + void *data) +{ + char tmp[1024]; + VAProbabilityDataBufferVP8 *p = (VAProbabilityDataBufferVP8 *)data; + DPY2TRACECTX(dpy); + int i,j,k,l; + + va_TraceMsg(trace_ctx, "\t--VAProbabilityDataBufferVP8\n"); + + for (i = 0; i < 4; i++) + for (j = 0; j < 8; j++) { + memset(tmp, 0, sizeof tmp); + for (k=0; k<3; k++) + for (l=0; l<11; l++) + sprintf(tmp + strlen(tmp), "%2x, ", p->dct_coeff_probs[i][j][k][l]); + va_TraceMsg(trace_ctx,"\t\t[%d, %d] = %s\n", i, j, tmp); + } + + va_TraceMsg(trace_ctx, NULL); + + return; +} void va_TraceBeginPicture( VADisplay dpy, @@ -2723,12 +2746,12 @@ static void va_TraceVP8Buf( case VASliceParameterBufferType: va_TraceVASliceParameterBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); break; - case VAProbabilityBufferType: - va_TraceVAProbabilityDataBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); - break; case VASliceDataBufferType: va_TraceVABuffers(dpy, context, buffer, type, size, num_elements, pbuf); break; + case VAProbabilityBufferType: + va_TraceVAProbabilityBufferVP8(dpy, context, buffer, type, size, num_elements, pbuf); + break; case VAMacroblockParameterBufferType: break; case VAResidualDataBufferType: diff --git a/va/va_vpp.h b/va/va_vpp.h index 637ccf9..290fa16 100644 --- a/va/va_vpp.h +++ b/va/va_vpp.h @@ -736,6 +736,12 @@ typedef struct _VAProcFilterParameterBuffer { * if this is not set then assumes the frame contains two interleaved fields. */ #define VA_DEINTERLACING_ONE_FIELD 0x0004 +/** + * \brief Film Mode Detection is enabled. If enabled, driver performs inverse + * of various pulldowns, such as 3:2 pulldown. + * if this is not set then assumes FMD is disabled. + */ +#define VA_DEINTERLACING_FMD_ENABLE 0x0008 /**@}*/ /** \brief Deinterlacing filter parametrization. */ @@ -809,21 +815,36 @@ typedef struct _VAProcFilterParameterBufferColorBalance { float value; } VAProcFilterParameterBufferColorBalance; +/** @name FRC Custom Rate types. */ +/**@{*/ +/** \brief 24p to 60p. */ +#define VA_FRAME_RATE_CONVERSION_24p_60p 0x0001 +/** \brief 30p to 60p. */ +#define VA_FRAME_RATE_CONVERSION_30p_60p 0x0002 +/**@}*/ + /** \brief Frame rate conversion filter parametrization. */ typedef struct _VAProcFilterParamterBufferFrameRateConversion { /** \brief filter type. Shall be set to #VAProcFilterFrameRateConversion. */ - VAProcFilterType type; + VAProcFilterType type; /** \brief FPS of input sequence. */ - unsigned int input_fps; + unsigned int input_fps; /** \brief FPS of output sequence. */ - unsigned int output_fps; - /** \brief Number of output frames in addition to the first output frame. */ - unsigned int num_output_frames; + unsigned int output_fps; + /** \brief Number of output frames in addition to the first output frame. + \brief If num_output_frames returned from pipeline query is 0, + \brief vaRenderPicture() will only produce one output frame with each call*/ + unsigned int num_output_frames; /** * \brief Array to store output frames in addition to the first one. - * The first output frame is stored in the render target from vaBeginPicture(). - */ - VASurfaceID* output_frames; + * \brief The first output frame is stored in the render target from vaBeginPicture(). */ + VASurfaceID* output_frames; + /** \brief if frame repeat or not. 1: repeat 0: do not repeat */ + unsigned int repeat_frame; + /** \brief Counter within one complete FRC Cycle. + \brief The counter would run from 0 to 4 for 24to60p in each cycle. + \brief The counter would run from 0 to 1 for 30to60p in each cycle. */ + unsigned int cyclic_counter; } VAProcFilterParameterBufferFrameRateConversion; /** \brief Total color correction filter parametrization. */ @@ -923,6 +944,26 @@ typedef struct _VAProcFilterCapNonLinearAnamorphicScaling { VAProcFilterValueRange nonlinear_crop_range; } VAProcFilterCapNonLinearAnamorphicScaling; +/** \brief Capabilities specification for the Frame Rate Conversion filter. */ +typedef struct _VAProcFilterCapFrameRateConversion { + /** \brief Should be set to 1 if only supported rates are requested. + \brief Set to 0 to get the rest of the caps for the particular custom rate */ + unsigned int bget_custom_rates; + /** \brief FRC custom rates supported by the pipeline in the first query + \brief App request caps for a custom rate in the second query */ + unsigned int frc_custom_rates; + /** \brief FPS of input sequence. */ + unsigned int input_fps; + /** \brief FPS of output sequence. */ + unsigned int output_fps; + /** \brief Number of input frames. */ + unsigned int input_frames; + /** \brief Number of output frames. */ + unsigned int output_frames; + /** \brief Set to 1 if interlaced input is supoorted. */ + unsigned int input_interlaced; +} VAProcFilterCapFrameRateConversion; + /** * \brief Queries video processing filters. * diff --git a/va/vendor/intel/va_intel_fei.h b/va/vendor/intel/va_intel_fei.h new file mode 100644 index 0000000..a036bea --- /dev/null +++ b/va/vendor/intel/va_intel_fei.h @@ -0,0 +1,268 @@ +/* + * Copyright (c) 2007-2013 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 + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file va_intel_fei.h + * \brief The Intel FEI (Flexible Encoding Infrastructure) encoding API + * + * This file contains the \ref api_intel_fei "Intel FEI (Flexible Encoding Infrastructure) encoding API". + */ + +#ifndef VA_INTEL_FEI_H +#define VA_INTEL_FEI_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** + * \defgroup api_intel_fei Intel FEI (Flexible Encoding Infrastructure) encoding API + * + * @{ + */ + +/** \brief FEI frame level control buffer for H.264 */ +typedef struct _VAEncMiscParameterFEIFrameControlH264Intel { + unsigned int function; /* one of the VAConfigAttribEncFunctionType values */ + /** \brief MB (16x16) control input surface. It is valid only when (mb_input | mb_size_ctrl) + * is set to 1. The data in this buffer correspond to the input source. 16x16 MB is in raster scan order, + * each MB control data structure is defined by VAEncFEIMBControlBufferH264. + * Buffer size shall not be less than the number of 16x16 blocks multiplied by + * sizeof(VAEncFEIMBControlBufferH264Intel). + * Note: if mb_qp is set, VAEncQpBufferH264 is expected. + */ + VASurfaceID mb_ctrl; + /** \brief MV predictor. It is valid only when mv_predictor_enable is set to 1. + * Each 16x16 block has one or more pair of motion vectors and the corresponding + * reference indexes as defined by VAEncMVPredictorBufferH264. 16x16 block is in raster scan order. + * Buffer size shall not be less than the number of 16x16 blocks multiplied by + * sizeof(VAEncMVPredictorBufferH264). */ + VASurfaceID mv_predictor; + + /** \brief number of MV predictors. It must not be greater than maximum supported MV predictor. */ + unsigned int num_mv_predictors; + + /** \brief control parameters */ + unsigned int max_len_sp : 8; + unsigned int len_sp : 8; + unsigned int reserved0 : 16; + + unsigned int sub_mb_part_mask : 7; + unsigned int intra_part_mask : 5; + unsigned int multi_pred_l0 : 1; + unsigned int multi_pred_l1 : 1; + unsigned int sub_pel_mode : 2; + unsigned int inter_sad : 2; + unsigned int intra_sad : 2; + unsigned int distortion_type : 1; + unsigned int repartition_check_enable : 1; + unsigned int adaptive_search : 1; + unsigned int mv_predictor_enable : 1; + unsigned int mb_qp : 1; + unsigned int mb_input : 1; + unsigned int mb_size_ctrl : 1; + unsigned int reserved1 : 5; + + unsigned int ref_width : 8; + unsigned int ref_height : 8; + unsigned int search_window : 3; + unsigned int reserved2 : 13; +} VAEncMiscParameterFEIFrameControlH264Intel; + + +/** \brief FEI MB level control data structure */ +typedef struct _VAEncFEIMBControlH264Intel { + /** \brief when set, correposndent MB is coded as skip */ + unsigned int force_to_skip : 1; + /** \brief when set, correposndent MB is coded as intra */ + unsigned int force_to_intra : 1; + unsigned int reserved1 : 30; + + /** \brief when mb_size_ctrl is set, size here is used to budget accumulatively. Set to 0xFF if don't care. */ + unsigned int max_size_in_word : 8; + unsigned int target_size_in_word : 8; + unsigned int reserved2 : 16; + + unsigned int reserved3; +} VAEncFEIMBControlH264Intel; + + +/** \brief Application can use this definition as reference to allocate the buffer + * based on MaxNumPredictor returned from attribute VAConfigAttribEncMVPredictorsIntel query. + **/ +typedef struct _VAEncMVPredictorH264Intel { + /** \brief Reference index corresponding to the entry of RefPicList0 & RefPicList1 in VAEncSliceParameterBufferH264. + * Note that RefPicList0 & RefPicList1 needs to be the same for all slices. + * ref_idx_l0_x : index to RefPicList0; ref_idx_l1_x : index to RefPicList1; x : 0 - MaxNumPredictor. + **/ + unsigned int ref_idx_l0_0 : 4; + unsigned int ref_idx_l1_0 : 4; + unsigned int ref_idx_l0_1 : 4; + unsigned int ref_idx_l1_1 : 4; + unsigned int ref_idx_l0_2 : 4; + unsigned int ref_idx_l1_2 : 4; + unsigned int ref_idx_l0_3 : 4; + unsigned int ref_idx_l1_3 : 4; + unsigned int reserved; + /** \brief MV. MaxNumPredictor must be the returned value from attribute VAConfigAttribEncMVPredictors query. + * Even application doesn't use the maximum predictors, the VAEncMVPredictorH264 structure size + * has to be defined as maximum so each MB can be at a fixed location. + * Note that 0x8000 must be used for correspondent intra block. + **/ + struct _mv + { + /** \brief Motion vector corresponding to ref0x_index. + * mv0[0] is horizontal motion vector and mv0[1] is vertical motion vector. */ + short mv0[2]; + /** \brief Motion vector corresponding to ref1x_index. + * mv1[0] is horizontal motion vector and mv1[1] is vertical motion vector. */ + short mv1[2]; + } mv[4]; /* MaxNumPredictor is 4 */ +} VAEncMVPredictorH264Intel; + + +/** \brief FEI output */ +/** + * Motion vector output is per 4x4 block. For each 4x4 block there is a pair of MVs + * for RefPicList0 and RefPicList1 and each MV is 4 bytes including horizontal and vertical directions. + * Depending on Subblock partition, for the shape that is not 4x4, the MV is replicated + * so each 4x4 block has a pair of MVs. The 16x16 block has 32 MVs (128 bytes). + * 0x8000 is used for correspondent intra block. The 16x16 block is in raster scan order, + * within the 16x16 block, each 4x4 block MV is ordered as below in memory. + * The buffer size shall be greater than or equal to the number of 16x16 blocks multiplied by 128 bytes. + * Note that, when separate ENC and PAK is enabled, the exact layout of this buffer is needed for PAK input. + * App can reuse this buffer, or copy to a different buffer as PAK input. + * 16x16 Block + * ----------------------------------------- + * | 1 | 2 | 5 | 6 | + * ----------------------------------------- + * | 3 | 4 | 7 | 8 | + * ----------------------------------------- + * | 9 | 10 | 13 | 14 | + * ----------------------------------------- + * | 11 | 12 | 15 | 16 | + * ----------------------------------------- + **/ + +/** \brief VAEncFEIModeBufferIntel defines the data structure for VAEncFEIModeBufferTypeIntel per 16x16 MB block. + * The 16x16 block is in raster scan order. Buffer size shall not be less than the number of 16x16 blocks + * multiplied by sizeof(VAEncFEIModeBufferH264Intel). Note that, when separate ENC and PAK is enabled, + * the exact layout of this buffer is needed for PAK input. App can reuse this buffer, + * or copy to a different buffer as PAK input, reserved elements must not be modified when used as PAK input. + **/ +typedef struct _VAEncFEIModeBufferH264Intel { + unsigned int reserved0; + unsigned int reserved1[3]; + + unsigned int inter_mb_mode : 2; + unsigned int mb_skip_flag : 1; + unsigned int reserved00 : 1; + unsigned int intra_mb_mode : 2; + unsigned int reserved01 : 1; + unsigned int field_mb_polarity_flag : 1; + unsigned int mb_type : 5; + unsigned int intra_mb_flag : 1; + unsigned int field_mb_flag : 1; + unsigned int transform8x8_flag : 1; + unsigned int reserved02 : 1; + unsigned int dc_block_coded_cr_flag : 1; + unsigned int dc_block_coded_cb_flag : 1; + unsigned int dc_block_coded_y_flag : 1; + unsigned int reserved03 : 12; + + unsigned int horz_origin : 8; + unsigned int vert_origin : 8; + unsigned int cbp_y : 16; + + unsigned int cbp_cb : 16; + unsigned int cbp_cr : 16; + + unsigned int qp_prime_y : 8; + unsigned int reserved30 : 17; + unsigned int mb_skip_conv_disable : 1; + unsigned int is_last_mb : 1; + unsigned int enable_coefficient_clamp : 1; + unsigned int direct8x8_pattern : 4; + + union + { + /* Intra MBs */ + struct + { + unsigned int luma_intra_pred_modes0 : 16; + unsigned int luma_intra_pred_modes1 : 16; + + unsigned int luma_intra_pred_modes2 : 16; + unsigned int luma_intra_pred_modes3 : 16; + + unsigned int mb_intra_struct : 8; + unsigned int reserved60 : 24; + } intra_mb; + + /* Inter MBs */ + struct + { + unsigned int sub_mb_shapes : 8; + unsigned int sub_mb_pred_modes : 8; + unsigned int reserved40 : 16; + + unsigned int ref_idx_l0_0 : 8; + unsigned int ref_idx_l0_1 : 8; + unsigned int ref_idx_l0_2 : 8; + unsigned int ref_idx_l0_3 : 8; + + unsigned int ref_idx_l1_0 : 8; + unsigned int ref_idx_l1_1 : 8; + unsigned int ref_idx_l1_2 : 8; + unsigned int ref_idx_l1_3 : 8; + } inter_mb; + } mb_mode; + + unsigned int reserved70 : 16; + unsigned int target_size_in_word : 8; + unsigned int max_size_in_word : 8; + + unsigned int reserved2[4]; +} VAEncFEIModeBufferH264Intel; + +/** \brief VAEncFEIDistortionBufferIntel defines the data structure for + * VAEncFEIDistortionBufferType per 16x16 MB block. The 16x16 block is in raster scan order. + * Buffer size shall not be less than the number of 16x16 blocks multiple by sizeof(VAEncFEIDistortionBufferIntel). + **/ +typedef struct _VAEncFEIDistortionBufferH264Intel { + /** \brief Inter-prediction-distortion associated with motion vector i (co-located with subblock_4x4_i). + * Its meaning is determined by sub-shape. It must be zero if the corresponding sub-shape is not chosen. + **/ + unsigned short inter_distortion[16]; + unsigned short best_inter_distortion; + unsigned short best_intra_distortion; +} VAEncFEIDistortionBufferH264Intel; + +#ifdef __cplusplus +} +#endif + +#endif /* VA_INTEL_FEI_H */ diff --git a/va/vendor/intel/va_intel_statistics.h b/va/vendor/intel/va_intel_statistics.h new file mode 100644 index 0000000..d63ca78 --- /dev/null +++ b/va/vendor/intel/va_intel_statistics.h @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2013 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 + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file va_intel_statistics.h + * \brief the Intel statistics API + * +*/ + +#ifndef VA_INTEL_STATISTICS_H +#define VA_INTEL_STATISTICS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** \brief Processing function for getting motion vectors and statistics. */ + +/** This processing function can output motion vectors, distortions (pure pixel distortion, no cost), + * number of non-zero coefficients, MB variance and MB pixel average. + * The purpose is to assist application to perform SCD, complexity analysis, segmentation, BRC, etc. + **/ + + +/** \brief Motion Vector and Statistics frame level controls. + * VAStatsStatisticsParameterBufferTypeIntel for 16x16 block + **/ +typedef struct _VAStatsStatisticsParameter16x16Intel +{ + /** \brief Source surface ID. */ + VASurfaceID input; + + VASurfaceID *past_references; + unsigned int num_past_references; + VASurfaceID *future_references; + unsigned int num_future_references; + + /** \brief ID of the output surface. + * The number of outputs is determined by below DisableMVOutput and DisableStatisticsOutput. + * The output layout is defined by VAStatsStatisticsBufferType and VAStatsMotionVectorBufferType. + **/ + VASurfaceID *outputs; + + /** \brief MV predictor. It is valid only when mv_predictor_ctrl is not 0. + * Each 16x16 block has a pair of MVs, one for past and one for future reference + * as defined by VAMotionVector. The 16x16 block is in raster scan order. + * Buffer size shall not be less than the number of 16x16 blocks multiplied by sizeof(VAMotionVector). + **/ + VASurfaceID mv_predictor; + + /** \brief Qp input surface. It is valid only when mb_qp is set to 1. + * The data in this buffer correspond to the input source. + * One Qp per 16x16 block in raster scan order, each Qp is a signed char (8-bit) value. + **/ + VASurfaceID qp; + + unsigned int frame_qp : 8; + unsigned int len_sp : 8; + unsigned int max_len_sp : 8; + unsigned int reserved0 : 8; + + unsigned int sub_mb_part_mask : 7; + unsigned int sub_pel_mode : 2; + unsigned int inter_sad : 2; + unsigned int intra_sad : 2; + unsigned int adaptive_search : 1; + /** \brief indicate if future or/and past MV in mv_predictor buffer is valid. + * 0: MV predictor disabled + * 1: MV predictor enabled for past reference + * 2: MV predictor enabled for future reference + * 3: MV predictor enabled for both past and future references + **/ + unsigned int mv_predictor_ctrl : 3; + unsigned int mb_qp : 1; + unsigned int ft_enable : 1; + unsigned int reserved1 : 13; + + unsigned int ref_width : 8; + unsigned int ref_height : 8; + unsigned int search_window : 3; + unsigned int reserved2 : 13; + + /** \brief MVOutput. When set to 1, MV output is NOT provided */ + unsigned int disable_mv_output : 1; + /** \brief StatisticsOutput. When set to 1, Statistics output is NOT provided. */ + unsigned int disable_statistics_output : 1; + unsigned int reserved3 : 30; + +} VAStatsStatisticsParameter16x16Intel; + +/** \brief VAStatsMotionVectorBufferTypeIntel. Motion vector buffer layout. + * Motion vector output is per 4x4 block. For each 4x4 block there is a pair of past and future + * reference MVs as defined in VAMotionVectorIntel. Depending on Subblock partition, + * for the shape that is not 4x4, the MV is replicated so each 4x4 block has a pair of MVs. + * If only past reference is used, future MV should be ignored, and vice versa. + * The 16x16 block is in raster scan order, within the 16x16 block, each 4x4 block MV is ordered as below in memory. + * The buffer size shall be greater than or equal to the number of 16x16 blocks multiplied by (sizeof(VAMotionVector) * 16). + * + * 16x16 Block + * ----------------------------------------- + * | 1 | 2 | 5 | 6 | + * ----------------------------------------- + * | 3 | 4 | 7 | 8 | + * ----------------------------------------- + * | 9 | 10 | 13 | 14 | + * ----------------------------------------- + * | 11 | 12 | 15 | 16 | + * ----------------------------------------- + * + **/ + +/** \brief Motion vector data structure. */ +typedef struct _VAMotionVectorIntel { + /** \mv0[0]: horizontal motion vector for past reference */ + /** \mv0[1]: vertical motion vector for past reference */ + /** \mv1[0]: horizontal motion vector for future reference */ + /** \mv1[1]: vertical motion vector for future reference */ + unsigned short mv0[2]; /* past reference */ + unsigned short mv1[2]; /* future reference */ +} VAMotionVectorIntel; + + +/** \brief VAStatsStatisticsBufferTypeIntel. Statistics buffer layout. + * Statistics output is per 16x16 block. Data structure per 16x16 block is defined below. + * The 16x16 block is in raster scan order. The buffer size shall be greater than or equal to + * the number of 16x16 blocks multiplied by sizeof(VAStatsStatistics16x16Intel). + **/ +typedef struct _VAStatsStatistics16x16Intel +{ + /** \brief past reference */ + unsigned int best_inter_distortion0 : 16; + unsigned int inter_mode0 : 16; + + /** \brief future reference */ + unsigned int best_inter_distortion1 : 16; + unsigned int inter_mode1 : 16; + + unsigned int best_intra_distortion : 16; + unsigned int intra_mode : 16; + + unsigned int num_non_zero_coef : 16; + unsigned int reserved : 16; + + unsigned int sum_coef; + + unsigned int variance; + unsigned int pixel_average; +} VAStatsStatistics16x16Intel; + +#ifdef __cplusplus +} +#endif + +#endif /* VA_INTEL_STATISTICS_H */ -- cgit v1.2.3