| 1 |
/* |
| 2 |
* Copyright (c) 2011-2023, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file codechal.h |
| 24 |
//! \brief Defines the public interface for CodecHal. |
| 25 |
//! |
| 26 |
#ifndef __CODECHAL_H__ |
| 27 |
#define __CODECHAL_H__ |
| 28 |
|
| 29 |
#include "codechal_common.h" |
| 30 |
#include "mhw_cp_interface.h" |
| 31 |
#include "codec_def_common.h" |
| 32 |
|
| 33 |
#ifdef __cplusplus |
| 34 |
extern "C" { |
| 35 |
#endif // __cplusplus |
| 36 |
|
| 37 |
#define CODECHAL_PUBLIC_CHK_NULL(_ptr) \ |
| 38 |
MOS_CHK_NULL(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_PUBLIC, _ptr) |
| 39 |
|
| 40 |
#define CODECHAL_PUBLIC_CHK_STATUS(_stmt) \ |
| 41 |
MOS_CHK_STATUS(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_PUBLIC, _stmt) |
| 42 |
|
| 43 |
#define CODECHAL_PUBLIC_CHK_NULL_NO_STATUS(_ptr) \ |
| 44 |
MOS_CHK_NULL_NO_STATUS(MOS_COMPONENT_CODEC, MOS_CODEC_SUBCOMP_PUBLIC, _ptr) |
| 45 |
|
| 46 |
//----------------------------------------------------------------------------- |
| 47 |
// Forward declaration - |
| 48 |
// IMPORTANT - DDI interfaces are NOT to access internal CODECHAL states |
| 49 |
//----------------------------------------------------------------------------- |
| 50 |
class CodechalDecode; |
| 51 |
class CodechalEncoderState; |
| 52 |
|
| 53 |
// Forward Declarations |
| 54 |
class USERMODE_DEVICE_CONTEXT; |
| 55 |
|
| 56 |
#if (_DEBUG || _RELEASE_INTERNAL) |
| 57 |
|
| 58 |
#define CODECHAL_UPDATE_ENCODE_MMC_USER_FEATURE(surface, mosCtx) \ |
| 59 |
{ \ |
| 60 |
MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData; \ |
| 61 |
\ |
| 62 |
userFeatureWriteData = __NULL_USER_FEATURE_VALUE_WRITE_DATA__; \ |
| 63 |
userFeatureWriteData.Value.i32Data = surface.bCompressible; \ |
| 64 |
userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_MMC_ENC_RECON_COMPRESSIBLE_ID; \ |
| 65 |
MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, mosCtx); \ |
| 66 |
\ |
| 67 |
userFeatureWriteData = __NULL_USER_FEATURE_VALUE_WRITE_DATA__; \ |
| 68 |
userFeatureWriteData.Value.i32Data = surface.MmcState; \ |
| 69 |
userFeatureWriteData.ValueID = __MEDIA_USER_FEATURE_VALUE_MMC_ENC_RECON_COMPRESSMODE_ID; \ |
| 70 |
MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, mosCtx); \ |
| 71 |
} |
| 72 |
#endif |
| 73 |
|
| 74 |
#define CODECHAL_UPDATE_VDBOX_USER_FEATURE(videoGpuNode, mosCtx) \ |
| 75 |
do \ |
| 76 |
{ \ |
| 77 |
MOS_USER_FEATURE_VALUE_ID valueID; \ |
| 78 |
MOS_USER_FEATURE_VALUE_DATA userFeatureData; \ |
| 79 |
MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData; \ |
| 80 |
\ |
| 81 |
valueID = ((videoGpuNode == MOS_GPU_NODE_VIDEO2) ? \ |
| 82 |
__MEDIA_USER_FEATURE_VALUE_NUMBER_OF_CODEC_DEVICES_ON_VDBOX2_ID : \ |
| 83 |
__MEDIA_USER_FEATURE_VALUE_NUMBER_OF_CODEC_DEVICES_ON_VDBOX1_ID); \ |
| 84 |
\ |
| 85 |
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData)); \ |
| 86 |
MOS_UserFeature_ReadValue_ID( \ |
| 87 |
nullptr, \ |
| 88 |
valueID, \ |
| 89 |
&userFeatureData, \ |
| 90 |
mosCtx); \ |
| 91 |
\ |
| 92 |
userFeatureData.i32Data++; \ |
| 93 |
MOS_ZeroMemory(&userFeatureWriteData, sizeof(userFeatureWriteData)); \ |
| 94 |
userFeatureWriteData.ValueID = valueID; \ |
| 95 |
userFeatureWriteData.Value.i32Data = userFeatureData.i32Data; \ |
| 96 |
MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, mosCtx); \ |
| 97 |
} while (0) |
| 98 |
|
| 99 |
#define CODECHAL_UPDATE_USED_VDBOX_ID_USER_FEATURE(instanceId, mosCtx) \ |
| 100 |
do \ |
| 101 |
{ \ |
| 102 |
MOS_USER_FEATURE_VALUE_ID valueID; \ |
| 103 |
MOS_USER_FEATURE_VALUE_DATA userFeatureData; \ |
| 104 |
MOS_USER_FEATURE_VALUE_WRITE_DATA userFeatureWriteData; \ |
| 105 |
\ |
| 106 |
valueID = __MEDIA_USER_FEATURE_VALUE_VDBOX_ID_USED; \ |
| 107 |
MOS_ZeroMemory(&userFeatureData, sizeof(userFeatureData)); \ |
| 108 |
MOS_UserFeature_ReadValue_ID( \ |
| 109 |
nullptr, \ |
| 110 |
valueID, \ |
| 111 |
&userFeatureData, \ |
| 112 |
mosCtx); \ |
| 113 |
\ |
| 114 |
if(!(userFeatureData.i32DataFlag & (1 << ((instanceId) << 2)))) \ |
| 115 |
{ \ |
| 116 |
userFeatureData.i32Data |= 1 << ((instanceId) << 2); \ |
| 117 |
userFeatureWriteData = __NULL_USER_FEATURE_VALUE_WRITE_DATA__; \ |
| 118 |
userFeatureWriteData.ValueID = valueID; \ |
| 119 |
userFeatureWriteData.Value.i32Data = userFeatureData.i32Data; \ |
| 120 |
MOS_UserFeature_WriteValues_ID(nullptr, &userFeatureWriteData, 1, mosCtx); \ |
| 121 |
} \ |
| 122 |
} while (0) |
| 123 |
|
| 124 |
// VP8 Coefficient Probability data |
| 125 |
typedef struct _CODECHAL_VP8_COEFFPROB_DATA |
| 126 |
{ |
| 127 |
uint8_t CoeffProbs[4][8][3][11]; |
| 128 |
} CODECHAL_VP8_COEFFPROB_DATA, *PCODECHAL_VP8_COEFFPROB_DATA; |
| 129 |
|
| 130 |
typedef struct _CODECHAL_VP8_HYBRIDPAK_FRAMEUPDATE |
| 131 |
{ |
| 132 |
uint32_t PrevFrameSize; |
| 133 |
uint8_t TwoPrevFrameFlag; |
| 134 |
uint16_t RefFrameCost[4]; |
| 135 |
uint16_t IntraModeCost[4][4]; |
| 136 |
uint16_t InterModeCost[4]; |
| 137 |
uint8_t IntraNonDCPenalty16x16[4]; |
| 138 |
uint8_t IntraNonDCPenalty4x4[4]; |
| 139 |
uint8_t RefQpIndex[3]; |
| 140 |
}CODECHAL_VP8_HYBRIDPAK_FRAMEUPDATE, *PCODECHAL_VP8_HYBRIDPAK_FRAMEUPDATE; |
| 141 |
|
| 142 |
/*! \brief Information pertaining to the PAK object and MV data. |
| 143 |
*/ |
| 144 |
typedef struct _CODEC_ENCODE_MBDATA_LAYOUT |
| 145 |
{ |
| 146 |
uint32_t uiMbCodeBottomFieldOffset; //!< Offset to the PAK objects for the bottom field |
| 147 |
uint32_t uiMvOffset; //!< Base offset of the MV data |
| 148 |
uint32_t uiMvBottomFieldOffset; //!< Offset to the MV data for the bottom field |
| 149 |
} CODEC_ENCODE_MBDATA_LAYOUT, *PCODEC_ENCODE_MBDATA_LAYOUT; |
| 150 |
|
| 151 |
#ifdef __cplusplus |
| 152 |
} |
| 153 |
#endif // __cplusplus |
| 154 |
|
| 155 |
#endif // __CODECHAL_H__ |