Loading media/codec2/core/include/C2Param.h +2 −0 Original line number Diff line number Diff line Loading @@ -427,7 +427,9 @@ public: inline bool operator==(const C2Param &o) const { return equals(o) && memcmp(this, &o, _mSize) == 0; } #if __cplusplus < 202002 inline bool operator!=(const C2Param &o) const { return !operator==(o); } #endif /// safe(r) type cast from pointer and size inline static C2Param* From(void *addr, size_t len) { Loading media/codec2/core/include/C2ParamDef.h +28 −8 Original line number Diff line number Diff line Loading @@ -212,6 +212,26 @@ protected: } }; /// Define equality (and inequality) operators for params. #if __cplusplus < 202002 #define DEFINE_EQUALITY_OPERATORS(_Type, T) \ inline bool operator==(const _Type &o) const { \ return this->T::operator==(o); \ } \ inline bool operator!=(const _Type &o) const { \ return !operator==(o); \ } #else #define DEFINE_EQUALITY_OPERATORS(_Type, T) \ inline bool operator==(const _Type &o) const { \ return this->T::operator==(o); \ } #endif /// Define From() cast operators for params. #define DEFINE_CAST_OPERATORS(_Type) \ inline static _Type* From(C2Param *other) { \ Loading Loading @@ -404,12 +424,12 @@ public: /// Specialization for an input port parameter. struct input : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Wrapper around base structure's constructor. template<typename ...Args> inline input(const Args(&... args)) : T(sizeof(_Type), input::PARAM_TYPE), S(args...) { } DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_CAST_OPERATORS(input) }; Loading @@ -417,12 +437,12 @@ public: /// Specialization for an output port parameter. struct output : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Wrapper around base structure's constructor. template<typename ...Args> inline output(const Args(&... args)) : T(sizeof(_Type), output::PARAM_TYPE), S(args...) { } DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_CAST_OPERATORS(output) }; }; Loading Loading @@ -472,7 +492,6 @@ public: /// Specialization for an input port parameter. struct input : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> { using T::operator!=; private: /// Wrapper around base structure's constructor while also specifying port/direction. template<typename ...Args> Loading @@ -482,6 +501,7 @@ public: public: S m; ///< wrapped flexible structure DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_FLEXIBLE_METHODS(input, S) DEFINE_CAST_OPERATORS(input) }; Loading @@ -489,7 +509,6 @@ public: /// Specialization for an output port parameter. struct output : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> { using T::operator!=; private: /// Wrapper around base structure's constructor while also specifying port/direction. template<typename ...Args> Loading @@ -499,6 +518,7 @@ public: public: S m; ///< wrapped flexible structure DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_FLEXIBLE_METHODS(output, S) DEFINE_CAST_OPERATORS(output) }; Loading Loading @@ -553,7 +573,6 @@ public: struct input : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Default constructor. Stream-ID is undefined. Loading @@ -565,6 +584,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_CAST_OPERATORS(input) }; Loading @@ -572,7 +592,6 @@ public: struct output : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Default constructor. Stream-ID is undefined. Loading @@ -584,6 +603,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_CAST_OPERATORS(output) }; }; Loading Loading @@ -640,7 +660,6 @@ public: struct input : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> { using T::operator!=; private: /// Default constructor. Stream-ID is undefined. inline input(size_t flexCount) : T(_Type::CalcSize(flexCount), input::PARAM_TYPE) { } Loading @@ -655,6 +674,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_FLEXIBLE_METHODS(input, S) DEFINE_CAST_OPERATORS(input) }; Loading @@ -663,7 +683,6 @@ public: struct output : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> { using T::operator!=; private: /// Default constructor. Stream-ID is undefined. inline output(size_t flexCount) : T(_Type::CalcSize(flexCount), output::PARAM_TYPE) { } Loading @@ -678,6 +697,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_FLEXIBLE_METHODS(output, S) DEFINE_CAST_OPERATORS(output) }; Loading media/codec2/tests/C2ComponentInterface_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ void C2CompIntfTest::queryParamAsExpected(const T &expected) { // |*heapParams[0]| is a parameter value. The size of |heapParams| has to be one. ASSERT_EQ(1u, heapParams.size()); EXPECT_TRUE(heapParams[0]); EXPECT_EQ(*heapParams[0], expected); EXPECT_EQ(*heapParams[0], (C2Param &)(expected)); } template <typename T> void C2CompIntfTest::querySupportedParam() { Loading Loading
media/codec2/core/include/C2Param.h +2 −0 Original line number Diff line number Diff line Loading @@ -427,7 +427,9 @@ public: inline bool operator==(const C2Param &o) const { return equals(o) && memcmp(this, &o, _mSize) == 0; } #if __cplusplus < 202002 inline bool operator!=(const C2Param &o) const { return !operator==(o); } #endif /// safe(r) type cast from pointer and size inline static C2Param* From(void *addr, size_t len) { Loading
media/codec2/core/include/C2ParamDef.h +28 −8 Original line number Diff line number Diff line Loading @@ -212,6 +212,26 @@ protected: } }; /// Define equality (and inequality) operators for params. #if __cplusplus < 202002 #define DEFINE_EQUALITY_OPERATORS(_Type, T) \ inline bool operator==(const _Type &o) const { \ return this->T::operator==(o); \ } \ inline bool operator!=(const _Type &o) const { \ return !operator==(o); \ } #else #define DEFINE_EQUALITY_OPERATORS(_Type, T) \ inline bool operator==(const _Type &o) const { \ return this->T::operator==(o); \ } #endif /// Define From() cast operators for params. #define DEFINE_CAST_OPERATORS(_Type) \ inline static _Type* From(C2Param *other) { \ Loading Loading @@ -404,12 +424,12 @@ public: /// Specialization for an input port parameter. struct input : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Wrapper around base structure's constructor. template<typename ...Args> inline input(const Args(&... args)) : T(sizeof(_Type), input::PARAM_TYPE), S(args...) { } DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_CAST_OPERATORS(input) }; Loading @@ -417,12 +437,12 @@ public: /// Specialization for an output port parameter. struct output : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Wrapper around base structure's constructor. template<typename ...Args> inline output(const Args(&... args)) : T(sizeof(_Type), output::PARAM_TYPE), S(args...) { } DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_CAST_OPERATORS(output) }; }; Loading Loading @@ -472,7 +492,6 @@ public: /// Specialization for an input port parameter. struct input : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_INPUT> { using T::operator!=; private: /// Wrapper around base structure's constructor while also specifying port/direction. template<typename ...Args> Loading @@ -482,6 +501,7 @@ public: public: S m; ///< wrapped flexible structure DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_FLEXIBLE_METHODS(input, S) DEFINE_CAST_OPERATORS(input) }; Loading @@ -489,7 +509,6 @@ public: /// Specialization for an output port parameter. struct output : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::DIR_OUTPUT> { using T::operator!=; private: /// Wrapper around base structure's constructor while also specifying port/direction. template<typename ...Args> Loading @@ -499,6 +518,7 @@ public: public: S m; ///< wrapped flexible structure DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_FLEXIBLE_METHODS(output, S) DEFINE_CAST_OPERATORS(output) }; Loading Loading @@ -553,7 +573,6 @@ public: struct input : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Default constructor. Stream-ID is undefined. Loading @@ -565,6 +584,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_CAST_OPERATORS(input) }; Loading @@ -572,7 +592,6 @@ public: struct output : public T, public S, public _C2StructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> { using T::operator!=; _C2_CORE_INDEX_OVERRIDE(ParamIndex) /// Default constructor. Stream-ID is undefined. Loading @@ -584,6 +603,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_CAST_OPERATORS(output) }; }; Loading Loading @@ -640,7 +660,6 @@ public: struct input : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_INPUT> { using T::operator!=; private: /// Default constructor. Stream-ID is undefined. inline input(size_t flexCount) : T(_Type::CalcSize(flexCount), input::PARAM_TYPE) { } Loading @@ -655,6 +674,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(input, T) DEFINE_FLEXIBLE_METHODS(input, S) DEFINE_CAST_OPERATORS(input) }; Loading @@ -663,7 +683,6 @@ public: struct output : public T, public _C2FlexStructCheck<S, ParamIndex, T::PARAM_KIND | T::Index::IS_STREAM_FLAG | T::Type::DIR_OUTPUT> { using T::operator!=; private: /// Default constructor. Stream-ID is undefined. inline output(size_t flexCount) : T(_Type::CalcSize(flexCount), output::PARAM_TYPE) { } Loading @@ -678,6 +697,7 @@ public: /// Set stream-id. \retval true if the stream-id was successfully set. inline bool setStream(unsigned stream) { return C2Param::setStream(stream); } DEFINE_EQUALITY_OPERATORS(output, T) DEFINE_FLEXIBLE_METHODS(output, S) DEFINE_CAST_OPERATORS(output) }; Loading
media/codec2/tests/C2ComponentInterface_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -235,7 +235,7 @@ void C2CompIntfTest::queryParamAsExpected(const T &expected) { // |*heapParams[0]| is a parameter value. The size of |heapParams| has to be one. ASSERT_EQ(1u, heapParams.size()); EXPECT_TRUE(heapParams[0]); EXPECT_EQ(*heapParams[0], expected); EXPECT_EQ(*heapParams[0], (C2Param &)(expected)); } template <typename T> void C2CompIntfTest::querySupportedParam() { Loading