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

Commit 03ae5501 authored by Lajos Molnar's avatar Lajos Molnar Committed by Automerger Merge Worker
Browse files

Merge changes Ide01063f,I23847ac7,I5ab97357 am: e91e96ba am: 24cd6c17

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1405035

Change-Id: Ibb3355faff449deef45e545d7cbe7b9f35d372f1
parents 080ba894 24cd6c17
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ private:
/// \note this will contain any initialization, which we will remove when converting to lower-case
#define _C2_GET_ENUM_NAME(x, y) #x
/// mapper to get value of enum
#define _C2_GET_ENUM_VALUE(x, type) (_C2EnumConst<type>)x
#define _C2_GET_ENUM_VALUE(x, type_) (_C2EnumConst<typename std::underlying_type<type_>::type>)type_::x

/// \endcond

@@ -106,7 +106,7 @@ public:
template<> \
C2FieldDescriptor::NamedValuesType C2FieldDescriptor::namedValuesFor(const name &r __unused) { \
    return _C2EnumUtils::sanitizeEnumValues( \
            std::vector<C2Value::Primitive> { _C2_MAP(_C2_GET_ENUM_VALUE, type, __VA_ARGS__) }, \
            std::vector<C2Value::Primitive> { _C2_MAP(_C2_GET_ENUM_VALUE, name, __VA_ARGS__) }, \
            { _C2_MAP(_C2_GET_ENUM_NAME, type, __VA_ARGS__) }, \
            prefix); \
}
+8 −0
Original line number Diff line number Diff line
@@ -508,6 +508,14 @@ protected:
        return _mIndex.setPort(output);
    }

    /// sets the size of this parameter.
    inline void setSize(size_t size) {
        if (size < sizeof(C2Param)) {
            size = 0;
        }
        _mSize = c2_min(size, _mSize);
    }

public:
    /// invalidate this parameter. There is no recovery from this call; e.g. parameter
    /// cannot be 'corrected' to be valid.
+8 −0
Original line number Diff line number Diff line
@@ -97,6 +97,9 @@ public:
        PARAM_TYPE = CoreIndex | TypeFlags
    };

    // the underlying param struct type
    typedef S Struct;

protected:
    enum : uint32_t {
        FLEX_SIZE = 0,
@@ -270,6 +273,11 @@ protected:
        } \
        return 0; \
    } \
    inline void setFlexCount(size_t count) { \
        if (count < flexCount()) { \
            this->setSize(sizeof(_Type) + _Type::FLEX_SIZE * count); \
        } \
    } \

/// Mark flexible member variable and make structure flexible.
#define FLEX(cls, m) \
+11 −0
Original line number Diff line number Diff line
@@ -2328,6 +2328,17 @@ TEST_F(C2ParamTest, FlexParamOpsTest) {
        static_assert(std::is_same<decltype(blobValue->m.value), uint8_t[]>::value, "should be uint8_t[]");
        EXPECT_EQ(0, memcmp(blobValue->m.value, "ABCD\0", 6));
        EXPECT_EQ(6u, blobValue->flexCount());
        blobValue->setFlexCount(7u); // increasing the count does not change it
        EXPECT_EQ(6u, blobValue->flexCount());
        blobValue->setFlexCount(2u); // decreasing the count changes it to it
        EXPECT_EQ(2u, blobValue->flexCount());
        blobValue->setFlexCount(0u); // can decrease to 0 and blob remains valid
        EXPECT_EQ(0u, blobValue->flexCount());
        EXPECT_TRUE(*blobValue);
        blobValue->invalidate(); // flex params can be invalidated => results in 0 size
        EXPECT_FALSE(*blobValue);
        EXPECT_EQ(0u, blobValue->size());

        std::vector<C2FieldDescriptor> fields = blobValue->FieldList();
        EXPECT_EQ(1u, fields.size());
        EXPECT_EQ(FD::BLOB, fields.cbegin()->type());