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

Commit e41a230b authored by Xin Li's avatar Xin Li
Browse files

DO NOT MERGE - Merge qt-dev-plus-aosp-without-vendor (5713463) into stage-aosp-master

Bug: 134405016
Change-Id: I7e928492f14d661df6754935e21dc3e2226b2770
parents 72d2412c fa496f56
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -176,9 +176,9 @@ public:
            DIR_INPUT      = 0x00000000,
            DIR_OUTPUT     = 0x10000000,

            IS_STREAM_FLAG  = 0x00100000,
            STREAM_ID_MASK  = 0x03E00000,
            STREAM_ID_SHIFT = 21,
            IS_STREAM_FLAG  = 0x02000000,
            STREAM_ID_MASK  = 0x01F00000,
            STREAM_ID_SHIFT = 20,
            MAX_STREAM_ID   = STREAM_ID_MASK >> STREAM_ID_SHIFT,
            STREAM_MASK     = IS_STREAM_FLAG | STREAM_ID_MASK,

+9 −23
Original line number Diff line number Diff line
@@ -144,8 +144,7 @@ TEST_F(Codec2ComponentHidlTest, QueueEmptyWork) {

    // Queueing an empty WorkBundle
    std::list<std::unique_ptr<C2Work>> workList;
    err = mComponent->queue(&workList);
    ASSERT_EQ(err, C2_OK);
    mComponent->queue(&workList);

    err = mComponent->reset();
    ASSERT_EQ(err, C2_OK);
@@ -183,33 +182,23 @@ TEST_F(Codec2ComponentHidlTest, Config) {
// Test Multiple Start Stop Reset Test
TEST_F(Codec2ComponentHidlTest, MultipleStartStopReset) {
    ALOGV("Multiple Start Stop and Reset Test");
    c2_status_t err = C2_OK;

    for (size_t i = 0; i < MAX_RETRY; i++) {
        err = mComponent->start();
        ASSERT_EQ(err, C2_OK);

        err = mComponent->stop();
        ASSERT_EQ(err, C2_OK);
        mComponent->start();
        mComponent->stop();
    }

    err = mComponent->start();
    ASSERT_EQ(err, C2_OK);
    ASSERT_EQ(mComponent->start(), C2_OK);

    for (size_t i = 0; i < MAX_RETRY; i++) {
        err = mComponent->reset();
        ASSERT_EQ(err, C2_OK);
        mComponent->reset();
    }

    err = mComponent->start();
    ASSERT_EQ(err, C2_OK);

    err = mComponent->stop();
    ASSERT_EQ(err, C2_OK);
    ASSERT_EQ(mComponent->start(), C2_OK);
    ASSERT_EQ(mComponent->stop(), C2_OK);

    // Second stop should return error
    err = mComponent->stop();
    ASSERT_NE(err, C2_OK);
    ASSERT_NE(mComponent->stop(), C2_OK);
}

// Test Component Release API
@@ -233,8 +222,7 @@ TEST_F(Codec2ComponentHidlTest, MultipleRelease) {
    ASSERT_EQ(failures.size(), 0u);

    for (size_t i = 0; i < MAX_RETRY; i++) {
        err = mComponent->release();
        ASSERT_EQ(err, C2_OK);
        mComponent->release();
    }
}

@@ -332,14 +320,12 @@ TEST_F(Codec2ComponentHidlTest, Timeout) {
    timeConsumed = getNowUs() - startTime;
    ALOGV("mComponent->queue() timeConsumed=%" PRId64 " us", timeConsumed);
    CHECK_TIMEOUT(timeConsumed, QUEUE_TIME_OUT, "queue()");
    ASSERT_EQ(err, C2_OK);

    startTime = getNowUs();
    err = mComponent->flush(C2Component::FLUSH_COMPONENT, &workList);
    timeConsumed = getNowUs() - startTime;
    ALOGV("mComponent->flush() timeConsumed=%" PRId64 " us", timeConsumed);
    CHECK_TIMEOUT(timeConsumed, FLUSH_TIME_OUT, "flush()");
    ASSERT_EQ(err, C2_OK);

    startTime = getNowUs();
    err = mComponent->stop();
+1 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@
 */

cc_test {
    name: "VtsHalMeidaC2V1_0TargetVideoDecTest",
    name: "VtsHalMediaC2V1_0TargetVideoDecTest",
    defaults: ["VtsHalMediaC2V1_0Defaults"],
    srcs: ["VtsHalMediaC2V1_0TargetVideoDecTest.cpp"],
}
+9 −4
Original line number Diff line number Diff line
@@ -46,6 +46,10 @@ class LinearBuffer : public C2Buffer {
    explicit LinearBuffer(const std::shared_ptr<C2LinearBlock>& block)
        : C2Buffer(
              {block->share(block->offset(), block->size(), ::C2Fence())}) {}

    explicit LinearBuffer(const std::shared_ptr<C2LinearBlock>& block, size_t size)
        : C2Buffer(
              {block->share(block->offset(), size, ::C2Fence())}) {}
};

static ComponentTestEnvironment* gEnv = nullptr;
@@ -371,11 +375,12 @@ void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp
        ASSERT_EQ(eleStream.gcount(), size);

        work->input.buffers.clear();
        auto alignedSize = ALIGN(size, PAGE_SIZE);
        if (size) {
            std::shared_ptr<C2LinearBlock> block;
            ASSERT_EQ(C2_OK,
                    linearPool->fetchLinearBlock(
                        size, {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE},
                        alignedSize, {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE},
                        &block));
            ASSERT_TRUE(block);

@@ -385,13 +390,13 @@ void decodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp
                fprintf(stderr, "C2LinearBlock::map() failed : %d", view.error());
                break;
            }
            ASSERT_EQ((size_t)size, view.capacity());
            ASSERT_EQ((size_t)alignedSize, view.capacity());
            ASSERT_EQ(0u, view.offset());
            ASSERT_EQ((size_t)size, view.size());
            ASSERT_EQ((size_t)alignedSize, view.size());

            memcpy(view.base(), data, size);

            work->input.buffers.emplace_back(new LinearBuffer(block));
            work->input.buffers.emplace_back(new LinearBuffer(block, size));
            free(data);
        }
        work->worklets.clear();
+61 −21
Original line number Diff line number Diff line
@@ -284,15 +284,16 @@ void encodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp
                   std::list<std::unique_ptr<C2Work>>& workQueue,
                   std::list<uint64_t>& flushedIndices,
                   std::shared_ptr<C2BlockPool>& graphicPool,
                   std::ifstream& eleStream, uint32_t frameID,
                   uint32_t nFrames, uint32_t nWidth, int32_t nHeight,
                   bool flushed = false,bool signalEOS = true) {
                   std::ifstream& eleStream, bool& disableTest,
                   uint32_t frameID, uint32_t nFrames, uint32_t nWidth,
                   int32_t nHeight, bool flushed = false, bool signalEOS = true) {
    typedef std::unique_lock<std::mutex> ULock;

    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;
        uint32_t flags = 0;
@@ -333,16 +334,21 @@ void encodeNFrames(const std::shared_ptr<android::Codec2Client::Component>& comp
            ASSERT_EQ(eleStream.gcount(), bytesCount);
        }
        std::shared_ptr<C2GraphicBlock> block;
        ASSERT_EQ(
            C2_OK,
            graphicPool->fetchGraphicBlock(
        err = graphicPool->fetchGraphicBlock(
                nWidth, nHeight, HAL_PIXEL_FORMAT_YV12,
                {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block));
                {C2MemoryUsage::CPU_READ, C2MemoryUsage::CPU_WRITE}, &block);
        if (err != C2_OK) {
            fprintf(stderr, "fetchGraphicBlock failed : %d\n", err);
            disableTest = true;
            break;
        }

        ASSERT_TRUE(block);
        // Graphic View
        C2GraphicView view = block->map().get();
        if (view.error() != C2_OK) {
            fprintf(stderr, "C2GraphicBlock::map() failed : %d", view.error());
            disableTest = true;
            break;
        }

@@ -420,8 +426,16 @@ TEST_P(Codec2VideoEncEncodeTest, EncodeTest) {
    ASSERT_EQ(mComponent->start(), C2_OK);
    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream,
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      0, 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 suceeded
    // In this cases, we skip encoding the input stream
    if (mDisableTest) {
        std::cout << "[   WARN   ] Test Disabled \n";
        ASSERT_EQ(mComponent->stop(), C2_OK);
        return;
    }

    // If EOS is not sent, sending empty input with EOS flag
    inputFrames = ENC_NUM_FRAMES;
@@ -531,8 +545,17 @@ TEST_F(Codec2VideoEncHidlTest, FlushTest) {
    ALOGV("mURL : %s", mURL);
    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream,
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      0, numFramesFlushed, nWidth, nHeight));
    // mDisableTest will be set if buffer was not fetched properly.
    // This may happen when resolution is not proper but config suceeded
    // In this cases, we skip encoding the input stream
    if (mDisableTest) {
        std::cout << "[   WARN   ] Test Disabled \n";
        ASSERT_EQ(mComponent->stop(), C2_OK);
        return;
    }

    std::list<std::unique_ptr<C2Work>> flushedWork;
    c2_status_t err =
        mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
@@ -561,10 +584,19 @@ TEST_F(Codec2VideoEncHidlTest, FlushTest) {
    mFlushedIndices.clear();
    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream,
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      numFramesFlushed, numFrames - numFramesFlushed,
                      nWidth, nHeight, true));
    eleStream.close();
    // mDisableTest will be set if buffer was not fetched properly.
    // This may happen when resolution is not proper but config suceeded
    // In this cases, we skip encoding the input stream
    if (mDisableTest) {
        std::cout << "[   WARN   ] Test Disabled \n";
        ASSERT_EQ(mComponent->stop(), C2_OK);
        return;
    }

    err = mComponent->flush(C2Component::FLUSH_COMPONENT, &flushedWork);
    ASSERT_EQ(err, C2_OK);
    ASSERT_NO_FATAL_FAILURE(
@@ -607,19 +639,19 @@ TEST_F(Codec2VideoEncHidlTest, InvalidBufferTest) {

    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream,
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      0, 1, nWidth, nHeight, false, false));

    // Feed larger input buffer.
    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream,
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      1, 1, nWidth*2, nHeight*2, false, false));

    // Feed smaller input buffer.
    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream,
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      2, 1, nWidth/2, nHeight/2, false, true));

    // blocking call to ensures application to Wait till all the inputs are
