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 5d4b00105c..da8225cef0 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 @@ void workDone(const std::shared_ptr& component typedef std::unique_lock 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 6debb564eb..ecc56f5f51 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 @@ class GraphicBuffer : public C2Buffer { : C2Buffer({block->share(C2Rect(block->width(), block->height()), ::C2Fence())}) {} }; -static std::vector> kEncodeTestParameters; +static std::vector> + kEncodeTestParameters; static std::vector> kEncodeResolutionTestParameters; @@ -293,7 +294,6 @@ void encodeNFrames(const std::shared_ptr& comp 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 @@ void encodeNFrames(const std::shared_ptr& comp } 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 @@ void encodeNFrames(const std::shared_ptr& comp 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 @@ TEST_P(Codec2VideoEncHidlTest, validateCompName) { class Codec2VideoEncEncodeTest : public Codec2VideoEncHidlTestBase, - public ::testing::WithParamInterface> { + public ::testing::WithParamInterface< + std::tuple> { void getParams() { mInstanceName = std::get<0>(GetParam()); mComponentName = std::get<1>(GetParam()); @@ -403,6 +403,8 @@ TEST_P(Codec2VideoEncEncodeTest, EncodeTest) { 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 @@ TEST_P(Codec2VideoEncEncodeTest, EncodeTest) { 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 @@ TEST_P(Codec2VideoEncEncodeTest, EncodeTest) { } // 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 @@ int main(int argc, char** argv) { 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), "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")); + 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"));