diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2023-12-14 10:46:16 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-12-14 10:46:16 +0000 |
commit | a25ecd5501816e86b8ffb82c4a9b91e4575c0c19 (patch) | |
tree | 7207c88e56f2212852c1b80083792eb92c3e86f5 | |
parent | 07fcccabe527881a765314e6e778394baaa29ab5 (diff) | |
parent | 2d9dccd0059b710a2e77aaa0a3b270661f2e0773 (diff) | |
download | av-a25ecd5501816e86b8ffb82c4a9b91e4575c0c19.tar.gz |
Merge "Cleanup of Vts-Flags" into main am: 32a0d178cf am: 26ddfc1fb6 am: 2d9dccd005
Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/2780767
Change-Id: Iface0b4904a8f9f0ed055110e4100bdc6525144c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
4 files changed, 65 insertions, 57 deletions
diff --git a/media/codec2/hal/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp b/media/codec2/hal/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp index ce9fc39e68..c7c04c588c 100644 --- a/media/codec2/hal/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp +++ b/media/codec2/hal/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp @@ -90,8 +90,8 @@ class Codec2AudioDecHidlTestBase : public ::testing::Test { std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore(); CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAllocator), C2_OK); - mLinearPool = std::make_shared<C2PooledBlockPool>( - mLinearAllocator, mBlockPoolId++, getBufferPoolVer()); + mLinearPool = std::make_shared<C2PooledBlockPool>(mLinearAllocator, mBlockPoolId++, + getBufferPoolVer()); ASSERT_NE(mLinearPool, nullptr); std::vector<std::unique_ptr<C2Param>> queried; @@ -336,7 +336,9 @@ void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp ASSERT_TRUE(false) << "Wait for generating C2Work exceeded timeout"; } int64_t timestamp = (*Info)[frameID].timestamp; - flags = ((*Info)[frameID].flags == FLAG_CONFIG_DATA) ? C2FrameData::FLAG_CODEC_CONFIG : 0; + flags = ((*Info)[frameID].vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) + ? C2FrameData::FLAG_CODEC_CONFIG + : 0; if (signalEOS && ((frameID == (int)Info->size() - 1) || (frameID == (offset + range - 1)))) flags |= C2FrameData::FLAG_END_OF_STREAM; @@ -531,14 +533,10 @@ TEST_P(Codec2AudioDecHidlTest, ThumbnailTest) { // request EOS for thumbnail // signal EOS flag with last frame - size_t i = -1; - uint32_t flags; - do { - i++; - flags = 0; - if (Info[i].flags) flags = 1u << (Info[i].flags - 1); - - } while (!(flags & SYNC_FRAME)); + size_t i; + for (i = 0; i < Info.size(); i++) { + if (Info[i].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) break; + } std::ifstream eleStream; eleStream.open(mInputFile, std::ifstream::binary); ASSERT_EQ(eleStream.is_open(), true); @@ -643,14 +641,11 @@ TEST_P(Codec2AudioDecHidlTest, FlushTest) { mFlushedIndices.clear(); int index = numFramesFlushed; bool keyFrame = false; - uint32_t flags = 0; while (index < (int)Info.size()) { - if (Info[index].flags) flags = 1u << (Info[index].flags - 1); - if ((flags & SYNC_FRAME) == SYNC_FRAME) { + if (Info[index].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) { keyFrame = true; break; } - flags = 0; eleStream.ignore(Info[index].bytesCount); index++; } @@ -684,24 +679,24 @@ TEST_P(Codec2AudioDecHidlTest, DecodeTestEmptyBuffersInserted) { int bytesCount = 0; uint32_t frameId = 0; uint32_t flags = 0; + uint32_t vtsFlags = 0; uint32_t timestamp = 0; bool codecConfig = false; // This test introduces empty CSD after every 20th frame // and empty input frames at an interval of 5 frames. while (1) { if (!(frameId % 5)) { - if (!(frameId % 20)) - flags = 32; - else - flags = 0; + vtsFlags = !(frameId % 20) ? (1 << VTS_BIT_FLAG_CSD_FRAME) : 0; bytesCount = 0; } else { if (!(eleInfo >> bytesCount)) break; eleInfo >> flags; + vtsFlags = mapInfoFlagstoVtsFlags(flags); + ASSERT_NE(vtsFlags, 0xFF) << "unrecognized flag entry in info file: " << mInfoFile; eleInfo >> timestamp; - codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0; + codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0; } - Info.push_back({bytesCount, flags, timestamp}); + Info.push_back({bytesCount, vtsFlags, timestamp}); frameId++; } eleInfo.close(); diff --git a/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp b/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp index f36bc4151d..a72f7bd524 100644 --- a/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp +++ b/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp @@ -233,18 +233,24 @@ int32_t populateInfoVector(std::string info, android::Vector<FrameInfo>* frameIn int32_t numCsds = 0; int32_t bytesCount = 0; uint32_t flags = 0; + uint32_t vtsFlags = 0; uint32_t timestamp = 0; while (1) { if (!(eleInfo >> bytesCount)) break; eleInfo >> flags; + vtsFlags = mapInfoFlagstoVtsFlags(flags); + if (vtsFlags == 0xFF) { + ALOGE("unrecognized flag entry in info file %s", info.c_str()); + return -1; + } eleInfo >> timestamp; - bool codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0; + bool codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0 ; if (codecConfig) numCsds++; - bool nonDisplayFrame = ((flags & FLAG_NON_DISPLAY_FRAME) != 0); + bool nonDisplayFrame = (vtsFlags & (1 << VTS_BIT_FLAG_NO_SHOW_FRAME)) != 0; if (timestampDevTest && !codecConfig && !nonDisplayFrame) { timestampUslist->push_back(timestamp); } - frameInfo->push_back({bytesCount, flags, timestamp}); + frameInfo->push_back({bytesCount, vtsFlags, timestamp}); } ALOGV("numCsds : %d", numCsds); eleInfo.close(); @@ -273,3 +279,11 @@ void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork, ASSERT_EQ(flushedIndices.empty(), true); flushedWork.clear(); } + +int mapInfoFlagstoVtsFlags(int infoFlags) { + if (infoFlags == 0) return 0; + else if (infoFlags == 0x1) return (1 << VTS_BIT_FLAG_SYNC_FRAME); + else if (infoFlags == 0x10) return (1 << VTS_BIT_FLAG_NO_SHOW_FRAME); + else if (infoFlags == 0x20) return (1 << VTS_BIT_FLAG_CSD_FRAME); + return 0xFF; +} diff --git a/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h b/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h index 48e80a4929..eda7b9928a 100644 --- a/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h +++ b/media/codec2/hal/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h @@ -29,9 +29,6 @@ #include <chrono> #include <fstream> -#define FLAG_NON_DISPLAY_FRAME (1 << 4) -#define FLAG_CONFIG_DATA (1 << 5) - #define MAX_RETRY 20 #define TIME_OUT 400ms #define MAX_INPUT_BUFFERS 8 @@ -53,9 +50,15 @@ extern std::string sResourceDir; // Component name prefix extern std::string sComponentNamePrefix; +enum c2_vts_flags_t { + VTS_BIT_FLAG_SYNC_FRAME = 1, + VTS_BIT_FLAG_NO_SHOW_FRAME = 2, + VTS_BIT_FLAG_CSD_FRAME = 3, +}; + struct FrameInfo { int bytesCount; - uint32_t flags; + uint32_t vtsFlags; int64_t timestamp; }; @@ -165,4 +168,7 @@ int32_t populateInfoVector(std::string info, android::Vector<FrameInfo>* frameIn void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork, std::list<std::unique_ptr<C2Work>>& workQueue, std::list<uint64_t>& flushedIndices, std::mutex& queueLock); + +int mapInfoFlagstoVtsFlags(int infoFlags); + #endif // MEDIA_C2_HIDL_TEST_COMMON_H diff --git a/media/codec2/hal/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp b/media/codec2/hal/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp index 2cf0d6e2c4..fdb28f4fbe 100644 --- a/media/codec2/hal/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp +++ b/media/codec2/hal/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp @@ -120,8 +120,8 @@ class Codec2VideoDecHidlTestBase : public ::testing::Test { std::shared_ptr<C2AllocatorStore> store = android::GetCodec2PlatformAllocatorStore(); CHECK_EQ(store->fetchAllocator(C2AllocatorStore::DEFAULT_LINEAR, &mLinearAllocator), C2_OK); - mLinearPool = std::make_shared<C2PooledBlockPool>( - mLinearAllocator, mBlockPoolId++, getBufferPoolVer()); + mLinearPool = std::make_shared<C2PooledBlockPool>(mLinearAllocator, mBlockPoolId++, + getBufferPoolVer()); ASSERT_NE(mLinearPool, nullptr); std::vector<std::unique_ptr<C2Param>> queried; @@ -463,7 +463,9 @@ void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp } int64_t timestamp = (*Info)[frameID].timestamp; - flags = ((*Info)[frameID].flags == FLAG_CONFIG_DATA) ? C2FrameData::FLAG_CODEC_CONFIG : 0; + flags = ((*Info)[frameID].vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) + ? C2FrameData::FLAG_CODEC_CONFIG + : 0; if (signalEOS && ((frameID == (int)Info->size() - 1) || (frameID == (offset + range - 1)))) flags |= C2FrameData::FLAG_END_OF_STREAM; @@ -711,17 +713,19 @@ TEST_P(Codec2VideoDecHidlTest, AdaptiveDecodeTest) { ASSERT_EQ(eleInfo.is_open(), true) << mInputFile << " - file not found"; int bytesCount = 0; uint32_t flags = 0; + uint32_t vtsFlags = 0; uint32_t timestamp = 0; uint32_t timestampMax = 0; while (1) { if (!(eleInfo >> bytesCount)) break; eleInfo >> flags; + vtsFlags = mapInfoFlagstoVtsFlags(flags); + ASSERT_NE(vtsFlags, 0xFF) << "unrecognized flag entry in info file: " << mInfoFile; eleInfo >> timestamp; timestamp += timestampOffset; - Info.push_back({bytesCount, flags, timestamp}); - bool codecConfig = - flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0; - bool nonDisplayFrame = ((flags & FLAG_NON_DISPLAY_FRAME) != 0); + Info.push_back({bytesCount, vtsFlags, timestamp}); + bool codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0; + bool nonDisplayFrame = (vtsFlags & (1 << VTS_BIT_FLAG_NO_SHOW_FRAME)) != 0; { ULock l(mQueueLock); @@ -795,20 +799,15 @@ TEST_P(Codec2VideoDecHidlTest, ThumbnailTest) { int32_t numCsds = populateInfoVector(mInfoFile, &Info, mTimestampDevTest, &mTimestampUslist); ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << mInfoFile; - uint32_t flags = 0; for (size_t i = 0; i < MAX_ITERATIONS; i++) { ASSERT_EQ(mComponent->start(), C2_OK); // request EOS for thumbnail // signal EOS flag with last frame size_t j = -1; - do { - j++; - flags = 0; - if (Info[j].flags) flags = 1u << (Info[j].flags - 1); - - } while (!(flags & SYNC_FRAME)); - + for (j = 0; j < Info.size(); j++) { + if (Info[j].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) break; + } std::ifstream eleStream; eleStream.open(mInputFile, std::ifstream::binary); ASSERT_EQ(eleStream.is_open(), true); @@ -908,14 +907,11 @@ TEST_P(Codec2VideoDecHidlTest, FlushTest) { // Seek to next key frame and start decoding till the end int index = numFramesFlushed; bool keyFrame = false; - uint32_t flags = 0; while (index < (int)Info.size()) { - if (Info[index].flags) flags = 1u << (Info[index].flags - 1); - if ((flags & SYNC_FRAME) == SYNC_FRAME) { + if (Info[index].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) { keyFrame = true; break; } - flags = 0; eleStream.ignore(Info[index].bytesCount); index++; } @@ -949,24 +945,24 @@ TEST_P(Codec2VideoDecHidlTest, DecodeTestEmptyBuffersInserted) { int bytesCount = 0; uint32_t frameId = 0; uint32_t flags = 0; + uint32_t vtsFlags = 0; uint32_t timestamp = 0; bool codecConfig = false; // This test introduces empty CSD after every 20th frame // and empty input frames at an interval of 5 frames. while (1) { if (!(frameId % 5)) { - if (!(frameId % 20)) - flags = 32; - else - flags = 0; + vtsFlags = !(frameId % 20) ? (1 << VTS_BIT_FLAG_CSD_FRAME) : 0; bytesCount = 0; } else { if (!(eleInfo >> bytesCount)) break; eleInfo >> flags; + vtsFlags = mapInfoFlagstoVtsFlags(flags); + ASSERT_NE(vtsFlags, 0xFF) << "unrecognized flag entry in info file: " << mInfoFile; eleInfo >> timestamp; - codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0; + codecConfig = (vtsFlags & (1 << VTS_BIT_FLAG_CSD_FRAME)) != 0; } - Info.push_back({bytesCount, flags, timestamp}); + Info.push_back({bytesCount, vtsFlags, timestamp}); frameId++; } eleInfo.close(); @@ -1046,12 +1042,9 @@ TEST_P(Codec2VideoDecCsdInputTests, CSDFlushTest) { } int offset = framesToDecode; - uint32_t flags = 0; while (1) { while (offset < (int)Info.size()) { - flags = 0; - if (Info[offset].flags) flags = 1u << (Info[offset].flags - 1); - if (flags & SYNC_FRAME) { + if (Info[offset].vtsFlags & (1 << VTS_BIT_FLAG_SYNC_FRAME)) { keyFrame = true; break; } |