Merge changes Ie3b71978,Iead1be02,Id79fad2d,Ie3759e6c into rvc-dev am: d9ea505469 am: 00a3780781 am: ec7418896b am: 96b3afbd17
Change-Id: I7a7b77ce52aa29c32f90675c218cc40c03edea8a
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp
index 264abba..ed2016f 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioDecTest.cpp
@@ -22,7 +22,6 @@
#include <hidl/GtestPrinter.h>
#include <stdio.h>
#include <algorithm>
-#include <fstream>
#include <C2AllocatorIon.h>
#include <C2Buffer.h>
@@ -35,12 +34,6 @@
#include "media_c2_hidl_test_common.h"
-struct FrameInfo {
- int bytesCount;
- uint32_t flags;
- int64_t timestamp;
-};
-
static std::vector<std::tuple<std::string, std::string, std::string, std::string>>
kDecodeTestParameters;
@@ -105,6 +98,7 @@
mEos = false;
mFramesReceived = 0;
mTimestampUs = 0u;
+ mWorkResult = C2_OK;
mTimestampDevTest = false;
if (mCompName == unknown_comp) mDisableTest = true;
if (mDisableTest) std::cout << "[ WARN ] Test Disabled \n";
@@ -121,6 +115,8 @@
// Get the test parameters from GetParam call.
virtual void getParams() {}
+ virtual void validateTimestampList(int32_t* bitStreamInfo);
+
struct outputMetaData {
uint64_t timestampUs;
uint32_t rangeLength;
@@ -131,6 +127,7 @@
if (!work->worklets.empty()) {
// For decoder components current timestamp always exceeds
// previous timestamp
+ mWorkResult |= work->result;
bool codecConfig = ((work->worklets.front()->output.flags &
C2FrameData::FLAG_CODEC_CONFIG) != 0);
if (!codecConfig && !work->worklets.front()->output.buffers.empty()) {
@@ -182,6 +179,8 @@
bool mDisableTest;
bool mTimestampDevTest;
standardComp mCompName;
+
+ int32_t mWorkResult;
uint64_t mTimestampUs;
uint32_t mFramesReceived;
std::list<uint64_t> mFlushedIndices;
@@ -457,6 +456,31 @@
}
}
+void Codec2AudioDecHidlTestBase::validateTimestampList(int32_t* bitStreamInfo) {
+ uint32_t samplesReceived = 0;
+ // Update SampleRate and ChannelCount
+ ASSERT_NO_FATAL_FAILURE(getInputChannelInfo(mComponent, mCompName, bitStreamInfo));
+ int32_t nSampleRate = bitStreamInfo[0];
+ int32_t nChannels = bitStreamInfo[1];
+ std::list<uint64_t>::iterator itIn = mTimestampUslist.begin();
+ auto itOut = oBufferMetaData.begin();
+ EXPECT_EQ(*itIn, itOut->timestampUs);
+ uint64_t expectedTimeStamp = *itIn;
+ while (itOut != oBufferMetaData.end()) {
+ EXPECT_EQ(expectedTimeStamp, itOut->timestampUs);
+ if (expectedTimeStamp != itOut->timestampUs) break;
+ // buffer samples = ((total bytes) / (ac * (bits per sample / 8))
+ samplesReceived += ((itOut->rangeLength) / (nChannels * 2));
+ expectedTimeStamp = samplesReceived * 1000000ll / nSampleRate;
+ itOut++;
+ }
+ itIn = mTimestampUslist.end();
+ --itIn;
+ EXPECT_GT(expectedTimeStamp, *itIn);
+ oBufferMetaData.clear();
+ mTimestampUslist.clear();
+}
+
TEST_P(Codec2AudioDecHidlTest, validateCompName) {
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
ALOGV("Checks if the given component is a valid audio component");
@@ -493,7 +517,7 @@
bool signalEOS = !std::get<3>(GetParam()).compare("true");
mTimestampDevTest = true;
char mURL[512], info[512];
- std::ifstream eleStream, eleInfo;
+ android::Vector<FrameInfo> Info;
strcpy(mURL, sResourceDir.c_str());
strcpy(info, sResourceDir.c_str());
@@ -503,21 +527,9 @@
return;
}
- eleInfo.open(info);
- ASSERT_EQ(eleInfo.is_open(), true);
- android::Vector<FrameInfo> Info;
- int bytesCount = 0;
- uint32_t flags = 0;
- uint32_t timestamp = 0;
- while (1) {
- if (!(eleInfo >> bytesCount)) break;
- eleInfo >> flags;
- eleInfo >> timestamp;
- bool codecConfig = ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0;
- if (mTimestampDevTest && !codecConfig) mTimestampUslist.push_back(timestamp);
- Info.push_back({bytesCount, flags, timestamp});
- }
- eleInfo.close();
+ int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
+ ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
+
// Reset total no of frames received
mFramesReceived = 0;
mTimestampUs = 0;
@@ -534,6 +546,7 @@
}
ASSERT_EQ(mComponent->start(), C2_OK);
ALOGV("mURL : %s", mURL);
+ std::ifstream eleStream;
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
@@ -550,7 +563,7 @@
}
// blocking call to ensures application to Wait till all the inputs are
// consumed
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
eleStream.close();
if (mFramesReceived != infoSize) {
ALOGE("Input buffer count and Output buffer count mismatch");
@@ -558,32 +571,12 @@
ASSERT_TRUE(false);
}
ASSERT_EQ(mEos, true);
+
if (mTimestampDevTest) {
- uint64_t expTs;
- uint32_t samplesReceived = 0;
- // Update SampleRate and ChannelCount
- ASSERT_NO_FATAL_FAILURE(getInputChannelInfo(mComponent, mCompName, bitStreamInfo));
- int nSampleRate = bitStreamInfo[0];
- int nChannels = bitStreamInfo[1];
- std::list<uint64_t>::iterator itIn = mTimestampUslist.begin();
- auto itOut = oBufferMetaData.begin();
- EXPECT_EQ(*itIn, itOut->timestampUs);
- expTs = *itIn;
- while (itOut != oBufferMetaData.end()) {
- EXPECT_EQ(expTs, itOut->timestampUs);
- if (expTs != itOut->timestampUs) break;
- // buffer samples = ((total bytes) / (ac * (bits per sample / 8))
- samplesReceived += ((itOut->rangeLength) / (nChannels * 2));
- expTs = samplesReceived * 1000000ll / nSampleRate;
- itOut++;
- }
- itIn = mTimestampUslist.end();
- --itIn;
- EXPECT_GT(expTs, *itIn);
- oBufferMetaData.clear();
- mTimestampUslist.clear();
+ validateTimestampList(bitStreamInfo);
}
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
// thumbnail test
@@ -592,25 +585,15 @@
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
char mURL[512], info[512];
- std::ifstream eleStream, eleInfo;
+ android::Vector<FrameInfo> Info;
strcpy(mURL, sResourceDir.c_str());
strcpy(info, sResourceDir.c_str());
GetURLForComponent(mCompName, mURL, info);
- eleInfo.open(info);
- ASSERT_EQ(eleInfo.is_open(), true);
- android::Vector<FrameInfo> Info;
- int bytesCount = 0;
- uint32_t flags = 0;
- uint32_t timestamp = 0;
- while (1) {
- if (!(eleInfo >> bytesCount)) break;
- eleInfo >> flags;
- eleInfo >> timestamp;
- Info.push_back({bytesCount, flags, timestamp});
- }
- eleInfo.close();
+ int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
+ ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
+
int32_t bitStreamInfo[2] = {0};
if (mCompName == raw) {
bitStreamInfo[0] = 8000;
@@ -628,22 +611,25 @@
// 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));
+ std::ifstream eleStream;
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mLinearPool, eleStream, &Info, 0,
i + 1));
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
eleStream.close();
EXPECT_GE(mFramesReceived, 1U);
ASSERT_EQ(mEos, true);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
TEST_P(Codec2AudioDecHidlTest, EOSTest) {
@@ -684,33 +670,22 @@
ASSERT_EQ(mEos, true);
ASSERT_EQ(mWorkQueue.size(), (size_t)MAX_INPUT_BUFFERS);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
TEST_P(Codec2AudioDecHidlTest, FlushTest) {
description("Tests Flush calls");
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
- typedef std::unique_lock<std::mutex> ULock;
char mURL[512], info[512];
- std::ifstream eleStream, eleInfo;
+ android::Vector<FrameInfo> Info;
strcpy(mURL, sResourceDir.c_str());
strcpy(info, sResourceDir.c_str());
GetURLForComponent(mCompName, mURL, info);
- eleInfo.open(info);
- ASSERT_EQ(eleInfo.is_open(), true);
- android::Vector<FrameInfo> Info;
- int bytesCount = 0;
- uint32_t flags = 0;
- uint32_t timestamp = 0;
- mFlushedIndices.clear();
- while (1) {
- if (!(eleInfo >> bytesCount)) break;
- eleInfo >> flags;
- eleInfo >> timestamp;
- Info.push_back({bytesCount, flags, timestamp});
- }
- eleInfo.close();
+ int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
+ ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
+
int32_t bitStreamInfo[2] = {0};
if (mCompName == raw) {
bitStreamInfo[0] = 8000;
@@ -723,44 +698,37 @@
return;
}
ASSERT_EQ(mComponent->start(), C2_OK);
- ALOGV("mURL : %s", mURL);
- eleStream.open(mURL, std::ifstream::binary);
- ASSERT_EQ(eleStream.is_open(), true);
- // Decode 128 frames and flush. here 128 is chosen to ensure there is a key
- // frame after this so that the below section can be covered for all
- // components
- uint32_t numFramesFlushed = 128;
- ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
- mFlushedIndices, mLinearPool, eleStream, &Info, 0,
- numFramesFlushed, false));
// flush
std::list<std::unique_ptr<C2Work>> flushedWork;
c2_status_t err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- uint64_t frameIndex;
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+
+ ALOGV("mURL : %s", mURL);
+ std::ifstream eleStream;
+ eleStream.open(mURL, std::ifstream::binary);
+ ASSERT_EQ(eleStream.is_open(), true);
+ // Decode 30 frames and flush.
+ uint32_t numFramesFlushed = FLUSH_INTERVAL;
+ ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
+ mFlushedIndices, mLinearPool, eleStream, &Info, 0,
+ numFramesFlushed, false));
+ // flush
+ err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
+ ASSERT_EQ(err, C2_OK);
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+
// Seek to next key frame and start decoding till the end
mFlushedIndices.clear();
int index = numFramesFlushed;
bool keyFrame = false;
- flags = 0;
+ 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) {
@@ -779,25 +747,13 @@
eleStream.close();
err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
- ASSERT_EQ(mFlushedIndices.empty(), true);
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+ // TODO: (b/154671521)
+ // Add assert for mWorkResult
ASSERT_EQ(mComponent->stop(), C2_OK);
}
@@ -862,7 +818,7 @@
// consumed
if (!mEos) {
ALOGV("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
}
eleStream.close();
@@ -909,4 +865,4 @@
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
-}
\ No newline at end of file
+}
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
index 5f3ae41..63f39de 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHalMediaC2V1_0TargetAudioEncTest.cpp
@@ -95,6 +95,7 @@
mEos = false;
mCsd = false;
mFramesReceived = 0;
+ mWorkResult = C2_OK;
if (mCompName == unknown_comp) mDisableTest = true;
if (mDisableTest) std::cout << "[ WARN ] Test Disabled \n";
getInputMaxBufSize();
@@ -115,6 +116,7 @@
void handleWorkDone(std::list<std::unique_ptr<C2Work>>& workItems) {
for (std::unique_ptr<C2Work>& work : workItems) {
if (!work->worklets.empty()) {
+ mWorkResult |= work->result;
workDone(mComponent, work, mFlushedIndices, mQueueLock, mQueueCondition, mWorkQueue,
mEos, mCsd, mFramesReceived);
}
@@ -135,6 +137,8 @@
bool mCsd;
bool mDisableTest;
standardComp mCompName;
+
+ int32_t mWorkResult;
uint32_t mFramesReceived;
int32_t mInputMaxBufSize;
std::list<uint64_t> mFlushedIndices;
@@ -236,6 +240,41 @@
return false;
}
+// Get config params for a component
+bool getConfigParams(Codec2AudioEncHidlTest::standardComp compName, int32_t* nChannels,
+ int32_t* nSampleRate, int32_t* samplesPerFrame) {
+ switch (compName) {
+ case Codec2AudioEncHidlTest::aac:
+ *nChannels = 2;
+ *nSampleRate = 48000;
+ *samplesPerFrame = 1024;
+ break;
+ case Codec2AudioEncHidlTest::flac:
+ *nChannels = 2;
+ *nSampleRate = 48000;
+ *samplesPerFrame = 1152;
+ break;
+ case Codec2AudioEncHidlTest::opus:
+ *nChannels = 2;
+ *nSampleRate = 48000;
+ *samplesPerFrame = 960;
+ break;
+ case Codec2AudioEncHidlTest::amrnb:
+ *nChannels = 1;
+ *nSampleRate = 8000;
+ *samplesPerFrame = 160;
+ break;
+ case Codec2AudioEncHidlTest::amrwb:
+ *nChannels = 1;
+ *nSampleRate = 16000;
+ *samplesPerFrame = 160;
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
// LookUpTable of clips and metadata for component testing
void GetURLForComponent(Codec2AudioEncHidlTest::standardComp comp, char* mURL) {
struct CompToURL {
@@ -367,36 +406,18 @@
bool signalEOS = !std::get<2>(GetParam()).compare("true");
// Ratio w.r.t to mInputMaxBufSize
int32_t inputMaxBufRatio = std::stoi(std::get<3>(GetParam()));
- ;
- // Setting default sampleRate
- int32_t nChannels = 2;
- int32_t nSampleRate = 44100;
- switch (mCompName) {
- case aac:
- nChannels = 2;
- nSampleRate = 48000;
- break;
- case flac:
- nChannels = 2;
- nSampleRate = 48000;
- break;
- case opus:
- nChannels = 2;
- nSampleRate = 48000;
- break;
- case amrnb:
- nChannels = 1;
- nSampleRate = 8000;
- break;
- case amrwb:
- nChannels = 1;
- nSampleRate = 16000;
- break;
- default:
- ASSERT_TRUE(false);
+ int32_t nChannels;
+ int32_t nSampleRate;
+ int32_t samplesPerFrame;
+
+ if (!getConfigParams(mCompName, &nChannels, &nSampleRate, &samplesPerFrame)) {
+ std::cout << "Failed to get the config params for " << mCompName << " component\n";
+ std::cout << "[ WARN ] Test Skipped \n";
+ return;
}
- int32_t samplesPerFrame = ((mInputMaxBufSize / inputMaxBufRatio) / (nChannels * 2));
+
+ samplesPerFrame = ((mInputMaxBufSize / inputMaxBufRatio) / (nChannels * 2));
ALOGV("signalEOS %d mInputMaxBufSize %d samplesPerFrame %d", signalEOS, mInputMaxBufSize,
samplesPerFrame);
@@ -416,7 +437,7 @@
// If EOS is not sent, sending empty input with EOS flag
if (!signalEOS) {
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1);
ASSERT_NO_FATAL_FAILURE(testInputBuffer(mComponent, mQueueLock, mWorkQueue,
C2FrameData::FLAG_END_OF_STREAM, false));
numFrames += 1;
@@ -424,7 +445,7 @@
// blocking call to ensures application to Wait till all the inputs are
// consumed
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
eleStream.close();
if (mFramesReceived != numFrames) {
ALOGE("Input buffer count and Output buffer count mismatch");
@@ -439,6 +460,7 @@
}
ASSERT_EQ(mEos, true);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
TEST_P(Codec2AudioEncHidlTest, EOSTest) {
@@ -479,50 +501,26 @@
}
ASSERT_EQ(mEos, true);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
TEST_P(Codec2AudioEncHidlTest, FlushTest) {
description("Test Request for flush");
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
- typedef std::unique_lock<std::mutex> ULock;
char mURL[512];
strcpy(mURL, sResourceDir.c_str());
GetURLForComponent(mCompName, mURL);
- // Setting default configuration
mFlushedIndices.clear();
- int32_t nChannels = 2;
- int32_t nSampleRate = 44100;
- int32_t samplesPerFrame = 1024;
- switch (mCompName) {
- case aac:
- nChannels = 2;
- nSampleRate = 48000;
- samplesPerFrame = 1024;
- break;
- case flac:
- nChannels = 2;
- nSampleRate = 48000;
- samplesPerFrame = 1152;
- break;
- case opus:
- nChannels = 2;
- nSampleRate = 48000;
- samplesPerFrame = 960;
- break;
- case amrnb:
- nChannels = 1;
- nSampleRate = 8000;
- samplesPerFrame = 160;
- break;
- case amrwb:
- nChannels = 1;
- nSampleRate = 16000;
- samplesPerFrame = 160;
- break;
- default:
- ASSERT_TRUE(false);
+ int32_t nChannels;
+ int32_t nSampleRate;
+ int32_t samplesPerFrame;
+
+ if (!getConfigParams(mCompName, &nChannels, &nSampleRate, &samplesPerFrame)) {
+ std::cout << "Failed to get the config params for " << mCompName << " component\n";
+ std::cout << "[ WARN ] Test Skipped \n";
+ return;
}
if (!setupConfigParam(mComponent, nChannels, nSampleRate)) {
@@ -536,33 +534,24 @@
uint32_t numFrames = 128;
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
+ // flush
+ std::list<std::unique_ptr<C2Work>> flushedWork;
+ c2_status_t err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
+ ASSERT_EQ(err, C2_OK);
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
ALOGV("mURL : %s", mURL);
ASSERT_NO_FATAL_FAILURE(encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mLinearPool, eleStream, numFramesFlushed,
samplesPerFrame, nChannels, nSampleRate));
- std::list<std::unique_ptr<C2Work>> flushedWork;
- c2_status_t err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
+ err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- uint64_t frameIndex;
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
- mFlushedIndices.clear();
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
ASSERT_NO_FATAL_FAILURE(encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mLinearPool, eleStream,
numFrames - numFramesFlushed, samplesPerFrame, nChannels,
@@ -570,25 +559,13 @@
eleStream.close();
err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
- ASSERT_EQ(mFlushedIndices.empty(), true);
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+ // TODO: (b/154671521)
+ // Add assert for mWorkResult
ASSERT_EQ(mComponent->stop(), C2_OK);
}
diff --git a/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp b/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp
index da8225c..a41c2dc 100644
--- a/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.cpp
@@ -160,4 +160,57 @@
}
return parameters;
-}
\ No newline at end of file
+}
+
+// Populate Info vector and return number of CSDs
+int32_t populateInfoVector(std::string info, android::Vector<FrameInfo>* frameInfo,
+ bool timestampDevTest, std::list<uint64_t>* timestampUslist) {
+ std::ifstream eleInfo;
+ eleInfo.open(info);
+ if (!eleInfo.is_open()) {
+ ALOGE("Can't open info file");
+ return -1;
+ }
+ int32_t numCsds = 0;
+ int32_t bytesCount = 0;
+ uint32_t flags = 0;
+ uint32_t timestamp = 0;
+ while (1) {
+ if (!(eleInfo >> bytesCount)) break;
+ eleInfo >> flags;
+ eleInfo >> timestamp;
+ bool codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0;
+ if (codecConfig) numCsds++;
+ bool nonDisplayFrame = ((flags & FLAG_NON_DISPLAY_FRAME) != 0);
+ if (timestampDevTest && !codecConfig && !nonDisplayFrame) {
+ timestampUslist->push_back(timestamp);
+ }
+ frameInfo->push_back({bytesCount, flags, timestamp});
+ }
+ ALOGV("numCsds : %d", numCsds);
+ eleInfo.close();
+ return numCsds;
+}
+
+void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork,
+ std::list<std::unique_ptr<C2Work>>& workQueue,
+ std::list<uint64_t>& flushedIndices, std::mutex& queueLock) {
+ // Update mFlushedIndices based on the index received from flush()
+ typedef std::unique_lock<std::mutex> ULock;
+ uint64_t frameIndex;
+ ULock l(queueLock);
+ for (std::unique_ptr<C2Work>& work : flushedWork) {
+ ASSERT_NE(work, nullptr);
+ frameIndex = work->input.ordinal.frameIndex.peeku();
+ std::list<uint64_t>::iterator frameIndexIt =
+ std::find(flushedIndices.begin(), flushedIndices.end(), frameIndex);
+ if (!flushedIndices.empty() && (frameIndexIt != flushedIndices.end())) {
+ flushedIndices.erase(frameIndexIt);
+ work->input.buffers.clear();
+ work->worklets.clear();
+ workQueue.push_back(std::move(work));
+ }
+ }
+ ASSERT_EQ(flushedIndices.empty(), true);
+ flushedWork.clear();
+}
diff --git a/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h b/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h
index 4b5e0a6..50e3ac5 100644
--- a/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h
+++ b/media/codec2/hidl/1.0/vts/functional/common/media_c2_hidl_test_common.h
@@ -25,10 +25,13 @@
#include <gtest/gtest.h>
#include <hidl/HidlSupport.h>
#include <chrono>
+#include <fstream>
+#define FLAG_NON_DISPLAY_FRAME (1 << 4)
#define MAX_RETRY 20
#define TIME_OUT 400ms
#define MAX_INPUT_BUFFERS 8
+#define FLUSH_INTERVAL 30
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
@@ -39,6 +42,12 @@
static std::vector<std::tuple<std::string, std::string>> kTestParameters;
+struct FrameInfo {
+ int bytesCount;
+ uint32_t flags;
+ int64_t timestamp;
+};
+
/*
* Handle Callback functions onWorkDone(), onTripped(),
* onError(), onDeath(), onFramesRendered()
@@ -123,4 +132,10 @@
int64_t getNowUs();
+int32_t populateInfoVector(std::string info, android::Vector<FrameInfo>* frameInfo,
+ bool timestampDevTest, std::list<uint64_t>* timestampUslist);
+
+void verifyFlushOutput(std::list<std::unique_ptr<C2Work>>& flushedWork,
+ std::list<std::unique_ptr<C2Work>>& workQueue,
+ std::list<uint64_t>& flushedIndices, std::mutex& queueLock);
#endif // MEDIA_C2_HIDL_TEST_COMMON_H
diff --git a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp
index f216429..3362336 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoDecTest.cpp
@@ -21,7 +21,6 @@
#include <gtest/gtest.h>
#include <hidl/GtestPrinter.h>
#include <stdio.h>
-#include <fstream>
#include <C2AllocatorIon.h>
#include <C2Buffer.h>
@@ -39,12 +38,6 @@
#include "media_c2_hidl_test_common.h"
#include "media_c2_video_hidl_test_common.h"
-struct FrameInfo {
- int bytesCount;
- uint32_t flags;
- int64_t timestamp;
-};
-
static std::vector<std::tuple<std::string, std::string, std::string, std::string>>
kDecodeTestParameters;
@@ -111,6 +104,7 @@
mEos = false;
mFramesReceived = 0;
mTimestampUs = 0u;
+ mWorkResult = C2_OK;
mTimestampDevTest = false;
if (mCompName == unknown_comp) mDisableTest = true;
@@ -141,6 +135,7 @@
// For decoder components current timestamp always exceeds
// previous timestamp
typedef std::unique_lock<std::mutex> ULock;
+ mWorkResult |= work->result;
bool codecConfig = ((work->worklets.front()->output.flags &
C2FrameData::FLAG_CODEC_CONFIG) != 0);
if (!codecConfig && !work->worklets.front()->output.buffers.empty()) {
@@ -170,7 +165,7 @@
}
}
}
- bool mCsd;
+ bool mCsd = false;
workDone(mComponent, work, mFlushedIndices, mQueueLock, mQueueCondition, mWorkQueue,
mEos, mCsd, mFramesReceived);
(void)mCsd;
@@ -200,6 +195,8 @@
std::list<uint64_t> mTimestampUslist;
std::list<uint64_t> mFlushedIndices;
standardComp mCompName;
+
+ int32_t mWorkResult;
uint32_t mFramesReceived;
C2BlockPool::local_id_t mBlockPoolId;
std::shared_ptr<C2BlockPool> mLinearPool;
@@ -463,38 +460,27 @@
uint32_t streamIndex = std::stoi(std::get<2>(GetParam()));
bool signalEOS = !std::get<2>(GetParam()).compare("true");
+ mTimestampDevTest = true;
char mURL[512], info[512];
- std::ifstream eleStream, eleInfo;
+ android::Vector<FrameInfo> Info;
+
strcpy(mURL, sResourceDir.c_str());
strcpy(info, sResourceDir.c_str());
+
GetURLForComponent(mCompName, mURL, info, streamIndex);
- eleInfo.open(info);
- ASSERT_EQ(eleInfo.is_open(), true) << mURL << " - file not found";
- android::Vector<FrameInfo> Info;
- int bytesCount = 0;
- uint32_t flags = 0;
- uint32_t timestamp = 0;
- mTimestampDevTest = true;
mFlushedIndices.clear();
mTimestampUslist.clear();
- while (1) {
- if (!(eleInfo >> bytesCount)) break;
- eleInfo >> flags;
- eleInfo >> timestamp;
- bool codecConfig = flags ? ((1 << (flags - 1)) & C2FrameData::FLAG_CODEC_CONFIG) != 0 : 0;
- bool nonDisplayFrame = ((flags & FLAG_NON_DISPLAY_FRAME) != 0);
- if (mTimestampDevTest && !codecConfig && !nonDisplayFrame)
- mTimestampUslist.push_back(timestamp);
- Info.push_back({bytesCount, flags, timestamp});
- }
- eleInfo.close();
+
+ int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
+ ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
ASSERT_EQ(mComponent->start(), C2_OK);
// Reset total no of frames received
mFramesReceived = 0;
mTimestampUs = 0;
ALOGV("mURL : %s", mURL);
+ std::ifstream eleStream;
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
@@ -504,7 +490,7 @@
// If EOS is not sent, sending empty input with EOS flag
size_t infoSize = Info.size();
if (!signalEOS) {
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1);
ASSERT_NO_FATAL_FAILURE(testInputBuffer(mComponent, mQueueLock, mWorkQueue,
C2FrameData::FLAG_END_OF_STREAM, false));
infoSize += 1;
@@ -513,7 +499,7 @@
// consumed
if (!mEos) {
ALOGV("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
}
eleStream.close();
@@ -525,6 +511,7 @@
if (mTimestampDevTest) EXPECT_EQ(mTimestampUslist.empty(), true);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
// Adaptive Test
@@ -622,7 +609,7 @@
// blocking call to ensures application to Wait till all the inputs are
// consumed
ALOGV("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
if (mFramesReceived != ((Info.size()) + 1)) {
ALOGE("Input buffer count and Output buffer count mismatch");
@@ -631,6 +618,7 @@
}
if (mTimestampDevTest) EXPECT_EQ(mTimestampUslist.empty(), true);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
// thumbnail test
@@ -639,26 +627,16 @@
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
char mURL[512], info[512];
- std::ifstream eleStream, eleInfo;
+ android::Vector<FrameInfo> Info;
strcpy(mURL, sResourceDir.c_str());
strcpy(info, sResourceDir.c_str());
GetURLForComponent(mCompName, mURL, info);
- eleInfo.open(info);
- ASSERT_EQ(eleInfo.is_open(), true);
- android::Vector<FrameInfo> Info;
- int bytesCount = 0;
- uint32_t flags = 0;
- uint32_t timestamp = 0;
- while (1) {
- if (!(eleInfo >> bytesCount)) break;
- eleInfo >> flags;
- eleInfo >> timestamp;
- Info.push_back({bytesCount, flags, timestamp});
- }
- eleInfo.close();
+ int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
+ ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
+ uint32_t flags = 0;
for (size_t i = 0; i < MAX_ITERATIONS; i++) {
ASSERT_EQ(mComponent->start(), C2_OK);
@@ -671,18 +649,21 @@
if (Info[j].flags) flags = 1u << (Info[j].flags - 1);
} while (!(flags & SYNC_FRAME));
+
+ std::ifstream eleStream;
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mLinearPool, eleStream, &Info, 0,
j + 1));
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
eleStream.close();
EXPECT_GE(mFramesReceived, 1U);
ASSERT_EQ(mEos, true);
ASSERT_EQ(mComponent->stop(), C2_OK);
}
ASSERT_EQ(mComponent->release(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
TEST_P(Codec2VideoDecHidlTest, EOSTest) {
@@ -723,72 +704,59 @@
ASSERT_EQ(mEos, true);
ASSERT_EQ(mWorkQueue.size(), (size_t)MAX_INPUT_BUFFERS);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mWorkResult, C2_OK);
}
TEST_P(Codec2VideoDecHidlTest, FlushTest) {
description("Tests Flush calls");
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
- typedef std::unique_lock<std::mutex> ULock;
+
ASSERT_EQ(mComponent->start(), C2_OK);
+
char mURL[512], info[512];
- std::ifstream eleStream, eleInfo;
+ android::Vector<FrameInfo> Info;
strcpy(mURL, sResourceDir.c_str());
strcpy(info, sResourceDir.c_str());
GetURLForComponent(mCompName, mURL, info);
- eleInfo.open(info);
- ASSERT_EQ(eleInfo.is_open(), true);
- android::Vector<FrameInfo> Info;
- int bytesCount = 0;
- uint32_t flags = 0;
- uint32_t timestamp = 0;
mFlushedIndices.clear();
- while (1) {
- if (!(eleInfo >> bytesCount)) break;
- eleInfo >> flags;
- eleInfo >> timestamp;
- Info.push_back({bytesCount, flags, timestamp});
- }
- eleInfo.close();
+
+ int32_t numCsds = populateInfoVector(info, &Info, mTimestampDevTest, &mTimestampUslist);
+ ASSERT_GE(numCsds, 0) << "Error in parsing input info file: " << info;
ALOGV("mURL : %s", mURL);
- eleStream.open(mURL, std::ifstream::binary);
- ASSERT_EQ(eleStream.is_open(), true);
- // Decode 128 frames and flush. here 128 is chosen to ensure there is a key
- // frame after this so that the below section can be covered for all
- // components
- uint32_t numFramesFlushed = 128;
- ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
- mFlushedIndices, mLinearPool, eleStream, &Info, 0,
- numFramesFlushed, false));
+
// flush
std::list<std::unique_ptr<C2Work>> flushedWork;
c2_status_t err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- auto frameIndexIt = std::find(mFlushedIndices.begin(), mFlushedIndices.end(),
- work->input.ordinal.frameIndex.peeku());
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
+ std::ifstream eleStream;
+ eleStream.open(mURL, std::ifstream::binary);
+ ASSERT_EQ(eleStream.is_open(), true);
+ // Decode 30 frames and flush. here 30 is chosen to ensure there is a key
+ // frame after this so that the below section can be covered for all
+ // components
+ uint32_t numFramesFlushed = FLUSH_INTERVAL;
+ ASSERT_NO_FATAL_FAILURE(decodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
+ mFlushedIndices, mLinearPool, eleStream, &Info, 0,
+ numFramesFlushed, false));
+ // flush
+ err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
+ ASSERT_EQ(err, C2_OK);
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
// Seek to next key frame and start decoding till the end
- mFlushedIndices.clear();
int index = numFramesFlushed;
bool keyFrame = false;
- flags = 0;
+ 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) {
@@ -807,25 +775,13 @@
eleStream.close();
err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- uint64_t frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
- ASSERT_EQ(mFlushedIndices.empty(), true);
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+ // TODO: (b/154671521)
+ // Add assert for mWorkResult
ASSERT_EQ(mComponent->stop(), C2_OK);
}
@@ -880,7 +836,7 @@
// consumed
if (!mEos) {
ALOGV("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
}
eleStream.close();
@@ -930,4 +886,4 @@
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
-}
\ No newline at end of file
+}
diff --git a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp
index 823e11b..9e425d2 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/video/VtsHalMediaC2V1_0TargetVideoEncTest.cpp
@@ -492,7 +492,7 @@
// If EOS is not sent, sending empty input with EOS flag
inputFrames += ENC_NUM_FRAMES;
if (!signalEOS) {
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1);
ASSERT_NO_FATAL_FAILURE(testInputBuffer(mComponent, mQueueLock, mWorkQueue,
C2FrameData::FLAG_END_OF_STREAM, false));
inputFrames += 1;
@@ -501,7 +501,7 @@
// blocking call to ensures application to Wait till all the inputs are
// consumed
ALOGD("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
eleStream.close();
if (mFramesReceived != inputFrames) {
@@ -520,6 +520,9 @@
if (mTimestampDevTest) EXPECT_EQ(mTimestampUslist.empty(), true);
ASSERT_EQ(mComponent->stop(), C2_OK);
+
+ // TODO: (b/155534991)
+ // Add assert for mFailedWorkReceived
}
TEST_P(Codec2VideoEncHidlTest, EOSTest) {
@@ -560,13 +563,13 @@
}
ASSERT_EQ(mEos, true);
ASSERT_EQ(mComponent->stop(), C2_OK);
+ ASSERT_EQ(mFailedWorkReceived, 0);
}
TEST_P(Codec2VideoEncHidlTest, FlushTest) {
description("Test Request for flush");
if (mDisableTest) GTEST_SKIP() << "Test is disabled";
- typedef std::unique_lock<std::mutex> ULock;
char mURL[512];
int32_t nWidth = ENC_DEFAULT_FRAME_WIDTH;
int32_t nHeight = ENC_DEFAULT_FRAME_HEIGHT;
@@ -587,9 +590,17 @@
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
ALOGV("mURL : %s", mURL);
+ // flush
+ std::list<std::unique_ptr<C2Work>> flushedWork;
+ c2_status_t err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
+ ASSERT_EQ(err, C2_OK);
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+
ASSERT_NO_FATAL_FAILURE(encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mGraphicPool, eleStream, mDisableTest, 0,
- numFramesFlushed, nWidth, nHeight));
+ numFramesFlushed, nWidth, nHeight, false, false));
// mDisableTest will be set if buffer was not fetched properly.
// This may happen when resolution is not proper but config succeeded
// In this cases, we skip encoding the input stream
@@ -599,29 +610,14 @@
return;
}
- std::list<std::unique_ptr<C2Work>> flushedWork;
- c2_status_t err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
+ // flush
+ err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- uint64_t frameIndex;
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
- mFlushedIndices.clear();
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
ASSERT_NO_FATAL_FAILURE(encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
numFramesFlushed, numFrames - numFramesFlushed, nWidth,
@@ -638,25 +634,13 @@
err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
ASSERT_EQ(err, C2_OK);
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
- (size_t)MAX_INPUT_BUFFERS - flushedWork.size()));
- {
- // Update mFlushedIndices based on the index received from flush()
- ULock l(mQueueLock);
- for (std::unique_ptr<C2Work>& work : flushedWork) {
- ASSERT_NE(work, nullptr);
- frameIndex = work->input.ordinal.frameIndex.peeku();
- std::list<uint64_t>::iterator frameIndexIt =
- std::find(mFlushedIndices.begin(), mFlushedIndices.end(), frameIndex);
- if (!mFlushedIndices.empty() && (frameIndexIt != mFlushedIndices.end())) {
- mFlushedIndices.erase(frameIndexIt);
- work->input.buffers.clear();
- work->worklets.clear();
- mWorkQueue.push_back(std::move(work));
- }
- }
- }
- ASSERT_EQ(mFlushedIndices.empty(), true);
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue,
+ (size_t)MAX_INPUT_BUFFERS - flushedWork.size());
+ ASSERT_NO_FATAL_FAILURE(
+ verifyFlushOutput(flushedWork, mWorkQueue, mFlushedIndices, mQueueLock));
+ ASSERT_EQ(mWorkQueue.size(), MAX_INPUT_BUFFERS);
+ // TODO: (b/154671521)
+ // Add assert for mFailedWorkReceived
ASSERT_EQ(mComponent->stop(), C2_OK);
}
@@ -691,7 +675,7 @@
// blocking call to ensures application to Wait till all the inputs are
// consumed
ALOGD("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
if (mFramesReceived != 3) {
std::cout << "[ WARN ] Component didn't receive all buffers back \n";
@@ -746,7 +730,7 @@
}
ALOGD("Waiting for input consumption");
- ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue);
ASSERT_EQ(mEos, true);
ASSERT_EQ(mComponent->stop(), C2_OK);
diff --git a/media/codec2/hidl/1.0/vts/functional/video/media_c2_video_hidl_test_common.h b/media/codec2/hidl/1.0/vts/functional/video/media_c2_video_hidl_test_common.h
index 9c1a5cb..d3a693b 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/media_c2_video_hidl_test_common.h
+++ b/media/codec2/hidl/1.0/vts/functional/video/media_c2_video_hidl_test_common.h
@@ -22,7 +22,6 @@
#define ENC_DEFAULT_FRAME_WIDTH 352
#define ENC_DEFAULT_FRAME_HEIGHT 288
#define MAX_ITERATIONS 128
-#define FLAG_NON_DISPLAY_FRAME (1 << 4)
#define ALIGN(_sz, _align) ((_sz + (_align - 1)) & ~(_align - 1))