@@ -629,15 +661,13 @@ TEST_F(Codec2VideoEncHidlTest, InvalidBufferTest) {
        waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));

    if (mFramesReceived != 3) {
        ALOGE("Input buffer count and Output buffer count mismatch");
        ALOGE("framesReceived : %d inputFrames : 3", mFramesReceived);
        ASSERT_TRUE(false);
        std::cout << "[   WARN   ] Component didn't receive all buffers back \n";
        ALOGW("framesReceived : %d inputFrames : 3", mFramesReceived);
    }

    if (mFailedWorkReceived == 0) {
        ALOGE("Expected failed frame count mismatch");
        ALOGE("failedFramesReceived : %d", mFailedWorkReceived);
        ASSERT_TRUE(false);
        std::cout << "[   WARN   ] Expected failed frame count mismatch \n";
        ALOGW("failedFramesReceived : %d", mFailedWorkReceived);
    }

    ASSERT_EQ(mComponent->stop(), C2_OK);
@@ -665,8 +695,17 @@ TEST_P(Codec2VideoEncResolutionTest, ResolutionTest) {

    ASSERT_NO_FATAL_FAILURE(
        encodeNFrames(mComponent, mQueueLock, mQueueCondition, mWorkQueue,
                      mFlushedIndices, mGraphicPool, eleStream, 0,
                      MAX_INPUT_BUFFERS, nWidth, nHeight));
                      mFlushedIndices, mGraphicPool, eleStream, mDisableTest,
                      0, MAX_INPUT_BUFFERS, nWidth, nHeight, false, true));

    // mDisableTest will be set if buffer was not fetched properly.
    // This may happen when resolution is not proper but config suceeded
    // In this cases, we skip encoding the input stream
    if (mDisableTest) {
        std::cout << "[   WARN   ] Test Disabled \n";
        ASSERT_EQ(mComponent->stop(), C2_OK);
        return;
    }

    ALOGD("Waiting for input consumption");
    ASSERT_NO_FATAL_FAILURE(
@@ -676,6 +715,7 @@ TEST_P(Codec2VideoEncResolutionTest, ResolutionTest) {
    ASSERT_EQ(mComponent->stop(), C2_OK);
    ASSERT_EQ(mComponent->reset(), C2_OK);
}

INSTANTIATE_TEST_CASE_P(NonStdSizes, Codec2VideoEncResolutionTest, ::testing::Values(
    std::make_pair(52, 18),
    std::make_pair(365, 365),
Loading