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

Commit 03f44055 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 7756953 from 76f1d33e to sc-v2-release

Change-Id: I8cfa9a914a5fd20ae42950aea2e03ad5fa4ff72e
parents a1a74bb7 76f1d33e
Loading
Loading
Loading
Loading
+18 −20
Original line number Diff line number Diff line
@@ -100,8 +100,10 @@ class Codec2AudioDecHidlTestBase : public ::testing::Test {
        ASSERT_NE(mLinearPool, nullptr);

        std::vector<std::unique_ptr<C2Param>> queried;
        mComponent->query({}, {C2PortMediaTypeSetting::input::PARAM_TYPE}, C2_DONT_BLOCK, &queried);
        ASSERT_GT(queried.size(), 0);
        c2_status_t c2err = mComponent->query({}, {C2PortMediaTypeSetting::input::PARAM_TYPE},
                                              C2_DONT_BLOCK, &queried);
        ASSERT_EQ(c2err, C2_OK) << "Query media type failed";
        ASSERT_EQ(queried.size(), 1) << "Size of the vector returned is invalid";

        mMime = ((C2PortMediaTypeSetting::input*)queried[0].get())->m.value;

@@ -277,15 +279,11 @@ void getInputChannelInfo(const std::shared_ptr<android::Codec2Client::Component>
    };
    std::vector<std::unique_ptr<C2Param>> inParams;
    c2_status_t status = component->query({}, indices, C2_DONT_BLOCK, &inParams);
    if (status != C2_OK && inParams.size() == 0) {
        ALOGE("Query media type 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);
        }
    ASSERT_EQ(status, C2_OK) << "Query sample rate and channel count info failed";
    ASSERT_EQ(inParams.size(), indices.size()) << "Size of the vector returned is invalid";

    bitStreamInfo[0] = C2StreamSampleRateInfo::output::From(inParams[0].get())->value;
    bitStreamInfo[1] = C2StreamChannelCountInfo::output::From(inParams[1].get())->value;
    if (mime.find("3gpp") != std::string::npos) {
        ASSERT_EQ(bitStreamInfo[0], 8000);
        ASSERT_EQ(bitStreamInfo[1], 1);
@@ -294,7 +292,7 @@ void getInputChannelInfo(const std::shared_ptr<android::Codec2Client::Component>
        ASSERT_EQ(bitStreamInfo[1], 1);
    } else if (mime.find("gsm") != std::string::npos) {
        ASSERT_EQ(bitStreamInfo[0], 8000);
        }
        ASSERT_EQ(bitStreamInfo[1], 1);
    }
}

+59 −64
Original line number Diff line number Diff line
@@ -73,26 +73,22 @@ class Codec2AudioEncHidlTestBase : public ::testing::Test {
        ASSERT_NE(mLinearPool, nullptr);

        std::vector<std::unique_ptr<C2Param>> queried;
        mComponent->query({}, {C2PortMediaTypeSetting::output::PARAM_TYPE}, C2_DONT_BLOCK,
                          &queried);
        ASSERT_GT(queried.size(), 0);
        c2_status_t c2err = mComponent->query({}, {C2PortMediaTypeSetting::output::PARAM_TYPE},
                                              C2_DONT_BLOCK, &queried);
        ASSERT_EQ(c2err, C2_OK) << "Query media type failed";
        ASSERT_EQ(queried.size(), 1) << "Size of the vector returned is invalid";

        mMime = ((C2PortMediaTypeSetting::output*)queried[0].get())->m.value;
        mEos = false;
        mCsd = false;
        mFramesReceived = 0;
        mEncoderFrameSize = 0;
        mWorkResult = C2_OK;
        mOutputSize = 0u;
        getInputMaxBufSize();

        c2_status_t status = getChannelCount(&mNumChannels);
        ASSERT_EQ(status, C2_OK) << "Unable to get supported channel count";

        status = getSampleRate(&mSampleRate);
        ASSERT_EQ(status, C2_OK) << "Unable to get supported sample rate";

        status = getSamplesPerFrame(mNumChannels, &mSamplesPerFrame);
        ASSERT_EQ(status, C2_OK) << "Unable to get supported number of samples per frame";
        ASSERT_NO_FATAL_FAILURE(getInputMaxBufSize());
        ASSERT_NO_FATAL_FAILURE(getChannelCount(&mNumChannels));
        ASSERT_NO_FATAL_FAILURE(getSampleRate(&mSampleRate));
        ASSERT_NO_FATAL_FAILURE(getSamplesPerFrame(mNumChannels, &mSamplesPerFrame));

        getFile(mNumChannels, mSampleRate);
    }
@@ -108,9 +104,9 @@ class Codec2AudioEncHidlTestBase : public ::testing::Test {
    // Get the test parameters from GetParam call.
    virtual void getParams() {}

    c2_status_t getChannelCount(int32_t* nChannels);
    c2_status_t getSampleRate(int32_t* nSampleRate);
    c2_status_t getSamplesPerFrame(int32_t nChannels, int32_t* samplesPerFrame);
    void getChannelCount(int32_t* nChannels);
    void getSampleRate(int32_t* nSampleRate);
    void getSamplesPerFrame(int32_t nChannels, int32_t* samplesPerFrame);

    void getFile(int32_t channelCount, int32_t sampleRate);

@@ -146,6 +142,7 @@ class Codec2AudioEncHidlTestBase : public ::testing::Test {
    uint32_t mFramesReceived;
    int32_t mInputMaxBufSize;
    uint64_t mOutputSize;
    uint32_t mEncoderFrameSize;
    std::list<uint64_t> mFlushedIndices;

    C2BlockPool::local_id_t mBlockPoolId;
@@ -173,21 +170,13 @@ class Codec2AudioEncHidlTestBase : public ::testing::Test {

    // 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];
        ASSERT_EQ(status, C2_OK) << "Query max buffer size info failed";
        ASSERT_EQ(inParams.size(), 1) << "Size of the vector returned is invalid";

        mInputMaxBufSize = C2StreamMaxBufferSizeInfo::input::From(inParams[0].get())->value;
    }
};

@@ -243,17 +232,15 @@ bool setupConfigParam(const std::shared_ptr<android::Codec2Client::Component>& c
    return false;
}

c2_status_t Codec2AudioEncHidlTestBase::getChannelCount(int32_t* nChannels) {
void Codec2AudioEncHidlTestBase::getChannelCount(int32_t* nChannels) {
    std::unique_ptr<C2StreamChannelCountInfo::input> channelCount =
            std::make_unique<C2StreamChannelCountInfo::input>();
    std::vector<C2FieldSupportedValuesQuery> validValueInfos = {
            C2FieldSupportedValuesQuery::Current(
                    C2ParamField(channelCount.get(), &C2StreamChannelCountInfo::value))};
    c2_status_t c2err = mComponent->querySupportedValues(validValueInfos, C2_DONT_BLOCK);
    if (c2err != C2_OK || validValueInfos.size() != 1u) {
        ALOGE("querySupportedValues_vb failed for channelCount");
        return c2err;
    }
    ASSERT_EQ(c2err, C2_OK) << "Query channel count info failed";
    ASSERT_EQ(validValueInfos.size(), 1) << "Size of the vector returned is invalid";

    // setting default value of channelCount
    *nChannels = 1;
@@ -280,37 +267,45 @@ c2_status_t Codec2AudioEncHidlTestBase::getChannelCount(int32_t* nChannels) {
            break;
        }
        default:
            ASSERT_TRUE(false) << "Unsupported type: " << c2FSV.type;
            break;
    }
    return C2_OK;
    return;
}
c2_status_t Codec2AudioEncHidlTestBase::getSampleRate(int32_t* nSampleRate) {
void Codec2AudioEncHidlTestBase::getSampleRate(int32_t* nSampleRate) {
    // Use the default sample rate for mComponents
    std::vector<std::unique_ptr<C2Param>> queried;
    c2_status_t c2err = mComponent->query({}, {C2StreamSampleRateInfo::input::PARAM_TYPE},
                                          C2_DONT_BLOCK, &queried);
    if (c2err != C2_OK || queried.size() == 0) return c2err;

    size_t offset = sizeof(C2Param);
    C2Param* param = queried[0].get();
    *nSampleRate = *(int32_t*)((uint8_t*)param + offset);
    ASSERT_EQ(c2err, C2_OK) << "Query sample rate info failed";
    ASSERT_EQ(queried.size(), 1) << "Size of the vector returned is invalid";

    return C2_OK;
    *nSampleRate = C2StreamSampleRateInfo::input::From(queried[0].get())->value;
    return;
}

c2_status_t Codec2AudioEncHidlTestBase::getSamplesPerFrame(int32_t nChannels,
                                                           int32_t* samplesPerFrame) {
void Codec2AudioEncHidlTestBase::getSamplesPerFrame(int32_t nChannels, int32_t* samplesPerFrame) {
    std::vector<std::unique_ptr<C2Param>> queried;
    c2_status_t c2err = mComponent->query({}, {C2StreamMaxBufferSizeInfo::input::PARAM_TYPE},
    c2_status_t c2err = mComponent->query({}, {C2StreamAudioFrameSizeInfo::input::PARAM_TYPE},
                                          C2_DONT_BLOCK, &queried);
    if (c2err != C2_OK || queried.size() == 0) return c2err;

    size_t offset = sizeof(C2Param);
    C2Param* param = queried[0].get();
    uint32_t maxInputSize = *(uint32_t*)((uint8_t*)param + offset);
    if (c2err == C2_OK && queried.size() == 1) {
        mEncoderFrameSize = C2StreamAudioFrameSizeInfo::input::From(queried[0].get())->value;
        if (mEncoderFrameSize) {
            *samplesPerFrame = mEncoderFrameSize;
            return;
        }
    }

    c2err = mComponent->query({}, {C2StreamMaxBufferSizeInfo::input::PARAM_TYPE}, C2_DONT_BLOCK,
                              &queried);
    ASSERT_EQ(c2err, C2_OK) << "Query max buffer size info failed";
    ASSERT_EQ(queried.size(), 1) << "Size of the vector returned is invalid";

    uint32_t maxInputSize = C2StreamMaxBufferSizeInfo::input::From(queried[0].get())->value;
    *samplesPerFrame = std::min((maxInputSize / (nChannels * 2)), kMaxSamplesPerFrame);

    return C2_OK;
    return;
}

// LookUpTable of clips and metadata for component testing
@@ -440,10 +435,13 @@ TEST_P(Codec2AudioEncEncodeTest, EncodeTest) {
    ALOGV("EncodeTest");
    if (mDisableTest) GTEST_SKIP() << "Test is disabled";
    bool signalEOS = std::get<2>(GetParam());
    // Set samples per frame based on inputMaxBufRatio if component does not
    // advertise supported frame size
    if (!mEncoderFrameSize) {
        // Ratio w.r.t to mInputMaxBufSize
        int32_t inputMaxBufRatio = std::get<3>(GetParam());
        mSamplesPerFrame = ((mInputMaxBufSize / inputMaxBufRatio) / (mNumChannels * 2));

    }
    ALOGV("signalEOS %d mInputMaxBufSize %d mSamplesPerFrame %d", signalEOS, mInputMaxBufSize,
          mSamplesPerFrame);

@@ -603,12 +601,11 @@ TEST_P(Codec2AudioEncHidlTest, MultiChannelCountTest) {
        std::vector<std::unique_ptr<C2Param>> inParams;
        c2_status_t c2_status = mComponent->query({}, {C2StreamChannelCountInfo::input::PARAM_TYPE},
                                                  C2_DONT_BLOCK, &inParams);
        ASSERT_TRUE(!c2_status && inParams.size())
                << "Query configured channelCount failed => %d" << c2_status;
        ASSERT_EQ(c2_status, C2_OK) << "Query channel count info failed";
        ASSERT_EQ(inParams.size(), 1) << "Size of the vector returned is invalid";

        int32_t channelCount = C2StreamChannelCountInfo::input::From(inParams[0].get())->value;

        size_t offset = sizeof(C2Param);
        C2Param* param = inParams[0].get();
        int32_t channelCount = *(int32_t*)((uint8_t*)param + offset);
        if (channelCount != nChannels) {
            std::cout << "[   WARN   ] Test Skipped for ChannelCount " << nChannels << "\n";
            continue;
@@ -692,13 +689,11 @@ TEST_P(Codec2AudioEncHidlTest, MultiSampleRateTest) {
        std::vector<std::unique_ptr<C2Param>> inParams;
        c2_status_t c2_status = mComponent->query({}, {C2StreamSampleRateInfo::input::PARAM_TYPE},
                                                  C2_DONT_BLOCK, &inParams);
        ASSERT_EQ(c2_status, C2_OK) << "Query sample rate info failed";
        ASSERT_EQ(inParams.size(), 1) << "Size of the vector returned is invalid";

        ASSERT_TRUE(!c2_status && inParams.size())
                << "Query configured SampleRate failed => %d" << c2_status;
        size_t offset = sizeof(C2Param);
        C2Param* param = inParams[0].get();
        int32_t configuredSampleRate = *(int32_t*)((uint8_t*)param + offset);

        int32_t configuredSampleRate =
                C2StreamSampleRateInfo::input::From(inParams[0].get())->value;
        if (configuredSampleRate != nSampleRate) {
            std::cout << "[   WARN   ] Test Skipped for SampleRate " << nSampleRate << "\n";
            continue;
+4 −2
Original line number Diff line number Diff line
@@ -123,8 +123,10 @@ class Codec2VideoDecHidlTestBase : public ::testing::Test {
        ASSERT_NE(mLinearPool, nullptr);

        std::vector<std::unique_ptr<C2Param>> queried;
        mComponent->query({}, {C2PortMediaTypeSetting::input::PARAM_TYPE}, C2_DONT_BLOCK, &queried);
        ASSERT_GT(queried.size(), 0);
        c2_status_t c2err = mComponent->query({}, {C2PortMediaTypeSetting::input::PARAM_TYPE},
                                              C2_DONT_BLOCK, &queried);
        ASSERT_EQ(c2err, C2_OK) << "Query media type failed";
        ASSERT_EQ(queried.size(), 1) << "Size of the vector returned is invalid";

        mMime = ((C2PortMediaTypeSetting::input*)queried[0].get())->m.value;
        mEos = false;
+15 −6
Original line number Diff line number Diff line
@@ -74,9 +74,10 @@ class Codec2VideoEncHidlTestBase : public ::testing::Test {
        ASSERT_NE(mGraphicPool, nullptr);

        std::vector<std::unique_ptr<C2Param>> queried;
        mComponent->query({}, {C2PortMediaTypeSetting::output::PARAM_TYPE}, C2_DONT_BLOCK,
                          &queried);
        ASSERT_GT(queried.size(), 0);
        c2_status_t c2err = mComponent->query({}, {C2PortMediaTypeSetting::output::PARAM_TYPE},
                                              C2_DONT_BLOCK, &queried);
        ASSERT_EQ(c2err, C2_OK) << "Query media type failed";
        ASSERT_EQ(queried.size(), 1) << "Size of the vector returned is invalid";

        mMime = ((C2PortMediaTypeSetting::output*)queried[0].get())->m.value;
        std::cout << "mime : " << mMime << "\n";
@@ -531,9 +532,17 @@ TEST_P(Codec2VideoEncEncodeTest, EncodeTest) {
                  << " resetting num BFrames to 0\n";
        mConfigBPictures = false;
    } else {
        size_t offset = sizeof(C2Param);
        C2Param* param = inParams[0].get();
        int32_t numBFrames = *(int32_t*)((uint8_t*)param + offset);
        int32_t numBFrames = 0;
        C2StreamGopTuning::output* gop = C2StreamGopTuning::output::From(inParams[0].get());
        if (gop && gop->flexCount() >= 1) {
            for (size_t i = 0; i < gop->flexCount(); ++i) {
                const C2GopLayerStruct& layer = gop->m.values[i];
                if (layer.type_ == C2Config::picture_type_t(P_FRAME | B_FRAME)) {
                    numBFrames = layer.count;
                    break;
                }
            }
        }

        if (!numBFrames) {
            std::cout << "[   WARN   ] Bframe not supported for " << mComponentName
+4 −1
Original line number Diff line number Diff line
@@ -96,7 +96,10 @@ void CCodecBuffers::handleImageData(const sp<Codec2Buffer> &buffer) {
        if (img->mNumPlanes > 0 && img->mType != img->MEDIA_IMAGE_TYPE_UNKNOWN) {
            int32_t stride = img->mPlane[0].mRowInc;
            mFormatWithImageData->setInt32(KEY_STRIDE, stride);
            ALOGD("[%s] updating stride = %d", mName, stride);
            mFormatWithImageData->setInt32(KEY_WIDTH, img->mWidth);
            mFormatWithImageData->setInt32(KEY_HEIGHT, img->mHeight);
            ALOGD("[%s] updating stride = %d, width: %d, height: %d",
                  mName, stride, img->mWidth, img->mHeight);
            if (img->mNumPlanes > 1 && stride > 0) {
                int64_t offsetDelta =
                    (int64_t)img->mPlane[1].mOffset - (int64_t)img->mPlane[0].mOffset;
Loading