| 1 |
/* |
| 2 |
* Copyright (c) 2018, 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 |
#ifndef __TEST_DATA_DECODE_H__ |
| 23 |
#define __TEST_DATA_DECODE_H__ |
| 24 |
|
| 25 |
#include <memory> |
| 26 |
#include <map> |
| 27 |
#include <string> |
| 28 |
#include <string.h> |
| 29 |
#include "driver_loader.h" |
| 30 |
|
| 31 |
#define DEC_FRAME_NUM 3 |
| 32 |
|
| 33 |
const FeatureID TEST_Intel_Decode_HEVC = { VAProfileHEVCMain, VAEntrypointVLD, }; |
| 34 |
const FeatureID TEST_Intel_Decode_AVC = { VAProfileH264Main, VAEntrypointVLD, }; |
| 35 |
|
| 36 |
class DecBufHEVC |
| 37 |
{ |
| 38 |
public: |
| 39 |
|
| 40 |
DecBufHEVC(); |
| 41 |
|
| 42 |
uint32_t GetPpsSize() { return sizeof(VAPictureParameterBufferHEVC); } |
| 43 |
|
| 44 |
uint32_t GetSlcSize() { return sizeof(VASliceParameterBufferHEVC); } |
| 45 |
|
| 46 |
size_t GetBsSize() { return m_bitstream.size(); } |
| 47 |
|
| 48 |
VAPictureParameterBufferHEVC *GetPpsBuf() { return m_pps.get(); } |
| 49 |
|
| 50 |
VASliceParameterBufferHEVC *GetSlcBuf() { return m_slc.get(); } |
| 51 |
|
| 52 |
uint8_t *GetBsBuf() { return &m_bitstream[0]; } |
| 53 |
|
| 54 |
private: |
| 55 |
|
| 56 |
std::shared_ptr<VAPictureParameterBufferHEVC> m_pps; |
| 57 |
std::shared_ptr<VASliceParameterBufferHEVC> m_slc; |
| 58 |
std::vector<uint8_t> m_bitstream; |
| 59 |
}; |
| 60 |
|
| 61 |
class DecBufAVC |
| 62 |
{ |
| 63 |
public: |
| 64 |
|
| 65 |
DecBufAVC(); |
| 66 |
|
| 67 |
uint32_t GetPpsSize() { return sizeof(VAPictureParameterBufferH264); } |
| 68 |
|
| 69 |
uint32_t GetSlcSize() { return sizeof(VASliceParameterBufferH264); } |
| 70 |
|
| 71 |
size_t GetBsSize() { return m_bitstream.size(); } |
| 72 |
|
| 73 |
VAPictureParameterBufferH264 *GetPpsBuf() { return m_pps.get(); } |
| 74 |
|
| 75 |
VASliceParameterBufferH264 *GetSlcBuf() { return m_slc.get(); } |
| 76 |
|
| 77 |
uint8_t *GetBsBuf() { return &m_bitstream[0]; } |
| 78 |
|
| 79 |
private: |
| 80 |
|
| 81 |
std::shared_ptr<VAPictureParameterBufferH264> m_pps; |
| 82 |
std::shared_ptr<VASliceParameterBufferH264> m_slc; |
| 83 |
std::vector<uint8_t> m_bitstream; |
| 84 |
}; |
| 85 |
|
| 86 |
class DecTestData |
| 87 |
{ |
| 88 |
public: |
| 89 |
|
| 90 |
virtual ~DecTestData() { } |
| 91 |
|
| 92 |
FeatureID GetFeatureID() { return m_featureId; } |
| 93 |
|
| 94 |
uint32_t GetWidth() { return m_picWidth; } |
| 95 |
|
| 96 |
uint32_t GetHeight() { return m_picHeight; } |
| 97 |
|
| 98 |
std::vector<std::vector<CompBufConif>> &GetCompBuffers() { return m_compBufs; } |
| 99 |
|
| 100 |
std::vector<VASurfaceID> &GetResources() { return m_resources; } |
| 101 |
|
| 102 |
std::vector<VAConfigAttrib> &GetConfAttrib() {return m_confAttrib; } |
| 103 |
|
| 104 |
virtual void UpdateCompBuffers(int frameId) { } |
| 105 |
|
| 106 |
public: |
| 107 |
|
| 108 |
int m_num_frames; |
| 109 |
|
| 110 |
protected: |
| 111 |
|
| 112 |
FeatureID m_featureId; |
| 113 |
uint32_t m_picWidth; |
| 114 |
uint32_t m_picHeight; |
| 115 |
uint32_t m_surfacesNum; |
| 116 |
std::vector<std::vector<CompBufConif>> m_compBufs; |
| 117 |
std::vector<VASurfaceID> m_resources; |
| 118 |
std::vector<VAConfigAttrib> m_confAttrib; |
| 119 |
}; |
| 120 |
|
| 121 |
class DecTestDataHEVC : public DecTestData |
| 122 |
{ |
| 123 |
public: |
| 124 |
|
| 125 |
DecTestDataHEVC(FeatureID testFeatureID, bool bInShortFormat); |
| 126 |
|
| 127 |
void UpdateCompBuffers(int frameId) override; |
| 128 |
|
| 129 |
struct DecFrameDataHEVC |
| 130 |
{ |
| 131 |
std::vector<uint8_t> picParam; |
| 132 |
std::vector<uint8_t> slcParam; |
| 133 |
std::vector<uint8_t> bsData; |
| 134 |
}; |
| 135 |
|
| 136 |
protected: |
| 137 |
|
| 138 |
void InitCompBuffers(); |
| 139 |
|
| 140 |
protected: |
| 141 |
|
| 142 |
bool m_bShortFormat; |
| 143 |
std::vector<DecFrameDataHEVC> m_frameArray; |
| 144 |
std::vector<DecFrameDataHEVC> m_frameArrayLong; |
| 145 |
std::shared_ptr<DecBufHEVC> m_pBufs = nullptr; |
| 146 |
}; |
| 147 |
|
| 148 |
class DecTestDataHEVCLong : public DecTestDataHEVC |
| 149 |
{ |
| 150 |
public: |
| 151 |
|
| 152 |
DecTestDataHEVCLong(FeatureID testFeatureID) : DecTestDataHEVC(testFeatureID, false) { } |
| 153 |
}; |
| 154 |
|
| 155 |
class DecTestDataHEVCShort:public DecTestDataHEVC |
| 156 |
{ |
| 157 |
public: |
| 158 |
|
| 159 |
DecTestDataHEVCShort(FeatureID testFeatureID) : DecTestDataHEVC(testFeatureID, true) { } |
| 160 |
}; |
| 161 |
|
| 162 |
class DecTestDataAVC : public DecTestData |
| 163 |
{ |
| 164 |
public: |
| 165 |
|
| 166 |
DecTestDataAVC(FeatureID testFeatureID, bool bInShortFormat); |
| 167 |
|
| 168 |
void UpdateCompBuffers(int frameId) override; |
| 169 |
|
| 170 |
struct DecFrameDataAVC |
| 171 |
{ |
| 172 |
std::vector<uint8_t> picParam; |
| 173 |
std::vector<uint8_t> slcParam; |
| 174 |
std::vector<uint8_t> bsData; |
| 175 |
}; |
| 176 |
|
| 177 |
protected: |
| 178 |
|
| 179 |
void InitCompBuffers(); |
| 180 |
|
| 181 |
protected: |
| 182 |
|
| 183 |
bool m_bShortFormat; |
| 184 |
std::vector<DecFrameDataAVC> m_frameArray; |
| 185 |
std::vector<DecFrameDataAVC> m_frameArrayLong; |
| 186 |
std::shared_ptr<DecBufAVC> m_pBufs = nullptr; |
| 187 |
}; |
| 188 |
|
| 189 |
class DecTestDataAVCLong : public DecTestDataAVC |
| 190 |
{ |
| 191 |
public: |
| 192 |
|
| 193 |
DecTestDataAVCLong(FeatureID testFeatureID) : DecTestDataAVC(testFeatureID, false) { } |
| 194 |
|
| 195 |
protected: |
| 196 |
|
| 197 |
void InitCompBuffers(); |
| 198 |
}; |
| 199 |
|
| 200 |
class DecTestDataAVCShort : public DecTestDataAVC |
| 201 |
{ |
| 202 |
public: |
| 203 |
|
| 204 |
DecTestDataAVCShort(FeatureID testFeatureID) : DecTestDataAVC(testFeatureID, true) { } |
| 205 |
|
| 206 |
protected: |
| 207 |
|
| 208 |
void InitCompBuffers() { } |
| 209 |
}; |
| 210 |
|
| 211 |
class DecTestDataFactory |
| 212 |
{ |
| 213 |
public: |
| 214 |
|
| 215 |
static DecTestData *GetDecTestData(const std::string &description) |
| 216 |
{ |
| 217 |
if (description == "HEVC-Long") |
| 218 |
{ |
| 219 |
return new DecTestDataHEVCLong(TEST_Intel_Decode_HEVC); |
| 220 |
} |
| 221 |
if (description == "AVC-Long") |
| 222 |
{ |
| 223 |
return new DecTestDataAVCLong(TEST_Intel_Decode_AVC); |
| 224 |
} |
| 225 |
|
| 226 |
return nullptr; |
| 227 |
} |
| 228 |
}; |
| 229 |
|
| 230 |
#endif // __TEST_DATA_DECODE_H__ |