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

Commit e349be3c authored by Wonsik Kim's avatar Wonsik Kim Committed by Cherrypicker Worker
Browse files

CCodec: fix to check a type of input allocator at GetCommonAllocatorIds()



some components like as video encoder may support
C2Allocator::GRAPHIC as input allocator.
therefore, GetCommonAllocatorIds() should check a type of input stream buffer
and compare than requested type of allocator.

Signed-off-by: default avatarTaehwan Kim <t_h.kim@samsung.com>
(cherry picked from commit 900b49c0)
Merged-In:I307e994a6554e7e66a6af2d389fc0834d2c63e2f

Change-Id: I6a4402ebd67013fb3d768303aa376df36a9ba845
parents 9ac4cb4f 1cfdc6b7
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -2619,7 +2619,10 @@ public:
        std::vector<std::unique_ptr<C2Param>> params;
        err = intf->query(
                {&mApiFeatures},
                {C2PortAllocatorsTuning::input::PARAM_TYPE},
                {
                    C2StreamBufferTypeSetting::input::PARAM_TYPE,
                    C2PortAllocatorsTuning::input::PARAM_TYPE
                },
                C2_MAY_BLOCK,
                &params);
        if (err != C2_OK && err != C2_BAD_INDEX) {
@@ -2632,7 +2635,10 @@ public:
            if (!param) {
                continue;
            }
            if (param->type() == C2PortAllocatorsTuning::input::PARAM_TYPE) {
            if (param->type() == C2StreamBufferTypeSetting::input::PARAM_TYPE) {
                mInputStreamFormat.reset(
                        C2StreamBufferTypeSetting::input::From(param));
            } else if (param->type() == C2PortAllocatorsTuning::input::PARAM_TYPE) {
                mInputAllocators.reset(
                        C2PortAllocatorsTuning::input::From(param));
            }
@@ -2652,6 +2658,16 @@ public:
        return mApiFeatures;
    }

    const C2StreamBufferTypeSetting::input &getInputStreamFormat() const {
        static std::unique_ptr<C2StreamBufferTypeSetting::input> sInvalidated = []{
            std::unique_ptr<C2StreamBufferTypeSetting::input> param;
            param.reset(new C2StreamBufferTypeSetting::input(0u, C2BufferData::INVALID));
            param->invalidate();
            return param;
        }();
        return mInputStreamFormat ? *mInputStreamFormat : *sInvalidated;
    }

    const C2PortAllocatorsTuning::input &getInputAllocators() const {
        static std::unique_ptr<C2PortAllocatorsTuning::input> sInvalidated = []{
            std::unique_ptr<C2PortAllocatorsTuning::input> param =
@@ -2667,6 +2683,7 @@ private:

    std::vector<C2FieldSupportedValuesQuery> mFields;
    C2ApiFeaturesSetting mApiFeatures;
    std::unique_ptr<C2StreamBufferTypeSetting::input> mInputStreamFormat;
    std::unique_ptr<C2PortAllocatorsTuning::input> mInputAllocators;
};

@@ -2708,6 +2725,24 @@ static status_t GetCommonAllocatorIds(
        if (intfCache.initCheck() != OK) {
            continue;
        }
        const C2StreamBufferTypeSetting::input &streamFormat = intfCache.getInputStreamFormat();
        if (streamFormat) {
            C2Allocator::type_t allocatorType = C2Allocator::LINEAR;
            if (streamFormat.value == C2BufferData::GRAPHIC
                    || streamFormat.value == C2BufferData::GRAPHIC_CHUNKS) {
                allocatorType = C2Allocator::GRAPHIC;
            }

            if (type != allocatorType) {
                // requested type is not supported at input allocators
                ids->clear();
                ids->insert(defaultAllocatorId);
                ALOGV("name(%s) does not support a type(0x%x) as input allocator."
                        " uses default allocator id(%d)", name.c_str(), type, defaultAllocatorId);
                break;
            }
        }

        const C2PortAllocatorsTuning::input &allocators = intfCache.getInputAllocators();
        if (firstIteration) {
            firstIteration = false;