Merge changes from topic "c2hal_vts_0307"
* changes:
codec2: VTS add support for Empty EOS in AudioDectest
codec2: VTS fix Master test for multiple IComponent services
codec2: VTS add support for nSamplesPerFrame in AudioEnctest
codec2: VTS add support for Empty EOS in VideoEnctest
codec2: VTS add support for Empty EOS in VideoDectest
codec2: VTS add support for Empty EOS in AudioEnctest
VTS: Fix DecodeTest For Audio Decoders.
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp
index d3b37d7..89947d4 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp
@@ -506,16 +506,17 @@
ASSERT_EQ(mComponent->stop(), C2_OK);
}
-class Codec2AudioDecDecodeTest : public Codec2AudioDecHidlTest,
- public ::testing::WithParamInterface<int32_t> {
+class Codec2AudioDecDecodeTest
+ : public Codec2AudioDecHidlTest,
+ public ::testing::WithParamInterface<std::pair<int32_t, bool>> {
};
TEST_P(Codec2AudioDecDecodeTest, DecodeTest) {
description("Decodes input file");
if (mDisableTest) return;
- uint32_t streamIndex = GetParam();
- ASSERT_EQ(mComponent->start(), C2_OK);
+ uint32_t streamIndex = GetParam().first;
+ bool signalEOS = GetParam().second;
mTimestampDevTest = true;
char mURL[512], info[512];
std::ifstream eleStream, eleInfo;
@@ -567,16 +568,27 @@
ASSERT_EQ(eleStream.is_open(), true);
ASSERT_NO_FATAL_FAILURE(decodeNFrames(
mComponent, mQueueLock, mQueueCondition, mWorkQueue, mFlushedIndices,
- mLinearPool, eleStream, &Info, 0, (int)Info.size()));
+ mLinearPool, eleStream, &Info, 0, (int)Info.size(), signalEOS));
+
+ // 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));
+ ASSERT_NO_FATAL_FAILURE(
+ testInputBuffer(mComponent, mQueueLock, mWorkQueue,
+ C2FrameData::FLAG_END_OF_STREAM, false));
+ infoSize += 1;
+ }
// blocking call to ensures application to Wait till all the inputs are
// consumed
ASSERT_NO_FATAL_FAILURE(
waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
eleStream.close();
- if (mFramesReceived != Info.size()) {
+ if (mFramesReceived != infoSize) {
ALOGE("Input buffer count and Output buffer count mismatch");
ALOGE("framesReceived : %d inputFrames : %zu", mFramesReceived,
- Info.size());
+ infoSize);
ASSERT_TRUE(false);
}
ASSERT_EQ(mEos, true);
@@ -608,9 +620,12 @@
}
ASSERT_EQ(mComponent->stop(), C2_OK);
}
-
-INSTANTIATE_TEST_CASE_P(StreamIndexes, Codec2AudioDecDecodeTest,
- ::testing::Values(0, 1));
+// DecodeTest with StreamIndex and EOS / No EOS
+INSTANTIATE_TEST_CASE_P(StreamIndexAndEOS, Codec2AudioDecDecodeTest,
+ ::testing::Values(std::make_pair(0, false),
+ std::make_pair(0, true),
+ std::make_pair(1, false),
+ std::make_pair(1, true)));
// thumbnail test
TEST_F(Codec2AudioDecHidlTest, ThumbnailTest) {
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioEncTest.cpp
index a74d43e..0946fa6 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioEncTest.cpp
@@ -123,6 +123,7 @@
mFramesReceived = 0;
if (mCompName == unknown_comp) mDisableTest = true;
if (mDisableTest) std::cout << "[ WARN ] Test Disabled \n";
+ getInputMaxBufSize();
}
virtual void TearDown() override {
@@ -157,6 +158,7 @@
bool mDisableTest;
standardComp mCompName;
uint32_t mFramesReceived;
+ int32_t mInputMaxBufSize;
std::list<uint64_t> mFlushedIndices;
C2BlockPool::local_id_t mBlockPoolId;
@@ -175,6 +177,27 @@
static void description(const std::string& description) {
RecordProperty("description", description);
}
+
+ // In encoder components, fetch the size of input buffer allocated
+ void getInputMaxBufSize() {
+ int32_t bitStreamInfo[1] = {0};
+ std::vector<std::unique_ptr<C2Param>> inParams;
+ c2_status_t status = mComponent->query(
+ {}, {C2StreamMaxBufferSizeInfo::input::PARAM_TYPE}, C2_DONT_BLOCK,
+ &inParams);
+ if (status != C2_OK && inParams.size() == 0) {
+ ALOGE("Query MaxBufferSizeInfo failed => %d", status);
+ ASSERT_TRUE(false);
+ } else {
+ size_t offset = sizeof(C2Param);
+ for (size_t i = 0; i < inParams.size(); ++i) {
+ C2Param* param = inParams[i].get();
+ bitStreamInfo[i] = *(int32_t*)((uint8_t*)param + offset);
+ }
+ }
+ mInputMaxBufSize = bitStreamInfo[0];
+ }
+
};
void validateComponent(
@@ -355,60 +378,79 @@
ASSERT_EQ(mDisableTest, false);
}
-TEST_F(Codec2AudioEncHidlTest, EncodeTest) {
+class Codec2AudioEncEncodeTest
+ : public Codec2AudioEncHidlTest,
+ public ::testing::WithParamInterface<std::pair<bool, int32_t>> {
+};
+
+TEST_P(Codec2AudioEncEncodeTest, EncodeTest) {
ALOGV("EncodeTest");
if (mDisableTest) return;
char mURL[512];
strcpy(mURL, gEnv->getRes().c_str());
GetURLForComponent(mCompName, mURL);
+ bool signalEOS = GetParam().first;
+ // Ratio w.r.t to mInputMaxBufSize
+ int32_t inputMaxBufRatio = GetParam().second;
- // Setting default configuration
+ // Setting default sampleRate
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 samplesPerFrame =
+ ((mInputMaxBufSize / inputMaxBufRatio) / (nChannels * 2));
+ ALOGV("signalEOS %d mInputMaxBufSize %d samplesPerFrame %d", signalEOS,
+ mInputMaxBufSize, samplesPerFrame);
+
if (!setupConfigParam(mComponent, nChannels, nSampleRate)) {
std::cout << "[ WARN ] Test Skipped \n";
return;
}
ASSERT_EQ(mComponent->start(), C2_OK);
std::ifstream eleStream;
- uint32_t numFrames = 128;
+ uint32_t numFrames = 16;
eleStream.open(mURL, std::ifstream::binary);
ASSERT_EQ(eleStream.is_open(), true);
ALOGV("mURL : %s", mURL);
ASSERT_NO_FATAL_FAILURE(
encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mLinearPool, eleStream, numFrames,
- samplesPerFrame, nChannels, nSampleRate));
+ samplesPerFrame, nChannels, nSampleRate, false,
+ signalEOS));
+
+ // If EOS is not sent, sending empty input with EOS flag
+ if (!signalEOS) {
+ ASSERT_NO_FATAL_FAILURE(
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
+ ASSERT_NO_FATAL_FAILURE(
+ testInputBuffer(mComponent, mQueueLock, mWorkQueue,
+ C2FrameData::FLAG_END_OF_STREAM, false));
+ numFrames += 1;
+ }
+
// blocking call to ensures application to Wait till all the inputs are
// consumed
ASSERT_NO_FATAL_FAILURE(
@@ -429,6 +471,15 @@
ASSERT_EQ(mComponent->stop(), C2_OK);
}
+// EncodeTest with EOS / No EOS and inputMaxBufRatio
+// inputMaxBufRatio is ratio w.r.t. to mInputMaxBufSize
+INSTANTIATE_TEST_CASE_P(EncodeTest, Codec2AudioEncEncodeTest,
+ ::testing::Values(std::make_pair(false, 1),
+ std::make_pair(false, 2),
+ std::make_pair(true, 1),
+ std::make_pair(true, 2)));
+
+
TEST_F(Codec2AudioEncHidlTest, EOSTest) {
description("Test empty input buffer with EOS flag");
if (mDisableTest) return;
diff --git a/media/codec2/hidl/1.0/vts/functional/master/VtsHidlC2V1_0TargetMasterTest.cpp b/media/codec2/hidl/1.0/vts/functional/master/VtsHidlC2V1_0TargetMasterTest.cpp
index 01e64cb..e88fbc7 100644
--- a/media/codec2/hidl/1.0/vts/functional/master/VtsHidlC2V1_0TargetMasterTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/master/VtsHidlC2V1_0TargetMasterTest.cpp
@@ -64,7 +64,7 @@
C2String name = mClient->getName();
EXPECT_NE(name.empty(), true) << "Invalid Codec2Client Name";
- // Get List of components from HIDL Codec2Client instance
+ // Get List of components from all known services
const std::vector<C2Component::Traits> listTraits =
mClient->ListComponents();
@@ -78,8 +78,9 @@
listener.reset(new CodecListener());
ASSERT_NE(listener, nullptr);
- mClient->createComponent(listTraits[i].name.c_str(), listener,
- &component);
+ // Create component from all known services
+ component = mClient->CreateComponentByName(
+ listTraits[i].name.c_str(), listener, &mClient);
ASSERT_NE(component, nullptr) << "Create component failed for "
<< listTraits[i].name.c_str();
}
diff --git a/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoDecTest.cpp
index 8cbb7a7..dffcb6e 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoDecTest.cpp
@@ -421,8 +421,9 @@
ASSERT_EQ(mDisableTest, false);
}
-class Codec2VideoDecDecodeTest : public Codec2VideoDecHidlTest,
- public ::testing::WithParamInterface<int32_t> {
+class Codec2VideoDecDecodeTest
+ : public Codec2VideoDecHidlTest,
+ public ::testing::WithParamInterface<std::pair<int32_t, bool>> {
};
// Bitstream Test
@@ -430,7 +431,8 @@
description("Decodes input file");
if (mDisableTest) return;
- uint32_t streamIndex = GetParam();
+ uint32_t streamIndex = GetParam().first;
+ bool signalEOS = GetParam().second;
char mURL[512], info[512];
std::ifstream eleStream, eleInfo;
strcpy(mURL, gEnv->getRes().c_str());
@@ -464,8 +466,18 @@
ASSERT_EQ(eleStream.is_open(), true);
ASSERT_NO_FATAL_FAILURE(decodeNFrames(
mComponent, mQueueLock, mQueueCondition, mWorkQueue, mFlushedIndices,
- mLinearPool, eleStream, &Info, 0, (int)Info.size()));
+ mLinearPool, eleStream, &Info, 0, (int)Info.size(), signalEOS));
+ // 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));
+ ASSERT_NO_FATAL_FAILURE(
+ testInputBuffer(mComponent, mQueueLock, mWorkQueue,
+ C2FrameData::FLAG_END_OF_STREAM, false));
+ infoSize += 1;
+ }
// blocking call to ensures application to Wait till all the inputs are
// consumed
if (!mEos) {
@@ -475,19 +487,22 @@
}
eleStream.close();
- if (mFramesReceived != Info.size()) {
+ if (mFramesReceived != infoSize) {
ALOGE("Input buffer count and Output buffer count mismatch");
ALOGV("framesReceived : %d inputFrames : %zu", mFramesReceived,
- Info.size());
+ infoSize);
ASSERT_TRUE(false);
}
if (mTimestampDevTest) EXPECT_EQ(mTimestampUslist.empty(), true);
ASSERT_EQ(mComponent->stop(), C2_OK);
}
-
-INSTANTIATE_TEST_CASE_P(StreamIndexes, Codec2VideoDecDecodeTest,
- ::testing::Values(0, 1));
+// DecodeTest with StreamIndex and EOS / No EOS
+INSTANTIATE_TEST_CASE_P(StreamIndexAndEOS, Codec2VideoDecDecodeTest,
+ ::testing::Values(std::make_pair(0, false),
+ std::make_pair(0, true),
+ std::make_pair(1, false),
+ std::make_pair(1, true)));
// Adaptive Test
TEST_F(Codec2VideoDecHidlTest, AdaptiveDecodeTest) {
diff --git a/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoEncTest.cpp b/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoEncTest.cpp
index 7db41c0..673dc85 100644
--- a/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoEncTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/video/VtsHidlC2V1_0TargetVideoEncTest.cpp
@@ -343,13 +343,18 @@
ASSERT_EQ(mDisableTest, false);
}
-TEST_F(Codec2VideoEncHidlTest, EncodeTest) {
+class Codec2VideoEncEncodeTest : public Codec2VideoEncHidlTest,
+ public ::testing::WithParamInterface<bool> {
+};
+
+TEST_P(Codec2VideoEncEncodeTest, EncodeTest) {
description("Encodes input file");
if (mDisableTest) return;
char mURL[512];
int32_t nWidth = ENC_DEFAULT_FRAME_WIDTH;
int32_t nHeight = ENC_DEFAULT_FRAME_HEIGHT;
+ bool signalEOS = GetParam();
strcpy(mURL, gEnv->getRes().c_str());
GetURLForComponent(mURL);
@@ -367,7 +372,18 @@
ASSERT_NO_FATAL_FAILURE(
encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
mFlushedIndices, mGraphicPool, eleStream,
- 0, ENC_NUM_FRAMES, nWidth, nHeight));
+ 0, ENC_NUM_FRAMES, nWidth, nHeight, false, signalEOS));
+
+ // If EOS is not sent, sending empty input with EOS flag
+ uint32_t inputFrames = ENC_NUM_FRAMES;
+ if (!signalEOS) {
+ ASSERT_NO_FATAL_FAILURE(
+ waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
+ ASSERT_NO_FATAL_FAILURE(
+ testInputBuffer(mComponent, mQueueLock, mWorkQueue,
+ C2FrameData::FLAG_END_OF_STREAM, false));
+ inputFrames += 1;
+ }
// blocking call to ensures application to Wait till all the inputs are
// consumed
@@ -376,10 +392,10 @@
waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
eleStream.close();
- if (mFramesReceived != ENC_NUM_FRAMES) {
+ if (mFramesReceived != inputFrames) {
ALOGE("Input buffer count and Output buffer count mismatch");
ALOGE("framesReceived : %d inputFrames : %d", mFramesReceived,
- ENC_NUM_FRAMES);
+ inputFrames);
ASSERT_TRUE(false);
}
@@ -394,6 +410,10 @@
ASSERT_EQ(mComponent->stop(), C2_OK);
}
+// EncodeTest with EOS / No EOS
+INSTANTIATE_TEST_CASE_P(EncodeTestwithEOS, Codec2VideoEncEncodeTest,
+ ::testing::Values(true, false));
+
TEST_F(Codec2VideoEncHidlTest, EOSTest) {
description("Test empty input buffer with EOS flag");
if (mDisableTest) return;