10f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/*
20f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * Copyright (c) 2013 Intel Corporation. All Rights Reserved.
30f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *
40f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * Permission is hereby granted, free of charge, to any person obtaining a
50f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * copy of this software and associated documentation files (the
60f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * "Software"), to deal in the Software without restriction, including
70f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * without limitation the rights to use, copy, modify, merge, publish,
80f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * distribute, sub license, and/or sell copies of the Software, and to
90f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * permit persons to whom the Software is furnished to do so, subject to
100f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * the following conditions:
110f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *
120f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * The above copyright notice and this permission notice (including the
130f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * next paragraph) shall be included in all copies or substantial portions
140f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * of the Software.
150f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *
160f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
170f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
180f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
190f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * IN NO EVENT SHALL INTEL AND/OR ITS SUPPLIERS BE LIABLE FOR
200f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
210f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
220f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
230f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan */
240f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
250f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/**
260f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * \file va_intel_statistics.h
270f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * \brief the Intel statistics API
280f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *
290f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan*/
300f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
310f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#ifndef VA_INTEL_STATISTICS_H
320f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#define VA_INTEL_STATISTICS_H
330f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
340f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#ifdef __cplusplus
350f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuanextern "C" {
360f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#endif
370f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
380f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/** \brief Processing function for getting motion vectors and statistics. */
390f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
400f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/** This processing function can output motion vectors, distortions (pure pixel distortion, no cost),
410f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * number of non-zero coefficients, MB variance and MB pixel average.
420f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * The purpose is to assist application to perform SCD, complexity analysis, segmentation, BRC, etc.
430f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan **/
440f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
450f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
460f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/** \brief Motion Vector and Statistics frame level controls.
470f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * VAStatsStatisticsParameterBufferTypeIntel for 16x16 block
480f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan **/
490f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuantypedef struct _VAStatsStatisticsParameter16x16Intel
500f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan{
510f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief Source surface ID.  */
520f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    VASurfaceID     input;
530f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
540f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    VASurfaceID     *past_references;
550f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    num_past_references;
560f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    VASurfaceID     *future_references;
570f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    num_future_references;
580f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
590f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief ID of the output surface.
600f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * The number of outputs is determined by below DisableMVOutput and DisableStatisticsOutput.
610f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * The output layout is defined by VAStatsStatisticsBufferType and VAStatsMotionVectorBufferType.
620f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     **/
630f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    VASurfaceID     *outputs;
640f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
650f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief MV predictor. It is valid only when mv_predictor_ctrl is not 0.
660f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * Each 16x16 block has a pair of MVs, one for past and one for future reference
670f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * as defined by VAMotionVector. The 16x16 block is in raster scan order.
680f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * Buffer size shall not be less than the number of 16x16 blocks multiplied by sizeof(VAMotionVector).
690f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     **/
700f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    VASurfaceID     mv_predictor;
710f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
720f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief Qp input surface. It is valid only when mb_qp is set to 1.
730f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * The data in this buffer correspond to the input source.
740f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * One Qp per 16x16 block in raster scan order, each Qp is a signed char (8-bit) value.
750f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     **/
760f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    VASurfaceID     qp;
770f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
780f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    frame_qp                    : 8;
790f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    len_sp                      : 8;
800f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    max_len_sp                  : 8;
810f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    reserved0                   : 8;
820f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
830f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    sub_mb_part_mask            : 7;
840f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    sub_pel_mode                : 2;
850f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    inter_sad                   : 2;
860f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    intra_sad                   : 2;
870f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    adaptive_search	            : 1;
880f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief indicate if future or/and past MV in mv_predictor buffer is valid.
890f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * 0: MV predictor disabled
900f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * 1: MV predictor enabled for past reference
910f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * 2: MV predictor enabled for future reference
920f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     * 3: MV predictor enabled for both past and future references
930f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan     **/
940f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    mv_predictor_ctrl           : 3;
950f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    mb_qp                       : 1;
960f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    ft_enable                   : 1;
970f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    reserved1                   : 13;
980f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
990f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    ref_width                   : 8;
1000f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    ref_height                  : 8;
1010f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    search_window               : 3;
1020f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    reserved2                   : 13;
1030f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1040f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief MVOutput. When set to 1, MV output is NOT provided */
1050f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int	disable_mv_output           : 1;
1060f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief StatisticsOutput. When set to 1, Statistics output is NOT provided. */
1070f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    disable_statistics_output   : 1;
1080f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    reserved3                   : 30;
1090f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1100f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan} VAStatsStatisticsParameter16x16Intel;
1110f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1120f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/** \brief VAStatsMotionVectorBufferTypeIntel. Motion vector buffer layout.
1130f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * Motion vector output is per 4x4 block. For each 4x4 block there is a pair of past and future
11410d94aff40fa7cb9349f839613856ea37327268cAustin Yuan * reference MVs as defined in VAMotionVector. Depending on Subblock partition,
1150f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * for the shape that is not 4x4, the MV is replicated so each 4x4 block has a pair of MVs.
1160f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * If only past reference is used, future MV should be ignored, and vice versa.
1170f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * The 16x16 block is in raster scan order, within the 16x16 block, each 4x4 block MV is ordered as below in memory.
1180f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * The buffer size shall be greater than or equal to the number of 16x16 blocks multiplied by (sizeof(VAMotionVector) * 16).
1190f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *
1200f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *                      16x16 Block
1210f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        -----------------------------------------
1220f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        |    1    |    2    |    5    |    6    |
1230f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        -----------------------------------------
1240f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        |    3    |    4    |    7    |    8    |
1250f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        -----------------------------------------
1260f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        |    9    |    10   |    13   |    14   |
1270f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        -----------------------------------------
1280f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        |    11   |    12   |    15   |    16   |
1290f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *        -----------------------------------------
1300f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan *
1310f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan **/
1320f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1330f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan/** \brief VAStatsStatisticsBufferTypeIntel. Statistics buffer layout.
1340f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * Statistics output is per 16x16 block. Data structure per 16x16 block is defined below.
1350f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * The 16x16 block is in raster scan order. The buffer size shall be greater than or equal to
1360f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan * the number of 16x16 blocks multiplied by sizeof(VAStatsStatistics16x16Intel).
1370f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan **/
1380f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuantypedef struct _VAStatsStatistics16x16Intel
1390f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan{
1400f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief past reference  */
1410f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    best_inter_distortion0 : 16;
1420f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    inter_mode0            : 16;
1430f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1440f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    /** \brief future reference  */
1450f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    best_inter_distortion1 : 16;
1460f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    inter_mode1            : 16;
1470f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1480f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    best_intra_distortion  : 16;
1490f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    intra_mode             : 16;
1500f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1510f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    num_non_zero_coef      : 16;
1520f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    reserved               : 16;
1530f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1540f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    sum_coef;
1550f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1560f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    variance;
1570f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan    unsigned int    pixel_average;
1580f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan} VAStatsStatistics16x16Intel;
1590f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1600f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#ifdef __cplusplus
1610f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan}
1620f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#endif
1630f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan
1640f5162def402b0b2fa7db332b323e7497b413cc1Austin Yuan#endif /* VA_INTEL_STATISTICS_H */
165