Codec2: C2ParamDescriptor fixes
type() is now index()
added dependencies
use attributes instead of individual boolean flags
Bug: 64121714
Change-Id: If0b5326e19cf007cece517231cb55147607e3379
diff --git a/media/libstagefright/codec2/include/C2Param.h b/media/libstagefright/codec2/include/C2Param.h
index e2df62d..1d6e2eb 100644
--- a/media/libstagefright/codec2/include/C2Param.h
+++ b/media/libstagefright/codec2/include/C2Param.h
@@ -1020,7 +1020,7 @@
* For vendor-defined components, it can be true even for vendor-defined params,
* but it is not recommended, in case the component becomes platform-defined.
*/
- inline bool isRequired() const { return _mIsRequired; }
+ inline bool isRequired() const { return _mAttrib & IS_REQUIRED; }
/**
* Returns whether this parameter is persistent. This is always true for C2Tuning and C2Setting,
@@ -1029,35 +1029,43 @@
* current frame and is not assumed to have the same value (or even be present) on subsequent
* frames, unless it is specified for those frames.
*/
- inline bool isPersistent() const { return _mIsPersistent; }
+ inline bool isPersistent() const { return _mAttrib & IS_PERSISTENT; }
/// Returns the name of this param.
/// This defaults to the underlying C2Struct's name, but could be altered for a component.
inline C2String name() const { return _mName; }
- /// Returns the parameter type
- /// \todo fix this
- inline C2Param::Type type() const { return _mType; }
+ /// Returns the parameter index
+ inline C2Param::Index index() const { return _mIndex; }
+
+ /// Returns the indices of parameters that this parameter has a dependency on
+ inline const std::vector<C2Param::Index> &dependencies() const { return mDependencies; }
+
+ // TODO: add more constructors that allow setting dependencies and attributes
template<typename T>
inline C2ParamDescriptor(bool isRequired, C2StringLiteral name, const T*)
- : _mIsRequired(isRequired),
- _mIsPersistent(true),
- _mName(name),
- _mType(T::PARAM_TYPE) { }
+ : _mIndex(T::PARAM_TYPE),
+ _mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
+ _mName(name) { }
inline C2ParamDescriptor(
- bool isRequired, C2StringLiteral name, C2Param::Type type)
- : _mIsRequired(isRequired),
- _mIsPersistent(true),
- _mName(name),
- _mType(type) { }
+ bool isRequired, C2StringLiteral name, C2Param::Index index)
+ : _mIndex(index),
+ _mAttrib(IS_PERSISTENT | (isRequired ? IS_REQUIRED : 0)),
+ _mName(name) { }
private:
- const bool _mIsRequired;
- const bool _mIsPersistent;
+ enum attrib_t : uint32_t {
+ IS_REQUIRED = 1u << 0,
+ IS_PERSISTENT = 1u << 1,
+ };
+ const C2Param::Index _mIndex;
+ const uint32_t _mAttrib;
const C2String _mName;
- const C2Param::Type _mType;
+ std::vector<C2Param::Index> mDependencies;
+
+ friend struct _C2ParamInspector;
};
/// \ingroup internal
diff --git a/media/libstagefright/codec2/include/C2ParamDef.h b/media/libstagefright/codec2/include/C2ParamDef.h
index b5834f2..3691e01 100644
--- a/media/libstagefright/codec2/include/C2ParamDef.h
+++ b/media/libstagefright/codec2/include/C2ParamDef.h
@@ -225,7 +225,7 @@
#define DEFINE_CAST_OPERATORS(_Type) \
inline static _Type* From(C2Param *other) { \
return (_Type*)C2Param::ifSuitable( \
- other, sizeof(_Type),_Type::PARAM_TYPE, _Type::FLEX_SIZE, \
+ other, sizeof(_Type), _Type::PARAM_TYPE, _Type::FLEX_SIZE, \
(_Type::PARAM_TYPE & T::Index::DIR_UNDEFINED) != T::Index::DIR_UNDEFINED); \
} \
inline static const _Type* From(const C2Param *other) { \
diff --git a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
index f50af81..bf352af 100644
--- a/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
+++ b/media/libstagefright/codec2/tests/C2ComponentInterface_test.cpp
@@ -529,7 +529,7 @@
const C2Param ¶m,
const std::vector<std::shared_ptr<C2ParamDescriptor>> &sParams) {
for (const auto &pd : sParams) {
- if (param.type() == pd->type().type()) {
+ if (param.type() == pd->index().type()) {
return true;
}
}
diff --git a/media/libstagefright/codec2/tests/C2Param_test.cpp b/media/libstagefright/codec2/tests/C2Param_test.cpp
index d186292..e3f9ca6 100644
--- a/media/libstagefright/codec2/tests/C2Param_test.cpp
+++ b/media/libstagefright/codec2/tests/C2Param_test.cpp
@@ -2736,7 +2736,7 @@
cout << "persistent ";
}
cout << "struct ";
- dumpType(pd.type());
+ dumpType(C2Param::Type(pd.index().type()));
cout << " " << pd.name() << ";" << endl;
}