Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a9ae531 authored by Sungtak Lee's avatar Sungtak Lee Committed by Android (Google) Code Review
Browse files

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.
parents e631c1f4 1a1953b3
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -506,16 +506,17 @@ TEST_F(Codec2AudioDecHidlTest, configComp) {
    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 @@ TEST_P(Codec2AudioDecDecodeTest, DecodeTest) {
    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 @@ TEST_P(Codec2AudioDecDecodeTest, DecodeTest) {
    }
    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) {
+61 −10
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ class Codec2AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase {
        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 @@ class Codec2AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    bool mDisableTest;
    standardComp mCompName;
    uint32_t mFramesReceived;
    int32_t mInputMaxBufSize;
    std::list<uint64_t> mFlushedIndices;

    C2BlockPool::local_id_t mBlockPoolId;
@@ -175,6 +177,27 @@ class Codec2AudioEncHidlTest : public ::testing::VtsHalHidlTargetTestBase {
    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 @@ TEST_F(Codec2AudioEncHidlTest, validateCompName) {
    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 @@ TEST_F(Codec2AudioEncHidlTest, EncodeTest) {
    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;
+4 −3
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ TEST_F(Codec2MasterHalTest, ListComponents) {
    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 @@ TEST_F(Codec2MasterHalTest, ListComponents) {
            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();
        }
+24 −9
Original line number Diff line number Diff line
@@ -421,8 +421,9 @@ TEST_F(Codec2VideoDecHidlTest, validateCompName) {
    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 @@ TEST_P(Codec2VideoDecDecodeTest, DecodeTest) {
    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 @@ TEST_P(Codec2VideoDecDecodeTest, DecodeTest) {
    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 @@ TEST_P(Codec2VideoDecDecodeTest, DecodeTest) {
    }

    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) {
+24 −4
Original line number Diff line number Diff line
@@ -343,13 +343,18 @@ TEST_F(Codec2VideoEncHidlTest, validateCompName) {
    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 @@ TEST_F(Codec2VideoEncHidlTest, EncodeTest) {
    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 @@ TEST_F(Codec2VideoEncHidlTest, EncodeTest) {
        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 @@ TEST_F(Codec2VideoEncHidlTest, EncodeTest) {
    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;