VTS: add support for sending empty first frame in EncodeTest
This is done to trigger CSD without 1st encoded frame.
Test: atest VtsHalMediaC2V1_0TargetVideoEncTest
Bug: 133463875
Change-Id: I723eabbf0c942bfdfa5601d568f0c273f4f00647
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 5d4b001..da8225c 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
@@ -115,7 +115,8 @@
typedef std::unique_lock<std::mutex> ULock;
ULock l(queueLock);
workQueue.push_back(std::move(work));
- if (!flushedIndices.empty()) {
+ if (!flushedIndices.empty() &&
+ (frameIndexIt != flushedIndices.end())) {
flushedIndices.erase(frameIndexIt);
}
queueCondition.notify_all();
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 6debb56..ecc56f5 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
@@ -41,7 +41,8 @@
: C2Buffer({block->share(C2Rect(block->width(), block->height()), ::C2Fence())}) {}
};
-static std::vector<std::tuple<std::string, std::string, std::string>> kEncodeTestParameters;
+static std::vector<std::tuple<std::string, std::string, std::string, std::string>>
+ kEncodeTestParameters;
static std::vector<std::tuple<std::string, std::string, std::string, std::string>>
kEncodeResolutionTestParameters;
@@ -293,7 +294,6 @@
uint32_t maxRetry = 0;
int bytesCount = nWidth * nHeight * 3 >> 1;
int32_t timestampIncr = ENCODER_TIMESTAMP_INCREMENT;
- uint64_t timestamp = 0;
c2_status_t err = C2_OK;
while (1) {
if (nFrames == 0) break;
@@ -320,7 +320,7 @@
}
work->input.flags = (C2FrameData::flags_t)flags;
- work->input.ordinal.timestamp = timestamp;
+ work->input.ordinal.timestamp = frameID * timestampIncr;
work->input.ordinal.frameIndex = frameID;
{
ULock l(queueLock);
@@ -373,7 +373,6 @@
ASSERT_EQ(component->queue(&items), C2_OK);
ALOGV("Frame #%d size = %d queued", frameID, bytesCount);
nFrames--;
- timestamp += timestampIncr;
frameID++;
maxRetry = 0;
}
@@ -388,7 +387,8 @@
class Codec2VideoEncEncodeTest
: public Codec2VideoEncHidlTestBase,
- public ::testing::WithParamInterface<std::tuple<std::string, std::string, std::string>> {
+ public ::testing::WithParamInterface<
+ std::tuple<std::string, std::string, std::string, std::string>> {
void getParams() {
mInstanceName = std::get<0>(GetParam());
mComponentName = std::get<1>(GetParam());
@@ -403,6 +403,8 @@
int32_t nWidth = ENC_DEFAULT_FRAME_WIDTH;
int32_t nHeight = ENC_DEFAULT_FRAME_HEIGHT;
bool signalEOS = !std::get<2>(GetParam()).compare("true");
+ // Send an empty frame to receive CSD data from encoder.
+ bool sendEmptyFirstFrame = !std::get<3>(GetParam()).compare("true");
strcpy(mURL, sResourceDir.c_str());
GetURLForComponent(mURL);
@@ -416,22 +418,30 @@
mTimestampDevTest = true;
mFlushedIndices.clear();
mTimestampUslist.clear();
- uint32_t inputFrames = ENC_NUM_FRAMES;
+ int32_t inputFrames = ENC_NUM_FRAMES + (sendEmptyFirstFrame ? 1 : 0);
uint32_t timestamp = 0;
+
// Add input timestamp to timestampUslist
while (inputFrames) {
if (mTimestampDevTest) mTimestampUslist.push_back(timestamp);
timestamp += ENCODER_TIMESTAMP_INCREMENT;
inputFrames--;
}
+
if (!setupConfigParam(nWidth, nHeight)) {
std::cout << "[ WARN ] Test Skipped \n";
return;
}
ASSERT_EQ(mComponent->start(), C2_OK);
+
+ if (sendEmptyFirstFrame) {
+ ASSERT_NO_FATAL_FAILURE(testInputBuffer(mComponent, mQueueLock, mWorkQueue, 0, false));
+ inputFrames += 1;
+ }
ASSERT_NO_FATAL_FAILURE(encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
- mFlushedIndices, mGraphicPool, eleStream, mDisableTest, 0,
- ENC_NUM_FRAMES, nWidth, nHeight, false, signalEOS));
+ mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
+ inputFrames, ENC_NUM_FRAMES, nWidth, nHeight, false,
+ signalEOS));
// 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
@@ -442,7 +452,7 @@
}
// If EOS is not sent, sending empty input with EOS flag
- inputFrames = ENC_NUM_FRAMES;
+ inputFrames += ENC_NUM_FRAMES;
if (!signalEOS) {
ASSERT_NO_FATAL_FAILURE(waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
ASSERT_NO_FATAL_FAILURE(testInputBuffer(mComponent, mQueueLock, mWorkQueue,
@@ -807,9 +817,13 @@
kTestParameters = getTestParameters(C2Component::DOMAIN_VIDEO, C2Component::KIND_ENCODER);
for (auto params : kTestParameters) {
kEncodeTestParameters.push_back(
- std::make_tuple(std::get<0>(params), std::get<1>(params), "true"));
+ std::make_tuple(std::get<0>(params), std::get<1>(params), "true", "true"));
kEncodeTestParameters.push_back(
- std::make_tuple(std::get<0>(params), std::get<1>(params), "false"));
+ std::make_tuple(std::get<0>(params), std::get<1>(params), "true", "false"));
+ kEncodeTestParameters.push_back(
+ std::make_tuple(std::get<0>(params), std::get<1>(params), "false", "true"));
+ kEncodeTestParameters.push_back(
+ std::make_tuple(std::get<0>(params), std::get<1>(params), "false", "false"));
kEncodeResolutionTestParameters.push_back(
std::make_tuple(std::get<0>(params), std::get<1>(params), "52", "18"));