Merge "VTS: add support for sending empty first frame in EncodeTest" into rvc-dev

gugelfrei
TreeHugger Robot 4 years ago committed by Android (Google) Code Review
commit fc8cd670b7

@ -115,7 +115,8 @@ void workDone(const std::shared_ptr<android::Codec2Client::Component>& component
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();

@ -41,7 +41,8 @@ class GraphicBuffer : public C2Buffer {
: 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 @@ void encodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& 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<android::Codec2Client::Component>& 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<android::Codec2Client::Component>& 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<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 @@ 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"));

Loading…
Cancel
Save