Skip to content

Commit cdd5e6e

Browse files
committed
Updated decoder tests to enable HBD
Enable 10-bit tests for YUV420 and YUV400. YUV422 and YUV444 path has few failures, hence those are currently disabled.
1 parent cbe8abb commit cdd5e6e

6 files changed

Lines changed: 26 additions & 8 deletions

File tree

‎tests/common/RawBuf.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ size_t RawBuf::planeHeight(size_t planeIdx) const {
7878
return 0;
7979
}
8080

81-
bool RawBuf::allocBuffer(size_t width, size_t height,
81+
bool RawBuf::allocBuffer(size_t width, size_t height, size_t bitDepth,
8282
libhevc::test::Format format, size_t alignment) {
8383
mWidth = width;
8484
mHeight = height;
85+
mBitDepth = bitDepth ? bitDepth : 8;
8586
mFormat = format;
8687

8788
size_t planesCount = numPlanes();
@@ -92,6 +93,7 @@ bool RawBuf::allocBuffer(size_t width, size_t height,
9293
mOffsets[i] = 0;
9394
}
9495

96+
size_t elementSize = (mBitDepth + 7) / 8;
9597
for (size_t i = 0; i < planesCount; ++i) {
9698
size_t w = planeWidth(i);
9799
size_t h = planeHeight(i);
@@ -100,7 +102,7 @@ bool RawBuf::allocBuffer(size_t width, size_t height,
100102
size_t alignedStride = (w + alignment - 1) & ~(alignment - 1);
101103
mStrides[i] = alignedStride;
102104
mOffsets[i] = totalSize;
103-
totalSize += alignedStride * h;
105+
totalSize += alignedStride * h * elementSize;
104106
}
105107

106108
mStorage.resize(totalSize);

‎tests/common/RawBuf.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class RawBuf {
3030
~RawBuf() = default;
3131

3232
// Allocates buffer with aligned strides for each plane based on video format.
33-
bool allocBuffer(size_t width, size_t height, libhevc::test::Format format,
34-
size_t alignment = 1);
33+
bool allocBuffer(size_t width, size_t height, size_t bitDepth,
34+
libhevc::test::Format format, size_t alignment = 1);
3535
void freeBuffer();
3636

3737
uint8_t* planeData(size_t planeIdx);
@@ -40,6 +40,7 @@ class RawBuf {
4040
size_t stride(size_t planeIdx) const { return mStrides[planeIdx]; }
4141
size_t planeWidth(size_t planeIdx) const;
4242
size_t planeHeight(size_t planeIdx) const;
43+
size_t bitDepth() const { return mBitDepth; }
4344
size_t numPlanes() const;
4445

4546
size_t width() const { return mWidth; }
@@ -50,6 +51,7 @@ class RawBuf {
5051
std::vector<uint8_t> mStorage;
5152
size_t mWidth = 0;
5253
size_t mHeight = 0;
54+
size_t mBitDepth = 0;
5355
libhevc::test::Format mFormat = libhevc::test::Format::yuv420p;
5456
size_t mStrides[3] = {0, 0, 0};
5557
size_t mOffsets[3] = {0, 0, 0};

‎tests/decoder/DecHelper.cpp‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,11 @@ bool DecHelper::decodeHeader(size_t& bytesConsumed) {
321321
if (ret == IV_SUCCESS) {
322322
mWidth = decodeOp.s_ivd_video_decode_op_t.u4_pic_wd;
323323
mHeight = decodeOp.s_ivd_video_decode_op_t.u4_pic_ht;
324+
mBitDepth = decodeOp.s_ivd_video_decode_op_t.u4_bit_depth;
324325
mHeaderDecoded = true;
325326

326327
// Allocate the output reconstructed YUV frame buffer
327-
if (!mOutputBuf.allocBuffer(mWidth, mHeight, mFormat)) {
328+
if (!mOutputBuf.allocBuffer(mWidth, mHeight, mBitDepth, mFormat)) {
328329
return false;
329330
}
330331

@@ -435,12 +436,13 @@ std::string DecHelper::computeFrameMd5(const RawBuf& buf) {
435436
size_t planesCount = buf.numPlanes();
436437
for (size_t p = 0; p < planesCount; ++p) {
437438
const uint8_t* planePtr = buf.planeData(p);
439+
size_t pixelSize = (buf.bitDepth() + 7) / 8;
438440
size_t planeW = buf.planeWidth(p);
439441
size_t planeH = buf.planeHeight(p);
440442
size_t planeStride = buf.stride(p);
441443

442444
for (size_t r = 0; r < planeH; ++r) {
443-
md5.update(planePtr + (r * planeStride), planeW);
445+
md5.update(planePtr + (r * planeStride * pixelSize), planeW * pixelSize);
444446
}
445447
}
446448

‎tests/decoder/DecHelper.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class DecHelper {
107107
bool mInFlushMode = false;
108108
size_t mWidth = 0;
109109
size_t mHeight = 0;
110+
size_t mBitDepth = 8;
110111
libhevc::test::Format mFormat = libhevc::test::Format::yuv420p;
111112
size_t mCores = 1;
112113
libhevc::test::Arch mArch = libhevc::test::Arch::defaultArch;

‎tests/decoder/DecTests.cpp‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,18 @@ static const std::vector<DecodeStreamConfig> kDecodeStreams = {
7878
{"bbb_176x144_yuv400.hevc", Format::yuv400p, "bbb_176x144_yuv400_md5.txt"},
7979
{"bbb_176x144_yuv420.hevc", Format::yuv420p, "bbb_176x144_yuv420_md5.txt"},
8080
{"bbb_176x144_yuv422.hevc", Format::yuv422p, "bbb_176x144_yuv422_md5.txt"},
81-
{"bbb_176x144_yuv444.hevc", Format::yuv444p, "bbb_176x144_yuv444_md5.txt"}};
81+
{"bbb_176x144_yuv444.hevc", Format::yuv444p, "bbb_176x144_yuv444_md5.txt"},
82+
{"bbb_10b_176x144_yuv400.hevc", Format::yuv400p,
83+
"bbb_10b_176x144_yuv400_md5.txt"},
84+
{"bbb_10b_176x144_yuv420.hevc", Format::yuv420p,
85+
"bbb_10b_176x144_yuv420_md5.txt"},
86+
/* TODO() - enable when 10 bit format is supported
87+
{"bbb_10b_176x144_yuv422.hevc", Format::yuv422p,
88+
"bbb_10b_176x144_yuv422_md5.txt"},
89+
{"bbb_10b_176x144_yuv444.hevc", Format::yuv444p,
90+
"bbb_10b_176x144_yuv444_md5.txt"},
91+
*/
92+
};
8293

8394
INSTANTIATE_TEST_SUITE_P(DecoderRegression, DecTestFixture,
8495
::testing::Combine(::testing::ValuesIn(kDecodeStreams),

‎tests/encoder/EncHelper.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ bool EncHelper::initEncoder() {
215215
return false;
216216
}
217217

218-
if (!mInputBuf.allocBuffer(mWidth, mHeight, mFormat)) {
218+
if (!mInputBuf.allocBuffer(mWidth, mHeight, /* bitDepth */ 8, mFormat)) {
219219
deinitEncoder();
220220
return false;
221221
}

0 commit comments

Comments
 (0)